|
@@ -200,13 +200,14 @@ vips_resize_go(VipsImage *in, VipsImage **out, double wscale, double hscale) {
|
|
|
VipsBandFormat format = vips_band_format(in);
|
|
|
|
|
|
VipsImage *base = vips_image_new();
|
|
|
- VipsImage **t = (VipsImage **) vips_object_local_array(VIPS_OBJECT(base), 3);
|
|
|
+ VipsImage **t = (VipsImage **) vips_object_local_array(VIPS_OBJECT(base), 4);
|
|
|
|
|
|
int res =
|
|
|
vips_premultiply(in, &t[0], NULL) ||
|
|
|
- vips_resize(t[0], &t[1], wscale, "vscale", hscale, NULL) ||
|
|
|
- vips_unpremultiply(t[1], &t[2], NULL) ||
|
|
|
- vips_cast(t[2], out, format, NULL);
|
|
|
+ vips_cast(t[0], &t[1], format, NULL) ||
|
|
|
+ vips_resize(t[1], &t[2], wscale, "vscale", hscale, NULL) ||
|
|
|
+ vips_unpremultiply(t[2], &t[3], NULL) ||
|
|
|
+ vips_cast(t[3], out, format, NULL);
|
|
|
|
|
|
clear_image(&base);
|
|
|
|
|
@@ -306,14 +307,17 @@ vips_apply_filters(VipsImage *in, VipsImage **out, double blur_sigma,
|
|
|
double sharp_sigma, int pixelate_pixels) {
|
|
|
|
|
|
VipsImage *base = vips_image_new();
|
|
|
- VipsImage **t = (VipsImage **) vips_object_local_array(VIPS_OBJECT(base), 9);
|
|
|
+ VipsImage **t = (VipsImage **) vips_object_local_array(VIPS_OBJECT(base), 10);
|
|
|
|
|
|
VipsInterpretation interpretation = in->Type;
|
|
|
VipsBandFormat format = in->BandFmt;
|
|
|
gboolean premultiplied = FALSE;
|
|
|
|
|
|
if ((blur_sigma > 0 || sharp_sigma > 0) && vips_image_hasalpha(in)) {
|
|
|
- if (vips_premultiply(in, &t[0], NULL)) {
|
|
|
+ if (
|
|
|
+ vips_premultiply(in, &t[0], NULL) ||
|
|
|
+ vips_cast(t[0], &t[1], format, NULL)
|
|
|
+ ) {
|
|
|
clear_image(&base);
|
|
|
return 1;
|
|
|
}
|
|
@@ -323,21 +327,21 @@ vips_apply_filters(VipsImage *in, VipsImage **out, double blur_sigma,
|
|
|
}
|
|
|
|
|
|
if (blur_sigma > 0.0) {
|
|
|
- if (vips_gaussblur(in, &t[1], blur_sigma, NULL)) {
|
|
|
+ if (vips_gaussblur(in, &t[2], blur_sigma, NULL)) {
|
|
|
clear_image(&base);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
- in = t[1];
|
|
|
+ in = t[2];
|
|
|
}
|
|
|
|
|
|
if (sharp_sigma > 0.0) {
|
|
|
- if (vips_sharpen(in, &t[2], "sigma", sharp_sigma, NULL)) {
|
|
|
+ if (vips_sharpen(in, &t[3], "sigma", sharp_sigma, NULL)) {
|
|
|
clear_image(&base);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
- in = t[2];
|
|
|
+ in = t[3];
|
|
|
}
|
|
|
|
|
|
pixelate_pixels = VIPS_MIN(pixelate_pixels, VIPS_MAX(in->Xsize, in->Ysize));
|
|
@@ -352,46 +356,46 @@ vips_apply_filters(VipsImage *in, VipsImage **out, double blur_sigma,
|
|
|
th = (int)(VIPS_CEIL((double)h / pixelate_pixels)) * pixelate_pixels;
|
|
|
|
|
|
if (tw > w || th > h) {
|
|
|
- if (vips_embed(in, &t[3], 0, 0, tw, th, "extend", VIPS_EXTEND_MIRROR, NULL)) {
|
|
|
+ if (vips_embed(in, &t[4], 0, 0, tw, th, "extend", VIPS_EXTEND_MIRROR, NULL)) {
|
|
|
clear_image(&base);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
- in = t[3];
|
|
|
+ in = t[4];
|
|
|
}
|
|
|
|
|
|
if (
|
|
|
- vips_shrink(in, &t[4], pixelate_pixels, pixelate_pixels, NULL) ||
|
|
|
- vips_zoom(t[4], &t[5], pixelate_pixels, pixelate_pixels, NULL)
|
|
|
+ vips_shrink(in, &t[5], pixelate_pixels, pixelate_pixels, NULL) ||
|
|
|
+ vips_zoom(t[5], &t[6], pixelate_pixels, pixelate_pixels, NULL)
|
|
|
) {
|
|
|
clear_image(&base);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
- in = t[5];
|
|
|
+ in = t[6];
|
|
|
|
|
|
if (tw > w || th > h) {
|
|
|
- if (vips_extract_area(in, &t[6], 0, 0, w, h, NULL)) {
|
|
|
+ if (vips_extract_area(in, &t[7], 0, 0, w, h, NULL)) {
|
|
|
clear_image(&base);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
- in = t[6];
|
|
|
+ in = t[7];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (premultiplied) {
|
|
|
- if (vips_unpremultiply(in, &t[7], NULL)) {
|
|
|
+ if (vips_unpremultiply(in, &t[8], NULL)) {
|
|
|
clear_image(&base);
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
- in = t[7];
|
|
|
+ in = t[8];
|
|
|
}
|
|
|
|
|
|
int res =
|
|
|
- vips_colourspace(in, &t[8], interpretation, NULL) ||
|
|
|
- vips_cast(t[8], out, format, NULL);
|
|
|
+ vips_colourspace(in, &t[9], interpretation, NULL) ||
|
|
|
+ vips_cast(t[9], out, format, NULL);
|
|
|
|
|
|
clear_image(&base);
|
|
|
|