diff options
author | jaseg <jaseg@jaseg.net> | 2014-01-30 20:11:59 +0100 |
---|---|---|
committer | jaseg <jaseg@jaseg.net> | 2014-01-30 20:11:59 +0100 |
commit | 5a77d3a0e0a24c2c637aec0195919a13d42ac769 (patch) | |
tree | 80e40cad3eef9ddb1cdb79676f83c2ec99f3e832 /host/gif.c | |
parent | dd677c6fa77d2bc10b1640172263eb0ba5325c6c (diff) | |
download | matelight-5a77d3a0e0a24c2c637aec0195919a13d42ac769.tar.gz matelight-5a77d3a0e0a24c2c637aec0195919a13d42ac769.tar.bz2 matelight-5a77d3a0e0a24c2c637aec0195919a13d42ac769.zip |
GIF reading fixes
Diffstat (limited to 'host/gif.c')
-rw-r--r-- | host/gif.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -14,7 +14,8 @@ int gif_buffer_input (GifFileType *gif, GifByteType *dest, int n){ readBuffer_t *rb = gif->UserData; if(rb->index+n > rb->length) n = rb->length - rb->index; - memcpy(dest, rb->data, n); + memcpy(dest, rb->data + rb->index, n); + rb->index += n; return n; } @@ -38,6 +39,7 @@ void color_fill(color_t *dest, color_t src, size_t size){ } gifAnimationState_t *gif_read(uint8_t *buf, size_t buflength){ + color_t *fb = 0; gifAnimationState_t *st = malloc(sizeof(gifAnimationState_t)); if(!st){ fprintf(stderr, "Failed to allocate %lu bytes\n", sizeof(*st)); @@ -48,6 +50,12 @@ gifAnimationState_t *gif_read(uint8_t *buf, size_t buflength){ int err = 0; GifFileType *gif = DGifOpen(&readBuf, gif_buffer_input, &err); if(err){ + fprintf(stderr, "Could not open GIF: %s\n", GifErrorString(err)); + goto error; + } + + err = DGifSlurp(gif); + if(err){ fprintf(stderr, "Could not read GIF data: %s\n", GifErrorString(err)); goto error; } @@ -57,7 +65,7 @@ gifAnimationState_t *gif_read(uint8_t *buf, size_t buflength){ fprintf(stderr, "Invalid 0*0px gif\n"); goto error; } - color_t *fb = calloc(framesize, sizeof(color_t)); + fb = calloc(framesize, sizeof(color_t)); if(!fb){ fprintf(stderr, "Failed to allocate framebuffer for GIF (%lu bytes)\n", framesize*sizeof(color_t)); goto error; |