From 9c5e872f9c4f8a0a1d5d802d9d56b3a4d6862e83 Mon Sep 17 00:00:00 2001 From: Rangi Date: Thu, 10 Sep 2026 16:41:32 -0400 Subject: [PATCH] First color of `-c` palettes with transparent pixels is transparent $8000, not unspecified $ffff --- src/gfx/process.cpp | 14 ++++++++++++-- test/gfx/implicit-transparent.out.pal | Bin 0 -> 8 bytes 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 test/gfx/implicit-transparent.out.pal 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 0000000000000000000000000000000000000000..8d0318d1cad99366473abd5ad0578a4bf2e307db GIT binary patch literal 8 PcmZQ*V5pI2`2QaO32g%! literal 0 HcmV?d00001