From c19a86e12aa4f8258cbdb3cf25856f328171a4cb Mon Sep 17 00:00:00 2001 From: Albert-Jan de Vries Date: Wed, 5 Apr 2017 16:26:19 +0200 Subject: [PATCH] Change for older LIBVIPS versions. `vips_bandjoin_const1` is added in libvips 8.2. --- vips.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/vips.h b/vips.h index 1ac370b..67f081d 100644 --- a/vips.h +++ b/vips.h @@ -458,7 +458,19 @@ vips_sharpen_bridge(VipsImage *in, VipsImage **out, int radius, double x1, doubl int vips_add_band(VipsImage *in, VipsImage **out, double c) { - return vips_bandjoin_const1(in, out, c, NULL); +#if (VIPS_MAJOR_VERSION > 8 || (VIPS_MAJOR_VERSION >= 8 && VIPS_MINOR_VERSION >= 2)) + return vips_bandjoin_const1(in, out, c, NULL); +#else + VipsImage *base = vips_image_new(); + if ( + vips_black(&base, in->Xsize, in->Ysize, NULL) || + vips_linear1(base, &base, 1, c, NULL)) { + g_object_unref(base); + return 1; + } + g_object_unref(base); + return vips_bandjoin2(in, base, out, c, NULL); +#endif } int @@ -471,13 +483,13 @@ vips_watermark_image(VipsImage *in, VipsImage *sub, VipsImage **out, WatermarkIm t[1] = sub; if (has_alpha_channel(in) == 0) { - vips_bandjoin_const1(in, &t[0], 255.0, NULL); + vips_add_band(in, &t[0], 255.0); // in is no longer in the array and won't be unreffed, so add it at the end t[8] = in; } if (has_alpha_channel(sub) == 0) { - vips_bandjoin_const1(sub, &t[1], 255.0, NULL); + vips_add_band(sub, &t[1], 255.0); // sub is no longer in the array and won't be unreffed, so add it at the end t[9] = sub; }