svnno****@sourc*****
svnno****@sourc*****
2009年 2月 16日 (月) 01:55:22 JST
Revision: 119 http://svn.sourceforge.jp/view?root=swfed&view=rev&rev=119 Author: yoya Date: 2009-02-16 01:55:22 +0900 (Mon, 16 Feb 2009) Log Message: ----------- alpha 値(不透明度)が 0, 255 以外の時に表示される色がおかしくなる不具合を修正 - PNG の (R, G, B, A) を (R*A/255, G*A/255, B*A/255, A) に変換し Lossless2 タグに保存するように修正。 - GIF は透明度 pixel を (0, 0, 0, 0) で保存するように修正 Modified Paths: -------------- trunk/src/swf_gif.c trunk/src/swf_png.c -------------- next part -------------- Modified: trunk/src/swf_gif.c =================================================================== --- trunk/src/swf_gif.c 2009-02-14 15:55:25 UTC (rev 118) +++ trunk/src/swf_gif.c 2009-02-15 16:55:22 UTC (rev 119) @@ -173,9 +173,12 @@ result_colormap[i].green = ColorMap->Colors[i].Green; result_colormap[i].blue = ColorMap->Colors[i].Blue; if (i == trans_index) { - result_colormap[i].alpha = 0x0; + result_colormap[i].red = 0x0; + result_colormap[i].green = 0x0; + result_colormap[i].blue = 0x0; + result_colormap[i].alpha = 0x0; } else { - result_colormap[i].alpha = 0xff; + result_colormap[i].alpha = 0xff; } } *colormap = result_colormap; Modified: trunk/src/swf_png.c =================================================================== --- trunk/src/swf_png.c 2009-02-14 15:55:25 UTC (rev 118) +++ trunk/src/swf_png.c 2009-02-15 16:55:22 UTC (rev 119) @@ -191,13 +191,17 @@ } else { swf_rgba_t *result_colormap = malloc(sizeof(swf_rgba_t) * palette_num); // Lossless2 for (i=0 ; i < palette_num ; i++) { - result_colormap[i].red = palette[i].red; - result_colormap[i].green = palette[i].green; - result_colormap[i].blue = palette[i].blue; if (i <= num_trans) { - result_colormap[i].alpha = trans[i]; + int alpha_value = trans[i]; + result_colormap[i].red = palette[i].red * alpha_value / 0xff; + result_colormap[i].green = palette[i].green * alpha_value / 0xff; + result_colormap[i].blue = palette[i].blue * alpha_value / 0xff; + result_colormap[i].alpha = alpha_value; } else { - result_colormap[i].alpha = 0xff; // XXX + result_colormap[i].red = palette[i].red; + result_colormap[i].green = palette[i].green; + result_colormap[i].blue = palette[i].blue; + result_colormap[i].alpha = 0xff; // opaque } } *colormap = result_colormap; @@ -225,10 +229,11 @@ argb_list = malloc(sizeof(swf_argb_t) * png_width * png_height); for (y=0 ; y < png_height ; y++) { for (x=0 ; x < png_width ; x++) { - argb_list[x+y*png_width].red = png_image_data[y][4*x + 0]; - argb_list[x+y*png_width].green = png_image_data[y][4*x + 1]; - argb_list[x+y*png_width].blue = png_image_data[y][4*x + 2]; - argb_list[x+y*png_width].alpha = png_image_data[y][4*x + 3]; + int alpha_value = png_image_data[y][4*x + 3]; + argb_list[x+y*png_width].red = png_image_data[y][4*x + 0] * alpha_value / 0xff; + argb_list[x+y*png_width].green = png_image_data[y][4*x + 1] * alpha_value / 0xff; + argb_list[x+y*png_width].blue = png_image_data[y][4*x + 2] * alpha_value / 0xff; + argb_list[x+y*png_width].alpha = alpha_value; } } image_data = argb_list;