From 9e85c8daa1931663147dedbe5c57de6fb0a7cefe Mon Sep 17 00:00:00 2001 From: Vladimir Buyanov Date: Thu, 16 Jan 2020 14:16:30 +0200 Subject: [PATCH] Fix bug with images with alpha channel on embeding background --- vips.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/vips.h b/vips.h index e0d623a..b8b4734 100644 --- a/vips.h +++ b/vips.h @@ -241,9 +241,14 @@ vips_zoom_bridge(VipsImage *in, VipsImage **out, int xfac, int yfac) { int vips_embed_bridge(VipsImage *in, VipsImage **out, int left, int top, int width, int height, int extend, double r, double g, double b) { if (extend == VIPS_EXTEND_BACKGROUND) { + if (has_alpha_channel(in) == 1) { + double background[4] = {r, g, b, 0.0}; + VipsArrayDouble *vipsBackground = vips_array_double_new(background, 4); + return vips_embed(in, out, left, top, width, height, "extend", extend, "background", vipsBackground, NULL); + } else { double background[3] = {r, g, b}; - VipsArrayDouble *vipsBackground = vips_array_double_new(background, 3); - return vips_embed(in, out, left, top, width, height, "extend", extend, "background", vipsBackground, NULL); + VipsArrayDouble *vipsBackground = vips_array_double_new(background, 3); + return vips_embed(in, out, left, top, width, height, "extend", extend, "background", vipsBackground, NULL);} } return vips_embed(in, out, left, top, width, height, "extend", extend, NULL); }