2018-01-22 18:34:40 (UTC-02:00)
Marcel Rodrigues <marcelgmr@gmail.com>
Accept color spaces of any depth.
diff --git a/gifdec.c b/gifdec.c index 112e0c4..bf84782 100644 --- a/gifdec.c +++ b/gifdec.c @@ -38,7 +38,7 @@ gd_open_gif(const char *fname) { int fd; uint8_t sigver[3]; - uint16_t width, height; + uint16_t width, height, depth; uint8_t fdsz, bgidx, aspect; int gct_sz; gd_GIF *gif; @@ -68,10 +68,7 @@ gd_open_gif(const char *fname) goto fail; } /* Color Space's Depth */ - if (((fdsz >> 4) & 7) != 7) { - fprintf(stderr, "depth of color space is not 8 bits\n"); - goto fail; - } + depth = ((fdsz >> 4) & 7) + 1; /* Ignore Sort Flag. */ /* GCT Size */ gct_sz = 1 << ((fdsz & 0x07) + 1); @@ -85,6 +82,7 @@ gd_open_gif(const char *fname) gif->fd = fd; gif->width = width; gif->height = height; + gif->depth = depth; /* Read GCT */ gif->gct.size = gct_sz; read(fd, gif->gct.colors, 3 * gif->gct.size); diff --git a/gifdec.h b/gifdec.h index b938b20..32ee40e 100644 --- a/gifdec.h +++ b/gifdec.h @@ -21,6 +21,7 @@ typedef struct gd_GIF { int fd; off_t anim_start; uint16_t width, height; + uint16_t depth; uint16_t loop_count; gd_GCE gce; gd_Palette *palette;