From e3a4c0eb5197c8efd43dbf72ca02b1c6ed3492e3 Mon Sep 17 00:00:00 2001 From: Hayaki Saito Date: Sun, 5 Aug 2018 01:52:01 +0900 Subject: [PATCH 1/3] GIF loader: fix for #76 POC h001. don't believe image size declared in the header, use actual size. https://github.com/saitoha/libsixel/issues/76 --- src/fromgif.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/fromgif.c b/src/fromgif.c index c13b0055..051287de 100644 --- a/src/fromgif.c +++ b/src/fromgif.c @@ -72,6 +72,7 @@ typedef struct int start_x, start_y; int max_x, max_y; int cur_x, cur_y; + int actual_width, actual_height; int line_size; int loop_count; int delay; @@ -270,7 +271,14 @@ gif_out_code( return; } - g->out[g->cur_x + g->cur_y] = g->codes[code].suffix; + g->out[g->cur_x + g->cur_y * g->line_size] = g->codes[code].suffix; + if (g->cur_x >= g->actual_width) { + g->actual_width = g->cur_x + 1; + } + if (g->cur_y >= g->actual_height) { + g->actual_height = g->cur_y + 1; + } + g->cur_x++; if (g->cur_x >= g->max_x) { @@ -278,7 +286,7 @@ gif_out_code( g->cur_y += g->step; while (g->cur_y >= g->max_y && g->parse > 0) { - g->step = (1 << g->parse) * g->line_size; + g->step = 1 << g->parse; g->cur_y = g->start_y + (g->step >> 1); --g->parse; } @@ -422,19 +430,21 @@ gif_load_next( g->line_size = g->w; g->start_x = x; - g->start_y = y * g->line_size; + g->start_y = y; g->max_x = g->start_x + w; - g->max_y = g->start_y + h * g->line_size; + g->max_y = g->start_y + h; g->cur_x = g->start_x; g->cur_y = g->start_y; + g->actual_width = g->start_x; + g->actual_height = g->start_y; g->lflags = gif_get8(s); if (g->lflags & 0x40) { - g->step = 8 * g->line_size; /* first interlaced spacing */ + g->step = 8; /* first interlaced spacing */ g->parse = 3; } else { - g->step = g->line_size; + g->step = 1; g->parse = 0; } @@ -604,8 +614,8 @@ load_gif( break; } - frame->width = g.w; - frame->height = g.h; + frame->width = g.actual_width; + frame->height = g.actual_height; status = gif_init_frame(frame, &g, bgcolor, reqcolors, fuse_palette); if (status != SIXEL_OK) { goto end; From 747c324319fd47f869c25f7244de3d91996e00a6 Mon Sep 17 00:00:00 2001 From: Hayaki Saito Date: Fri, 13 Dec 2019 02:47:25 +0900 Subject: [PATCH 2/3] Ammend fix for e18ebe6 --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 29d306e4..d82ebcc4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,8 @@ matrix: env: XCC=clang HOST= PREFIX=/usr/local DEBUG="--enable-tests --enable-debug" WINE= LIBCURL=--without-libcurl JPEG=--without-jpeg PNG=--without-png - os: linux env: XCC=i686-w64-mingw32-gcc HOST="--host=i686-w64-mingw32" PREFIX="/usr/i686-w64-mingw32" DEBUG="--enable-tests --enable-debug" WINE=wine - - os: linux - env: XCC=i586-mingw32msvc-gcc HOST="--host=i586-mingw32msvc" PREFIX="/usr/i586-mingw32msvc" WINE=wine +#t - os: linux +# env: XCC=i586-mingw32msvc-gcc HOST="--host=i586-mingw32msvc" PREFIX="/usr/i586-mingw32msvc" WINE=wine - os: linux env: XCC=x86_64-w64-mingw32-gcc HOST="--host=x86_64-w64-mingw32" PREFIX="/usr/x86_64-w64-mingw32" DEBUG="--enable-tests --enable-debug" WINE=wine64 - os: linux From 962f97ff366d5e8d69456c1c922ec82776ef5a6f Mon Sep 17 00:00:00 2001 From: Hayaki Saito Date: Fri, 13 Dec 2019 02:34:29 +0900 Subject: [PATCH 3/3] Suppress glib deprecated warnings --- src/loader.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/loader.c b/src/loader.c index cb1e61f8..64da4315 100644 --- a/src/loader.c +++ b/src/loader.c @@ -941,10 +941,11 @@ load_with_gdkpixbuf( GdkPixbuf *pixbuf; GdkPixbufAnimation *animation; GdkPixbufLoader *loader = NULL; -#if 1 GdkPixbufAnimationIter *it; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" GTimeVal time_val; -#endif +#pragma GCC diagnostic pop sixel_frame_t *frame = NULL; int stride; unsigned char *p; @@ -963,7 +964,10 @@ load_with_gdkpixbuf( #if (!GLIB_CHECK_VERSION(2, 36, 0)) g_type_init(); #endif +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" g_get_current_time(&time_val); +#pragma GCC diagnostic pop loader = gdk_pixbuf_loader_new(); gdk_pixbuf_loader_write(loader, pchunk->buffer, pchunk->size, NULL); animation = gdk_pixbuf_loader_get_animation(loader); @@ -1006,7 +1010,10 @@ load_with_gdkpixbuf( goto end; } } else { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" g_get_current_time(&time_val); +#pragma GCC diagnostic pop frame->frame_no = 0; @@ -1014,7 +1021,10 @@ load_with_gdkpixbuf( for (;;) { while (!gdk_pixbuf_animation_iter_on_currently_loading_frame(it)) { frame->delay = gdk_pixbuf_animation_iter_get_delay_time(it); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" g_time_val_add(&time_val, frame->delay * 1000); +#pragma GCC diagnostic pop frame->delay /= 10; pixbuf = gdk_pixbuf_animation_iter_get_pixbuf(it); if (pixbuf == NULL) {