From 29d80fbf728fdb249949c17d004da72cd4502168 Mon Sep 17 00:00:00 2001 From: kramm Date: Sun, 6 Jun 2004 14:26:52 +0000 Subject: [PATCH] added 32 bit alpha handling for DEFINEBITSLOSSLESS2. --- src/swfextract.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/swfextract.c b/src/swfextract.c index c7e7ec0..80ca272 100644 --- a/src/swfextract.c +++ b/src/swfextract.c @@ -593,7 +593,7 @@ static void make_crc32_table(void) crc32_table[t] = c; } } -static void png_write_byte(FILE*fi, U8 byte) +static inline void png_write_byte(FILE*fi, U8 byte) { fwrite(&byte,1,1,fi); mycrc32 = crc32_table[(mycrc32 ^ byte) & 0xff] ^ (mycrc32 >> 8); @@ -738,8 +738,10 @@ void handlelossless(TAG*tag) png_write_byte(fi,8); if(format == 3) png_write_byte(fi,3); //indexed - else if(format == 5) + else if(format == 5 && alpha==0) png_write_byte(fi,2); //rgb + else if(format == 5 && alpha==1) + png_write_byte(fi,6); //rgba else return; png_write_byte(fi,0); //compression mode @@ -749,6 +751,7 @@ void handlelossless(TAG*tag) if(format == 3) { png_start_chunk(fi, "PLTE", 768); + for(t=0;t<256;t++) { png_write_byte(fi,palette[t].r); png_write_byte(fi,palette[t].g); @@ -766,12 +769,22 @@ void handlelossless(TAG*tag) { data3[pos2++]=0; //filter type if(bpp==32) { - // 32 bit to 24 bit "conversion" - for(x=0;x