From aebb8af803a45b3b09f1b5cb9ebbd93787c36f8d Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 4 Apr 2018 09:22:57 +0100 Subject: [PATCH] create funcs always make MULTIBAND Before, they could make B_W for one-band output. This caused problems with (for example) two black image bandjoined: the second band then looked like an alpha to hasalpha() and enabled premultiply/unpremultiply for operations like affine. Now, it's always MULTIBAND. This is the generic multiband image type, so you don't get any unexpected alpha handling. --- ChangeLog | 1 + libvips/create/black.c | 6 ++++-- libvips/create/gaussmat.c | 3 ++- libvips/create/gaussnoise.c | 2 +- libvips/create/logmat.c | 3 ++- libvips/create/perlin.c | 2 +- libvips/create/point.c | 7 +++---- libvips/create/text.c | 3 ++- libvips/create/worley.c | 3 ++- 9 files changed, 18 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 83949abd..2cde6127 100644 --- a/ChangeLog +++ b/ChangeLog @@ -11,6 +11,7 @@ - better header sniffing for small files - drop incompatible ICC profiles before save - better hasalpha rules +- create funcs always make MULTIBAND (ie. no alpha) 12/3/18 started 8.6.4 - better fitting of fonts with overhanging edges, thanks AdriĆ  diff --git a/libvips/create/black.c b/libvips/create/black.c index c613a154..33c4ab1c 100644 --- a/libvips/create/black.c +++ b/libvips/create/black.c @@ -15,6 +15,9 @@ * - gtkdoc * 31/10/11 * - redo as a class + * 3/4/18 + * - always write MULTIBAND, otherwise when we join up these things it'll + * look like we have an alpha */ /* @@ -97,8 +100,7 @@ vips_black_build( VipsObject *object ) vips_image_init_fields( create->out, black->width, black->height, black->bands, VIPS_FORMAT_UCHAR, VIPS_CODING_NONE, - black->bands == 1 ? - VIPS_INTERPRETATION_B_W : VIPS_INTERPRETATION_MULTIBAND, + VIPS_INTERPRETATION_MULTIBAND, 1.0, 1.0 ); vips_image_pipelinev( create->out, VIPS_DEMAND_STYLE_ANY, NULL ); diff --git a/libvips/create/gaussmat.c b/libvips/create/gaussmat.c index fa67c305..4ac21562 100644 --- a/libvips/create/gaussmat.c +++ b/libvips/create/gaussmat.c @@ -134,7 +134,8 @@ vips_gaussmat_build( VipsObject *object ) vips_image_init_fields( create->out, width, height, 1, - VIPS_FORMAT_DOUBLE, VIPS_CODING_NONE, VIPS_INTERPRETATION_B_W, + VIPS_FORMAT_DOUBLE, VIPS_CODING_NONE, + VIPS_INTERPRETATION_MULTIBAND, 1.0, 1.0 ); vips_image_pipelinev( create->out, VIPS_DEMAND_STYLE_ANY, NULL ); diff --git a/libvips/create/gaussnoise.c b/libvips/create/gaussnoise.c index 1566e39a..5ccf5510 100644 --- a/libvips/create/gaussnoise.c +++ b/libvips/create/gaussnoise.c @@ -134,7 +134,7 @@ vips_gaussnoise_build( VipsObject *object ) vips_image_init_fields( create->out, gaussnoise->width, gaussnoise->height, 1, VIPS_FORMAT_FLOAT, VIPS_CODING_NONE, - VIPS_INTERPRETATION_B_W, 1.0, 1.0 ); + VIPS_INTERPRETATION_MULTIBAND, 1.0, 1.0 ); vips_image_pipelinev( create->out, VIPS_DEMAND_STYLE_ANY, NULL ); diff --git a/libvips/create/logmat.c b/libvips/create/logmat.c index 5f15b3ea..43d753c7 100644 --- a/libvips/create/logmat.c +++ b/libvips/create/logmat.c @@ -153,7 +153,8 @@ vips_logmat_build( VipsObject *object ) vips_image_init_fields( create->out, width, height, 1, - VIPS_FORMAT_DOUBLE, VIPS_CODING_NONE, VIPS_INTERPRETATION_B_W, + VIPS_FORMAT_DOUBLE, VIPS_CODING_NONE, + VIPS_INTERPRETATION_MULTIBAND, 1.0, 1.0 ); vips_image_pipelinev( create->out, VIPS_DEMAND_STYLE_ANY, NULL ); diff --git a/libvips/create/perlin.c b/libvips/create/perlin.c index 5181f365..a6651f90 100644 --- a/libvips/create/perlin.c +++ b/libvips/create/perlin.c @@ -249,7 +249,7 @@ vips_perlin_build( VipsObject *object ) vips_image_init_fields( create->out, perlin->width, perlin->height, 1, perlin->uchar ? VIPS_FORMAT_UCHAR : VIPS_FORMAT_FLOAT, - VIPS_CODING_NONE, VIPS_INTERPRETATION_B_W, + VIPS_CODING_NONE, VIPS_INTERPRETATION_MULTIBAND, 1.0, 1.0 ); vips_image_pipelinev( create->out, VIPS_DEMAND_STYLE_ANY, NULL ); diff --git a/libvips/create/point.c b/libvips/create/point.c index 06e14229..f5f00841 100644 --- a/libvips/create/point.c +++ b/libvips/create/point.c @@ -109,10 +109,9 @@ vips_point_build( VipsObject *object ) return( -1 ); in = t[2]; - /* uchar mode always does B_W. We don't want FOURIER or - * whatever in this case. + /* We don't want FOURIER or whatever in this case. */ - in->Type = VIPS_INTERPRETATION_B_W; + in->Type = VIPS_INTERPRETATION_MULTIBAND; } if( vips_image_write( in, create->out ) ) @@ -137,7 +136,7 @@ vips_point_class_init( VipsPointClass *class ) class->point = NULL; class->min = -1.0; class->max = 1.0; - class->interpretation = VIPS_INTERPRETATION_B_W; + class->interpretation = VIPS_INTERPRETATION_MULTIBAND; VIPS_ARG_INT( class, "width", 2, _( "Width" ), diff --git a/libvips/create/text.c b/libvips/create/text.c index 8d26ed10..e8631638 100644 --- a/libvips/create/text.c +++ b/libvips/create/text.c @@ -379,7 +379,8 @@ vips_text_build( VipsObject *object ) vips_image_init_fields( create->out, text->bitmap.width, text->bitmap.rows, 1, - VIPS_FORMAT_UCHAR, VIPS_CODING_NONE, VIPS_INTERPRETATION_B_W, + VIPS_FORMAT_UCHAR, VIPS_CODING_NONE, + VIPS_INTERPRETATION_MULTIBAND, 1.0, 1.0 ); vips_image_pipelinev( create->out, VIPS_DEMAND_STYLE_ANY, NULL ); diff --git a/libvips/create/worley.c b/libvips/create/worley.c index 520fdd47..e2cdf424 100644 --- a/libvips/create/worley.c +++ b/libvips/create/worley.c @@ -281,7 +281,8 @@ vips_worley_build( VipsObject *object ) vips_image_init_fields( create->out, worley->width, worley->height, 1, - VIPS_FORMAT_FLOAT, VIPS_CODING_NONE, VIPS_INTERPRETATION_B_W, + VIPS_FORMAT_FLOAT, VIPS_CODING_NONE, + VIPS_INTERPRETATION_MULTIBAND, 1.0, 1.0 ); vips_image_pipelinev( create->out, VIPS_DEMAND_STYLE_ANY, NULL );