Prefer use of bandjoin_const() and list-initialization

This commit is contained in:
Kleis Auke Wolthuizen 2025-05-13 17:17:36 +02:00 committed by Lovell Fuller
parent 8e17c6f518
commit d36fd5064d

View File

@ -1003,8 +1003,7 @@ namespace sharp {
alphaColour = sharp::GetRgbaAsColourspace(alphaColour, image.interpretation(), premultiply); alphaColour = sharp::GetRgbaAsColourspace(alphaColour, image.interpretation(), premultiply);
// Add non-transparent alpha channel, if required // Add non-transparent alpha channel, if required
if (colour[3] < 255.0 && !image.has_alpha()) { if (colour[3] < 255.0 && !image.has_alpha()) {
image = image.bandjoin( image = image.bandjoin_const({ 255 * multiplier });
VImage::new_matrix(image.width(), image.height()).new_from_image(255 * multiplier).cast(image.format()));
} }
return std::make_tuple(image, alphaColour); return std::make_tuple(image, alphaColour);
} }
@ -1024,9 +1023,7 @@ namespace sharp {
*/ */
VImage EnsureAlpha(VImage image, double const value) { VImage EnsureAlpha(VImage image, double const value) {
if (!image.has_alpha()) { if (!image.has_alpha()) {
std::vector<double> alpha; image = image.bandjoin_const({ value * vips_interpretation_max_alpha(image.interpretation()) });
alpha.push_back(value * vips_interpretation_max_alpha(image.interpretation()));
image = image.bandjoin_const(alpha);
} }
return image; return image;
} }