Skip to content

Commit

Permalink
Merge the fix for the case h001 of #76, reported by @hongxuchen
Browse files Browse the repository at this point in the history
  • Loading branch information
saitoha committed Dec 14, 2019
2 parents 2d3d9ff + 962f97f commit 88561b7
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/fromgif.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,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;
Expand Down Expand Up @@ -274,15 +275,22 @@ 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) {
g->cur_x = g->start_x;
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;
}
Expand Down Expand Up @@ -434,11 +442,13 @@ 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;

/* Packed Fields (1 byte)
* +-+-+-+--+---+
Expand All @@ -455,10 +465,10 @@ gif_load_next(

/* Interlace Flag */
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;
}

Expand Down Expand Up @@ -629,8 +639,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;
Expand Down

0 comments on commit 88561b7

Please sign in to comment.