| 7241 | } |
| 7242 | |
| 7243 | static int stbi__gif_header(stbi__context* s, stbi__gif* g, int* comp, int is_info) { |
| 7244 | stbi_uc version; |
| 7245 | if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || |
| 7246 | stbi__get8(s) != '8') |
| 7247 | return stbi__err("not GIF", "Corrupt GIF"); |
| 7248 | |
| 7249 | version = stbi__get8(s); |
| 7250 | if (version != '7' && version != '9') |
| 7251 | return stbi__err("not GIF", "Corrupt GIF"); |
| 7252 | if (stbi__get8(s) != 'a') |
| 7253 | return stbi__err("not GIF", "Corrupt GIF"); |
| 7254 | |
| 7255 | stbi__g_failure_reason = ""; |
| 7256 | g->w = stbi__get16le(s); |
| 7257 | g->h = stbi__get16le(s); |
| 7258 | g->flags = stbi__get8(s); |
| 7259 | g->bgindex = stbi__get8(s); |
| 7260 | g->ratio = stbi__get8(s); |
| 7261 | g->transparent = -1; |
| 7262 | |
| 7263 | if (g->w > STBI_MAX_DIMENSIONS) |
| 7264 | return stbi__err("too large", "Very large image (corrupt?)"); |
| 7265 | if (g->h > STBI_MAX_DIMENSIONS) |
| 7266 | return stbi__err("too large", "Very large image (corrupt?)"); |
| 7267 | |
| 7268 | if (comp != 0) |
| 7269 | *comp = 4; // can't actually tell whether it's 3 or 4 until we parse the comments |
| 7270 | |
| 7271 | if (is_info) |
| 7272 | return 1; |
| 7273 | |
| 7274 | if (g->flags & 0x80) |
| 7275 | stbi__gif_parse_colortable(s, g->pal, 2 << (g->flags & 7), -1); |
| 7276 | |
| 7277 | return 1; |
| 7278 | } |
| 7279 | |
| 7280 | static int stbi__gif_info_raw(stbi__context* s, int* x, int* y, int* comp) { |
| 7281 | stbi__gif* g = (stbi__gif*)stbi__malloc(sizeof(stbi__gif)); |
no test coverage detected