From 56073b738103379003a594bbea31eb35c2fa58ee Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sun, 16 Jun 2013 00:39:31 +0200 Subject: [PATCH] libmemdraw: fix drawing to color mapped with alpha chan (m8a8) --- sys/src/libmemdraw/draw.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/sys/src/libmemdraw/draw.c b/sys/src/libmemdraw/draw.c index 574d597db..9416e0059 100644 --- a/sys/src/libmemdraw/draw.c +++ b/sys/src/libmemdraw/draw.c @@ -1541,8 +1541,8 @@ readcmap(Param *p, uchar *buf, int y) static void writecmap(Param *p, uchar *w, Buffer src) { - uchar *cmap, *red, *grn, *blu; - int i, dx, delta; + uchar *cmap, *red, *grn, *blu, *alpha; + int i, dx, delta, a, m; cmap = p->img->cmap->rgb2cmap; @@ -1552,8 +1552,20 @@ writecmap(Param *p, uchar *w, Buffer src) blu = src.blu; dx = p->dx; - for(i=0; i>4)*256+(*grn>>4)*16+(*blu>>4)]; + if(p->img->flags&Falpha){ + alpha = src.alpha; + m = p->img->shift[CMap]/8; + a = p->img->shift[CAlpha]/8; + for(i=0; i>4)*256+(*grn>>4)*16+(*blu>>4)]; + } + } else { + for(i=0; i>4)*256+(*grn>>4)*16+(*blu>>4)]; + } } #define DBG if(0) @@ -1752,7 +1764,7 @@ writefn(Memimage *img) { if(img->depth < 8) return writenbit; - if(img->chan == CMAP8) + if(img->nbits[CMap] == 8) return writecmap; return writebyte; }