From b0ad0b5b883227e3dfc331b7da3dff2b0e52538b Mon Sep 17 00:00:00 2001 From: kramm Date: Fri, 29 Apr 2005 08:45:30 +0000 Subject: [PATCH] fixed un-premultiply routines --- lib/modules/swfbits.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/modules/swfbits.c b/lib/modules/swfbits.c index 30f2e42..0af32c7 100644 --- a/lib/modules/swfbits.c +++ b/lib/modules/swfbits.c @@ -150,8 +150,10 @@ int swf_ImageGetNumberOfPaletteEntries(RGBA*img, int width, int height, RGBA*pal } lastcol32 = col32; } - if(palette_overflow) + if(palette_overflow) { + free(pal); return width*height; + } if(palette) { int i = 0; for(t=0;t<256;t++) { @@ -895,9 +897,16 @@ RGBA *swf_DefineLosslessBitsTagToImage(TAG * tag, int *dwidth, int *dheight) dest[pos2].r = data[pos + 1]; dest[pos2].g = data[pos + 2]; dest[pos2].b = data[pos + 3];*/ - dest[pos2].r = ((int)data[pos + 1]*255)/(int)data[pos+0]; - dest[pos2].g = ((int)data[pos + 2]*255)/(int)data[pos+0]; - dest[pos2].b = ((int)data[pos + 3]*255)/(int)data[pos+0]; + int alpha = data[pos+0]; + if(alpha) { + dest[pos2].r = ((int)data[pos + 1]*255)/alpha; + dest[pos2].g = ((int)data[pos + 2]*255)/alpha; + dest[pos2].b = ((int)data[pos + 3]*255)/alpha; + } else { + dest[pos2].r = data[pos + 1]; + dest[pos2].g = data[pos + 2]; + dest[pos2].b = data[pos + 3]; + } dest[pos2].a = data[pos + 0]; //alpha pos2++; pos += 4; -- 1.7.10.4