allow differential gif anamation. Reference: /n/sources/patch/applied/gifanamat Date: Fri Dec 2 15:59:54 CET 2011 Signed-off-by: quanstro@quanstro.net --- /sys/src/cmd/jpg/gif.c Fri Dec 2 15:59:06 2011 +++ /sys/src/cmd/jpg/gif.c Fri Dec 2 15:59:04 2011 @@ -14,6 +14,7 @@ ulong outchan = CMAP8; Image **allims; Image **allmasks; +Rawimage **allimages; int which; int defaultcolor = 1; @@ -52,7 +53,10 @@ border(screen, r, -Border, nil, ZP); r.min.x += allims[which]->r.min.x - allims[0]->r.min.x; r.min.y += allims[which]->r.min.y - allims[0]->r.min.y; - drawop(screen, r, allims[which], allmasks[which], allims[which]->r.min, S); + if(which>0 && allimages[which]->gifflags&TRANSP) + drawop(screen, r, allims[which], allmasks[which], allims[which]->r.min, SoverD); + else + drawop(screen, r, allims[which], allmasks[which], allims[which]->r.min, S); flushimage(display, 1); } @@ -229,7 +233,7 @@ * r is used only for reference; the image is already in c. */ void -whiteout(Rawimage *r, Rawimage *c) +blackout(Rawimage *r, Rawimage *c) { int i, trindex; uchar *rp, *cp; @@ -241,9 +245,9 @@ for(i=0; ichanlen; i++){ if(*rp == trindex){ *cp++ = 0x00; - *cp++ = 0xFF; - *cp++ = 0xFF; - *cp++ = 0xFF; + *cp++ = 0x00; + *cp++ = 0x00; + *cp++ = 0x00; }else{ *cp++ = 0xFF; cp += 3; @@ -254,7 +258,7 @@ for(i=0; ichanlen; i++){ if(*rp == trindex){ *cp++ = 0x00; - *cp++ = 0xFF; + *cp++ = 0x00; }else{ *cp++ = 0xFF; cp++; @@ -349,6 +353,7 @@ } } + allimages = images; allims = ims; allmasks = masks; loopcount = images[0]->gifloopcount; @@ -380,7 +385,7 @@ if(nineflag){ if(images[0]->gifflags&TRANSP){ addalpha(rgbv[0]); - whiteout(images[0], rgbv[0]); + blackout(images[0], rgbv[0]); } chantostr(buf, outchan); print("%11s %11d %11d %11d %11d ", buf, @@ -392,7 +397,7 @@ }else if(cflag){ if(images[0]->gifflags&TRANSP){ addalpha(rgbv[0]); - whiteout(images[0], rgbv[0]); + blackout(images[0], rgbv[0]); } if(writerawimage(1, rgbv[0]) < 0){ fprint(2, "gif: %s: write error: %r\n", name); @@ -403,6 +408,7 @@ Return: allims = nil; allmasks = nil; + allimages = nil; for(k=0; images[k]; k++){ for(j=0; jnchans; j++) free(images[k]->chans[j]);