diff --git a/src/render/quantization.cpp b/src/render/quantization.cpp index 08dff3362..f8601684c 100644 --- a/src/render/quantization.cpp +++ b/src/render/quantization.cpp @@ -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)); diff --git a/src/render/quantization.h b/src/render/quantization.h index 0efa89f24..7e8876840 100644 --- a/src/render/quantization.h +++ b/src/render/quantization.h @@ -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.