Quantization: Generate 1st pal entry w/alpha=0 for mask color on transparent layers when possible (fix #2109)

This commit is contained in:
David Capello 2019-08-12 16:42:51 -03:00
parent f317f9594d
commit 2a42cc1bf6
2 changed files with 9 additions and 5 deletions

View File

@ -1,6 +1,6 @@
// Aseprite Render Library
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (c) 2001-2018 David Capello
// Copyright (c) 2019 Igara Studio S.A.
// Copyright (c) 2001-2018 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -350,6 +350,9 @@ void PaletteOptimizer::feedWithImage(Image* image, bool withAlpha)
{
uint32_t color;
if (withAlpha)
m_withAlpha = true;
ASSERT(image);
switch (image->pixelFormat()) {
@ -431,7 +434,7 @@ void PaletteOptimizer::calculate(Palette* palette, int maskIndex)
palette->applyRemap(remap);
if (maskIndex < palette->size())
palette->setEntry(maskIndex, rgba(0, 0, 0, 255));
palette->setEntry(maskIndex, rgba(0, 0, 0, (m_withAlpha ? 0: 255)));
}
else
palette->resize(MAX(1, usedColors));

View File

@ -1,6 +1,6 @@
// Aseprite Rener Library
// Copyright (C) 2019 Igara Studio S.A.
// Copyright (c) 2001-2015, 2017 David Capello
// Copyright (c) 2019 Igara Studio S.A.
// Copyright (c) 2001-2017 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -34,6 +34,7 @@ namespace render {
private:
render::ColorHistogram<5, 6, 5, 5> m_histogram;
bool m_withAlpha = false;
};
// Creates a new palette suitable to quantize the given RGB sprite to Indexed color.