diff --git a/src/gfx/process.cpp b/src/gfx/process.cpp index f576894e..81f82ab1 100644 --- a/src/gfx/process.cpp +++ b/src/gfx/process.cpp @@ -365,8 +365,9 @@ static std::pair, std::vector> // LCOV_EXCL_STOP std::vector palettes(nbPalettes); + // If the image contains at least one transparent pixel, force transparency in the first slot of - // all palettes + // all palettes. if (options.hasTransparentPixels) { for (Palette &pal : palettes) { pal.colors[0] = Rgba::transparent; @@ -400,8 +401,17 @@ static std::pair, std::vector> static std::pair, std::vector> makePalsAsSpecified(std::vector const &colorSets) { - // Convert the palette spec to actual palettes std::vector palettes(options.palSpec.size()); + + // If the image contains at least one transparent pixel, force transparency in the first slot of + // all palettes + if (options.hasTransparentPixels) { + for (Palette &pal : palettes) { + pal.colors[0] = Rgba::transparent; + } + } + + // Convert the palette spec to actual palettes bool gaveDeprecationWarning = false; for (auto [spec, pal] : zip(options.palSpec, palettes)) { bool skipFirst = false; diff --git a/test/gfx/implicit-transparent.out.pal b/test/gfx/implicit-transparent.out.pal new file mode 100644 index 00000000..8d0318d1 Binary files /dev/null and b/test/gfx/implicit-transparent.out.pal differ