| 7043 | } |
| 7044 | |
| 7045 | static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) |
| 7046 | { |
| 7047 | stbi_uc *u = 0; |
| 7048 | stbi__gif g; |
| 7049 | memset(&g, 0, sizeof(g)); |
| 7050 | STBI_NOTUSED(ri); |
| 7051 | |
| 7052 | u = stbi__gif_load_next(s, &g, comp, req_comp, 0); |
| 7053 | if (u == (stbi_uc *) s) u = 0; // end of animated gif marker |
| 7054 | if (u) { |
| 7055 | *x = g.w; |
| 7056 | *y = g.h; |
| 7057 | |
| 7058 | // moved conversion to after successful load so that the same |
| 7059 | // can be done for multiple frames. |
| 7060 | if (req_comp && req_comp != 4) |
| 7061 | u = stbi__convert_format(u, 4, req_comp, g.w, g.h); |
| 7062 | } else if (g.out) { |
| 7063 | // if there was an error and we allocated an image buffer, free it! |
| 7064 | STBI_FREE(g.out); |
| 7065 | } |
| 7066 | |
| 7067 | // free buffers needed for multiple frame loading; |
| 7068 | STBI_FREE(g.history); |
| 7069 | STBI_FREE(g.background); |
| 7070 | |
| 7071 | return u; |
| 7072 | } |
| 7073 | |
| 7074 | static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp) |
| 7075 | { |
no test coverage detected