From 10b30005818a3e3b5255285f06d917a6c006c5aa Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 6 Feb 2019 10:24:11 +0000 Subject: [PATCH] reorganise magicksave a little --- libvips/foreign/magick.c | 44 ++++++++++++++---------------------- libvips/foreign/magick.h | 4 ++-- libvips/foreign/magicksave.c | 4 ++-- 3 files changed, 21 insertions(+), 31 deletions(-) diff --git a/libvips/foreign/magick.c b/libvips/foreign/magick.c index 507614bf..c7d18643 100644 --- a/libvips/foreign/magick.c +++ b/libvips/foreign/magick.c @@ -79,8 +79,8 @@ magick_import_pixels( Image *image, const ssize_t x, const ssize_t y, } void * -magick_images_to_blob( const ImageInfo *image_info, Image *images, size_t *length, - ExceptionInfo *exception ) +magick_images_to_blob( const ImageInfo *image_info, Image *images, + size_t *length, ExceptionInfo *exception ) { return( ImagesToBlob( image_info, images, length, exception ) ); } @@ -183,40 +183,30 @@ magick_import_pixels( Image *image, const ssize_t x, const ssize_t y, const size_t width, const size_t height, const char *map, const StorageType type, const void *pixels, ExceptionInfo *exception ) { - (void) exception; - - /* GM does not seem to have a simple equivalent, unfortunately. - * - * Looks like we'd need to call - * - * extern MagickExport PixelPacket - * *SetImagePixels(Image *image,const long x,const long y, - * const unsigned long columns,const unsigned - * long rows); - * - * then repack pixels into that area using map and storage_type. - */ #ifdef HAVE_IMPORTIMAGEPIXELS return( ImportImagePixels( image, x, y, width, height, map, type, pixels ) ); #else /*!HAVE_IMPORTIMAGEPIXELS*/ - g_assert(image != (Image *) NULL); - g_assert(image->signature == MagickSignature); + Image *constitute_image; - Image *constitute_image= - ConstituteImage(width,height,map,type,pixels,&image->exception); - if (constitute_image) { - (void) CompositeImage(image,CopyCompositeOp,constitute_image,x,y); - DestroyImage(constitute_image); - return (image->exception.severity == UndefinedException); - } - return( MagickFalse ); + g_assert( image ); + g_assert( image->signature == MagickSignature ); + + constitute_image = ConstituteImage( width, height, map, type, + pixels, &image->exception ); + if( !constitute_image ) + return( MagickFalse ); + + (void) CompositeImage( image, CopyCompositeOp, constitute_image, x, y ); + DestroyImage( constitute_image ); + + return( image->exception.severity == UndefinedException ); #endif /*HAVE_IMPORTIMAGEPIXELS*/ } void * -magick_images_to_blob( const ImageInfo *image_info, Image *images, size_t *length, - ExceptionInfo *exception ) +magick_images_to_blob( const ImageInfo *image_info, Image *images, + size_t *length, ExceptionInfo *exception ) { #ifdef HAVE_IMAGESTOBLOB return( ImagesToBlob( image_info, images, length, exception ) ); diff --git a/libvips/foreign/magick.h b/libvips/foreign/magick.h index 594b4c8d..1251175c 100644 --- a/libvips/foreign/magick.h +++ b/libvips/foreign/magick.h @@ -51,8 +51,8 @@ int magick_set_image_size( Image *image, int magick_import_pixels( Image *image, const ssize_t x, const ssize_t y, const size_t width, const size_t height, const char *map, const StorageType type,const void *pixels, ExceptionInfo *exception ); -void *magick_images_to_blob( const ImageInfo *image_info, Image *images, size_t *length, - ExceptionInfo *exception ); +void *magick_images_to_blob( const ImageInfo *image_info, Image *images, + size_t *length, ExceptionInfo *exception ); void magick_set_property( Image *image, const char *property, const char *value, ExceptionInfo *exception ); void magick_set_image_option( ImageInfo *image_info, diff --git a/libvips/foreign/magicksave.c b/libvips/foreign/magicksave.c index 036e732c..223395d4 100644 --- a/libvips/foreign/magicksave.c +++ b/libvips/foreign/magicksave.c @@ -1,6 +1,8 @@ /* save with libMagick * * 22/12/17 dlemstra + * 6/2/19 DarthSim + * - fix GraphicsMagick support */ /* @@ -221,7 +223,6 @@ vips_foreign_save_magick_build( VipsObject *object ) magick->exception = magick_acquire_exception(); magick->image_info = CloneImageInfo( NULL ); - magick->storage_type = CharPixel; switch( im->BandFmt ) { case VIPS_FORMAT_UCHAR: magick->storage_type = CharPixel; @@ -249,7 +250,6 @@ vips_foreign_save_magick_build( VipsObject *object ) return( -1 ); } - magick->map = NULL; switch( im->Bands ) { case 1: magick->map = g_strdup( "I" );