diff --git a/src/gfx/pal_spec.cpp b/src/gfx/pal_spec.cpp index 3fb84675..d87d672c 100644 --- a/src/gfx/pal_spec.cpp +++ b/src/gfx/pal_spec.cpp @@ -231,8 +231,7 @@ static std::optional parseDec(std::string const &str, size_t &n) { return std::optional{value}; } -static std::optional - parseColor(std::string const &str, size_t &n, uint16_t i) { +static std::optional parseColor(std::string const &str, size_t &n, uint16_t i) { std::optional r = parseDec(str, n); if (!r) { error("Failed to parse color #%d (\"%s\"): invalid red component", i + 1, str.c_str()); @@ -602,10 +601,9 @@ void parseExternalPalSpec(char const *arg) { std::tuple{"GBC", &parseGBCFile, std::ios::binary}, }; - auto iter = - std::find_if(RANGE(parsers), [&arg, &ptr](auto const &parser) { - return strncasecmp(arg, std::get<0>(parser), ptr - arg) == 0; - }); + auto iter = std::find_if(RANGE(parsers), [&arg, &ptr](auto const &parser) { + return strncasecmp(arg, std::get<0>(parser), ptr - arg) == 0; + }); if (iter == parsers.end()) { error( "Unknown external palette format \"%.*s\"", diff --git a/src/gfx/process.cpp b/src/gfx/process.cpp index 4b9d34e5..f27fb3e2 100644 --- a/src/gfx/process.cpp +++ b/src/gfx/process.cpp @@ -604,9 +604,9 @@ static std::tuple, std::vector> // Convert the palette spec to actual palettes std::vector palettes(options.palSpec.size()); for (auto [spec, pal] : zip(options.palSpec, palettes)) { - for (size_t i = 0; i < options.nbColorsPerPal && (!spec[i] || spec[i]->isOpaque()); ++i) { + for (size_t i = 0; i < options.nbColorsPerPal; ++i) { // If the spec has a gap, there's no need to copy anything. - if (spec[i]) { + if (spec[i].has_value() && !spec[i]->isTransparent()) { pal[i] = spec[i]->cgbColor(); } } diff --git a/src/gfx/rgba.cpp b/src/gfx/rgba.cpp index 0e0677ef..ace209f3 100644 --- a/src/gfx/rgba.cpp +++ b/src/gfx/rgba.cpp @@ -58,6 +58,7 @@ uint16_t Rgba::cgbColor() const { uint8_t Rgba::grayIndex() const { assume(isGray()); - // Convert from [0; 256[ to [0; maxOpaqueColors[ - return static_cast(255 - red) * options.maxOpaqueColors() / 256; + // Convert from 0..<256 to hasTransparentPixels..