From c13d47a6ee58043a1d8f50365b49d2b212754dc4 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Tue, 12 Feb 2008 07:56:56 +0000 Subject: [PATCH] applied patch from David Capello that fixes loading of fli files that 2008-02-12 Sven Neumann * plug-ins/gfli/fli.c: applied patch from David Capello that fixes loading of fli files that specify width and height as zero (interpreting this as 320x200). It also fixes a problem in an unused code path (writing of differential color chunks). svn path=/trunk/; revision=24869 --- ChangeLog | 7 +++++++ plug-ins/gfli/fli.c | 21 ++++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 35492a73f4..cc3faa878f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-02-12 Sven Neumann + + * plug-ins/gfli/fli.c: applied patch from David Capello that fixes + loading of fli files that specify width and height as zero + (interpreting this as 320x200). It also fixes a problem in an + unused code path (writing of differential color chunks). + 2008-02-12 Sven Neumann * app/widgets/gimplanguagestore-parser.c: inverted logic; #ifdef diff --git a/plug-ins/gfli/fli.c b/plug-ins/gfli/fli.c index 312e495494..f735262865 100644 --- a/plug-ins/gfli/fli.c +++ b/plug-ins/gfli/fli.c @@ -99,6 +99,12 @@ void fli_read_header(FILE *f, s_fli_header *fli_header) fli_header->magic = NO_HEADER; } } + + if (fli_header->width == 0) + fli_header->width = 320; + + if (fli_header->height == 0) + fli_header->height = 200; } void fli_write_header(FILE *f, s_fli_header *fli_header) @@ -268,14 +274,14 @@ int fli_write_color(FILE *f, s_fli_header *fli_header, unsigned char *old_cmap, fli_write_char(f, cmap[col_pos]>>2); } } else { - unsigned short num_packets, cnt_skip, cnt_col, col_pos, col_start; - num_packets=0; col_pos=0; + unsigned short cnt_skip, cnt_col, col_pos, col_start; + col_pos=0; do { cnt_skip=0; while ((col_pos<256) && (old_cmap[col_pos*3+0]==cmap[col_pos*3+0]) && (old_cmap[col_pos*3+1]==cmap[col_pos*3+1]) && (old_cmap[col_pos*3+2]==cmap[col_pos*3+2])) { cnt_skip++; col_pos++; } - col_start=col_pos; + col_start=col_pos*3; cnt_col=0; while ((col_pos<256) && !((old_cmap[col_pos*3+0]==cmap[col_pos*3+0]) && (old_cmap[col_pos*3+1]==cmap[col_pos*3+1]) && (old_cmap[col_pos*3+2]==cmap[col_pos*3+2]))) { cnt_col++; col_pos++; @@ -359,14 +365,14 @@ int fli_write_color_2(FILE *f, s_fli_header *fli_header, unsigned char *old_cmap fli_write_char(f, cmap[col_pos]); } } else { - unsigned short num_packets, cnt_skip, cnt_col, col_pos, col_start; - num_packets=0; col_pos=0; + unsigned short cnt_skip, cnt_col, col_pos, col_start; + col_pos=0; do { cnt_skip=0; while ((col_pos<256) && (old_cmap[col_pos*3+0]==cmap[col_pos*3+0]) && (old_cmap[col_pos*3+1]==cmap[col_pos*3+1]) && (old_cmap[col_pos*3+2]==cmap[col_pos*3+2])) { cnt_skip++; col_pos++; } - col_start=col_pos; + col_start=col_pos*3; cnt_col=0; while ((col_pos<256) && !((old_cmap[col_pos*3+0]==cmap[col_pos*3+0]) && (old_cmap[col_pos*3+1]==cmap[col_pos*3+1]) && (old_cmap[col_pos*3+2]==cmap[col_pos*3+2]))) { cnt_col++; col_pos++; @@ -375,10 +381,11 @@ int fli_write_color_2(FILE *f, s_fli_header *fli_header, unsigned char *old_cmap num_packets++; fli_write_char(f, cnt_skip); fli_write_char(f, cnt_col); - for (; cnt_col>0; cnt_col--) { + while (cnt_col>0) { fli_write_char(f, cmap[col_start++]); fli_write_char(f, cmap[col_start++]); fli_write_char(f, cmap[col_start++]); + cnt_col--; } } } while (col_pos<256);