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

Function stbi__load_main

include/stb/stb_image.h:1137–1188  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1135#endif // STBI_THREAD_LOCAL
1136
1137static void *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc)
1138{
1139 memset(ri, 0, sizeof(*ri)); // make sure it's initialized if we add new fields
1140 ri->bits_per_channel = 8; // default is 8 so most paths don't have to be changed
1141 ri->channel_order = STBI_ORDER_RGB; // all current input & output are this, but this is here so we can add BGR order
1142 ri->num_channels = 0;
1143
1144 // test the formats with a very explicit header first (at least a FOURCC
1145 // or distinctive magic number first)
1146 #ifndef STBI_NO_PNG
1147 if (stbi__png_test(s)) return stbi__png_load(s,x,y,comp,req_comp, ri);
1148 #endif
1149 #ifndef STBI_NO_BMP
1150 if (stbi__bmp_test(s)) return stbi__bmp_load(s,x,y,comp,req_comp, ri);
1151 #endif
1152 #ifndef STBI_NO_GIF
1153 if (stbi__gif_test(s)) return stbi__gif_load(s,x,y,comp,req_comp, ri);
1154 #endif
1155 #ifndef STBI_NO_PSD
1156 if (stbi__psd_test(s)) return stbi__psd_load(s,x,y,comp,req_comp, ri, bpc);
1157 #else
1158 STBI_NOTUSED(bpc);
1159 #endif
1160 #ifndef STBI_NO_PIC
1161 if (stbi__pic_test(s)) return stbi__pic_load(s,x,y,comp,req_comp, ri);
1162 #endif
1163
1164 // then the formats that can end up attempting to load with just 1 or 2
1165 // bytes matching expectations; these are prone to false positives, so
1166 // try them later
1167 #ifndef STBI_NO_JPEG
1168 if (stbi__jpeg_test(s)) return stbi__jpeg_load(s,x,y,comp,req_comp, ri);
1169 #endif
1170 #ifndef STBI_NO_PNM
1171 if (stbi__pnm_test(s)) return stbi__pnm_load(s,x,y,comp,req_comp, ri);
1172 #endif
1173
1174 #ifndef STBI_NO_HDR
1175 if (stbi__hdr_test(s)) {
1176 float *hdr = stbi__hdr_load(s, x,y,comp,req_comp, ri);
1177 return stbi__hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp);
1178 }
1179 #endif
1180
1181 #ifndef STBI_NO_TGA
1182 // test tga last because it's a crappy test!
1183 if (stbi__tga_test(s))
1184 return stbi__tga_load(s,x,y,comp,req_comp, ri);
1185 #endif
1186
1187 return stbi__errpuc("unknown image type", "Image not of any known type, or corrupt");
1188}
1189
1190static stbi_uc *stbi__convert_16_to_8(stbi__uint16 *orig, int w, int h, int channels)
1191{

Calls 15

stbi__png_testFunction · 0.85
stbi__png_loadFunction · 0.85
stbi__bmp_testFunction · 0.85
stbi__bmp_loadFunction · 0.85
stbi__gif_testFunction · 0.85
stbi__gif_loadFunction · 0.85
stbi__psd_testFunction · 0.85
stbi__psd_loadFunction · 0.85
stbi__pic_testFunction · 0.85
stbi__pic_loadFunction · 0.85
stbi__jpeg_testFunction · 0.85
stbi__jpeg_loadFunction · 0.85

Tested by

no test coverage detected