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

Function stbi__load_main

Source/Utils/stb_image.h:1136–1187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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