2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6 % SSSSS TTTTT RRRR EEEEE AAA M M %
7 % SS T R R E A A MM MM %
8 % SSS T RRRR EEE AAAAA M M M %
10 % SSSSS T R R EEEEE A A M M %
13 % MagickCore Pixel Stream Methods %
20 % Copyright 1999-2009 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
43 #include "magick/studio.h"
44 #include "magick/blob.h"
45 #include "magick/blob-private.h"
46 #include "magick/cache.h"
47 #include "magick/cache-private.h"
48 #include "magick/color-private.h"
49 #include "magick/composite-private.h"
50 #include "magick/constitute.h"
51 #include "magick/exception.h"
52 #include "magick/exception-private.h"
53 #include "magick/geometry.h"
54 #include "magick/memory_.h"
55 #include "magick/quantum.h"
56 #include "magick/quantum-private.h"
57 #include "magick/semaphore.h"
58 #include "magick/stream.h"
59 #include "magick/stream-private.h"
60 #include "magick/string_.h"
63 Typedef declaractions.
105 Declare pixel cache interfaces.
107 #if defined(__cplusplus) || defined(c_plusplus)
111 static const PixelPacket
112 *GetVirtualPixelStream(const Image *,const VirtualPixelMethod,const long,
113 const long,const unsigned long,const unsigned long,ExceptionInfo *);
115 static MagickBooleanType
116 StreamImagePixels(const StreamInfo *,const Image *,ExceptionInfo *),
117 SyncAuthenticPixelsStream(Image *,ExceptionInfo *);
120 *QueueAuthenticPixelsStream(Image *,const long,const long,const unsigned long,
121 const unsigned long,ExceptionInfo *);
123 #if defined(__cplusplus) || defined(c_plusplus)
128 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
132 + A c q u i r e S t r e a m I n f o %
136 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
138 % AcquireStreamInfo() allocates the StreamInfo structure.
140 % The format of the AcquireStreamInfo method is:
142 % StreamInfo *AcquireStreamInfo(const ImageInfo *image_info)
144 % A description of each parameter follows:
146 % o image_info: the image info.
149 MagickExport StreamInfo *AcquireStreamInfo(const ImageInfo *image_info)
154 stream_info=(StreamInfo *) AcquireMagickMemory(sizeof(*stream_info));
155 if (stream_info == (StreamInfo *) NULL)
156 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
157 (void) ResetMagickMemory(stream_info,0,sizeof(*stream_info));
158 stream_info->pixels=(unsigned char *) AcquireMagickMemory(
159 sizeof(*stream_info->pixels));
160 if (stream_info->pixels == (unsigned char *) NULL)
161 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
162 stream_info->map=ConstantString("RGB");
163 stream_info->storage_type=CharPixel;
164 stream_info->stream=AcquireImage(image_info);
165 stream_info->signature=MagickSignature;
170 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
174 + D e s t r o y P i x e l S t r e a m %
178 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
180 % DestroyPixelStream() deallocates memory associated with the pixel stream.
182 % The format of the DestroyPixelStream() method is:
184 % void DestroyPixelStream(Image *image)
186 % A description of each parameter follows:
188 % o image: the image.
192 static inline void RelinquishStreamPixels(CacheInfo *cache_info)
194 assert(cache_info != (CacheInfo *) NULL);
195 if (cache_info->mapped == MagickFalse)
196 (void) RelinquishMagickMemory(cache_info->pixels);
198 (void) UnmapBlob(cache_info->pixels,(size_t) cache_info->length);
199 cache_info->pixels=(PixelPacket *) NULL;
200 cache_info->indexes=(IndexPacket *) NULL;
201 cache_info->length=0;
202 cache_info->mapped=MagickFalse;
205 static void DestroyPixelStream(Image *image)
213 assert(image != (Image *) NULL);
214 assert(image->signature == MagickSignature);
215 if (image->debug != MagickFalse)
216 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
217 cache_info=(CacheInfo *) image->cache;
218 assert(cache_info->signature == MagickSignature);
220 (void) LockSemaphoreInfo(cache_info->semaphore);
221 cache_info->reference_count--;
222 if (cache_info->reference_count == 0)
224 (void) UnlockSemaphoreInfo(cache_info->semaphore);
225 if (destroy == MagickFalse)
227 RelinquishStreamPixels(cache_info);
228 if (cache_info->nexus_info != (NexusInfo **) NULL)
229 cache_info->nexus_info=DestroyPixelCacheNexus(cache_info->nexus_info,
230 cache_info->number_threads);
231 if (cache_info->disk_semaphore != (SemaphoreInfo *) NULL)
232 DestroySemaphoreInfo(&cache_info->disk_semaphore);
233 if (cache_info->semaphore != (SemaphoreInfo *) NULL)
234 DestroySemaphoreInfo(&cache_info->semaphore);
235 cache_info=(CacheInfo *) RelinquishMagickMemory(cache_info);
239 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
243 + D e s t r o y S t r e a m I n f o %
247 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
249 % DestroyStreamInfo() destroys memory associated with the StreamInfo
252 % The format of the DestroyStreamInfo method is:
254 % StreamInfo *DestroyStreamInfo(StreamInfo *stream_info)
256 % A description of each parameter follows:
258 % o stream_info: the stream info.
261 MagickExport StreamInfo *DestroyStreamInfo(StreamInfo *stream_info)
263 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
264 assert(stream_info != (StreamInfo *) NULL);
265 assert(stream_info->signature == MagickSignature);
266 if (stream_info->map != (char *) NULL)
267 stream_info->map=DestroyString(stream_info->map);
268 if (stream_info->pixels != (unsigned char *) NULL)
269 stream_info->pixels=(unsigned char *) RelinquishMagickMemory(
270 stream_info->pixels);
271 if (stream_info->stream != (Image *) NULL)
273 (void) CloseBlob(stream_info->stream);
274 stream_info->stream=DestroyImage(stream_info->stream);
276 if (stream_info->quantum_info != (QuantumInfo *) NULL)
277 stream_info->quantum_info=DestroyQuantumInfo(stream_info->quantum_info);
278 stream_info->signature=(~MagickSignature);
279 stream_info=(StreamInfo *) RelinquishMagickMemory(stream_info);
284 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
288 + G e t A u t h e n t i c I n d e x e s F r o m S t r e a m %
292 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
294 % GetAuthenticIndexesFromStream() returns the indexes associated with the
295 % last call to QueueAuthenticPixelsStream() or GetAuthenticPixelsStream().
297 % The format of the GetAuthenticIndexesFromStream() method is:
299 % IndexPacket *GetAuthenticIndexesFromStream(const Image *image)
301 % A description of each parameter follows:
303 % o image: the image.
306 static IndexPacket *GetAuthenticIndexesFromStream(const Image *image)
311 assert(image != (Image *) NULL);
312 assert(image->signature == MagickSignature);
313 if (image->debug != MagickFalse)
314 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
315 cache_info=(CacheInfo *) image->cache;
316 assert(cache_info->signature == MagickSignature);
317 return(cache_info->indexes);
321 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
325 + G e t A u t h e n t i c P i x e l S t r e a m %
329 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
331 % GetAuthenticPixelsStream() gets pixels from the in-memory or disk pixel
332 % cache as defined by the geometry parameters. A pointer to the pixels is
333 % returned if the pixels are transferred, otherwise a NULL is returned. For
334 % streams this method is a no-op.
336 % The format of the GetAuthenticPixelsStream() method is:
338 % PixelPacket *GetAuthenticPixelsStream(Image *image,const long x,
339 % const long y,const unsigned long columns,const unsigned long rows,
340 % ExceptionInfo *exception)
342 % A description of each parameter follows:
344 % o image: the image.
346 % o x,y,columns,rows: These values define the perimeter of a region of
349 % o exception: return any errors or warnings in this structure.
352 static PixelPacket *GetAuthenticPixelsStream(Image *image,const long x,
353 const long y,const unsigned long columns,const unsigned long rows,
354 ExceptionInfo *exception)
359 assert(image != (Image *) NULL);
360 assert(image->signature == MagickSignature);
361 if (image->debug != MagickFalse)
362 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
363 pixels=QueueAuthenticPixelsStream(image,x,y,columns,rows,exception);
368 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
372 + G e t A u t h e n t i c P i x e l F r o m S t e a m %
376 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
378 % GetAuthenticPixelsFromStream() returns the pixels associated with the last
379 % call to QueueAuthenticPixelsStream() or GetAuthenticPixelsStream().
381 % The format of the GetAuthenticPixelsFromStream() method is:
383 % PixelPacket *GetAuthenticPixelsFromStream(const Image image)
385 % A description of each parameter follows:
387 % o image: the image.
390 static PixelPacket *GetAuthenticPixelsFromStream(const Image *image)
395 assert(image != (Image *) NULL);
396 assert(image->signature == MagickSignature);
397 if (image->debug != MagickFalse)
398 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
399 cache_info=(CacheInfo *) image->cache;
400 assert(cache_info->signature == MagickSignature);
401 return(cache_info->pixels);
405 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
409 + G e t O n e A u t h e n t i c P i x e l F r o m S t r e a m %
413 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
415 % GetOneAuthenticPixelFromStream() returns a single pixel at the specified
416 % (x,y) location. The image background color is returned if an error occurs.
418 % The format of the GetOneAuthenticPixelFromStream() method is:
420 % MagickBooleanType GetOneAuthenticPixelFromStream(const Image image,
421 % const long x,const long y,PixelPacket *pixel,ExceptionInfo *exception)
423 % A description of each parameter follows:
425 % o image: the image.
427 % o pixel: return a pixel at the specified (x,y) location.
429 % o x,y: These values define the location of the pixel to return.
431 % o exception: return any errors or warnings in this structure.
434 static MagickBooleanType GetOneAuthenticPixelFromStream(Image *image,
435 const long x,const long y,PixelPacket *pixel,ExceptionInfo *exception)
440 assert(image != (Image *) NULL);
441 assert(image->signature == MagickSignature);
442 *pixel=image->background_color;
443 pixels=GetAuthenticPixelsStream(image,x,y,1,1,exception);
444 if (pixels != (PixelPacket *) NULL)
451 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
455 + G e t O n e V i r t u a l P i x e l F r o m S t r e a m %
459 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
461 % GetOneVirtualPixelFromStream() returns a single pixel at the specified
462 % (x.y) location. The image background color is returned if an error occurs.
464 % The format of the GetOneVirtualPixelFromStream() method is:
466 % MagickBooleanType GetOneVirtualPixelFromStream(const Image image,
467 % const VirtualPixelMethod virtual_pixel_method,const long x,
468 % const long y,PixelPacket *pixel,ExceptionInfo *exception)
470 % A description of each parameter follows:
472 % o image: the image.
474 % o virtual_pixel_method: the virtual pixel method.
476 % o x,y: These values define the location of the pixel to return.
478 % o pixel: return a pixel at the specified (x,y) location.
480 % o exception: return any errors or warnings in this structure.
483 static MagickBooleanType GetOneVirtualPixelFromStream(const Image *image,
484 const VirtualPixelMethod virtual_pixel_method,const long x,const long y,
485 PixelPacket *pixel,ExceptionInfo *exception)
490 assert(image != (Image *) NULL);
491 assert(image->signature == MagickSignature);
492 *pixel=image->background_color;
493 pixels=GetVirtualPixelStream(image,virtual_pixel_method,x,y,1,1,exception);
494 if (pixels != (const PixelPacket *) NULL)
501 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
505 + G e t S t r e a m I n f o C l i e n t D a t a %
509 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
511 % GetStreamInfoClientData() gets the stream info client data.
513 % The format of the SetStreamInfoClientData method is:
515 % const void *GetStreamInfoClientData(StreamInfo *stream_info)
517 % A description of each parameter follows:
519 % o stream_info: the stream info.
522 MagickExport const void *GetStreamInfoClientData(StreamInfo *stream_info)
524 assert(stream_info != (StreamInfo *) NULL);
525 assert(stream_info->signature == MagickSignature);
526 return(stream_info->client_data);
530 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
534 + G e t V i r t u a l P i x e l s F r o m S t r e a m %
538 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
540 % GetVirtualPixelsStream() returns the pixels associated with the last
541 % call to QueueAuthenticPixelsStream() or GetVirtualPixelStream().
543 % The format of the GetVirtualPixelsStream() method is:
545 % const IndexPacket *GetVirtualPixelsStream(const Image *image)
547 % A description of each parameter follows:
549 % o pixels: return the pixels associated with the last call to
550 % QueueAuthenticPixelsStream() or GetVirtualPixelStream().
552 % o image: the image.
555 static const PixelPacket *GetVirtualPixelsStream(const Image *image)
560 assert(image != (Image *) NULL);
561 assert(image->signature == MagickSignature);
562 if (image->debug != MagickFalse)
563 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
564 cache_info=(CacheInfo *) image->cache;
565 assert(cache_info->signature == MagickSignature);
566 return(cache_info->pixels);
570 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
574 + G e t V i r t u a l I n d e x e s F r o m S t r e a m %
578 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
580 % GetVirtualIndexesFromStream() returns the indexes associated with the last
581 % call to QueueAuthenticPixelsStream() or GetVirtualPixelStream().
583 % The format of the GetVirtualIndexesFromStream() method is:
585 % const IndexPacket *GetVirtualIndexesFromStream(const Image *image)
587 % A description of each parameter follows:
589 % o image: the image.
592 static const IndexPacket *GetVirtualIndexesFromStream(const Image *image)
597 assert(image != (Image *) NULL);
598 assert(image->signature == MagickSignature);
599 if (image->debug != MagickFalse)
600 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
601 cache_info=(CacheInfo *) image->cache;
602 assert(cache_info->signature == MagickSignature);
603 return(cache_info->indexes);
607 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
611 + G e t V i r t u a l P i x e l S t r e a m %
615 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
617 % GetVirtualPixelStream() gets pixels from the in-memory or disk pixel cache as
618 % defined by the geometry parameters. A pointer to the pixels is returned if
619 % the pixels are transferred, otherwise a NULL is returned. For streams this
622 % The format of the GetVirtualPixelStream() method is:
624 % const PixelPacket *GetVirtualPixelStream(const Image *image,
625 % const VirtualPixelMethod virtual_pixel_method,const long x,
626 % const long y,const unsigned long columns,const unsigned long rows,
627 % ExceptionInfo *exception)
629 % A description of each parameter follows:
631 % o image: the image.
633 % o virtual_pixel_method: the virtual pixel method.
635 % o x,y,columns,rows: These values define the perimeter of a region of
638 % o exception: return any errors or warnings in this structure.
642 static inline MagickBooleanType AcquireStreamPixels(CacheInfo *cache_info,
643 ExceptionInfo *exception)
645 if (cache_info->length != (MagickSizeType) ((size_t) cache_info->length))
647 cache_info->mapped=MagickFalse;
648 cache_info->pixels=(PixelPacket *) AcquireMagickMemory((size_t)
650 if (cache_info->pixels == (PixelPacket *) NULL)
652 cache_info->mapped=MagickTrue;
653 cache_info->pixels=(PixelPacket *) MapBlob(-1,IOMode,0,(size_t)
656 if (cache_info->pixels == (PixelPacket *) NULL)
658 (void) ThrowMagickException(exception,GetMagickModule(),
659 ResourceLimitError,"MemoryAllocationFailed","`%s'",
660 cache_info->filename);
666 static const PixelPacket *GetVirtualPixelStream(const Image *image,
667 const VirtualPixelMethod magick_unused(virtual_pixel_method),const long x,
668 const long y,const unsigned long columns,const unsigned long rows,
669 ExceptionInfo *exception)
684 Validate pixel cache geometry.
686 assert(image != (const Image *) NULL);
687 assert(image->signature == MagickSignature);
688 if (image->debug != MagickFalse)
689 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
690 if ((x < 0) || (y < 0) || ((x+(long) columns) > (long) image->columns) ||
691 ((y+(long) rows) > (long) image->rows) || (columns == 0) || (rows == 0))
693 (void) ThrowMagickException(exception,GetMagickModule(),StreamError,
694 "ImageDoesNotContainTheStreamGeometry","`%s'",image->filename);
695 return((PixelPacket *) NULL);
697 cache_info=(CacheInfo *) image->cache;
698 assert(cache_info->signature == MagickSignature);
700 Pixels are stored in a temporary buffer until they are synced to the cache.
702 number_pixels=(MagickSizeType) columns*rows;
703 length=(size_t) number_pixels*sizeof(PixelPacket);
704 if ((image->storage_class == PseudoClass) ||
705 (image->colorspace == CMYKColorspace))
706 length+=number_pixels*sizeof(IndexPacket);
707 if (cache_info->pixels == (PixelPacket *) NULL)
709 cache_info->length=length;
710 status=AcquireStreamPixels(cache_info,exception);
711 if (status == MagickFalse)
712 return((PixelPacket *) NULL);
715 if (cache_info->length != length)
717 RelinquishStreamPixels(cache_info);
718 cache_info->length=length;
719 status=AcquireStreamPixels(cache_info,exception);
720 if (status == MagickFalse)
721 return((PixelPacket *) NULL);
723 cache_info->indexes=(IndexPacket *) NULL;
724 if ((image->storage_class == PseudoClass) ||
725 (image->colorspace == CMYKColorspace))
726 cache_info->indexes=(IndexPacket *) (cache_info->pixels+number_pixels);
727 return(cache_info->pixels);
731 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
735 + O p e n S t r e a m %
739 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
741 % OpenStream() opens a stream for writing by the StreamImage() method.
743 % The format of the OpenStream method is:
745 % MagickBooleanType OpenStream(const ImageInfo *image_info,
746 % StreamInfo *stream_info,const char *filename,ExceptionInfo *exception)
748 % A description of each parameter follows:
750 % o image_info: the image info.
752 % o stream_info: the stream info.
754 % o filename: the stream filename.
756 % o exception: return any errors or warnings in this structure.
759 MagickExport MagickBooleanType OpenStream(const ImageInfo *image_info,
760 StreamInfo *stream_info,const char *filename,ExceptionInfo *exception)
765 (void) CopyMagickString(stream_info->stream->filename,filename,MaxTextExtent);
766 status=OpenBlob(image_info,stream_info->stream,WriteBinaryBlobMode,exception);
771 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
775 + Q u e u e A u t h e n t i c P i x e l s S t r e a m %
779 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
781 % QueueAuthenticPixelsStream() allocates an area to store image pixels as
782 % defined by the region rectangle and returns a pointer to the area. This
783 % area is subsequently transferred from the pixel cache with method
784 % SyncAuthenticPixelsStream(). A pointer to the pixels is returned if the
785 % pixels are transferred, otherwise a NULL is returned.
787 % The format of the QueueAuthenticPixelsStream() method is:
789 % PixelPacket *QueueAuthenticPixelsStream(Image *image,const long x,
790 % const long y,const unsigned long columns,const unsigned long rows,
791 % ExceptionInfo *exception)
793 % A description of each parameter follows:
795 % o image: the image.
797 % o x,y,columns,rows: These values define the perimeter of a region of
801 static PixelPacket *QueueAuthenticPixelsStream(Image *image,const long x,
802 const long y,const unsigned long columns,const unsigned long rows,
803 ExceptionInfo *exception)
818 Validate pixel cache geometry.
820 assert(image != (Image *) NULL);
821 if ((x < 0) || (y < 0) || ((x+(long) columns) > (long) image->columns) ||
822 ((y+(long) rows) > (long) image->rows) || (columns == 0) || (rows == 0))
824 (void) ThrowMagickException(exception,GetMagickModule(),StreamError,
825 "ImageDoesNotContainTheStreamGeometry","`%s'",image->filename);
826 return((PixelPacket *) NULL);
828 stream_handler=GetBlobStreamHandler(image);
829 if (stream_handler == (StreamHandler) NULL)
831 (void) ThrowMagickException(exception,GetMagickModule(),StreamError,
832 "NoStreamHandlerIsDefined","`%s'",image->filename);
833 return((PixelPacket *) NULL);
835 cache_info=(CacheInfo *) image->cache;
836 assert(cache_info->signature == MagickSignature);
837 if ((image->storage_class != GetPixelCacheStorageClass(image->cache)) ||
838 (image->colorspace != GetPixelCacheColorspace(image->cache)))
840 if (GetPixelCacheStorageClass(image->cache) == UndefinedClass)
841 (void) stream_handler(image,(const void *) NULL,(size_t)
842 cache_info->columns);
843 cache_info->storage_class=image->storage_class;
844 cache_info->colorspace=image->colorspace;
845 cache_info->columns=image->columns;
846 cache_info->rows=image->rows;
847 image->cache=cache_info;
850 Pixels are stored in a temporary buffer until they are synced to the cache.
852 cache_info->columns=columns;
853 cache_info->rows=rows;
854 number_pixels=(MagickSizeType) columns*rows;
855 length=(size_t) number_pixels*sizeof(PixelPacket);
856 if ((image->storage_class == PseudoClass) ||
857 (image->colorspace == CMYKColorspace))
858 length+=number_pixels*sizeof(IndexPacket);
859 if (cache_info->pixels == (PixelPacket *) NULL)
861 cache_info->pixels=(PixelPacket *) AcquireMagickMemory(length);
862 cache_info->length=(MagickSizeType) length;
865 if (cache_info->length < (MagickSizeType) length)
867 cache_info->pixels=(PixelPacket *) ResizeMagickMemory(
868 cache_info->pixels,length);
869 cache_info->length=(MagickSizeType) length;
871 if (cache_info->pixels == (void *) NULL)
872 return((PixelPacket *) NULL);
873 cache_info->indexes=(IndexPacket *) NULL;
874 if ((image->storage_class == PseudoClass) ||
875 (image->colorspace == CMYKColorspace))
876 cache_info->indexes=(IndexPacket *) (cache_info->pixels+number_pixels);
877 return(cache_info->pixels);
881 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
885 % R e a d S t r e a m %
889 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
891 % ReadStream() makes the image pixels available to a user supplied callback
892 % method immediately upon reading a scanline with the ReadImage() method.
894 % The format of the ReadStream() method is:
896 % Image *ReadStream(const ImageInfo *image_info,StreamHandler stream,
897 % ExceptionInfo *exception)
899 % A description of each parameter follows:
901 % o image_info: the image info.
903 % o stream: a callback method.
905 % o exception: return any errors or warnings in this structure.
908 MagickExport Image *ReadStream(const ImageInfo *image_info,StreamHandler stream,
909 ExceptionInfo *exception)
923 assert(image_info != (ImageInfo *) NULL);
924 assert(image_info->signature == MagickSignature);
925 if (image_info->debug != MagickFalse)
926 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
927 image_info->filename);
928 assert(exception != (ExceptionInfo *) NULL);
929 assert(exception->signature == MagickSignature);
930 read_info=CloneImageInfo(image_info);
931 read_info->cache=AcquirePixelCache(0);
932 GetPixelCacheMethods(&cache_methods);
933 cache_methods.get_virtual_pixel_handler=GetVirtualPixelStream;
934 cache_methods.get_virtual_indexes_from_handler=GetVirtualIndexesFromStream;
935 cache_methods.get_virtual_pixels_handler=GetVirtualPixelsStream;
936 cache_methods.get_authentic_pixels_handler=GetAuthenticPixelsStream;
937 cache_methods.queue_authentic_pixels_handler=QueueAuthenticPixelsStream;
938 cache_methods.sync_authentic_pixels_handler=SyncAuthenticPixelsStream;
939 cache_methods.get_authentic_pixels_from_handler=GetAuthenticPixelsFromStream;
940 cache_methods.get_authentic_indexes_from_handler=
941 GetAuthenticIndexesFromStream;
942 cache_methods.get_one_virtual_pixel_from_handler=GetOneVirtualPixelFromStream;
943 cache_methods.get_one_authentic_pixel_from_handler=
944 GetOneAuthenticPixelFromStream;
945 cache_methods.destroy_pixel_handler=DestroyPixelStream;
946 SetPixelCacheMethods(read_info->cache,&cache_methods);
947 read_info->stream=stream;
948 image=ReadImage(read_info,exception);
949 read_info=DestroyImageInfo(read_info);
954 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
958 + S e t S t r e a m I n f o C l i e n t D a t a %
962 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
964 % SetStreamInfoClientData() sets the stream info client data.
966 % The format of the SetStreamInfoClientData method is:
968 % void SetStreamInfoClientData(StreamInfo *stream_info,
969 % const void *client_data)
971 % A description of each parameter follows:
973 % o stream_info: the stream info.
975 % o client_data: the client data.
978 MagickExport void SetStreamInfoClientData(StreamInfo *stream_info,
979 const void *client_data)
981 assert(stream_info != (StreamInfo *) NULL);
982 assert(stream_info->signature == MagickSignature);
983 stream_info->client_data=client_data;
987 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
991 + S e t S t r e a m I n f o M a p %
995 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
997 % SetStreamInfoMap() sets the stream info map member.
999 % The format of the SetStreamInfoMap method is:
1001 % void SetStreamInfoMap(StreamInfo *stream_info,const char *map)
1003 % A description of each parameter follows:
1005 % o stream_info: the stream info.
1010 MagickExport void SetStreamInfoMap(StreamInfo *stream_info,const char *map)
1012 assert(stream_info != (StreamInfo *) NULL);
1013 assert(stream_info->signature == MagickSignature);
1014 (void) CloneString(&stream_info->map,map);
1018 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1022 + S e t S t r e a m I n f o S t o r a g e T y p e %
1026 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1028 % SetStreamInfoStorageType() sets the stream info storage type member.
1030 % The format of the SetStreamInfoStorageType method is:
1032 % void SetStreamInfoStorageType(StreamInfo *stream_info,
1033 % const StoreageType *storage_type)
1035 % A description of each parameter follows:
1037 % o stream_info: the stream info.
1039 % o storage_type: the storage type.
1042 MagickExport void SetStreamInfoStorageType(StreamInfo *stream_info,
1043 const StorageType storage_type)
1045 assert(stream_info != (StreamInfo *) NULL);
1046 assert(stream_info->signature == MagickSignature);
1047 stream_info->storage_type=storage_type;
1051 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1055 + S t r e a m I m a g e %
1059 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1061 % StreamImage() streams pixels from an image and writes them in a user
1062 % defined format and storage type (e.g. RGBA as 8-bit unsigned char).
1064 % The format of he wStreamImage() method is:
1066 % Image *StreamImage(const ImageInfo *image_info,
1067 % StreamInfo *stream_info,ExceptionInfo *exception)
1069 % A description of each parameter follows:
1071 % o image_info: the image info.
1073 % o stream_info: the stream info.
1075 % o exception: return any errors or warnings in this structure.
1079 #if defined(__cplusplus) || defined(c_plusplus)
1083 static size_t WriteStreamImage(const Image *image,const void *pixels,
1084 const size_t columns)
1099 stream_info=(StreamInfo *) image->client_data;
1100 switch (stream_info->storage_type)
1102 default: packet_size=sizeof(char); break;
1103 case CharPixel: packet_size=sizeof(char); break;
1104 case DoublePixel: packet_size=sizeof(double); break;
1105 case FloatPixel: packet_size=sizeof(float); break;
1106 case IntegerPixel: packet_size=sizeof(int); break;
1107 case LongPixel: packet_size=sizeof(long); break;
1108 case QuantumPixel: packet_size=sizeof(Quantum); break;
1109 case ShortPixel: packet_size=sizeof(unsigned short); break;
1111 packet_size*=strlen(stream_info->map);
1112 length=packet_size*image->columns;
1113 if (image != stream_info->image)
1119 Prepare stream for writing.
1121 stream_info->pixels=(unsigned char *) ResizeQuantumMemory(
1122 stream_info->pixels,length,sizeof(*stream_info->pixels));
1123 if (pixels == (unsigned char *) NULL)
1125 stream_info->image=image;
1126 write_info=CloneImageInfo(stream_info->image_info);
1127 (void) SetImageInfo(write_info,MagickFalse,stream_info->exception);
1128 if (write_info->extract != (char *) NULL)
1129 (void) ParseAbsoluteGeometry(write_info->extract,
1130 &stream_info->extract_info);
1132 write_info=DestroyImageInfo(write_info);
1134 extract_info=stream_info->extract_info;
1135 if ((extract_info.width == 0) ||
1136 (extract_info.height == 0))
1139 Write all pixels to stream.
1141 (void) StreamImagePixels(stream_info,image,stream_info->exception);
1142 count=WriteBlob(stream_info->stream,length,stream_info->pixels);
1144 return(count == 0 ? 0 : columns);
1146 if ((stream_info->y < extract_info.y) ||
1147 (stream_info->y >= (long) (extract_info.y+extract_info.height)))
1153 Write a portion of the pixel row to the stream.
1155 (void) StreamImagePixels(stream_info,image,stream_info->exception);
1156 length=packet_size*extract_info.width;
1157 count=WriteBlob(stream_info->stream,length,stream_info->pixels+
1158 packet_size*extract_info.x);
1160 return(count == 0 ? 0 : columns);
1163 #if defined(__cplusplus) || defined(c_plusplus)
1167 MagickExport Image *StreamImage(const ImageInfo *image_info,
1168 StreamInfo *stream_info,ExceptionInfo *exception)
1176 assert(image_info != (const ImageInfo *) NULL);
1177 assert(image_info->signature == MagickSignature);
1178 if (image_info->debug != MagickFalse)
1179 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
1180 image_info->filename);
1181 assert(stream_info != (StreamInfo *) NULL);
1182 assert(stream_info->signature == MagickSignature);
1183 assert(exception != (ExceptionInfo *) NULL);
1184 read_info=CloneImageInfo(image_info);
1185 stream_info->image_info=image_info;
1186 stream_info->exception=exception;
1187 read_info->client_data=(void *) stream_info;
1188 image=ReadStream(read_info,&WriteStreamImage,exception);
1189 read_info=DestroyImageInfo(read_info);
1190 stream_info->quantum_info=AcquireQuantumInfo(image_info,image);
1191 if (stream_info->quantum_info == (QuantumInfo *) NULL)
1192 image=DestroyImage(image);
1197 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1201 + S t r e a m I m a g e P i x e l s %
1205 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1207 % StreamImagePixels() extracts pixel data from an image and returns it in the
1208 % stream_info->pixels structure in the format as defined by
1209 % stream_info->quantum_info->map and stream_info->quantum_info->storage_type.
1211 % The format of the StreamImagePixels method is:
1213 % MagickBooleanType StreamImagePixels(const StreamInfo *stream_info,
1214 % const Image *image,ExceptionInfo *exception)
1216 % A description of each parameter follows:
1218 % o stream_info: the stream info.
1220 % o image: the image.
1222 % o exception: return any errors or warnings in this structure.
1225 static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info,
1226 const Image *image,ExceptionInfo *exception)
1238 register const PixelPacket
1241 register IndexPacket
1247 assert(stream_info != (StreamInfo *) NULL);
1248 assert(stream_info->signature == MagickSignature);
1249 assert(image != (Image *) NULL);
1250 assert(image->signature == MagickSignature);
1251 if (image->debug != MagickFalse)
1252 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1253 length=strlen(stream_info->map);
1254 quantum_map=(QuantumType *) AcquireQuantumMemory(length,sizeof(*quantum_map));
1255 if (quantum_map == (QuantumType *) NULL)
1257 (void) ThrowMagickException(exception,GetMagickModule(),
1258 ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);
1259 return(MagickFalse);
1261 for (i=0; i < (long) length; i++)
1263 switch (stream_info->map[i])
1268 quantum_map[i]=AlphaQuantum;
1274 quantum_map[i]=BlueQuantum;
1280 quantum_map[i]=CyanQuantum;
1281 if (image->colorspace == CMYKColorspace)
1283 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
1284 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
1285 "ColorSeparatedImageRequired","`%s'",stream_info->map);
1286 return(MagickFalse);
1291 quantum_map[i]=GreenQuantum;
1297 quantum_map[i]=IndexQuantum;
1303 quantum_map[i]=BlackQuantum;
1304 if (image->colorspace == CMYKColorspace)
1306 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
1307 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
1308 "ColorSeparatedImageRequired","`%s'",stream_info->map);
1309 return(MagickFalse);
1314 quantum_map[i]=MagentaQuantum;
1315 if (image->colorspace == CMYKColorspace)
1317 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
1318 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
1319 "ColorSeparatedImageRequired","`%s'",stream_info->map);
1320 return(MagickFalse);
1325 quantum_map[i]=OpacityQuantum;
1331 quantum_map[i]=UndefinedQuantum;
1337 quantum_map[i]=RedQuantum;
1343 quantum_map[i]=YellowQuantum;
1344 if (image->colorspace == CMYKColorspace)
1346 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
1347 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
1348 "ColorSeparatedImageRequired","`%s'",stream_info->map);
1349 return(MagickFalse);
1353 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
1354 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
1355 "UnrecognizedPixelMap","`%s'",stream_info->map);
1356 return(MagickFalse);
1360 quantum_info=stream_info->quantum_info;
1361 switch (stream_info->storage_type)
1365 register unsigned char
1368 q=(unsigned char *) stream_info->pixels;
1369 if (LocaleCompare(stream_info->map,"BGR") == 0)
1371 p=GetAuthenticPixelQueue(image);
1372 if (p == (const PixelPacket *) NULL)
1374 for (x=0; x < (long) GetImageExtent(image); x++)
1376 *q++=ScaleQuantumToChar(p->blue);
1377 *q++=ScaleQuantumToChar(p->green);
1378 *q++=ScaleQuantumToChar(p->red);
1383 if (LocaleCompare(stream_info->map,"BGRA") == 0)
1385 p=GetAuthenticPixelQueue(image);
1386 if (p == (const PixelPacket *) NULL)
1388 for (x=0; x < (long) GetImageExtent(image); x++)
1390 *q++=ScaleQuantumToChar(p->blue);
1391 *q++=ScaleQuantumToChar(p->green);
1392 *q++=ScaleQuantumToChar(p->red);
1393 *q++=ScaleQuantumToChar((Quantum) (QuantumRange-p->opacity));
1398 if (LocaleCompare(stream_info->map,"BGRP") == 0)
1400 p=GetAuthenticPixelQueue(image);
1401 if (p == (const PixelPacket *) NULL)
1403 for (x=0; x < (long) GetImageExtent(image); x++)
1405 *q++=ScaleQuantumToChar(p->blue);
1406 *q++=ScaleQuantumToChar(p->green);
1407 *q++=ScaleQuantumToChar(p->red);
1408 *q++=ScaleQuantumToChar((Quantum) 0);
1413 if (LocaleCompare(stream_info->map,"I") == 0)
1415 p=GetAuthenticPixelQueue(image);
1416 if (p == (const PixelPacket *) NULL)
1418 for (x=0; x < (long) GetImageExtent(image); x++)
1420 *q++=ScaleQuantumToChar(PixelIntensityToQuantum(p));
1425 if (LocaleCompare(stream_info->map,"RGB") == 0)
1427 p=GetAuthenticPixelQueue(image);
1428 if (p == (const PixelPacket *) NULL)
1430 for (x=0; x < (long) GetImageExtent(image); x++)
1432 *q++=ScaleQuantumToChar(p->red);
1433 *q++=ScaleQuantumToChar(p->green);
1434 *q++=ScaleQuantumToChar(p->blue);
1439 if (LocaleCompare(stream_info->map,"RGBA") == 0)
1441 p=GetAuthenticPixelQueue(image);
1442 if (p == (const PixelPacket *) NULL)
1444 for (x=0; x < (long) GetImageExtent(image); x++)
1446 *q++=ScaleQuantumToChar(p->red);
1447 *q++=ScaleQuantumToChar(p->green);
1448 *q++=ScaleQuantumToChar(p->blue);
1449 *q++=ScaleQuantumToChar((Quantum) (QuantumRange-p->opacity));
1454 if (LocaleCompare(stream_info->map,"RGBP") == 0)
1456 p=GetAuthenticPixelQueue(image);
1457 if (p == (const PixelPacket *) NULL)
1459 for (x=0; x < (long) GetImageExtent(image); x++)
1461 *q++=ScaleQuantumToChar(p->red);
1462 *q++=ScaleQuantumToChar(p->green);
1463 *q++=ScaleQuantumToChar(p->blue);
1464 *q++=ScaleQuantumToChar((Quantum) 0);
1469 p=GetAuthenticPixelQueue(image);
1470 if (p == (const PixelPacket *) NULL)
1472 indexes=GetAuthenticIndexQueue(image);
1473 for (x=0; x < (long) GetImageExtent(image); x++)
1475 for (i=0; i < (long) length; i++)
1478 switch (quantum_map[i])
1483 *q=ScaleQuantumToChar(p->red);
1487 case MagentaQuantum:
1489 *q=ScaleQuantumToChar(p->green);
1495 *q=ScaleQuantumToChar(p->blue);
1500 *q=ScaleQuantumToChar((Quantum) (QuantumRange-p->opacity));
1503 case OpacityQuantum:
1505 *q=ScaleQuantumToChar(p->opacity);
1510 if (image->colorspace == CMYKColorspace)
1511 *q=ScaleQuantumToChar(indexes[x]);
1516 *q=ScaleQuantumToChar(PixelIntensityToQuantum(p));
1533 q=(double *) stream_info->pixels;
1534 if (LocaleCompare(stream_info->map,"BGR") == 0)
1536 p=GetAuthenticPixelQueue(image);
1537 if (p == (const PixelPacket *) NULL)
1539 for (x=0; x < (long) GetImageExtent(image); x++)
1541 *q++=(double) ((QuantumScale*p->blue)*quantum_info->scale+
1542 quantum_info->minimum);
1543 *q++=(double) ((QuantumScale*p->green)*quantum_info->scale+
1544 quantum_info->minimum);
1545 *q++=(double) ((QuantumScale*p->red)*quantum_info->scale+
1546 quantum_info->minimum);
1551 if (LocaleCompare(stream_info->map,"BGRA") == 0)
1553 p=GetAuthenticPixelQueue(image);
1554 if (p == (const PixelPacket *) NULL)
1556 for (x=0; x < (long) GetImageExtent(image); x++)
1558 *q++=(double) ((QuantumScale*p->blue)*quantum_info->scale+
1559 quantum_info->minimum);
1560 *q++=(double) ((QuantumScale*p->green)*quantum_info->scale+
1561 quantum_info->minimum);
1562 *q++=(double) ((QuantumScale*p->red)*quantum_info->scale+
1563 quantum_info->minimum);
1564 *q++=(double) ((QuantumScale*((Quantum) (QuantumRange-p->opacity)))*
1565 quantum_info->scale+quantum_info->minimum);
1570 if (LocaleCompare(stream_info->map,"BGRP") == 0)
1572 p=GetAuthenticPixelQueue(image);
1573 if (p == (const PixelPacket *) NULL)
1575 for (x=0; x < (long) GetImageExtent(image); x++)
1577 *q++=(double) ((QuantumScale*p->blue)*quantum_info->scale+
1578 quantum_info->minimum);
1579 *q++=(double) ((QuantumScale*p->green)*quantum_info->scale+
1580 quantum_info->minimum);
1581 *q++=(double) ((QuantumScale*p->red)*quantum_info->scale+
1582 quantum_info->minimum);
1588 if (LocaleCompare(stream_info->map,"I") == 0)
1590 p=GetAuthenticPixelQueue(image);
1591 if (p == (const PixelPacket *) NULL)
1593 for (x=0; x < (long) GetImageExtent(image); x++)
1595 *q++=(double) ((QuantumScale*PixelIntensityToQuantum(p))*
1596 quantum_info->scale+quantum_info->minimum);
1601 if (LocaleCompare(stream_info->map,"RGB") == 0)
1603 p=GetAuthenticPixelQueue(image);
1604 if (p == (const PixelPacket *) NULL)
1606 for (x=0; x < (long) GetImageExtent(image); x++)
1608 *q++=(double) ((QuantumScale*p->red)*quantum_info->scale+
1609 quantum_info->minimum);
1610 *q++=(double) ((QuantumScale*p->green)*quantum_info->scale+
1611 quantum_info->minimum);
1612 *q++=(double) ((QuantumScale*p->blue)*quantum_info->scale+
1613 quantum_info->minimum);
1618 if (LocaleCompare(stream_info->map,"RGBA") == 0)
1620 p=GetAuthenticPixelQueue(image);
1621 if (p == (const PixelPacket *) NULL)
1623 for (x=0; x < (long) GetImageExtent(image); x++)
1625 *q++=(double) ((QuantumScale*p->red)*quantum_info->scale+
1626 quantum_info->minimum);
1627 *q++=(double) ((QuantumScale*p->green)*quantum_info->scale+
1628 quantum_info->minimum);
1629 *q++=(double) ((QuantumScale*p->blue)*quantum_info->scale+
1630 quantum_info->minimum);
1631 *q++=(double) ((QuantumScale*((Quantum) (QuantumRange-p->opacity)))*
1632 quantum_info->scale+quantum_info->minimum);
1637 if (LocaleCompare(stream_info->map,"RGBP") == 0)
1639 p=GetAuthenticPixelQueue(image);
1640 if (p == (const PixelPacket *) NULL)
1642 for (x=0; x < (long) GetImageExtent(image); x++)
1644 *q++=(double) ((QuantumScale*p->red)*quantum_info->scale+
1645 quantum_info->minimum);
1646 *q++=(double) ((QuantumScale*p->green)*quantum_info->scale+
1647 quantum_info->minimum);
1648 *q++=(double) ((QuantumScale*p->blue)*quantum_info->scale+
1649 quantum_info->minimum);
1655 p=GetAuthenticPixelQueue(image);
1656 if (p == (const PixelPacket *) NULL)
1658 indexes=GetAuthenticIndexQueue(image);
1659 for (x=0; x < (long) GetImageExtent(image); x++)
1661 for (i=0; i < (long) length; i++)
1664 switch (quantum_map[i])
1669 *q=(double) ((QuantumScale*p->red)*quantum_info->scale+
1670 quantum_info->minimum);
1674 case MagentaQuantum:
1676 *q=(double) ((QuantumScale*p->green)*quantum_info->scale+
1677 quantum_info->minimum);
1683 *q=(double) ((QuantumScale*p->blue)*quantum_info->scale+
1684 quantum_info->minimum);
1689 *q=(double) ((QuantumScale*((Quantum) (QuantumRange-
1690 p->opacity)))*quantum_info->scale+quantum_info->minimum);
1693 case OpacityQuantum:
1695 *q=(double) ((QuantumScale*p->opacity)*quantum_info->scale+
1696 quantum_info->minimum);
1701 if (image->colorspace == CMYKColorspace)
1702 *q=(double) ((QuantumScale*indexes[x])*quantum_info->scale+
1703 quantum_info->minimum);
1708 *q=(double) ((QuantumScale*PixelIntensityToQuantum(p))*
1709 quantum_info->scale+quantum_info->minimum);
1726 q=(float *) stream_info->pixels;
1727 if (LocaleCompare(stream_info->map,"BGR") == 0)
1729 p=GetAuthenticPixelQueue(image);
1730 if (p == (const PixelPacket *) NULL)
1732 for (x=0; x < (long) GetImageExtent(image); x++)
1734 *q++=(float) ((QuantumScale*p->blue)*quantum_info->scale+
1735 quantum_info->minimum);
1736 *q++=(float) ((QuantumScale*p->green)*quantum_info->scale+
1737 quantum_info->minimum);
1738 *q++=(float) ((QuantumScale*p->red)*quantum_info->scale+
1739 quantum_info->minimum);
1744 if (LocaleCompare(stream_info->map,"BGRA") == 0)
1746 p=GetAuthenticPixelQueue(image);
1747 if (p == (const PixelPacket *) NULL)
1749 for (x=0; x < (long) GetImageExtent(image); x++)
1751 *q++=(float) ((QuantumScale*p->blue)*quantum_info->scale+
1752 quantum_info->minimum);
1753 *q++=(float) ((QuantumScale*p->green)*quantum_info->scale+
1754 quantum_info->minimum);
1755 *q++=(float) ((QuantumScale*p->red)*quantum_info->scale+
1756 quantum_info->minimum);
1757 *q++=(float) ((QuantumScale*(Quantum) (QuantumRange-p->opacity))*
1758 quantum_info->scale+quantum_info->minimum);
1763 if (LocaleCompare(stream_info->map,"BGRP") == 0)
1765 p=GetAuthenticPixelQueue(image);
1766 if (p == (const PixelPacket *) NULL)
1768 for (x=0; x < (long) GetImageExtent(image); x++)
1770 *q++=(float) ((QuantumScale*p->blue)*quantum_info->scale+
1771 quantum_info->minimum);
1772 *q++=(float) ((QuantumScale*p->green)*quantum_info->scale+
1773 quantum_info->minimum);
1774 *q++=(float) ((QuantumScale*p->red)*quantum_info->scale+
1775 quantum_info->minimum);
1781 if (LocaleCompare(stream_info->map,"I") == 0)
1783 p=GetAuthenticPixelQueue(image);
1784 if (p == (const PixelPacket *) NULL)
1786 for (x=0; x < (long) GetImageExtent(image); x++)
1788 *q++=(float) ((QuantumScale*PixelIntensityToQuantum(p))*
1789 quantum_info->scale+quantum_info->minimum);
1794 if (LocaleCompare(stream_info->map,"RGB") == 0)
1796 p=GetAuthenticPixelQueue(image);
1797 if (p == (const PixelPacket *) NULL)
1799 for (x=0; x < (long) GetImageExtent(image); x++)
1801 *q++=(float) ((QuantumScale*p->red)*quantum_info->scale+
1802 quantum_info->minimum);
1803 *q++=(float) ((QuantumScale*p->green)*quantum_info->scale+
1804 quantum_info->minimum);
1805 *q++=(float) ((QuantumScale*p->blue)*quantum_info->scale+
1806 quantum_info->minimum);
1811 if (LocaleCompare(stream_info->map,"RGBA") == 0)
1813 p=GetAuthenticPixelQueue(image);
1814 if (p == (const PixelPacket *) NULL)
1816 for (x=0; x < (long) GetImageExtent(image); x++)
1818 *q++=(float) ((QuantumScale*p->red)*quantum_info->scale+
1819 quantum_info->minimum);
1820 *q++=(float) ((QuantumScale*p->green)*quantum_info->scale+
1821 quantum_info->minimum);
1822 *q++=(float) ((QuantumScale*p->blue)*quantum_info->scale+
1823 quantum_info->minimum);
1824 *q++=(float) ((QuantumScale*((Quantum) (QuantumRange-p->opacity)))*
1825 quantum_info->scale+quantum_info->minimum);
1830 if (LocaleCompare(stream_info->map,"RGBP") == 0)
1832 p=GetAuthenticPixelQueue(image);
1833 if (p == (const PixelPacket *) NULL)
1835 for (x=0; x < (long) GetImageExtent(image); x++)
1837 *q++=(float) ((QuantumScale*p->red)*quantum_info->scale+
1838 quantum_info->minimum);
1839 *q++=(float) ((QuantumScale*p->green)*quantum_info->scale+
1840 quantum_info->minimum);
1841 *q++=(float) ((QuantumScale*p->blue)*quantum_info->scale+
1842 quantum_info->minimum);
1848 p=GetAuthenticPixelQueue(image);
1849 if (p == (const PixelPacket *) NULL)
1851 indexes=GetAuthenticIndexQueue(image);
1852 for (x=0; x < (long) GetImageExtent(image); x++)
1854 for (i=0; i < (long) length; i++)
1857 switch (quantum_map[i])
1862 *q=(float) ((QuantumScale*p->red)*quantum_info->scale+
1863 quantum_info->minimum);
1867 case MagentaQuantum:
1869 *q=(float) ((QuantumScale*p->green)*quantum_info->scale+
1870 quantum_info->minimum);
1876 *q=(float) ((QuantumScale*p->blue)*quantum_info->scale+
1877 quantum_info->minimum);
1882 *q=(float) ((QuantumScale*((Quantum) (QuantumRange-
1883 p->opacity)))*quantum_info->scale+quantum_info->minimum);
1886 case OpacityQuantum:
1888 *q=(float) ((QuantumScale*p->opacity)*quantum_info->scale+
1889 quantum_info->minimum);
1894 if (image->colorspace == CMYKColorspace)
1895 *q=(float) ((QuantumScale*indexes[x])*quantum_info->scale+
1896 quantum_info->minimum);
1901 *q=(float) ((QuantumScale*PixelIntensityToQuantum(p))*
1902 quantum_info->scale+quantum_info->minimum);
1916 register unsigned int
1919 q=(unsigned int *) stream_info->pixels;
1920 if (LocaleCompare(stream_info->map,"BGR") == 0)
1922 p=GetAuthenticPixelQueue(image);
1923 if (p == (const PixelPacket *) NULL)
1925 for (x=0; x < (long) GetImageExtent(image); x++)
1927 *q++=(unsigned int) ScaleQuantumToLong(p->blue);
1928 *q++=(unsigned int) ScaleQuantumToLong(p->green);
1929 *q++=(unsigned int) ScaleQuantumToLong(p->red);
1934 if (LocaleCompare(stream_info->map,"BGRA") == 0)
1936 p=GetAuthenticPixelQueue(image);
1937 if (p == (const PixelPacket *) NULL)
1939 for (x=0; x < (long) GetImageExtent(image); x++)
1941 *q++=(unsigned int) ScaleQuantumToLong(p->blue);
1942 *q++=(unsigned int) ScaleQuantumToLong(p->green);
1943 *q++=(unsigned int) ScaleQuantumToLong(p->red);
1944 *q++=(unsigned int) ScaleQuantumToLong((Quantum) (QuantumRange-
1950 if (LocaleCompare(stream_info->map,"BGRP") == 0)
1952 p=GetAuthenticPixelQueue(image);
1953 if (p == (const PixelPacket *) NULL)
1955 for (x=0; x < (long) GetImageExtent(image); x++)
1957 *q++=(unsigned int) ScaleQuantumToLong(p->blue);
1958 *q++=(unsigned int) ScaleQuantumToLong(p->green);
1959 *q++=(unsigned int) ScaleQuantumToLong(p->red);
1965 if (LocaleCompare(stream_info->map,"I") == 0)
1967 p=GetAuthenticPixelQueue(image);
1968 if (p == (const PixelPacket *) NULL)
1970 for (x=0; x < (long) GetImageExtent(image); x++)
1972 *q++=(unsigned int) ScaleQuantumToLong(
1973 PixelIntensityToQuantum(p));
1978 if (LocaleCompare(stream_info->map,"RGB") == 0)
1980 p=GetAuthenticPixelQueue(image);
1981 if (p == (const PixelPacket *) NULL)
1983 for (x=0; x < (long) GetImageExtent(image); x++)
1985 *q++=(unsigned int) ScaleQuantumToLong(p->red);
1986 *q++=(unsigned int) ScaleQuantumToLong(p->green);
1987 *q++=(unsigned int) ScaleQuantumToLong(p->blue);
1992 if (LocaleCompare(stream_info->map,"RGBA") == 0)
1994 p=GetAuthenticPixelQueue(image);
1995 if (p == (const PixelPacket *) NULL)
1997 for (x=0; x < (long) GetImageExtent(image); x++)
1999 *q++=(unsigned int) ScaleQuantumToLong(p->red);
2000 *q++=(unsigned int) ScaleQuantumToLong(p->green);
2001 *q++=(unsigned int) ScaleQuantumToLong(p->blue);
2002 *q++=(unsigned int) ScaleQuantumToLong((Quantum)
2003 (QuantumRange-p->opacity));
2008 if (LocaleCompare(stream_info->map,"RGBP") == 0)
2010 p=GetAuthenticPixelQueue(image);
2011 if (p == (const PixelPacket *) NULL)
2013 for (x=0; x < (long) GetImageExtent(image); x++)
2015 *q++=(unsigned int) ScaleQuantumToLong(p->red);
2016 *q++=(unsigned int) ScaleQuantumToLong(p->green);
2017 *q++=(unsigned int) ScaleQuantumToLong(p->blue);
2023 p=GetAuthenticPixelQueue(image);
2024 if (p == (const PixelPacket *) NULL)
2026 indexes=GetAuthenticIndexQueue(image);
2027 for (x=0; x < (long) GetImageExtent(image); x++)
2029 for (i=0; i < (long) length; i++)
2032 switch (quantum_map[i])
2037 *q=(unsigned int) ScaleQuantumToLong(p->red);
2041 case MagentaQuantum:
2043 *q=(unsigned int) ScaleQuantumToLong(p->green);
2049 *q=(unsigned int) ScaleQuantumToLong(p->blue);
2054 *q=(unsigned int) ScaleQuantumToLong((Quantum) (QuantumRange-
2058 case OpacityQuantum:
2060 *q=(unsigned int) ScaleQuantumToLong(p->opacity);
2065 if (image->colorspace == CMYKColorspace)
2066 *q=(unsigned int) ScaleQuantumToLong(indexes[x]);
2072 ScaleQuantumToLong(PixelIntensityToQuantum(p));
2086 register unsigned long
2089 q=(unsigned long *) stream_info->pixels;
2090 if (LocaleCompare(stream_info->map,"BGR") == 0)
2092 p=GetAuthenticPixelQueue(image);
2093 if (p == (const PixelPacket *) NULL)
2095 for (x=0; x < (long) GetImageExtent(image); x++)
2097 *q++=ScaleQuantumToLong(p->blue);
2098 *q++=ScaleQuantumToLong(p->green);
2099 *q++=ScaleQuantumToLong(p->red);
2104 if (LocaleCompare(stream_info->map,"BGRA") == 0)
2106 p=GetAuthenticPixelQueue(image);
2107 if (p == (const PixelPacket *) NULL)
2109 for (x=0; x < (long) GetImageExtent(image); x++)
2111 *q++=ScaleQuantumToLong(p->blue);
2112 *q++=ScaleQuantumToLong(p->green);
2113 *q++=ScaleQuantumToLong(p->red);
2114 *q++=ScaleQuantumToLong((Quantum) (QuantumRange-p->opacity));
2119 if (LocaleCompare(stream_info->map,"BGRP") == 0)
2121 p=GetAuthenticPixelQueue(image);
2122 if (p == (const PixelPacket *) NULL)
2124 for (x=0; x < (long) GetImageExtent(image); x++)
2126 *q++=ScaleQuantumToLong(p->blue);
2127 *q++=ScaleQuantumToLong(p->green);
2128 *q++=ScaleQuantumToLong(p->red);
2134 if (LocaleCompare(stream_info->map,"I") == 0)
2136 p=GetAuthenticPixelQueue(image);
2137 if (p == (const PixelPacket *) NULL)
2139 for (x=0; x < (long) GetImageExtent(image); x++)
2141 *q++=ScaleQuantumToLong(PixelIntensityToQuantum(p));
2146 if (LocaleCompare(stream_info->map,"RGB") == 0)
2148 p=GetAuthenticPixelQueue(image);
2149 if (p == (const PixelPacket *) NULL)
2151 for (x=0; x < (long) GetImageExtent(image); x++)
2153 *q++=ScaleQuantumToLong(p->red);
2154 *q++=ScaleQuantumToLong(p->green);
2155 *q++=ScaleQuantumToLong(p->blue);
2160 if (LocaleCompare(stream_info->map,"RGBA") == 0)
2162 p=GetAuthenticPixelQueue(image);
2163 if (p == (const PixelPacket *) NULL)
2165 for (x=0; x < (long) GetImageExtent(image); x++)
2167 *q++=ScaleQuantumToLong(p->red);
2168 *q++=ScaleQuantumToLong(p->green);
2169 *q++=ScaleQuantumToLong(p->blue);
2170 *q++=ScaleQuantumToLong((Quantum) (QuantumRange-p->opacity));
2175 if (LocaleCompare(stream_info->map,"RGBP") == 0)
2177 p=GetAuthenticPixelQueue(image);
2178 if (p == (const PixelPacket *) NULL)
2180 for (x=0; x < (long) GetImageExtent(image); x++)
2182 *q++=ScaleQuantumToLong(p->red);
2183 *q++=ScaleQuantumToLong(p->green);
2184 *q++=ScaleQuantumToLong(p->blue);
2190 p=GetAuthenticPixelQueue(image);
2191 if (p == (const PixelPacket *) NULL)
2193 indexes=GetAuthenticIndexQueue(image);
2194 for (x=0; x < (long) GetImageExtent(image); x++)
2196 for (i=0; i < (long) length; i++)
2199 switch (quantum_map[i])
2204 *q=ScaleQuantumToLong(p->red);
2208 case MagentaQuantum:
2210 *q=ScaleQuantumToLong(p->green);
2216 *q=ScaleQuantumToLong(p->blue);
2221 *q=ScaleQuantumToLong((Quantum) (QuantumRange-p->opacity));
2224 case OpacityQuantum:
2226 *q=ScaleQuantumToLong(p->opacity);
2231 if (image->colorspace == CMYKColorspace)
2232 *q=ScaleQuantumToLong(indexes[x]);
2237 *q=ScaleQuantumToLong(PixelIntensityToQuantum(p));
2254 q=(Quantum *) stream_info->pixels;
2255 if (LocaleCompare(stream_info->map,"BGR") == 0)
2257 p=GetAuthenticPixelQueue(image);
2258 if (p == (const PixelPacket *) NULL)
2260 for (x=0; x < (long) GetImageExtent(image); x++)
2269 if (LocaleCompare(stream_info->map,"BGRA") == 0)
2271 p=GetAuthenticPixelQueue(image);
2272 if (p == (const PixelPacket *) NULL)
2274 for (x=0; x < (long) GetImageExtent(image); x++)
2279 *q++=(Quantum) (QuantumRange-p->opacity);
2284 if (LocaleCompare(stream_info->map,"BGRP") == 0)
2286 p=GetAuthenticPixelQueue(image);
2287 if (p == (const PixelPacket *) NULL)
2289 for (x=0; x < (long) GetImageExtent(image); x++)
2299 if (LocaleCompare(stream_info->map,"I") == 0)
2301 p=GetAuthenticPixelQueue(image);
2302 if (p == (const PixelPacket *) NULL)
2304 for (x=0; x < (long) GetImageExtent(image); x++)
2306 *q++=PixelIntensityToQuantum(p);
2311 if (LocaleCompare(stream_info->map,"RGB") == 0)
2313 p=GetAuthenticPixelQueue(image);
2314 if (p == (const PixelPacket *) NULL)
2316 for (x=0; x < (long) GetImageExtent(image); x++)
2325 if (LocaleCompare(stream_info->map,"RGBA") == 0)
2327 p=GetAuthenticPixelQueue(image);
2328 if (p == (const PixelPacket *) NULL)
2330 for (x=0; x < (long) GetImageExtent(image); x++)
2335 *q++=(Quantum) (QuantumRange-p->opacity);
2340 if (LocaleCompare(stream_info->map,"RGBP") == 0)
2342 p=GetAuthenticPixelQueue(image);
2343 if (p == (const PixelPacket *) NULL)
2345 for (x=0; x < (long) GetImageExtent(image); x++)
2355 p=GetAuthenticPixelQueue(image);
2356 if (p == (const PixelPacket *) NULL)
2358 indexes=GetAuthenticIndexQueue(image);
2359 for (x=0; x < (long) GetImageExtent(image); x++)
2361 for (i=0; i < (long) length; i++)
2364 switch (quantum_map[i])
2373 case MagentaQuantum:
2386 *q=(Quantum) (QuantumRange-p->opacity);
2389 case OpacityQuantum:
2396 if (image->colorspace == CMYKColorspace)
2402 *q=(PixelIntensityToQuantum(p));
2416 register unsigned short
2419 q=(unsigned short *) stream_info->pixels;
2420 if (LocaleCompare(stream_info->map,"BGR") == 0)
2422 p=GetAuthenticPixelQueue(image);
2423 if (p == (const PixelPacket *) NULL)
2425 for (x=0; x < (long) GetImageExtent(image); x++)
2427 *q++=ScaleQuantumToShort(p->blue);
2428 *q++=ScaleQuantumToShort(p->green);
2429 *q++=ScaleQuantumToShort(p->red);
2434 if (LocaleCompare(stream_info->map,"BGRA") == 0)
2436 p=GetAuthenticPixelQueue(image);
2437 if (p == (const PixelPacket *) NULL)
2439 for (x=0; x < (long) GetImageExtent(image); x++)
2441 *q++=ScaleQuantumToShort(p->blue);
2442 *q++=ScaleQuantumToShort(p->green);
2443 *q++=ScaleQuantumToShort(p->red);
2444 *q++=ScaleQuantumToShort((Quantum) (QuantumRange-p->opacity));
2449 if (LocaleCompare(stream_info->map,"BGRP") == 0)
2451 p=GetAuthenticPixelQueue(image);
2452 if (p == (const PixelPacket *) NULL)
2454 for (x=0; x < (long) GetImageExtent(image); x++)
2456 *q++=ScaleQuantumToShort(p->blue);
2457 *q++=ScaleQuantumToShort(p->green);
2458 *q++=ScaleQuantumToShort(p->red);
2464 if (LocaleCompare(stream_info->map,"I") == 0)
2466 p=GetAuthenticPixelQueue(image);
2467 if (p == (const PixelPacket *) NULL)
2469 for (x=0; x < (long) GetImageExtent(image); x++)
2471 *q++=ScaleQuantumToShort(PixelIntensityToQuantum(p));
2476 if (LocaleCompare(stream_info->map,"RGB") == 0)
2478 p=GetAuthenticPixelQueue(image);
2479 if (p == (const PixelPacket *) NULL)
2481 for (x=0; x < (long) GetImageExtent(image); x++)
2483 *q++=ScaleQuantumToShort(p->red);
2484 *q++=ScaleQuantumToShort(p->green);
2485 *q++=ScaleQuantumToShort(p->blue);
2490 if (LocaleCompare(stream_info->map,"RGBA") == 0)
2492 p=GetAuthenticPixelQueue(image);
2493 if (p == (const PixelPacket *) NULL)
2495 for (x=0; x < (long) GetImageExtent(image); x++)
2497 *q++=ScaleQuantumToShort(p->red);
2498 *q++=ScaleQuantumToShort(p->green);
2499 *q++=ScaleQuantumToShort(p->blue);
2500 *q++=ScaleQuantumToShort((Quantum) (QuantumRange-p->opacity));
2505 if (LocaleCompare(stream_info->map,"RGBP") == 0)
2507 p=GetAuthenticPixelQueue(image);
2508 if (p == (const PixelPacket *) NULL)
2510 for (x=0; x < (long) GetImageExtent(image); x++)
2512 *q++=ScaleQuantumToShort(p->red);
2513 *q++=ScaleQuantumToShort(p->green);
2514 *q++=ScaleQuantumToShort(p->blue);
2520 p=GetAuthenticPixelQueue(image);
2521 if (p == (const PixelPacket *) NULL)
2523 indexes=GetAuthenticIndexQueue(image);
2524 for (x=0; x < (long) GetImageExtent(image); x++)
2526 for (i=0; i < (long) length; i++)
2529 switch (quantum_map[i])
2534 *q=ScaleQuantumToShort(p->red);
2538 case MagentaQuantum:
2540 *q=ScaleQuantumToShort(p->green);
2546 *q=ScaleQuantumToShort(p->blue);
2551 *q=ScaleQuantumToShort((Quantum) (QuantumRange-p->opacity));
2554 case OpacityQuantum:
2556 *q=ScaleQuantumToShort(p->opacity);
2561 if (image->colorspace == CMYKColorspace)
2562 *q=ScaleQuantumToShort(indexes[x]);
2567 *q=ScaleQuantumToShort(PixelIntensityToQuantum(p));
2581 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
2582 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
2583 "UnrecognizedPixelMap","`%s'",stream_info->map);
2587 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
2592 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2596 + S y n c A u t h e n t i c P i x e l s S t r e a m %
2600 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2602 % SyncAuthenticPixelsStream() calls the user supplied callback method with
2603 % the latest stream of pixels.
2605 % The format of the SyncAuthenticPixelsStream method is:
2607 % MagickBooleanType SyncAuthenticPixelsStream(Image *image,
2608 % ExceptionInfo *exception)
2610 % A description of each parameter follows:
2612 % o image: the image.
2614 % o exception: return any errors or warnings in this structure.
2617 static MagickBooleanType SyncAuthenticPixelsStream(Image *image,
2618 ExceptionInfo *exception)
2629 assert(image != (Image *) NULL);
2630 assert(image->signature == MagickSignature);
2631 if (image->debug != MagickFalse)
2632 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2633 cache_info=(CacheInfo *) image->cache;
2634 assert(cache_info->signature == MagickSignature);
2635 stream_handler=GetBlobStreamHandler(image);
2636 if (stream_handler == (StreamHandler) NULL)
2638 (void) ThrowMagickException(exception,GetMagickModule(),StreamError,
2639 "NoStreamHandlerIsDefined","`%s'",image->filename);
2640 return(MagickFalse);
2642 length=stream_handler(image,cache_info->pixels,(size_t) cache_info->columns);
2643 return(length == cache_info->columns ? MagickTrue : MagickFalse);
2647 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2651 % W r i t e S t r e a m %
2655 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2657 % WriteStream() makes the image pixels available to a user supplied callback
2658 % method immediately upon writing pixel data with the WriteImage() method.
2660 % The format of the WriteStream() method is:
2662 % MagickBooleanType WriteStream(const ImageInfo *image_info,Image *,
2663 % StreamHandler stream)
2665 % A description of each parameter follows:
2667 % o image_info: the image info.
2669 % o stream: A callback method.
2672 MagickExport MagickBooleanType WriteStream(const ImageInfo *image_info,
2673 Image *image,StreamHandler stream)
2681 assert(image_info != (ImageInfo *) NULL);
2682 assert(image_info->signature == MagickSignature);
2683 if (image_info->debug != MagickFalse)
2684 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
2685 image_info->filename);
2686 assert(image != (Image *) NULL);
2687 assert(image->signature == MagickSignature);
2688 write_info=CloneImageInfo(image_info);
2689 write_info->stream=stream;
2690 status=WriteImage(write_info,image);
2691 write_info=DestroyImageInfo(write_info);