1
stbi_test_main(stbi__context * s)2 static int stbi_test_main(stbi__context *s)
3 {
4 #ifndef STBI_NO_JPEG
5 if (stbi__jpeg_test(s)) return STBI_jpeg;
6 #endif
7 #ifndef STBI_NO_PNG
8 if (stbi__png_test(s)) return STBI_png;
9 #endif
10 #ifndef STBI_NO_BMP
11 if (stbi__bmp_test(s)) return STBI_bmp;
12 #endif
13 #ifndef STBI_NO_GIF
14 if (stbi__gif_test(s)) return STBI_gif;
15 #endif
16 #ifndef STBI_NO_PSD
17 if (stbi__psd_test(s)) return STBI_psd;
18 #endif
19 #ifndef STBI_NO_PIC
20 if (stbi__pic_test(s)) return STBI_pic;
21 #endif
22 #ifndef STBI_NO_PNM
23 if (stbi__pnm_test(s)) return STBI_pnm;
24 #endif
25 #ifndef STBI_NO_DDS
26 if (stbi__dds_test(s)) return STBI_dds;
27 #endif
28 #ifndef STBI_NO_PVR
29 if (stbi__pvr_test(s)) return STBI_pvr;
30 #endif
31 #ifndef STBI_NO_PKM
32 if (stbi__pkm_test(s)) return STBI_pkm;
33 #endif
34 #ifndef STBI_NO_HDR
35 if (stbi__hdr_test(s)) return STBI_hdr;
36 #endif
37 #ifndef STBI_NO_TGA
38 if (stbi__tga_test(s)) return STBI_tga;
39 #endif
40 return STBI_unknown;
41 }
42
43 #ifndef STBI_NO_STDIO
stbi_test_from_file(FILE * f)44 int stbi_test_from_file(FILE *f)
45 {
46 stbi__context s;
47 stbi__start_file(&s,f);
48 return stbi_test_main(&s);
49 }
50
stbi_test(char const * filename)51 int stbi_test(char const *filename)
52 {
53 FILE *f = fopen(filename, "rb");
54 int result;
55 if (!f) return STBI_unknown;
56 result = stbi_test_from_file(f);
57 fclose(f);
58 return result;
59 }
60 #endif //!STBI_NO_STDIO
61
stbi_test_from_memory(stbi_uc const * buffer,int len)62 int stbi_test_from_memory(stbi_uc const *buffer, int len)
63 {
64 stbi__context s;
65 stbi__start_mem(&s,buffer,len);
66 return stbi_test_main(&s);
67 }
68
stbi_test_from_callbacks(stbi_io_callbacks const * clbk,void * user)69 int stbi_test_from_callbacks(stbi_io_callbacks const *clbk, void *user)
70 {
71 stbi__context s;
72 stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user);
73 return stbi_test_main(&s);
74 }
75