From: Cristy Date: Wed, 1 Feb 2017 14:23:15 +0000 (-0500) Subject: ... X-Git-Tag: 7.0.4-7~25 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=93452f0abf7bf0b1ae34d8b1f8984f48a842383e;p=imagemagick ... --- diff --git a/MagickCore/blob-private.h b/MagickCore/blob-private.h index 152a0b259..7f7d797ec 100644 --- a/MagickCore/blob-private.h +++ b/MagickCore/blob-private.h @@ -139,7 +139,12 @@ extern MagickExport void GetBlobInfo(BlobInfo *), *MapBlob(int,const MapMode,const MagickOffsetType,const size_t), MSBOrderLong(unsigned char *,const size_t), - MSBOrderShort(unsigned char *,const size_t); + MSBOrderShort(unsigned char *,const size_t), + SetBlobCustomStream(BlobInfo *, + ssize_t (*reader)(const unsigned char *,const size_t,const void *), + ssize_t (*writer)(const unsigned char *,const size_t,const void *), + size_t (*seeker)(const MagickOffsetType,const int,const void *), + MagickOffsetType (*teller)(const void *)); #if defined(__cplusplus) || defined(c_plusplus) } diff --git a/MagickCore/blob.c b/MagickCore/blob.c index 2c43fd30d..ae1ed4735 100644 --- a/MagickCore/blob.c +++ b/MagickCore/blob.c @@ -94,6 +94,31 @@ /* Typedef declarations. */ +typedef ssize_t + (*BlobHandler)(const unsigned char *,const size_t,const void *); + +typedef size_t + (*BlobSeeker)(const MagickOffsetType offset,const int whence,const void *); + +typedef MagickOffsetType + (*BlobTeller)(const void *); + +struct _CustomStreamInfo +{ + BlobHandler + reader, + writer; + + BlobSeeker + seeker; + + BlobTeller + teller; + + void + *data; +}; + typedef union FileInfo { FILE @@ -145,8 +170,8 @@ struct _BlobInfo StreamHandler stream; - CustomBlobInfo - *custom_info; + CustomStreamInfo + *custom_stream; unsigned char *data; @@ -465,7 +490,7 @@ MagickExport BlobInfo *CloneBlobInfo(const BlobInfo *blob_info) clone_info->file_info.file=blob_info->file_info.file; clone_info->properties=blob_info->properties; clone_info->stream=blob_info->stream; - clone_info->custom_info=blob_info->custom_info; + clone_info->custom_stream=blob_info->custom_stream; clone_info->data=blob_info->data; clone_info->debug=IsEventLogging(); clone_info->reference_count=1; @@ -708,7 +733,7 @@ MagickExport void *DetachBlob(BlobInfo *blob_info) data=blob_info->data; blob_info->data=(unsigned char *) NULL; blob_info->stream=(StreamHandler) NULL; - blob_info->custom_info=(CustomBlobInfo *) NULL; + blob_info->custom_stream=(CustomStreamInfo *) NULL; return(data); } @@ -1632,19 +1657,19 @@ MagickExport void *ImageToBlob(const ImageInfo *image_info, % % % % % % -+ I m a g e T o C u s t o m B l o b % ++ I m a g e T o C u s t o m S t r e a m % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% ImageToCustomBlob() is the equivalent of WriteImage(), but writes the -% formatted "file" to the supplied method rather than to an actual file. +% ImageToCustomStream() is the equivalent of WriteImage(), but writes the +% formatted "file" to the custom stream rather than to an actual file. % -% The format of the ImageToCustomBlob method is: +% The format of the ImageToCustomStream method is: % -% void ImageToCustomBlob(const ImageInfo *image_info,Image *image, -% CustomBlobInfo *custom_info,ExceptionInfo *exception) +% void ImageToCustomStream(const ImageInfo *image_info,Image *image, +% CustomStreamInfo *custom_stream,ExceptionInfo *exception) % % A description of each parameter follows: % @@ -1652,13 +1677,13 @@ MagickExport void *ImageToBlob(const ImageInfo *image_info, % % o image: the image. % -% o custom_info: the methods to use when writing and seeking. +% o custom_stream: the methods to use when writing and seeking. % % o exception: return any errors or warnings in this structure. % */ -MagickExport void ImageToCustomBlob(const ImageInfo *image_info,Image *image, - CustomBlobInfo *custom_info,ExceptionInfo *exception) +MagickExport void ImageToCustomStream(const ImageInfo *image_info,Image *image, + CustomStreamInfo *custom_stream,ExceptionInfo *exception) { const MagickInfo *magick_info; @@ -1676,13 +1701,13 @@ MagickExport void ImageToCustomBlob(const ImageInfo *image_info,Image *image, image_info->filename); assert(image != (Image *) NULL); assert(image->signature == MagickCoreSignature); - assert(custom_info != (CustomBlobInfo *) NULL); - assert(custom_info->reader != (BlobHandler) NULL); - assert(custom_info->writer != (BlobHandler) NULL); + assert(custom_stream != (CustomStreamInfo *) NULL); + assert(custom_stream->reader != (BlobHandler) NULL); + assert(custom_stream->writer != (BlobHandler) NULL); assert(exception != (ExceptionInfo *) NULL); blob_info=CloneImageInfo(image_info); blob_info->adjoin=MagickFalse; - blob_info->custom_info=custom_info; + blob_info->custom_stream=custom_stream; (void) SetImageInfo(blob_info,1,exception); if (*blob_info->magick != '\0') (void) CopyMagickString(image->magick,blob_info->magick,MagickPathExtent); @@ -1720,7 +1745,7 @@ MagickExport void ImageToCustomBlob(const ImageInfo *image_info,Image *image, /* Write file to disk in blob image format. */ - blob_info->custom_info=(CustomBlobInfo *) NULL; + blob_info->custom_stream=(CustomStreamInfo *) NULL; blob=(unsigned char *) AcquireQuantumMemory(MagickMaxBufferExtent, sizeof(*blob)); if (blob == (unsigned char *) NULL) @@ -1757,7 +1782,7 @@ MagickExport void ImageToCustomBlob(const ImageInfo *image_info,Image *image, { count=(ssize_t) fread(blob,sizeof(*blob),MagickMaxBufferExtent, blob_info->file); - custom_info->writer(blob,count,custom_info->data); + custom_stream->writer(blob,count,custom_stream->data); } } (void) fclose(blob_info->file); @@ -2037,13 +2062,13 @@ MagickExport void *ImagesToBlob(const ImageInfo *image_info,Image *images, % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% ImagesToCustomBlob() is the equivalent of WriteImages(), but writes the -% formatted "file" to the supplied method rather than to an actual file. +% ImagesToCustomStream() is the equivalent of WriteImages(), but writes the +% formatted "file" to the custom stream rather than to an actual file. % -% The format of the ImageToCustomBlob method is: +% The format of the ImageToCustomStream method is: % -% void ImagesToCustomBlob(const ImageInfo *image_info,Image *images, -% CustomBlobInfo *custom_info,ExceptionInfo *exception) +% void ImagesToCustomStream(const ImageInfo *image_info,Image *images, +% CustomStreamInfo *custom_stream,ExceptionInfo *exception) % % A description of each parameter follows: % @@ -2051,13 +2076,13 @@ MagickExport void *ImagesToBlob(const ImageInfo *image_info,Image *images, % % o images: the image list. % -% o custom_info: the methods to use when writing and seeking. +% o custom_stream: the methods to use when writing and seeking. % % o exception: return any errors or warnings in this structure. % */ -MagickExport void ImagesToCustomBlob(const ImageInfo *image_info,Image *images, - CustomBlobInfo *custom_info,ExceptionInfo *exception) +MagickExport void ImagesToCustomStream(const ImageInfo *image_info, + Image *images,CustomStreamInfo *custom_stream,ExceptionInfo *exception) { const MagickInfo *magick_info; @@ -2075,12 +2100,12 @@ MagickExport void ImagesToCustomBlob(const ImageInfo *image_info,Image *images, image_info->filename); assert(images != (Image *) NULL); assert(images->signature == MagickCoreSignature); - assert(custom_info != (CustomBlobInfo *) NULL); - assert(custom_info->reader != (BlobHandler) NULL); - assert(custom_info->writer != (BlobHandler) NULL); + assert(custom_stream != (CustomStreamInfo *) NULL); + assert(custom_stream->reader != (BlobHandler) NULL); + assert(custom_stream->writer != (BlobHandler) NULL); assert(exception != (ExceptionInfo *) NULL); blob_info=CloneImageInfo(image_info); - blob_info->custom_info=custom_info; + blob_info->custom_stream=custom_stream; (void) SetImageInfo(blob_info,(unsigned int) GetImageListLength(images), exception); if (*blob_info->magick != '\0') @@ -2120,7 +2145,7 @@ MagickExport void ImagesToCustomBlob(const ImageInfo *image_info,Image *images, /* Write file to disk in blob image format. */ - blob_info->custom_info=(CustomBlobInfo *) NULL; + blob_info->custom_stream=(CustomStreamInfo *) NULL; blob=(unsigned char *) AcquireQuantumMemory(MagickMaxBufferExtent, sizeof(*blob)); if (blob == (unsigned char *) NULL) @@ -2157,7 +2182,7 @@ MagickExport void ImagesToCustomBlob(const ImageInfo *image_info,Image *images, { count=(ssize_t) fread(blob,sizeof(*blob),MagickMaxBufferExtent, blob_info->file); - custom_info->writer(blob,count,custom_info->data); + custom_stream->writer(blob,count,custom_stream->data); } } (void) fclose(blob_info->file); @@ -2408,8 +2433,8 @@ MagickExport MagickBooleanType IsBlobSeekable(const Image *image) } case CustomStream: { - if ((image->blob->custom_info->seeker != (BlobSeeker) NULL) && - (image->blob->custom_info->teller != (BlobTeller) NULL)) + if ((image->blob->custom_stream->seeker != (BlobSeeker) NULL) && + (image->blob->custom_stream->teller != (BlobTeller) NULL)) seekable=MagickTrue; else seekable=MagickFalse; @@ -2719,11 +2744,11 @@ MagickExport MagickBooleanType OpenBlob(const ImageInfo *image_info, AttachBlob(image->blob,image_info->blob,image_info->length); return(MagickTrue); } - if ((image_info->custom_info != (CustomBlobInfo *) NULL) && + if ((image_info->custom_stream != (CustomStreamInfo *) NULL) && (*image->filename == '\0')) { image->blob->type=CustomStream; - image->blob->custom_info=image_info->custom_info; + image->blob->custom_stream=image_info->custom_stream; return(MagickTrue); } (void) DetachBlob(image->blob); @@ -3278,8 +3303,8 @@ MagickExport ssize_t ReadBlob(Image *image,const size_t length,void *data) } case CustomStream: { - count=image->blob->custom_info->reader(q,length, - image->blob->custom_info->data); + count=image->blob->custom_stream->reader(q,length, + image->blob->custom_stream->data); break; } } @@ -4345,10 +4370,10 @@ MagickExport MagickOffsetType SeekBlob(Image *image, } case CustomStream: { - if (image->blob->custom_info->seeker == (BlobSeeker) NULL) + if (image->blob->custom_stream->seeker == (BlobSeeker) NULL) return(-1); - image->blob->offset=image->blob->custom_info->seeker(offset,whence, - image->blob->custom_info->data); + image->blob->offset=image->blob->custom_stream->seeker(offset,whence, + image->blob->custom_stream->data); break; } } @@ -4360,6 +4385,54 @@ MagickExport MagickOffsetType SeekBlob(Image *image, % % % % % % +% S e t B l o b C u s t o m S t r e a m % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% SetBlobCustomStream() sets the blob's custom stream handlers. +% +% The format of the SetBlobCustomStream method is: +% +% void SetBlobCustomStream(BlobInfo *blob_info, +% ssize_t (*reader)(const unsigned char *,const size_t,const void *), +% ssize_t (*writer)(const unsigned char *,const size_t,const void *), +% size_t (*seeker)(const MagickOffsetType,const int,const void *), +% MagickOffsetType (*teller)(const void *)) +% +% A description of each parameter follows: +% +% o blob_info: the blob info. +% +% o reader: your custom stream reader. +% +% o writer: your custom stream writer. +% +% o seeker: your custom stream seeker. +% +% o teller: your custom stream teller. +% +*/ +MagickExport void SetBlobCustomStream(BlobInfo *blob_info, + ssize_t (*reader)(const unsigned char *,const size_t,const void *), + ssize_t (*writer)(const unsigned char *,const size_t,const void *), + size_t (*seeker)(const MagickOffsetType,const int,const void *), + MagickOffsetType (*teller)(const void *)) +{ + assert(blob_info != (BlobInfo *) NULL); + assert(blob_info->signature == MagickCoreSignature); + blob_info->custom_stream->reader=reader; + blob_info->custom_stream->writer=writer; + blob_info->custom_stream->seeker=seeker; + blob_info->custom_stream->teller=teller; +} + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % + S e t B l o b E x e m p t % % % % % @@ -4672,8 +4745,8 @@ MagickExport MagickOffsetType TellBlob(const Image *image) } case CustomStream: { - if (image->blob->custom_info->teller != (BlobTeller) NULL) - offset=image->blob->custom_info->teller(image->blob->custom_info->data); + if (image->blob->custom_stream->teller != (BlobTeller) NULL) + offset=image->blob->custom_stream->teller(image->blob->custom_stream->data); break; } } @@ -4725,34 +4798,31 @@ MagickExport MagickBooleanType UnmapBlob(void *map,const size_t length) % % % % % % -% C u s t o m B l o b T o I m a g e % +% C u s t o m S t r e a m T o I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% CustomBlobToImage() is the equivalent of ReadImage(), but reads the +% CustomStreamToImage() is the equivalent of ReadImage(), but reads the % formatted "file" from the suplied method rather than to an actual file. % -% The format of the BlobToImage method is: +% The format of the CustomStreamToImage method is: % -% Image *BlobToImage(const ImageInfo *image_info,const void *blob, -% const size_t length,ExceptionInfo *exception) +% Image *CustomStreamToImage(const ImageInfo *image_info, +% CustomStreamInfo *custom_stream,ExceptionInfo *exception) % % A description of each parameter follows: % % o image_info: the image info. % -% o blob: the address of a character stream in one of the image formats -% understood by ImageMagick. -% -% o length: This size_t integer reflects the length in bytes of the blob. +% o custom_stream: the methods to use when writing and seeking. % % o exception: return any errors or warnings in this structure. % */ -MagickExport Image *CustomBlobToImage(const ImageInfo *image_info, - CustomBlobInfo *custom_info,ExceptionInfo *exception) +MagickExport Image *CustomStreamToImage(const ImageInfo *image_info, + CustomStreamInfo *custom_stream,ExceptionInfo *exception) { const MagickInfo *magick_info; @@ -4768,11 +4838,11 @@ MagickExport Image *CustomBlobToImage(const ImageInfo *image_info, if (image_info->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", image_info->filename); - assert(custom_info != (CustomBlobInfo *) NULL); - assert(custom_info->reader != (BlobHandler) NULL); + assert(custom_stream != (CustomStreamInfo *) NULL); + assert(custom_stream->reader != (BlobHandler) NULL); assert(exception != (ExceptionInfo *) NULL); blob_info=CloneImageInfo(image_info); - blob_info->custom_info=custom_info; + blob_info->custom_stream=custom_stream; if (*blob_info->magick == '\0') (void) SetImageInfo(blob_info,0,exception); magick_info=GetMagickInfo(blob_info->magick,exception); @@ -4786,7 +4856,7 @@ MagickExport Image *CustomBlobToImage(const ImageInfo *image_info, } image=(Image *) NULL; if ((GetMagickBlobSupport(magick_info) != MagickFalse) || - (blob_info->custom_info == (CustomBlobInfo *) NULL)) + (blob_info->custom_stream == (CustomStreamInfo *) NULL)) { /* Native blob support for this image format or SetImageInfo changed the @@ -4813,7 +4883,7 @@ MagickExport Image *CustomBlobToImage(const ImageInfo *image_info, /* Write data to file on disk. */ - blob_info->custom_info=(CustomBlobInfo *) NULL; + blob_info->custom_stream=(CustomStreamInfo *) NULL; blob=(unsigned char *) AcquireQuantumMemory(MagickMaxBufferExtent, sizeof(*blob)); if (blob == (unsigned char *) NULL) @@ -4842,8 +4912,8 @@ MagickExport Image *CustomBlobToImage(const ImageInfo *image_info, count=(ssize_t) MagickMaxBufferExtent; while (count == (ssize_t) MagickMaxBufferExtent) { - count=custom_info->reader(blob,MagickMaxBufferExtent, - custom_info->data); + count=custom_stream->reader(blob,MagickMaxBufferExtent, + custom_stream->data); count=(ssize_t) write(file,(const char *) blob,count); } (void) fclose(blob_info->file); @@ -5066,8 +5136,8 @@ MagickExport ssize_t WriteBlob(Image *image,const size_t length, } case CustomStream: { - count=image->blob->custom_info->writer((const unsigned char *) data, - length,image->blob->custom_info->data); + count=image->blob->custom_stream->writer((const unsigned char *) data, + length,image->blob->custom_stream->data); break; } } diff --git a/MagickCore/blob.h b/MagickCore/blob.h index 4e93e7e80..f4fe4e15c 100644 --- a/MagickCore/blob.h +++ b/MagickCore/blob.h @@ -18,9 +18,6 @@ #ifndef MAGICKCORE_BLOB_H #define MAGICKCORE_BLOB_H -typedef struct _CustomBlobInfo - CustomBlobInfo; - #include "MagickCore/image.h" #include "MagickCore/stream.h" @@ -37,30 +34,8 @@ typedef enum IOMode } MapMode; -typedef ssize_t - (*BlobHandler)(const unsigned char *,const size_t,const void *); - -typedef size_t - (*BlobSeeker)(const MagickOffsetType offset,const int whence,const void *); - -typedef MagickOffsetType - (*BlobTeller)(const void *); - -struct _CustomBlobInfo -{ - BlobHandler - reader, - writer; - - BlobSeeker - seeker; - - BlobTeller - teller; - - void - *data; -}; +typedef struct _CustomStreamInfo + CustomStreamInfo; extern MagickExport FILE *GetBlobFileHandle(const Image *); @@ -68,7 +43,7 @@ extern MagickExport FILE extern MagickExport Image *BlobToImage(const ImageInfo *,const void *,const size_t,ExceptionInfo *), *PingBlob(const ImageInfo *,const void *,const size_t,ExceptionInfo *), - *CustomBlobToImage(const ImageInfo *,CustomBlobInfo *,ExceptionInfo *); + *CustomStreamToImage(const ImageInfo *,CustomStreamInfo *,ExceptionInfo *); extern MagickExport MagickBooleanType BlobToFile(char *,const void *,const size_t,ExceptionInfo *), @@ -93,9 +68,10 @@ extern MagickExport void DuplicateBlob(Image *,const Image *), *FileToBlob(const char *,const size_t,size_t *,ExceptionInfo *), *ImageToBlob(const ImageInfo *,Image *,size_t *,ExceptionInfo *), - ImageToCustomBlob(const ImageInfo *,Image *,CustomBlobInfo *,ExceptionInfo *), + ImageToCustomStream(const ImageInfo *,Image *,CustomStreamInfo *, + ExceptionInfo *), *ImagesToBlob(const ImageInfo *,Image *,size_t *,ExceptionInfo *), - ImagesToCustomBlob(const ImageInfo *,Image *,CustomBlobInfo *, + ImagesToCustomStream(const ImageInfo *,Image *,CustomStreamInfo *, ExceptionInfo *), SetBlobExempt(Image *,const MagickBooleanType); diff --git a/MagickCore/image.c b/MagickCore/image.c index a994cde95..a7058da6b 100644 --- a/MagickCore/image.c +++ b/MagickCore/image.c @@ -996,7 +996,7 @@ MagickExport ImageInfo *CloneImageInfo(const ImageInfo *image_info) SetImageInfoFile(clone_info,image_info->file); SetImageInfoBlob(clone_info,image_info->blob,image_info->length); clone_info->stream=image_info->stream; - clone_info->custom_info=image_info->custom_info; + clone_info->custom_stream=image_info->custom_stream; (void) CopyMagickString(clone_info->magick,image_info->magick, MagickPathExtent); (void) CopyMagickString(clone_info->unique,image_info->unique, @@ -2200,6 +2200,84 @@ MagickExport MagickBooleanType ResetImagePage(Image *image,const char *page) % % % % % % +% S e t I m a g e A l p h a % +% % +% % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% SetImageAlpha() sets the alpha levels of the image. +% +% The format of the SetImageAlpha method is: +% +% MagickBooleanType SetImageAlpha(Image *image,const Quantum alpha, +% ExceptionInfo *exception) +% +% A description of each parameter follows: +% +% o image: the image. +% +% o Alpha: the level of transparency: 0 is fully opaque and QuantumRange is +% fully transparent. +% +*/ +MagickExport MagickBooleanType SetImageAlpha(Image *image,const Quantum alpha, + ExceptionInfo *exception) +{ + CacheView + *image_view; + + MagickBooleanType + status; + + ssize_t + y; + + assert(image != (Image *) NULL); + if (image->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); + assert(image->signature == MagickCoreSignature); + image->alpha_trait=BlendPixelTrait; + status=MagickTrue; + image_view=AcquireAuthenticCacheView(image,exception); +#if defined(MAGICKCORE_OPENMP_SUPPORT) + #pragma omp parallel for schedule(static,4) shared(status) \ + magick_threads(image,image,image->rows,1) +#endif + for (y=0; y < (ssize_t) image->rows; y++) + { + register Quantum + *magick_restrict q; + + register ssize_t + x; + + if (status == MagickFalse) + continue; + q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception); + if (q == (Quantum *) NULL) + { + status=MagickFalse; + continue; + } + for (x=0; x < (ssize_t) image->columns; x++) + { + if (GetPixelWriteMask(image,q) != 0) + SetPixelAlpha(image,alpha,q); + q+=GetPixelChannels(image); + } + if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse) + status=MagickFalse; + } + image_view=DestroyCacheView(image_view); + return(status); +} + +/* +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% % +% % % S e t I m a g e B a c k g r o u n d C o l o r % % % % % @@ -2892,33 +2970,47 @@ MagickExport void SetImageInfoBlob(ImageInfo *image_info,const void *blob, % % % % % % -% S e t I m a g e I n f o F i l e % +% S e t I m a g e I n f o C u s t o m S t r e a m % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% SetImageInfoFile() sets the image info file member. +% SetImageInfoCustomStream() sets the image info custom stream handlers. % -% The format of the SetImageInfoFile method is: +% The format of the SetImageInfoCustomStream method is: % -% void SetImageInfoFile(ImageInfo *image_info,FILE *file) +% void SetImageInfoCustomStream(ImageInfo *image_info, +% ssize_t (*reader)(const unsigned char *,const size_t,const void *), +% ssize_t (*writer)(const unsigned char *,const size_t,const void *), +% size_t (*seeker)(const MagickOffsetType,const int,const void *), +% MagickOffsetType (*teller)(const void *)) % % A description of each parameter follows: % % o image_info: the image info. % -% o file: the file. +% o reader: your custom stream reader. +% +% o writer: your custom stream writer. +% +% o seeker: your custom stream seeker. +% +% o teller: your custom stream teller. % */ -MagickExport void SetImageInfoFile(ImageInfo *image_info,FILE *file) +MagickExport void SetImageInfoCustomStream(ImageInfo *image_info, + ssize_t (*reader)(const unsigned char *,const size_t,const void *), + ssize_t (*writer)(const unsigned char *,const size_t,const void *), + size_t (*seeker)(const MagickOffsetType,const int,const void *), + MagickOffsetType (*teller)(const void *)) { assert(image_info != (ImageInfo *) NULL); assert(image_info->signature == MagickCoreSignature); if (image_info->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", image_info->filename); - image_info->file=file; + SetBlobCustomStream(image_info->blob,reader,writer,seeker,teller); } /* @@ -2926,77 +3018,33 @@ MagickExport void SetImageInfoFile(ImageInfo *image_info,FILE *file) % % % % % % -% S e t I m a g e A l p h a % +% S e t I m a g e I n f o F i l e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % -% SetImageAlpha() sets the alpha levels of the image. +% SetImageInfoFile() sets the image info file member. % -% The format of the SetImageAlpha method is: +% The format of the SetImageInfoFile method is: % -% MagickBooleanType SetImageAlpha(Image *image,const Quantum alpha, -% ExceptionInfo *exception) +% void SetImageInfoFile(ImageInfo *image_info,FILE *file) % % A description of each parameter follows: % -% o image: the image. +% o image_info: the image info. % -% o Alpha: the level of transparency: 0 is fully opaque and QuantumRange is -% fully transparent. +% o file: the file. % */ -MagickExport MagickBooleanType SetImageAlpha(Image *image,const Quantum alpha, - ExceptionInfo *exception) +MagickExport void SetImageInfoFile(ImageInfo *image_info,FILE *file) { - CacheView - *image_view; - - MagickBooleanType - status; - - ssize_t - y; - - assert(image != (Image *) NULL); - if (image->debug != MagickFalse) - (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); - assert(image->signature == MagickCoreSignature); - image->alpha_trait=BlendPixelTrait; - status=MagickTrue; - image_view=AcquireAuthenticCacheView(image,exception); -#if defined(MAGICKCORE_OPENMP_SUPPORT) - #pragma omp parallel for schedule(static,4) shared(status) \ - magick_threads(image,image,image->rows,1) -#endif - for (y=0; y < (ssize_t) image->rows; y++) - { - register Quantum - *magick_restrict q; - - register ssize_t - x; - - if (status == MagickFalse) - continue; - q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception); - if (q == (Quantum *) NULL) - { - status=MagickFalse; - continue; - } - for (x=0; x < (ssize_t) image->columns; x++) - { - if (GetPixelWriteMask(image,q) != 0) - SetPixelAlpha(image,alpha,q); - q+=GetPixelChannels(image); - } - if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse) - status=MagickFalse; - } - image_view=DestroyCacheView(image_view); - return(status); + assert(image_info != (ImageInfo *) NULL); + assert(image_info->signature == MagickCoreSignature); + if (image_info->debug != MagickFalse) + (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", + image_info->filename); + image_info->file=file; } /* diff --git a/MagickCore/image.h b/MagickCore/image.h index efe128484..6cd033f13 100644 --- a/MagickCore/image.h +++ b/MagickCore/image.h @@ -478,8 +478,8 @@ struct _ImageInfo size_t signature; - CustomBlobInfo - *custom_info; + void + *custom_stream; }; extern MagickExport ChannelType @@ -564,7 +564,12 @@ extern MagickExport void DisassociateImageStream(Image *), GetImageInfo(ImageInfo *), SetImageInfoBlob(ImageInfo *,const void *,const size_t), - SetImageInfoFile(ImageInfo *,FILE *); + SetImageInfoFile(ImageInfo *,FILE *), + SetImageInfoCustomStream(ImageInfo *, + ssize_t (*reader)(const unsigned char *,const size_t,const void *), + ssize_t (*writer)(const unsigned char *,const size_t,const void *), + size_t (*seeker)(const MagickOffsetType,const int,const void *), + MagickOffsetType (*teller)(const void *)); #if defined(__cplusplus) || defined(c_plusplus) }