From d36fd5064d3603597af9121c07c9cc0720fc7477 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Tue, 13 May 2025 17:17:36 +0200 Subject: [PATCH] Prefer use of `bandjoin_const()` and list-initialization --- src/common.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/common.cc b/src/common.cc index b00483c5..55571ccd 100644 --- a/src/common.cc +++ b/src/common.cc @@ -1003,8 +1003,7 @@ namespace sharp { alphaColour = sharp::GetRgbaAsColourspace(alphaColour, image.interpretation(), premultiply); // Add non-transparent alpha channel, if required if (colour[3] < 255.0 && !image.has_alpha()) { - image = image.bandjoin( - VImage::new_matrix(image.width(), image.height()).new_from_image(255 * multiplier).cast(image.format())); + image = image.bandjoin_const({ 255 * multiplier }); } return std::make_tuple(image, alphaColour); } @@ -1024,9 +1023,7 @@ namespace sharp { */ VImage EnsureAlpha(VImage image, double const value) { if (!image.has_alpha()) { - std::vector alpha; - alpha.push_back(value * vips_interpretation_max_alpha(image.interpretation())); - image = image.bandjoin_const(alpha); + image = image.bandjoin_const({ value * vips_interpretation_max_alpha(image.interpretation()) }); } return image; }