| 6603 | } |
| 6604 | |
| 6605 | static int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, int is_info) |
| 6606 | { |
| 6607 | stbi_uc version; |
| 6608 | if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') |
| 6609 | return stbi__err("not GIF", "Corrupt GIF"); |
| 6610 | |
| 6611 | version = stbi__get8(s); |
| 6612 | if (version != '7' && version != '9') return stbi__err("not GIF", "Corrupt GIF"); |
| 6613 | if (stbi__get8(s) != 'a') return stbi__err("not GIF", "Corrupt GIF"); |
| 6614 | |
| 6615 | stbi__g_failure_reason = ""; |
| 6616 | g->w = stbi__get16le(s); |
| 6617 | g->h = stbi__get16le(s); |
| 6618 | g->flags = stbi__get8(s); |
| 6619 | g->bgindex = stbi__get8(s); |
| 6620 | g->ratio = stbi__get8(s); |
| 6621 | g->transparent = -1; |
| 6622 | |
| 6623 | if (g->w > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)"); |
| 6624 | if (g->h > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)"); |
| 6625 | |
| 6626 | if (comp != 0) *comp = 4; // can't actually tell whether it's 3 or 4 until we parse the comments |
| 6627 | |
| 6628 | if (is_info) return 1; |
| 6629 | |
| 6630 | if (g->flags & 0x80) |
| 6631 | stbi__gif_parse_colortable(s,g->pal, 2 << (g->flags & 7), -1); |
| 6632 | |
| 6633 | return 1; |
| 6634 | } |
| 6635 | |
| 6636 | static int stbi__gif_info_raw(stbi__context *s, int *x, int *y, int *comp) |
| 6637 | { |
no test coverage detected