mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-01 01:13:40 +00:00
Fix conversion of Indexed images to RGB when the layer is transparent
This commit is contained in:
parent
df3b87c409
commit
7017332d62
@ -173,15 +173,30 @@ void DocumentApi::setPixelFormat(Sprite* sprite, PixelFormat newFormat, Ditherin
|
||||
// Use the rgbmap for the specified sprite
|
||||
const RgbMap* rgbmap = sprite->getRgbMap(frame);
|
||||
|
||||
// Get the list of cels from the background layer (if it
|
||||
// exists). This list will be used to check if each image belong to
|
||||
// the background layer.
|
||||
CelList bgCels;
|
||||
if (sprite->getBackgroundLayer() != NULL)
|
||||
sprite->getBackgroundLayer()->getCels(bgCels);
|
||||
|
||||
for (c=0; c<sprite->getStock()->size(); c++) {
|
||||
old_image = sprite->getStock()->getImage(c);
|
||||
if (!old_image)
|
||||
continue;
|
||||
|
||||
bool is_image_from_background = false;
|
||||
for (CelList::iterator it=bgCels.begin(), end=bgCels.end(); it != end; ++it) {
|
||||
if ((*it)->getImage() == c) {
|
||||
is_image_from_background = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
new_image = quantization::convert_pixel_format
|
||||
(old_image, newFormat, dithering_method, rgbmap,
|
||||
sprite->getPalette(frame),
|
||||
sprite->getBackgroundLayer() != NULL);
|
||||
is_image_from_background);
|
||||
|
||||
replaceStockImage(sprite, c, new_image);
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ Image* convert_pixel_format(const Image* image,
|
||||
DitheringMethod ditheringMethod,
|
||||
const RgbMap* rgbmap,
|
||||
const Palette* palette,
|
||||
bool has_background_layer)
|
||||
bool is_background_layer)
|
||||
{
|
||||
// RGB -> Indexed with ordered dithering
|
||||
if (image->getPixelFormat() == IMAGE_RGB &&
|
||||
@ -223,7 +223,7 @@ Image* convert_pixel_format(const Image* image,
|
||||
ASSERT(dst_it != dst_end);
|
||||
c = *src_it;
|
||||
|
||||
if (c == 0 && !has_background_layer)
|
||||
if (!is_background_layer && c == image->getMaskColor())
|
||||
*dst_it = 0;
|
||||
else
|
||||
*dst_it = rgba(rgba_getr(palette->getEntry(c)),
|
||||
@ -243,7 +243,7 @@ Image* convert_pixel_format(const Image* image,
|
||||
ASSERT(dst_it != dst_end);
|
||||
c = *src_it;
|
||||
|
||||
if (c == 0 && !has_background_layer)
|
||||
if (!is_background_layer && c == image->getMaskColor())
|
||||
*dst_it = 0;
|
||||
else {
|
||||
r = rgba_getr(palette->getEntry(c));
|
||||
@ -268,7 +268,7 @@ Image* convert_pixel_format(const Image* image,
|
||||
ASSERT(dst_it != dst_end);
|
||||
c = *src_it;
|
||||
|
||||
if (c == image->getMaskColor())
|
||||
if (!is_background_layer && c == image->getMaskColor())
|
||||
*dst_it = dstMaskColor;
|
||||
else {
|
||||
r = rgba_getr(palette->getEntry(c));
|
||||
|
@ -44,7 +44,7 @@ namespace raster {
|
||||
DitheringMethod ditheringMethod,
|
||||
const RgbMap* rgbmap,
|
||||
const Palette* palette,
|
||||
bool has_background_layer);
|
||||
bool is_background_layer);
|
||||
|
||||
} // namespace quantization
|
||||
} // namespace raster
|
||||
|
@ -135,15 +135,20 @@ bool Sprite::needAlpha() const
|
||||
void Sprite::setTransparentColor(color_t color)
|
||||
{
|
||||
m_transparentColor = color;
|
||||
|
||||
for (int i=0; i<m_stock->size(); i++) {
|
||||
Image* image = m_stock->getImage(i);
|
||||
if (image != NULL)
|
||||
image->setMaskColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
int Sprite::getMemSize() const
|
||||
{
|
||||
Image *image;
|
||||
int i, size = 0;
|
||||
int size = 0;
|
||||
|
||||
for (i=0; i<m_stock->size(); i++) {
|
||||
image = m_stock->getImage(i);
|
||||
for (int i=0; i<m_stock->size(); i++) {
|
||||
Image* image = m_stock->getImage(i);
|
||||
if (image != NULL)
|
||||
size += image->getRowStrideSize() * image->getHeight();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user