MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / stbi__pic_load

Function stbi__pic_load

Source/Utils/stb_image.h:6497–6536  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6495}
6496
6497static void *stbi__pic_load(stbi__context *s,int *px,int *py,int *comp,int req_comp, stbi__result_info *ri)
6498{
6499 stbi_uc *result;
6500 int i, x,y, internal_comp;
6501 STBI_NOTUSED(ri);
6502
6503 if (!comp) comp = &internal_comp;
6504
6505 for (i=0; i<92; ++i)
6506 stbi__get8(s);
6507
6508 x = stbi__get16be(s);
6509 y = stbi__get16be(s);
6510
6511 if (y > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
6512 if (x > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)");
6513
6514 if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pic header)");
6515 if (!stbi__mad3sizes_valid(x, y, 4, 0)) return stbi__errpuc("too large", "PIC image too large to decode");
6516
6517 stbi__get32be(s); //skip `ratio'
6518 stbi__get16be(s); //skip `fields'
6519 stbi__get16be(s); //skip `pad'
6520
6521 // intermediate buffer is RGBA
6522 result = (stbi_uc *) stbi__malloc_mad3(x, y, 4, 0);
6523 if (!result) return stbi__errpuc("outofmem", "Out of memory");
6524 memset(result, 0xff, x*y*4);
6525
6526 if (!stbi__pic_load_core(s,x,y,comp, result)) {
6527 STBI_FREE(result);
6528 result=0;
6529 }
6530 *px = x;
6531 *py = y;
6532 if (req_comp == 0) req_comp = *comp;
6533 result=stbi__convert_format(result,4,req_comp,x,y);
6534
6535 return result;
6536}
6537
6538static int stbi__pic_test(stbi__context *s)
6539{

Callers 1

stbi__load_mainFunction · 0.85

Calls 8

stbi__get8Function · 0.85
stbi__get16beFunction · 0.85
stbi__at_eofFunction · 0.85
stbi__mad3sizes_validFunction · 0.85
stbi__get32beFunction · 0.85
stbi__malloc_mad3Function · 0.85
stbi__pic_load_coreFunction · 0.85
stbi__convert_formatFunction · 0.85

Tested by

no test coverage detected