summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2015-03-11 12:59:19 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2015-03-11 12:59:19 +0100
commita44a1dbd19c2a9b05b497e32853e57ca88495397 (patch)
treee269782aa12a166b7a7e791f8ad36aadd72b05a8
parenta6f7507661ad7decb3a0a62994bea2ba276ff81d (diff)
downloadplan9front-a44a1dbd19c2a9b05b497e32853e57ca88495397.tar.xz
gif: fix color table clipping (for cb5.gif)
-rw-r--r--sys/src/cmd/jpg/readgif.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/sys/src/cmd/jpg/readgif.c b/sys/src/cmd/jpg/readgif.c
index d5c0d1d7d..cac585325 100644
--- a/sys/src/cmd/jpg/readgif.c
+++ b/sys/src/cmd/jpg/readgif.c
@@ -376,7 +376,7 @@ static
uchar*
decode(Header *h, Rawimage *i, Entry *tbl)
{
- int c, doclip, incode, codesize, CTM, EOD, pici, datai, stacki, nbits, sreg, fc, code, piclen;
+ int c, incode, codesize, CTM, EOD, pici, datai, stacki, nbits, sreg, fc, code, piclen;
int csize, nentry, maxentry, first, ocode, ndata, nb;
uchar clip, *p, *pic;
uchar stack[4096], data[256];
@@ -386,10 +386,6 @@ decode(Header *h, Rawimage *i, Entry *tbl)
codesize = h->buf[0];
if(codesize>8 || 0>codesize)
giferror(h, "ReadGIF: can't handle codesize %d", codesize);
- doclip = 0;
- if(i->cmap!=nil && i->cmaplen!=3*(1<<codesize)
- && (codesize!=2 || i->cmaplen!=3*2)) /* peculiar GIF bitmap files... */
- doclip = 1;
CTM =1<<codesize;
EOD = CTM+1;
@@ -490,10 +486,10 @@ decode(Header *h, Rawimage *i, Entry *tbl)
}
Return:
- if(doclip){
- clip = i->cmaplen/3;
+ if(i->cmap!=nil && i->cmaplen!=3*256){
+ clip = (i->cmaplen/3)-1;
for(p = pic; p < pic+piclen; p++)
- if(*p >= clip)
+ if(*p > clip)
*p = clip;
}
h->pic = nil;