MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / stbi__tga_test

Function stbi__tga_test

include/stb/stb_image.h:5820–5849  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5818}
5819
5820static int stbi__tga_test(stbi__context *s)
5821{
5822 int res = 0;
5823 int sz, tga_color_type;
5824 stbi__get8(s); // discard Offset
5825 tga_color_type = stbi__get8(s); // color type
5826 if ( tga_color_type > 1 ) goto errorEnd; // only RGB or indexed allowed
5827 sz = stbi__get8(s); // image type
5828 if ( tga_color_type == 1 ) { // colormapped (paletted) image
5829 if (sz != 1 && sz != 9) goto errorEnd; // colortype 1 demands image type 1 or 9
5830 stbi__skip(s,4); // skip index of first colormap entry and number of entries
5831 sz = stbi__get8(s); // check bits per palette color entry
5832 if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd;
5833 stbi__skip(s,4); // skip image x and y origin
5834 } else { // "normal" image w/o colormap
5835 if ( (sz != 2) && (sz != 3) && (sz != 10) && (sz != 11) ) goto errorEnd; // only RGB or grey allowed, +/- RLE
5836 stbi__skip(s,9); // skip colormap specification and image x/y origin
5837 }
5838 if ( stbi__get16le(s) < 1 ) goto errorEnd; // test width
5839 if ( stbi__get16le(s) < 1 ) goto errorEnd; // test height
5840 sz = stbi__get8(s); // bits per pixel
5841 if ( (tga_color_type == 1) && (sz != 8) && (sz != 16) ) goto errorEnd; // for colormapped images, bpp is size of an index
5842 if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd;
5843
5844 res = 1; // if we got this far, everything's good and we can return 1 instead of 0
5845
5846errorEnd:
5847 stbi__rewind(s);
5848 return res;
5849}
5850
5851// read 16bit value and convert to 24bit RGB
5852static void stbi__tga_read_rgb16(stbi__context *s, stbi_uc* out)

Callers 1

stbi__load_mainFunction · 0.85

Calls 4

stbi__get8Function · 0.85
stbi__skipFunction · 0.85
stbi__get16leFunction · 0.85
stbi__rewindFunction · 0.85

Tested by

no test coverage detected