reorganise magicksave a little

This commit is contained in:
John Cupitt 2019-02-06 10:24:11 +00:00
parent 71664346c0
commit 10b3000581
3 changed files with 21 additions and 31 deletions

View File

@ -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 ) );

View File

@ -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,

View File

@ -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" );