MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / stbi__load_main

Function stbi__load_main

lite/example/cpp_example/mge/cv/stb_image.h:1144–1205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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