better GraphicsMagick image write

We were not setting matte or depth correctly, thanks bfriesen.
This commit is contained in:
John Cupitt 2020-10-16 00:05:17 +01:00
parent 0a91e2d8c7
commit c0102c5814
2 changed files with 40 additions and 0 deletions

View File

@ -7,6 +7,7 @@
- add missing flushes on write to target [harukizaemon]
- hide info messages you could get with some older glibs [kleisauke]
- fix --no-strip on dzsave with icc-profiles [altert]
- better GraphicsMagick image write [bfriesen]
6/9/20 started 8.10.2
- update magicksave/load profile handling [kelilevi]

View File

@ -4,6 +4,8 @@
*
* 24/7/18
* - add the sniffer
* 16/10/20 [bfriesen]
* - set matte and depth appropriately for GM in magick_import_pixels()
*/
/*
@ -319,6 +321,7 @@ magick_import_pixels( Image *image, const ssize_t x, const ssize_t y,
type, pixels ) );
#else /*!HAVE_IMPORTIMAGEPIXELS*/
Image *constitute_image;
unsigned int storage_type_depth;
g_assert( image );
g_assert( image->signature == MagickSignature );
@ -328,7 +331,43 @@ magick_import_pixels( Image *image, const ssize_t x, const ssize_t y,
if( !constitute_image )
return( MagickFalse );
/* image needs to inherit these fields from constitute_image.
*/
switch( type ) {
case CharPixel:
storage_type_depth = sizeof( unsigned char ) * 8;
break;
case ShortPixel:
storage_type_depth = sizeof( unsigned short ) * 8;
break;
case IntegerPixel:
storage_type_depth = sizeof( unsigned short ) * 8;
break;
case LongPixel:
storage_type_depth = sizeof( unsigned long ) * 8;
break;
case FloatPixel:
storage_type_depth = sizeof( float ) * 8;
break;
case DoublePixel:
storage_type_depth = sizeof( double ) * 8;
break;
default:
storage_type_depth = QuantumDepth;
break;
}
image->depth = VIPS_MIN( storage_type_depth, QuantumDepth );
image->matte = constitute_image->matte;
(void) CompositeImage( image, CopyCompositeOp, constitute_image, x, y );
DestroyImage( constitute_image );
return( image->exception.severity == UndefinedException );