vips: add a vips__gaussblur method

handle both < 7.41 and higher.
Prior 7.41, vips_gaussblur took only a int param, the radius.
The radius was then divided by 2.0 (min_ampl) in vips_gaussblur.
After, you can now parameter the min_ampl and radius became sigma (and
passed from an integer to a double).
master
Thomas Meson 10 years ago
parent 0f31f20ded
commit 404cbf902f

@ -91,6 +91,11 @@ type Watermark struct {
Background Color
}
type GaussianBlur struct {
Sigma float64
MinAmpl float64
}
type Options struct {
Height int
Width int
@ -117,4 +122,5 @@ type Options struct {
Type ImageType
Interpolator Interpolator
Interpretation Interpretation
GaussianBlur GaussianBlur
}

@ -432,3 +432,14 @@ func boolToInt(b bool) int {
}
return 0
}
func vipsGaussianBlur(image *C.VipsImage, o GaussianBlur) (*C.VipsImage, error) {
var out *C.VipsImage
defer C.g_object_unref(C.gpointer(image))
err := C.vips__gaussblur(image, &out, C.double(o.Sigma), C.double(o.MinAmpl))
if err != 0 {
return nil, catchVipsError()
}
return out, nil
}

@ -16,6 +16,9 @@
*/
#if (VIPS_MAJOR_VERSION == 7 && VIPS_MINOR_VERSION < 41)
/* we need math.h for ceil() in vips__gaussblur */
#include <math.h>
#define VIPS_ANGLE_D0 VIPS_ANGLE_0
#define VIPS_ANGLE_D90 VIPS_ANGLE_90
#define VIPS_ANGLE_D180 VIPS_ANGLE_180
@ -321,3 +324,12 @@ vips_watermark(VipsImage *in, VipsImage **out, WatermarkTextOptions *to, Waterma
g_object_unref(base);
return 0;
}
int
vips__gaussblur(VipsImage *in, VipsImage **out, double sigma, double min_ampl) {
#if (VIPS_MAJOR_VERSION == 7 && VIPS_MINOR_VERSION < 41)
return vips_gaussblur(in, out, ceil(sigma), NULL);
#else
return vips_gaussblur(in, out, sigma, NULL, "min_ampl", min_ampl);
#endif
}

Loading…
Cancel
Save