libmemdraw: fix drawing to color mapped with alpha chan (m8a8)
This commit is contained in:
parent
4cbfe26da4
commit
56073b7381
1 changed files with 17 additions and 5 deletions
|
@ -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<dx; i++, red+=delta, grn+=delta, blu+=delta)
|
||||
*w++ = cmap[(*red>>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<dx; i++, red+=delta, grn+=delta, blu+=delta, w+=2){
|
||||
w[a] = *alpha;
|
||||
if(alpha != &ones)
|
||||
alpha+=delta;
|
||||
w[m] = cmap[(*red>>4)*256+(*grn>>4)*16+(*blu>>4)];
|
||||
}
|
||||
} else {
|
||||
for(i=0; i<dx; i++, red+=delta, grn+=delta, blu+=delta)
|
||||
*w++ = cmap[(*red>>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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue