Fix bug with images with alpha channel on embeding background

master
Vladimir Buyanov 6 years ago
parent 5a9d7f21d9
commit 9e85c8daa1
No known key found for this signature in database
GPG Key ID: 0488462FBB426863

@ -241,9 +241,14 @@ vips_zoom_bridge(VipsImage *in, VipsImage **out, int xfac, int yfac) {
int int
vips_embed_bridge(VipsImage *in, VipsImage **out, int left, int top, int width, int height, int extend, double r, double g, double b) { 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 (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}; double background[3] = {r, g, b};
VipsArrayDouble *vipsBackground = vips_array_double_new(background, 3); 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, "background", vipsBackground, NULL);}
} }
return vips_embed(in, out, left, top, width, height, "extend", extend, NULL); return vips_embed(in, out, left, top, width, height, "extend", extend, NULL);
} }

Loading…
Cancel
Save