From db3a4528eb65fe2358a6334a3536aca73c3df5de Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Tue, 13 May 2025 17:19:02 +0200 Subject: [PATCH] Simplify 94481a9 --- src/common.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/common.cc b/src/common.cc index 55571ccd..abbfe705 100644 --- a/src/common.cc +++ b/src/common.cc @@ -995,9 +995,8 @@ namespace sharp { } // Add alpha channel(s) to alphaColour colour if (colour[3] < 255.0 || image.has_alpha()) { - do { - alphaColour.push_back(colour[3] * multiplier); - } while (alphaColour.size() < static_cast(image.bands())); + int extraBands = image.bands() > 4 ? image.bands() - 3 : 1; + alphaColour.insert(alphaColour.end(), extraBands, colour[3] * multiplier); } // Ensure alphaColour colour uses correct colourspace alphaColour = sharp::GetRgbaAsColourspace(alphaColour, image.interpretation(), premultiply);