OSDN Git Service

alpha 値(不透明度)が 0, 255 以外の時に表示される色がおかしくなる不具合を修正
authoryoya <yoya@7c90b180-03d5-4157-b861-58a559ae9d1e>
Sun, 15 Feb 2009 16:55:22 +0000 (16:55 +0000)
committeryoya <yoya@7c90b180-03d5-4157-b861-58a559ae9d1e>
Sun, 15 Feb 2009 16:55:22 +0000 (16:55 +0000)
- PNG の (R, G, B, A) を (R*A/255, G*A/255, B*A/255, A) に変換し Lossless2 タグに保存するように修正。
- GIF は透明度 pixel を (0, 0, 0, 0) で保存するように修正

git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/swfed/trunk@119 7c90b180-03d5-4157-b861-58a559ae9d1e

src/swf_gif.c
src/swf_png.c

index 2c9cf76..0c0c153 100644 (file)
@@ -173,9 +173,12 @@ gifconv_gif2lossless(unsigned char *gif_data, unsigned long gif_data_len,
             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;
index 58c2238..aeb5ba1 100644 (file)
@@ -191,13 +191,17 @@ pngconv_png2lossless(unsigned char *png_data, unsigned long png_data_len,
         } 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 @@ pngconv_png2lossless(unsigned char *png_data, unsigned long png_data_len,
         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;