Fix indexed -> RGB/grayscale conversion when palette colors have alpha

This commit is contained in:
David Capello 2015-06-30 21:25:27 -03:00
parent c856faee3e
commit 8f24c05451

View File

@ -85,7 +85,7 @@ Image* convert_pixel_format(
} }
color_t c; color_t c;
int r, g, b; int r, g, b, a;
switch (image->pixelFormat()) { switch (image->pixelFormat()) {
@ -226,9 +226,7 @@ Image* convert_pixel_format(
if (!is_background && c == image->maskColor()) if (!is_background && c == image->maskColor())
*dst_it = 0; *dst_it = 0;
else else
*dst_it = rgba(rgba_getr(palette->getEntry(c)), *dst_it = palette->getEntry(c);
rgba_getg(palette->getEntry(c)),
rgba_getb(palette->getEntry(c)), 255);
} }
ASSERT(dst_it == dst_end); ASSERT(dst_it == dst_end);
break; break;
@ -249,12 +247,14 @@ Image* convert_pixel_format(
if (!is_background && c == image->maskColor()) if (!is_background && c == image->maskColor())
*dst_it = 0; *dst_it = 0;
else { else {
r = rgba_getr(palette->getEntry(c)); c = palette->getEntry(c);
g = rgba_getg(palette->getEntry(c)); r = rgba_getr(c);
b = rgba_getb(palette->getEntry(c)); g = rgba_getg(c);
b = rgba_getb(c);
a = rgba_geta(c);
g = 255 * Hsv(Rgb(r, g, b)).valueInt() / 100; g = 255 * Hsv(Rgb(r, g, b)).valueInt() / 100;
*dst_it = graya(g, 255); *dst_it = graya(g, a);
} }
} }
ASSERT(dst_it == dst_end); ASSERT(dst_it == dst_end);