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-2011 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/pixel.h"
56 #include "magick/quantum.h"
57 #include "magick/quantum-private.h"
58 #include "magick/semaphore.h"
59 #include "magick/stream.h"
60 #include "magick/stream-private.h"
61 #include "magick/string_.h"
64 Typedef declaractions.
106 Declare pixel cache interfaces.
108 #if defined(__cplusplus) || defined(c_plusplus)
112 static const PixelPacket
113 *GetVirtualPixelStream(const Image *,const VirtualPixelMethod,const ssize_t,
114 const ssize_t,const size_t,const size_t,ExceptionInfo *);
116 static MagickBooleanType
117 StreamImagePixels(const StreamInfo *,const Image *,ExceptionInfo *),
118 SyncAuthenticPixelsStream(Image *,ExceptionInfo *);
121 *QueueAuthenticPixelsStream(Image *,const ssize_t,const ssize_t,const size_t,
122 const size_t,ExceptionInfo *);
124 #if defined(__cplusplus) || defined(c_plusplus)
129 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
133 + A c q u i r e S t r e a m I n f o %
137 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
139 % AcquireStreamInfo() allocates the StreamInfo structure.
141 % The format of the AcquireStreamInfo method is:
143 % StreamInfo *AcquireStreamInfo(const ImageInfo *image_info)
145 % A description of each parameter follows:
147 % o image_info: the image info.
150 MagickExport StreamInfo *AcquireStreamInfo(const ImageInfo *image_info)
155 stream_info=(StreamInfo *) AcquireMagickMemory(sizeof(*stream_info));
156 if (stream_info == (StreamInfo *) NULL)
157 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
158 (void) ResetMagickMemory(stream_info,0,sizeof(*stream_info));
159 stream_info->pixels=(unsigned char *) AcquireMagickMemory(
160 sizeof(*stream_info->pixels));
161 if (stream_info->pixels == (unsigned char *) NULL)
162 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
163 stream_info->map=ConstantString("RGB");
164 stream_info->storage_type=CharPixel;
165 stream_info->stream=AcquireImage(image_info);
166 stream_info->signature=MagickSignature;
171 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
175 + D e s t r o y P i x e l S t r e a m %
179 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
181 % DestroyPixelStream() deallocates memory associated with the pixel stream.
183 % The format of the DestroyPixelStream() method is:
185 % void DestroyPixelStream(Image *image)
187 % A description of each parameter follows:
189 % o image: the image.
193 static inline void RelinquishStreamPixels(CacheInfo *cache_info)
195 assert(cache_info != (CacheInfo *) NULL);
196 if (cache_info->mapped == MagickFalse)
197 (void) RelinquishMagickMemory(cache_info->pixels);
199 (void) UnmapBlob(cache_info->pixels,(size_t) cache_info->length);
200 cache_info->pixels=(PixelPacket *) NULL;
201 cache_info->indexes=(IndexPacket *) NULL;
202 cache_info->length=0;
203 cache_info->mapped=MagickFalse;
206 static void DestroyPixelStream(Image *image)
214 assert(image != (Image *) NULL);
215 assert(image->signature == MagickSignature);
216 if (image->debug != MagickFalse)
217 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
218 cache_info=(CacheInfo *) image->cache;
219 assert(cache_info->signature == MagickSignature);
221 LockSemaphoreInfo(cache_info->semaphore);
222 cache_info->reference_count--;
223 if (cache_info->reference_count == 0)
225 UnlockSemaphoreInfo(cache_info->semaphore);
226 if (destroy == MagickFalse)
228 RelinquishStreamPixels(cache_info);
229 if (cache_info->nexus_info != (NexusInfo **) NULL)
230 cache_info->nexus_info=DestroyPixelCacheNexus(cache_info->nexus_info,
231 cache_info->number_threads);
232 if (cache_info->disk_semaphore != (SemaphoreInfo *) NULL)
233 DestroySemaphoreInfo(&cache_info->disk_semaphore);
234 if (cache_info->semaphore != (SemaphoreInfo *) NULL)
235 DestroySemaphoreInfo(&cache_info->semaphore);
236 cache_info=(CacheInfo *) RelinquishMagickMemory(cache_info);
240 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
244 + D e s t r o y S t r e a m I n f o %
248 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
250 % DestroyStreamInfo() destroys memory associated with the StreamInfo
253 % The format of the DestroyStreamInfo method is:
255 % StreamInfo *DestroyStreamInfo(StreamInfo *stream_info)
257 % A description of each parameter follows:
259 % o stream_info: the stream info.
262 MagickExport StreamInfo *DestroyStreamInfo(StreamInfo *stream_info)
264 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
265 assert(stream_info != (StreamInfo *) NULL);
266 assert(stream_info->signature == MagickSignature);
267 if (stream_info->map != (char *) NULL)
268 stream_info->map=DestroyString(stream_info->map);
269 if (stream_info->pixels != (unsigned char *) NULL)
270 stream_info->pixels=(unsigned char *) RelinquishMagickMemory(
271 stream_info->pixels);
272 if (stream_info->stream != (Image *) NULL)
274 (void) CloseBlob(stream_info->stream);
275 stream_info->stream=DestroyImage(stream_info->stream);
277 if (stream_info->quantum_info != (QuantumInfo *) NULL)
278 stream_info->quantum_info=DestroyQuantumInfo(stream_info->quantum_info);
279 stream_info->signature=(~MagickSignature);
280 stream_info=(StreamInfo *) RelinquishMagickMemory(stream_info);
285 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
289 + 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 %
293 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
295 % GetAuthenticIndexesFromStream() returns the indexes associated with the
296 % last call to QueueAuthenticPixelsStream() or GetAuthenticPixelsStream().
298 % The format of the GetAuthenticIndexesFromStream() method is:
300 % IndexPacket *GetAuthenticIndexesFromStream(const Image *image)
302 % A description of each parameter follows:
304 % o image: the image.
307 static IndexPacket *GetAuthenticIndexesFromStream(const Image *image)
312 assert(image != (Image *) NULL);
313 assert(image->signature == MagickSignature);
314 if (image->debug != MagickFalse)
315 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
316 cache_info=(CacheInfo *) image->cache;
317 assert(cache_info->signature == MagickSignature);
318 return(cache_info->indexes);
322 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
326 + G e t A u t h e n t i c P i x e l S t r e a m %
330 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
332 % GetAuthenticPixelsStream() gets pixels from the in-memory or disk pixel
333 % cache as defined by the geometry parameters. A pointer to the pixels is
334 % returned if the pixels are transferred, otherwise a NULL is returned. For
335 % streams this method is a no-op.
337 % The format of the GetAuthenticPixelsStream() method is:
339 % PixelPacket *GetAuthenticPixelsStream(Image *image,const ssize_t x,
340 % const ssize_t y,const size_t columns,const size_t rows,
341 % ExceptionInfo *exception)
343 % A description of each parameter follows:
345 % o image: the image.
347 % o x,y,columns,rows: These values define the perimeter of a region of
350 % o exception: return any errors or warnings in this structure.
353 static PixelPacket *GetAuthenticPixelsStream(Image *image,const ssize_t x,
354 const ssize_t y,const size_t columns,const size_t rows,
355 ExceptionInfo *exception)
360 assert(image != (Image *) NULL);
361 assert(image->signature == MagickSignature);
362 if (image->debug != MagickFalse)
363 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
364 pixels=QueueAuthenticPixelsStream(image,x,y,columns,rows,exception);
369 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
373 + 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 %
377 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
379 % GetAuthenticPixelsFromStream() returns the pixels associated with the last
380 % call to QueueAuthenticPixelsStream() or GetAuthenticPixelsStream().
382 % The format of the GetAuthenticPixelsFromStream() method is:
384 % PixelPacket *GetAuthenticPixelsFromStream(const Image image)
386 % A description of each parameter follows:
388 % o image: the image.
391 static PixelPacket *GetAuthenticPixelsFromStream(const Image *image)
396 assert(image != (Image *) NULL);
397 assert(image->signature == MagickSignature);
398 if (image->debug != MagickFalse)
399 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
400 cache_info=(CacheInfo *) image->cache;
401 assert(cache_info->signature == MagickSignature);
402 return(cache_info->pixels);
406 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
410 + 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 %
414 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
416 % GetOneAuthenticPixelFromStream() returns a single pixel at the specified
417 % (x,y) location. The image background color is returned if an error occurs.
419 % The format of the GetOneAuthenticPixelFromStream() method is:
421 % MagickBooleanType GetOneAuthenticPixelFromStream(const Image image,
422 % const ssize_t x,const ssize_t y,PixelPacket *pixel,
423 % ExceptionInfo *exception)
425 % A description of each parameter follows:
427 % o image: the image.
429 % o pixel: return a pixel at the specified (x,y) location.
431 % o x,y: These values define the location of the pixel to return.
433 % o exception: return any errors or warnings in this structure.
436 static MagickBooleanType GetOneAuthenticPixelFromStream(Image *image,
437 const ssize_t x,const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
442 assert(image != (Image *) NULL);
443 assert(image->signature == MagickSignature);
444 *pixel=image->background_color;
445 pixels=GetAuthenticPixelsStream(image,x,y,1,1,exception);
446 if (pixels != (PixelPacket *) NULL)
453 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
457 + 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 %
461 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
463 % GetOneVirtualPixelFromStream() returns a single pixel at the specified
464 % (x.y) location. The image background color is returned if an error occurs.
466 % The format of the GetOneVirtualPixelFromStream() method is:
468 % MagickBooleanType GetOneVirtualPixelFromStream(const Image image,
469 % const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
470 % const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
472 % A description of each parameter follows:
474 % o image: the image.
476 % o virtual_pixel_method: the virtual pixel method.
478 % o x,y: These values define the location of the pixel to return.
480 % o pixel: return a pixel at the specified (x,y) location.
482 % o exception: return any errors or warnings in this structure.
485 static MagickBooleanType GetOneVirtualPixelFromStream(const Image *image,
486 const VirtualPixelMethod virtual_pixel_method,const ssize_t x,const ssize_t y,
487 PixelPacket *pixel,ExceptionInfo *exception)
492 assert(image != (Image *) NULL);
493 assert(image->signature == MagickSignature);
494 *pixel=image->background_color;
495 pixels=GetVirtualPixelStream(image,virtual_pixel_method,x,y,1,1,exception);
496 if (pixels != (const PixelPacket *) NULL)
503 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
507 + G e t S t r e a m I n f o C l i e n t D a t a %
511 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
513 % GetStreamInfoClientData() gets the stream info client data.
515 % The format of the SetStreamInfoClientData method is:
517 % const void *GetStreamInfoClientData(StreamInfo *stream_info)
519 % A description of each parameter follows:
521 % o stream_info: the stream info.
524 MagickExport const void *GetStreamInfoClientData(StreamInfo *stream_info)
526 assert(stream_info != (StreamInfo *) NULL);
527 assert(stream_info->signature == MagickSignature);
528 return(stream_info->client_data);
532 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
536 + 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 %
540 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
542 % GetVirtualPixelsStream() returns the pixels associated with the last
543 % call to QueueAuthenticPixelsStream() or GetVirtualPixelStream().
545 % The format of the GetVirtualPixelsStream() method is:
547 % const IndexPacket *GetVirtualPixelsStream(const Image *image)
549 % A description of each parameter follows:
551 % o pixels: return the pixels associated with the last call to
552 % QueueAuthenticPixelsStream() or GetVirtualPixelStream().
554 % o image: the image.
557 static const PixelPacket *GetVirtualPixelsStream(const Image *image)
562 assert(image != (Image *) NULL);
563 assert(image->signature == MagickSignature);
564 if (image->debug != MagickFalse)
565 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
566 cache_info=(CacheInfo *) image->cache;
567 assert(cache_info->signature == MagickSignature);
568 return(cache_info->pixels);
572 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
576 + 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 %
580 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
582 % GetVirtualIndexesFromStream() returns the indexes associated with the last
583 % call to QueueAuthenticPixelsStream() or GetVirtualPixelStream().
585 % The format of the GetVirtualIndexesFromStream() method is:
587 % const IndexPacket *GetVirtualIndexesFromStream(const Image *image)
589 % A description of each parameter follows:
591 % o image: the image.
594 static const IndexPacket *GetVirtualIndexesFromStream(const Image *image)
599 assert(image != (Image *) NULL);
600 assert(image->signature == MagickSignature);
601 if (image->debug != MagickFalse)
602 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
603 cache_info=(CacheInfo *) image->cache;
604 assert(cache_info->signature == MagickSignature);
605 return(cache_info->indexes);
609 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
613 + G e t V i r t u a l P i x e l S t r e a m %
617 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
619 % GetVirtualPixelStream() gets pixels from the in-memory or disk pixel cache as
620 % defined by the geometry parameters. A pointer to the pixels is returned if
621 % the pixels are transferred, otherwise a NULL is returned. For streams this
624 % The format of the GetVirtualPixelStream() method is:
626 % const PixelPacket *GetVirtualPixelStream(const Image *image,
627 % const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
628 % const ssize_t y,const size_t columns,const size_t rows,
629 % ExceptionInfo *exception)
631 % A description of each parameter follows:
633 % o image: the image.
635 % o virtual_pixel_method: the virtual pixel method.
637 % o x,y,columns,rows: These values define the perimeter of a region of
640 % o exception: return any errors or warnings in this structure.
644 static inline MagickBooleanType AcquireStreamPixels(CacheInfo *cache_info,
645 ExceptionInfo *exception)
647 if (cache_info->length != (MagickSizeType) ((size_t) cache_info->length))
649 cache_info->mapped=MagickFalse;
650 cache_info->pixels=(PixelPacket *) AcquireMagickMemory((size_t)
652 if (cache_info->pixels == (PixelPacket *) NULL)
654 cache_info->mapped=MagickTrue;
655 cache_info->pixels=(PixelPacket *) MapBlob(-1,IOMode,0,(size_t)
658 if (cache_info->pixels == (PixelPacket *) NULL)
660 (void) ThrowMagickException(exception,GetMagickModule(),
661 ResourceLimitError,"MemoryAllocationFailed","`%s'",
662 cache_info->filename);
668 static const PixelPacket *GetVirtualPixelStream(const Image *image,
669 const VirtualPixelMethod magick_unused(virtual_pixel_method),const ssize_t x,
670 const ssize_t y,const size_t columns,const size_t rows,
671 ExceptionInfo *exception)
686 Validate pixel cache geometry.
688 assert(image != (const Image *) NULL);
689 assert(image->signature == MagickSignature);
690 if (image->debug != MagickFalse)
691 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
692 if ((x < 0) || (y < 0) ||
693 ((x+(ssize_t) columns) > (ssize_t) image->columns) ||
694 ((y+(ssize_t) rows) > (ssize_t) image->rows) ||
695 (columns == 0) || (rows == 0))
697 (void) ThrowMagickException(exception,GetMagickModule(),StreamError,
698 "ImageDoesNotContainTheStreamGeometry","`%s'",image->filename);
699 return((PixelPacket *) NULL);
701 cache_info=(CacheInfo *) image->cache;
702 assert(cache_info->signature == MagickSignature);
704 Pixels are stored in a temporary buffer until they are synced to the cache.
706 cache_info->active_index_channel=((image->storage_class == PseudoClass) ||
707 (image->colorspace == CMYKColorspace)) ? MagickTrue : MagickFalse;
708 number_pixels=(MagickSizeType) columns*rows;
709 length=(size_t) number_pixels*sizeof(PixelPacket);
710 if (cache_info->active_index_channel != MagickFalse)
711 length+=number_pixels*sizeof(IndexPacket);
712 if (cache_info->pixels == (PixelPacket *) NULL)
714 cache_info->length=length;
715 status=AcquireStreamPixels(cache_info,exception);
716 if (status == MagickFalse)
718 cache_info->length=0;
719 return((PixelPacket *) NULL);
723 if (cache_info->length != length)
725 RelinquishStreamPixels(cache_info);
726 cache_info->length=length;
727 status=AcquireStreamPixels(cache_info,exception);
728 if (status == MagickFalse)
730 cache_info->length=0;
731 return((PixelPacket *) NULL);
734 cache_info->indexes=(IndexPacket *) NULL;
735 if (cache_info->active_index_channel != MagickFalse)
736 cache_info->indexes=(IndexPacket *) (cache_info->pixels+number_pixels);
737 return(cache_info->pixels);
741 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
745 + O p e n S t r e a m %
749 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
751 % OpenStream() opens a stream for writing by the StreamImage() method.
753 % The format of the OpenStream method is:
755 % MagickBooleanType OpenStream(const ImageInfo *image_info,
756 % StreamInfo *stream_info,const char *filename,ExceptionInfo *exception)
758 % A description of each parameter follows:
760 % o image_info: the image info.
762 % o stream_info: the stream info.
764 % o filename: the stream filename.
766 % o exception: return any errors or warnings in this structure.
769 MagickExport MagickBooleanType OpenStream(const ImageInfo *image_info,
770 StreamInfo *stream_info,const char *filename,ExceptionInfo *exception)
775 (void) CopyMagickString(stream_info->stream->filename,filename,MaxTextExtent);
776 status=OpenBlob(image_info,stream_info->stream,WriteBinaryBlobMode,exception);
781 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
785 + 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 %
789 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
791 % QueueAuthenticPixelsStream() allocates an area to store image pixels as
792 % defined by the region rectangle and returns a pointer to the area. This
793 % area is subsequently transferred from the pixel cache with method
794 % SyncAuthenticPixelsStream(). A pointer to the pixels is returned if the
795 % pixels are transferred, otherwise a NULL is returned.
797 % The format of the QueueAuthenticPixelsStream() method is:
799 % PixelPacket *QueueAuthenticPixelsStream(Image *image,const ssize_t x,
800 % const ssize_t y,const size_t columns,const size_t rows,
801 % ExceptionInfo *exception)
803 % A description of each parameter follows:
805 % o image: the image.
807 % o x,y,columns,rows: These values define the perimeter of a region of
811 static PixelPacket *QueueAuthenticPixelsStream(Image *image,const ssize_t x,
812 const ssize_t y,const size_t columns,const size_t rows,
813 ExceptionInfo *exception)
828 Validate pixel cache geometry.
830 assert(image != (Image *) NULL);
831 if ((x < 0) || (y < 0) ||
832 ((x+(ssize_t) columns) > (ssize_t) image->columns) ||
833 ((y+(ssize_t) rows) > (ssize_t) image->rows) ||
834 (columns == 0) || (rows == 0))
836 (void) ThrowMagickException(exception,GetMagickModule(),StreamError,
837 "ImageDoesNotContainTheStreamGeometry","`%s'",image->filename);
838 return((PixelPacket *) NULL);
840 stream_handler=GetBlobStreamHandler(image);
841 if (stream_handler == (StreamHandler) NULL)
843 (void) ThrowMagickException(exception,GetMagickModule(),StreamError,
844 "NoStreamHandlerIsDefined","`%s'",image->filename);
845 return((PixelPacket *) NULL);
847 cache_info=(CacheInfo *) image->cache;
848 assert(cache_info->signature == MagickSignature);
849 if ((image->storage_class != GetPixelCacheStorageClass(image->cache)) ||
850 (image->colorspace != GetPixelCacheColorspace(image->cache)))
852 if (GetPixelCacheStorageClass(image->cache) == UndefinedClass)
853 (void) stream_handler(image,(const void *) NULL,(size_t)
854 cache_info->columns);
855 cache_info->storage_class=image->storage_class;
856 cache_info->colorspace=image->colorspace;
857 cache_info->columns=image->columns;
858 cache_info->rows=image->rows;
859 image->cache=cache_info;
862 Pixels are stored in a temporary buffer until they are synced to the cache.
864 cache_info->active_index_channel=((image->storage_class == PseudoClass) ||
865 (image->colorspace == CMYKColorspace)) ? MagickTrue : MagickFalse;
866 cache_info->columns=columns;
867 cache_info->rows=rows;
868 number_pixels=(MagickSizeType) columns*rows;
869 length=(size_t) number_pixels*sizeof(PixelPacket);
870 if (cache_info->active_index_channel != MagickFalse)
871 length+=number_pixels*sizeof(IndexPacket);
872 if (cache_info->pixels == (PixelPacket *) NULL)
874 cache_info->pixels=(PixelPacket *) AcquireMagickMemory(length);
875 cache_info->length=(MagickSizeType) length;
878 if (cache_info->length < (MagickSizeType) length)
880 cache_info->pixels=(PixelPacket *) ResizeMagickMemory(
881 cache_info->pixels,length);
882 cache_info->length=(MagickSizeType) length;
884 if (cache_info->pixels == (void *) NULL)
885 return((PixelPacket *) NULL);
886 cache_info->indexes=(IndexPacket *) NULL;
887 if (cache_info->active_index_channel != MagickFalse)
888 cache_info->indexes=(IndexPacket *) (cache_info->pixels+number_pixels);
889 return(cache_info->pixels);
893 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
897 % R e a d S t r e a m %
901 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
903 % ReadStream() makes the image pixels available to a user supplied callback
904 % method immediately upon reading a scanline with the ReadImage() method.
906 % The format of the ReadStream() method is:
908 % Image *ReadStream(const ImageInfo *image_info,StreamHandler stream,
909 % ExceptionInfo *exception)
911 % A description of each parameter follows:
913 % o image_info: the image info.
915 % o stream: a callback method.
917 % o exception: return any errors or warnings in this structure.
920 MagickExport Image *ReadStream(const ImageInfo *image_info,StreamHandler stream,
921 ExceptionInfo *exception)
935 assert(image_info != (ImageInfo *) NULL);
936 assert(image_info->signature == MagickSignature);
937 if (image_info->debug != MagickFalse)
938 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
939 image_info->filename);
940 assert(exception != (ExceptionInfo *) NULL);
941 assert(exception->signature == MagickSignature);
942 read_info=CloneImageInfo(image_info);
943 read_info->cache=AcquirePixelCache(0);
944 GetPixelCacheMethods(&cache_methods);
945 cache_methods.get_virtual_pixel_handler=GetVirtualPixelStream;
946 cache_methods.get_virtual_indexes_from_handler=GetVirtualIndexesFromStream;
947 cache_methods.get_virtual_pixels_handler=GetVirtualPixelsStream;
948 cache_methods.get_authentic_pixels_handler=GetAuthenticPixelsStream;
949 cache_methods.queue_authentic_pixels_handler=QueueAuthenticPixelsStream;
950 cache_methods.sync_authentic_pixels_handler=SyncAuthenticPixelsStream;
951 cache_methods.get_authentic_pixels_from_handler=GetAuthenticPixelsFromStream;
952 cache_methods.get_authentic_indexes_from_handler=
953 GetAuthenticIndexesFromStream;
954 cache_methods.get_one_virtual_pixel_from_handler=GetOneVirtualPixelFromStream;
955 cache_methods.get_one_authentic_pixel_from_handler=
956 GetOneAuthenticPixelFromStream;
957 cache_methods.destroy_pixel_handler=DestroyPixelStream;
958 SetPixelCacheMethods(read_info->cache,&cache_methods);
959 read_info->stream=stream;
960 image=ReadImage(read_info,exception);
961 read_info=DestroyImageInfo(read_info);
966 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
970 + S e t S t r e a m I n f o C l i e n t D a t a %
974 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
976 % SetStreamInfoClientData() sets the stream info client data.
978 % The format of the SetStreamInfoClientData method is:
980 % void SetStreamInfoClientData(StreamInfo *stream_info,
981 % const void *client_data)
983 % A description of each parameter follows:
985 % o stream_info: the stream info.
987 % o client_data: the client data.
990 MagickExport void SetStreamInfoClientData(StreamInfo *stream_info,
991 const void *client_data)
993 assert(stream_info != (StreamInfo *) NULL);
994 assert(stream_info->signature == MagickSignature);
995 stream_info->client_data=client_data;
999 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1003 + S e t S t r e a m I n f o M a p %
1007 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1009 % SetStreamInfoMap() sets the stream info map member.
1011 % The format of the SetStreamInfoMap method is:
1013 % void SetStreamInfoMap(StreamInfo *stream_info,const char *map)
1015 % A description of each parameter follows:
1017 % o stream_info: the stream info.
1022 MagickExport void SetStreamInfoMap(StreamInfo *stream_info,const char *map)
1024 assert(stream_info != (StreamInfo *) NULL);
1025 assert(stream_info->signature == MagickSignature);
1026 (void) CloneString(&stream_info->map,map);
1030 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1034 + S e t S t r e a m I n f o S t o r a g e T y p e %
1038 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1040 % SetStreamInfoStorageType() sets the stream info storage type member.
1042 % The format of the SetStreamInfoStorageType method is:
1044 % void SetStreamInfoStorageType(StreamInfo *stream_info,
1045 % const StoreageType *storage_type)
1047 % A description of each parameter follows:
1049 % o stream_info: the stream info.
1051 % o storage_type: the storage type.
1054 MagickExport void SetStreamInfoStorageType(StreamInfo *stream_info,
1055 const StorageType storage_type)
1057 assert(stream_info != (StreamInfo *) NULL);
1058 assert(stream_info->signature == MagickSignature);
1059 stream_info->storage_type=storage_type;
1063 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1067 + S t r e a m I m a g e %
1071 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1073 % StreamImage() streams pixels from an image and writes them in a user
1074 % defined format and storage type (e.g. RGBA as 8-bit unsigned char).
1076 % The format of the StreamImage() method is:
1078 % Image *StreamImage(const ImageInfo *image_info,
1079 % StreamInfo *stream_info,ExceptionInfo *exception)
1081 % A description of each parameter follows:
1083 % o image_info: the image info.
1085 % o stream_info: the stream info.
1087 % o exception: return any errors or warnings in this structure.
1091 #if defined(__cplusplus) || defined(c_plusplus)
1095 static size_t WriteStreamImage(const Image *image,const void *pixels,
1096 const size_t columns)
1115 stream_info=(StreamInfo *) image->client_data;
1116 switch (stream_info->storage_type)
1118 default: packet_size=sizeof(char); break;
1119 case CharPixel: packet_size=sizeof(char); break;
1120 case DoublePixel: packet_size=sizeof(double); break;
1121 case FloatPixel: packet_size=sizeof(float); break;
1122 case IntegerPixel: packet_size=sizeof(int); break;
1123 case LongPixel: packet_size=sizeof(ssize_t); break;
1124 case QuantumPixel: packet_size=sizeof(Quantum); break;
1125 case ShortPixel: packet_size=sizeof(unsigned short); break;
1127 cache_info=(CacheInfo *) image->cache;
1128 assert(cache_info->signature == MagickSignature);
1129 packet_size*=strlen(stream_info->map);
1130 length=packet_size*cache_info->columns*cache_info->rows;
1131 if (image != stream_info->image)
1137 Prepare stream for writing.
1139 stream_info->pixels=(unsigned char *) ResizeQuantumMemory(
1140 stream_info->pixels,length,sizeof(*stream_info->pixels));
1141 if (stream_info->pixels == (unsigned char *) NULL)
1143 stream_info->image=image;
1144 write_info=CloneImageInfo(stream_info->image_info);
1145 (void) SetImageInfo(write_info,1,stream_info->exception);
1146 if (write_info->extract != (char *) NULL)
1147 (void) ParseAbsoluteGeometry(write_info->extract,
1148 &stream_info->extract_info);
1150 write_info=DestroyImageInfo(write_info);
1152 extract_info=stream_info->extract_info;
1153 if ((extract_info.width == 0) || (extract_info.height == 0))
1156 Write all pixels to stream.
1158 (void) StreamImagePixels(stream_info,image,stream_info->exception);
1159 count=WriteBlob(stream_info->stream,length,stream_info->pixels);
1161 return(count == 0 ? 0 : columns);
1163 if ((stream_info->y < extract_info.y) ||
1164 (stream_info->y >= (ssize_t) (extract_info.y+extract_info.height)))
1170 Write a portion of the pixel row to the stream.
1172 (void) StreamImagePixels(stream_info,image,stream_info->exception);
1173 length=packet_size*extract_info.width;
1174 count=WriteBlob(stream_info->stream,length,stream_info->pixels+packet_size*
1177 return(count == 0 ? 0 : columns);
1180 #if defined(__cplusplus) || defined(c_plusplus)
1184 MagickExport Image *StreamImage(const ImageInfo *image_info,
1185 StreamInfo *stream_info,ExceptionInfo *exception)
1193 assert(image_info != (const ImageInfo *) NULL);
1194 assert(image_info->signature == MagickSignature);
1195 if (image_info->debug != MagickFalse)
1196 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
1197 image_info->filename);
1198 assert(stream_info != (StreamInfo *) NULL);
1199 assert(stream_info->signature == MagickSignature);
1200 assert(exception != (ExceptionInfo *) NULL);
1201 read_info=CloneImageInfo(image_info);
1202 stream_info->image_info=image_info;
1203 stream_info->exception=exception;
1204 read_info->client_data=(void *) stream_info;
1205 image=ReadStream(read_info,&WriteStreamImage,exception);
1206 read_info=DestroyImageInfo(read_info);
1207 stream_info->quantum_info=AcquireQuantumInfo(image_info,image);
1208 if (stream_info->quantum_info == (QuantumInfo *) NULL)
1209 image=DestroyImage(image);
1214 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1218 + S t r e a m I m a g e P i x e l s %
1222 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1224 % StreamImagePixels() extracts pixel data from an image and returns it in the
1225 % stream_info->pixels structure in the format as defined by
1226 % stream_info->quantum_info->map and stream_info->quantum_info->storage_type.
1228 % The format of the StreamImagePixels method is:
1230 % MagickBooleanType StreamImagePixels(const StreamInfo *stream_info,
1231 % const Image *image,ExceptionInfo *exception)
1233 % A description of each parameter follows:
1235 % o stream_info: the stream info.
1237 % o image: the image.
1239 % o exception: return any errors or warnings in this structure.
1242 static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info,
1243 const Image *image,ExceptionInfo *exception)
1251 register const PixelPacket
1254 register IndexPacket
1264 assert(stream_info != (StreamInfo *) NULL);
1265 assert(stream_info->signature == MagickSignature);
1266 assert(image != (Image *) NULL);
1267 assert(image->signature == MagickSignature);
1268 if (image->debug != MagickFalse)
1269 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
1270 length=strlen(stream_info->map);
1271 quantum_map=(QuantumType *) AcquireQuantumMemory(length,sizeof(*quantum_map));
1272 if (quantum_map == (QuantumType *) NULL)
1274 (void) ThrowMagickException(exception,GetMagickModule(),
1275 ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);
1276 return(MagickFalse);
1278 for (i=0; i < (ssize_t) length; i++)
1280 switch (stream_info->map[i])
1285 quantum_map[i]=AlphaQuantum;
1291 quantum_map[i]=BlueQuantum;
1297 quantum_map[i]=CyanQuantum;
1298 if (image->colorspace == CMYKColorspace)
1300 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
1301 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
1302 "ColorSeparatedImageRequired","`%s'",stream_info->map);
1303 return(MagickFalse);
1308 quantum_map[i]=GreenQuantum;
1314 quantum_map[i]=IndexQuantum;
1320 quantum_map[i]=BlackQuantum;
1321 if (image->colorspace == CMYKColorspace)
1323 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
1324 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
1325 "ColorSeparatedImageRequired","`%s'",stream_info->map);
1326 return(MagickFalse);
1331 quantum_map[i]=MagentaQuantum;
1332 if (image->colorspace == CMYKColorspace)
1334 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
1335 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
1336 "ColorSeparatedImageRequired","`%s'",stream_info->map);
1337 return(MagickFalse);
1342 quantum_map[i]=OpacityQuantum;
1348 quantum_map[i]=UndefinedQuantum;
1354 quantum_map[i]=RedQuantum;
1360 quantum_map[i]=YellowQuantum;
1361 if (image->colorspace == CMYKColorspace)
1363 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
1364 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
1365 "ColorSeparatedImageRequired","`%s'",stream_info->map);
1366 return(MagickFalse);
1370 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
1371 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
1372 "UnrecognizedPixelMap","`%s'",stream_info->map);
1373 return(MagickFalse);
1377 quantum_info=stream_info->quantum_info;
1378 switch (stream_info->storage_type)
1382 register unsigned char
1385 q=(unsigned char *) stream_info->pixels;
1386 if (LocaleCompare(stream_info->map,"BGR") == 0)
1388 p=GetAuthenticPixelQueue(image);
1389 if (p == (const PixelPacket *) NULL)
1391 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
1393 *q++=ScaleQuantumToChar(GetBluePixelComponent(p));
1394 *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
1395 *q++=ScaleQuantumToChar(GetRedPixelComponent(p));
1400 if (LocaleCompare(stream_info->map,"BGRA") == 0)
1402 p=GetAuthenticPixelQueue(image);
1403 if (p == (const PixelPacket *) NULL)
1405 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
1407 *q++=ScaleQuantumToChar(GetBluePixelComponent(p));
1408 *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
1409 *q++=ScaleQuantumToChar(GetRedPixelComponent(p));
1410 *q++=ScaleQuantumToChar((Quantum) (GetAlphaPixelComponent(p)));
1415 if (LocaleCompare(stream_info->map,"BGRP") == 0)
1417 p=GetAuthenticPixelQueue(image);
1418 if (p == (const PixelPacket *) NULL)
1420 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
1422 *q++=ScaleQuantumToChar(GetBluePixelComponent(p));
1423 *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
1424 *q++=ScaleQuantumToChar(GetRedPixelComponent(p));
1425 *q++=ScaleQuantumToChar((Quantum) 0);
1430 if (LocaleCompare(stream_info->map,"I") == 0)
1432 p=GetAuthenticPixelQueue(image);
1433 if (p == (const PixelPacket *) NULL)
1435 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
1437 *q++=ScaleQuantumToChar(PixelIntensityToQuantum(p));
1442 if (LocaleCompare(stream_info->map,"RGB") == 0)
1444 p=GetAuthenticPixelQueue(image);
1445 if (p == (const PixelPacket *) NULL)
1447 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
1449 *q++=ScaleQuantumToChar(GetRedPixelComponent(p));
1450 *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
1451 *q++=ScaleQuantumToChar(GetBluePixelComponent(p));
1456 if (LocaleCompare(stream_info->map,"RGBA") == 0)
1458 p=GetAuthenticPixelQueue(image);
1459 if (p == (const PixelPacket *) NULL)
1461 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
1463 *q++=ScaleQuantumToChar(GetRedPixelComponent(p));
1464 *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
1465 *q++=ScaleQuantumToChar(GetBluePixelComponent(p));
1466 *q++=ScaleQuantumToChar((Quantum) (GetAlphaPixelComponent(p)));
1471 if (LocaleCompare(stream_info->map,"RGBP") == 0)
1473 p=GetAuthenticPixelQueue(image);
1474 if (p == (const PixelPacket *) NULL)
1476 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
1478 *q++=ScaleQuantumToChar(GetRedPixelComponent(p));
1479 *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
1480 *q++=ScaleQuantumToChar(GetBluePixelComponent(p));
1481 *q++=ScaleQuantumToChar((Quantum) 0);
1486 p=GetAuthenticPixelQueue(image);
1487 if (p == (const PixelPacket *) NULL)
1489 indexes=GetAuthenticIndexQueue(image);
1490 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
1492 for (i=0; i < (ssize_t) length; i++)
1495 switch (quantum_map[i])
1500 *q=ScaleQuantumToChar(GetRedPixelComponent(p));
1504 case MagentaQuantum:
1506 *q=ScaleQuantumToChar(GetGreenPixelComponent(p));
1512 *q=ScaleQuantumToChar(GetBluePixelComponent(p));
1517 *q=ScaleQuantumToChar((Quantum) (GetAlphaPixelComponent(p)));
1520 case OpacityQuantum:
1522 *q=ScaleQuantumToChar(GetOpacityPixelComponent(p));
1527 if (image->colorspace == CMYKColorspace)
1528 *q=ScaleQuantumToChar(indexes[x]);
1533 *q=ScaleQuantumToChar(PixelIntensityToQuantum(p));
1550 q=(double *) stream_info->pixels;
1551 if (LocaleCompare(stream_info->map,"BGR") == 0)
1553 p=GetAuthenticPixelQueue(image);
1554 if (p == (const PixelPacket *) NULL)
1556 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
1558 *q++=(double) ((QuantumScale*GetBluePixelComponent(p))*
1559 quantum_info->scale+quantum_info->minimum);
1560 *q++=(double) ((QuantumScale*GetGreenPixelComponent(p))*
1561 quantum_info->scale+quantum_info->minimum);
1562 *q++=(double) ((QuantumScale*GetRedPixelComponent(p))*
1563 quantum_info->scale+quantum_info->minimum);
1568 if (LocaleCompare(stream_info->map,"BGRA") == 0)
1570 p=GetAuthenticPixelQueue(image);
1571 if (p == (const PixelPacket *) NULL)
1573 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
1575 *q++=(double) ((QuantumScale*GetBluePixelComponent(p))*
1576 quantum_info->scale+quantum_info->minimum);
1577 *q++=(double) ((QuantumScale*GetGreenPixelComponent(p))*
1578 quantum_info->scale+quantum_info->minimum);
1579 *q++=(double) ((QuantumScale*GetRedPixelComponent(p))*
1580 quantum_info->scale+quantum_info->minimum);
1581 *q++=(double) ((QuantumScale*GetAlphaPixelComponent(p))*
1582 quantum_info->scale+quantum_info->minimum);
1587 if (LocaleCompare(stream_info->map,"BGRP") == 0)
1589 p=GetAuthenticPixelQueue(image);
1590 if (p == (const PixelPacket *) NULL)
1592 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
1594 *q++=(double) ((QuantumScale*GetBluePixelComponent(p))*
1595 quantum_info->scale+quantum_info->minimum);
1596 *q++=(double) ((QuantumScale*GetGreenPixelComponent(p))*
1597 quantum_info->scale+quantum_info->minimum);
1598 *q++=(double) ((QuantumScale*GetRedPixelComponent(p))*
1599 quantum_info->scale+quantum_info->minimum);
1605 if (LocaleCompare(stream_info->map,"I") == 0)
1607 p=GetAuthenticPixelQueue(image);
1608 if (p == (const PixelPacket *) NULL)
1610 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
1612 *q++=(double) ((QuantumScale*PixelIntensityToQuantum(p))*
1613 quantum_info->scale+quantum_info->minimum);
1618 if (LocaleCompare(stream_info->map,"RGB") == 0)
1620 p=GetAuthenticPixelQueue(image);
1621 if (p == (const PixelPacket *) NULL)
1623 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
1625 *q++=(double) ((QuantumScale*GetRedPixelComponent(p))*
1626 quantum_info->scale+quantum_info->minimum);
1627 *q++=(double) ((QuantumScale*GetGreenPixelComponent(p))*
1628 quantum_info->scale+quantum_info->minimum);
1629 *q++=(double) ((QuantumScale*GetBluePixelComponent(p))*
1630 quantum_info->scale+quantum_info->minimum);
1635 if (LocaleCompare(stream_info->map,"RGBA") == 0)
1637 p=GetAuthenticPixelQueue(image);
1638 if (p == (const PixelPacket *) NULL)
1640 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
1642 *q++=(double) ((QuantumScale*GetRedPixelComponent(p))*
1643 quantum_info->scale+quantum_info->minimum);
1644 *q++=(double) ((QuantumScale*GetGreenPixelComponent(p))*
1645 quantum_info->scale+quantum_info->minimum);
1646 *q++=(double) ((QuantumScale*GetBluePixelComponent(p))*
1647 quantum_info->scale+quantum_info->minimum);
1648 *q++=(double) ((QuantumScale*GetAlphaPixelComponent(p))*
1649 quantum_info->scale+quantum_info->minimum);
1654 if (LocaleCompare(stream_info->map,"RGBP") == 0)
1656 p=GetAuthenticPixelQueue(image);
1657 if (p == (const PixelPacket *) NULL)
1659 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
1661 *q++=(double) ((QuantumScale*GetRedPixelComponent(p))*
1662 quantum_info->scale+quantum_info->minimum);
1663 *q++=(double) ((QuantumScale*GetGreenPixelComponent(p))*
1664 quantum_info->scale+quantum_info->minimum);
1665 *q++=(double) ((QuantumScale*GetBluePixelComponent(p))*
1666 quantum_info->scale+quantum_info->minimum);
1672 p=GetAuthenticPixelQueue(image);
1673 if (p == (const PixelPacket *) NULL)
1675 indexes=GetAuthenticIndexQueue(image);
1676 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
1678 for (i=0; i < (ssize_t) length; i++)
1681 switch (quantum_map[i])
1686 *q=(double) ((QuantumScale*GetRedPixelComponent(p))*
1687 quantum_info->scale+quantum_info->minimum);
1691 case MagentaQuantum:
1693 *q=(double) ((QuantumScale*GetGreenPixelComponent(p))*
1694 quantum_info->scale+quantum_info->minimum);
1700 *q=(double) ((QuantumScale*GetBluePixelComponent(p))*
1701 quantum_info->scale+quantum_info->minimum);
1706 *q=(double) ((QuantumScale*GetAlphaPixelComponent(p))*
1707 quantum_info->scale+quantum_info->minimum);
1710 case OpacityQuantum:
1712 *q=(double) ((QuantumScale*GetOpacityPixelComponent(p))*
1713 quantum_info->scale+quantum_info->minimum);
1718 if (image->colorspace == CMYKColorspace)
1719 *q=(double) ((QuantumScale*indexes[x])*quantum_info->scale+
1720 quantum_info->minimum);
1725 *q=(double) ((QuantumScale*PixelIntensityToQuantum(p))*
1726 quantum_info->scale+quantum_info->minimum);
1743 q=(float *) stream_info->pixels;
1744 if (LocaleCompare(stream_info->map,"BGR") == 0)
1746 p=GetAuthenticPixelQueue(image);
1747 if (p == (const PixelPacket *) NULL)
1749 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
1751 *q++=(float) ((QuantumScale*GetBluePixelComponent(p))*
1752 quantum_info->scale+quantum_info->minimum);
1753 *q++=(float) ((QuantumScale*GetGreenPixelComponent(p))*
1754 quantum_info->scale+quantum_info->minimum);
1755 *q++=(float) ((QuantumScale*GetRedPixelComponent(p))*
1756 quantum_info->scale+quantum_info->minimum);
1761 if (LocaleCompare(stream_info->map,"BGRA") == 0)
1763 p=GetAuthenticPixelQueue(image);
1764 if (p == (const PixelPacket *) NULL)
1766 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
1768 *q++=(float) ((QuantumScale*GetBluePixelComponent(p))*
1769 quantum_info->scale+quantum_info->minimum);
1770 *q++=(float) ((QuantumScale*GetGreenPixelComponent(p))*
1771 quantum_info->scale+quantum_info->minimum);
1772 *q++=(float) ((QuantumScale*GetRedPixelComponent(p))*
1773 quantum_info->scale+quantum_info->minimum);
1774 *q++=(float) ((QuantumScale*(Quantum) (GetAlphaPixelComponent(p)))*
1775 quantum_info->scale+quantum_info->minimum);
1780 if (LocaleCompare(stream_info->map,"BGRP") == 0)
1782 p=GetAuthenticPixelQueue(image);
1783 if (p == (const PixelPacket *) NULL)
1785 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
1787 *q++=(float) ((QuantumScale*GetBluePixelComponent(p))*
1788 quantum_info->scale+quantum_info->minimum);
1789 *q++=(float) ((QuantumScale*GetGreenPixelComponent(p))*
1790 quantum_info->scale+quantum_info->minimum);
1791 *q++=(float) ((QuantumScale*GetRedPixelComponent(p))*
1792 quantum_info->scale+quantum_info->minimum);
1798 if (LocaleCompare(stream_info->map,"I") == 0)
1800 p=GetAuthenticPixelQueue(image);
1801 if (p == (const PixelPacket *) NULL)
1803 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
1805 *q++=(float) ((QuantumScale*PixelIntensityToQuantum(p))*
1806 quantum_info->scale+quantum_info->minimum);
1811 if (LocaleCompare(stream_info->map,"RGB") == 0)
1813 p=GetAuthenticPixelQueue(image);
1814 if (p == (const PixelPacket *) NULL)
1816 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
1818 *q++=(float) ((QuantumScale*GetRedPixelComponent(p))*
1819 quantum_info->scale+quantum_info->minimum);
1820 *q++=(float) ((QuantumScale*GetGreenPixelComponent(p))*
1821 quantum_info->scale+quantum_info->minimum);
1822 *q++=(float) ((QuantumScale*GetBluePixelComponent(p))*
1823 quantum_info->scale+quantum_info->minimum);
1828 if (LocaleCompare(stream_info->map,"RGBA") == 0)
1830 p=GetAuthenticPixelQueue(image);
1831 if (p == (const PixelPacket *) NULL)
1833 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
1835 *q++=(float) ((QuantumScale*GetRedPixelComponent(p))*
1836 quantum_info->scale+quantum_info->minimum);
1837 *q++=(float) ((QuantumScale*GetGreenPixelComponent(p))*
1838 quantum_info->scale+quantum_info->minimum);
1839 *q++=(float) ((QuantumScale*GetBluePixelComponent(p))*
1840 quantum_info->scale+quantum_info->minimum);
1841 *q++=(float) ((QuantumScale*GetAlphaPixelComponent(p))*
1842 quantum_info->scale+quantum_info->minimum);
1847 if (LocaleCompare(stream_info->map,"RGBP") == 0)
1849 p=GetAuthenticPixelQueue(image);
1850 if (p == (const PixelPacket *) NULL)
1852 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
1854 *q++=(float) ((QuantumScale*GetRedPixelComponent(p))*
1855 quantum_info->scale+quantum_info->minimum);
1856 *q++=(float) ((QuantumScale*GetGreenPixelComponent(p))*
1857 quantum_info->scale+quantum_info->minimum);
1858 *q++=(float) ((QuantumScale*GetBluePixelComponent(p))*
1859 quantum_info->scale+quantum_info->minimum);
1865 p=GetAuthenticPixelQueue(image);
1866 if (p == (const PixelPacket *) NULL)
1868 indexes=GetAuthenticIndexQueue(image);
1869 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
1871 for (i=0; i < (ssize_t) length; i++)
1874 switch (quantum_map[i])
1879 *q=(float) ((QuantumScale*GetRedPixelComponent(p))*
1880 quantum_info->scale+quantum_info->minimum);
1884 case MagentaQuantum:
1886 *q=(float) ((QuantumScale*GetGreenPixelComponent(p))*
1887 quantum_info->scale+quantum_info->minimum);
1893 *q=(float) ((QuantumScale*GetBluePixelComponent(p))*
1894 quantum_info->scale+quantum_info->minimum);
1899 *q=(float) ((QuantumScale*GetAlphaPixelComponent(p))*
1900 quantum_info->scale+quantum_info->minimum);
1903 case OpacityQuantum:
1905 *q=(float) ((QuantumScale*GetOpacityPixelComponent(p))*
1906 quantum_info->scale+quantum_info->minimum);
1911 if (image->colorspace == CMYKColorspace)
1912 *q=(float) ((QuantumScale*indexes[x])*quantum_info->scale+
1913 quantum_info->minimum);
1918 *q=(float) ((QuantumScale*PixelIntensityToQuantum(p))*
1919 quantum_info->scale+quantum_info->minimum);
1933 register unsigned int
1936 q=(unsigned int *) stream_info->pixels;
1937 if (LocaleCompare(stream_info->map,"BGR") == 0)
1939 p=GetAuthenticPixelQueue(image);
1940 if (p == (const PixelPacket *) NULL)
1942 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
1944 *q++=(unsigned int) ScaleQuantumToLong(GetBluePixelComponent(p));
1945 *q++=(unsigned int) ScaleQuantumToLong(GetGreenPixelComponent(p));
1946 *q++=(unsigned int) ScaleQuantumToLong(GetRedPixelComponent(p));
1951 if (LocaleCompare(stream_info->map,"BGRA") == 0)
1953 p=GetAuthenticPixelQueue(image);
1954 if (p == (const PixelPacket *) NULL)
1956 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
1958 *q++=(unsigned int) ScaleQuantumToLong(GetBluePixelComponent(p));
1959 *q++=(unsigned int) ScaleQuantumToLong(GetGreenPixelComponent(p));
1960 *q++=(unsigned int) ScaleQuantumToLong(GetRedPixelComponent(p));
1961 *q++=(unsigned int) ScaleQuantumToLong((Quantum) (QuantumRange-
1962 GetOpacityPixelComponent(p)));
1967 if (LocaleCompare(stream_info->map,"BGRP") == 0)
1969 p=GetAuthenticPixelQueue(image);
1970 if (p == (const PixelPacket *) NULL)
1972 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
1974 *q++=(unsigned int) ScaleQuantumToLong(GetBluePixelComponent(p));
1975 *q++=(unsigned int) ScaleQuantumToLong(GetGreenPixelComponent(p));
1976 *q++=(unsigned int) ScaleQuantumToLong(GetRedPixelComponent(p));
1982 if (LocaleCompare(stream_info->map,"I") == 0)
1984 p=GetAuthenticPixelQueue(image);
1985 if (p == (const PixelPacket *) NULL)
1987 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
1989 *q++=(unsigned int) ScaleQuantumToLong(
1990 PixelIntensityToQuantum(p));
1995 if (LocaleCompare(stream_info->map,"RGB") == 0)
1997 p=GetAuthenticPixelQueue(image);
1998 if (p == (const PixelPacket *) NULL)
2000 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
2002 *q++=(unsigned int) ScaleQuantumToLong(GetRedPixelComponent(p));
2003 *q++=(unsigned int) ScaleQuantumToLong(GetGreenPixelComponent(p));
2004 *q++=(unsigned int) ScaleQuantumToLong(GetBluePixelComponent(p));
2009 if (LocaleCompare(stream_info->map,"RGBA") == 0)
2011 p=GetAuthenticPixelQueue(image);
2012 if (p == (const PixelPacket *) NULL)
2014 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
2016 *q++=(unsigned int) ScaleQuantumToLong(GetRedPixelComponent(p));
2017 *q++=(unsigned int) ScaleQuantumToLong(GetGreenPixelComponent(p));
2018 *q++=(unsigned int) ScaleQuantumToLong(GetBluePixelComponent(p));
2019 *q++=(unsigned int) ScaleQuantumToLong((Quantum)
2020 (GetAlphaPixelComponent(p)));
2025 if (LocaleCompare(stream_info->map,"RGBP") == 0)
2027 p=GetAuthenticPixelQueue(image);
2028 if (p == (const PixelPacket *) NULL)
2030 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
2032 *q++=(unsigned int) ScaleQuantumToLong(GetRedPixelComponent(p));
2033 *q++=(unsigned int) ScaleQuantumToLong(GetGreenPixelComponent(p));
2034 *q++=(unsigned int) ScaleQuantumToLong(GetBluePixelComponent(p));
2040 p=GetAuthenticPixelQueue(image);
2041 if (p == (const PixelPacket *) NULL)
2043 indexes=GetAuthenticIndexQueue(image);
2044 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
2046 for (i=0; i < (ssize_t) length; i++)
2049 switch (quantum_map[i])
2054 *q=(unsigned int) ScaleQuantumToLong(GetRedPixelComponent(p));
2058 case MagentaQuantum:
2060 *q=(unsigned int) ScaleQuantumToLong(GetGreenPixelComponent(p));
2066 *q=(unsigned int) ScaleQuantumToLong(GetBluePixelComponent(p));
2071 *q=(unsigned int) ScaleQuantumToLong((Quantum) (QuantumRange-
2072 GetOpacityPixelComponent(p)));
2075 case OpacityQuantum:
2077 *q=(unsigned int) ScaleQuantumToLong(GetOpacityPixelComponent(p));
2082 if (image->colorspace == CMYKColorspace)
2083 *q=(unsigned int) ScaleQuantumToLong(indexes[x]);
2089 ScaleQuantumToLong(PixelIntensityToQuantum(p));
2106 q=(size_t *) stream_info->pixels;
2107 if (LocaleCompare(stream_info->map,"BGR") == 0)
2109 p=GetAuthenticPixelQueue(image);
2110 if (p == (const PixelPacket *) NULL)
2112 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
2114 *q++=ScaleQuantumToLong(GetBluePixelComponent(p));
2115 *q++=ScaleQuantumToLong(GetGreenPixelComponent(p));
2116 *q++=ScaleQuantumToLong(GetRedPixelComponent(p));
2121 if (LocaleCompare(stream_info->map,"BGRA") == 0)
2123 p=GetAuthenticPixelQueue(image);
2124 if (p == (const PixelPacket *) NULL)
2126 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
2128 *q++=ScaleQuantumToLong(GetBluePixelComponent(p));
2129 *q++=ScaleQuantumToLong(GetGreenPixelComponent(p));
2130 *q++=ScaleQuantumToLong(GetRedPixelComponent(p));
2131 *q++=ScaleQuantumToLong((Quantum) (GetAlphaPixelComponent(p)));
2136 if (LocaleCompare(stream_info->map,"BGRP") == 0)
2138 p=GetAuthenticPixelQueue(image);
2139 if (p == (const PixelPacket *) NULL)
2141 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
2143 *q++=ScaleQuantumToLong(GetBluePixelComponent(p));
2144 *q++=ScaleQuantumToLong(GetGreenPixelComponent(p));
2145 *q++=ScaleQuantumToLong(GetRedPixelComponent(p));
2151 if (LocaleCompare(stream_info->map,"I") == 0)
2153 p=GetAuthenticPixelQueue(image);
2154 if (p == (const PixelPacket *) NULL)
2156 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
2158 *q++=ScaleQuantumToLong(PixelIntensityToQuantum(p));
2163 if (LocaleCompare(stream_info->map,"RGB") == 0)
2165 p=GetAuthenticPixelQueue(image);
2166 if (p == (const PixelPacket *) NULL)
2168 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
2170 *q++=ScaleQuantumToLong(GetRedPixelComponent(p));
2171 *q++=ScaleQuantumToLong(GetGreenPixelComponent(p));
2172 *q++=ScaleQuantumToLong(GetBluePixelComponent(p));
2177 if (LocaleCompare(stream_info->map,"RGBA") == 0)
2179 p=GetAuthenticPixelQueue(image);
2180 if (p == (const PixelPacket *) NULL)
2182 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
2184 *q++=ScaleQuantumToLong(GetRedPixelComponent(p));
2185 *q++=ScaleQuantumToLong(GetGreenPixelComponent(p));
2186 *q++=ScaleQuantumToLong(GetBluePixelComponent(p));
2187 *q++=ScaleQuantumToLong((Quantum) (GetAlphaPixelComponent(p)));
2192 if (LocaleCompare(stream_info->map,"RGBP") == 0)
2194 p=GetAuthenticPixelQueue(image);
2195 if (p == (const PixelPacket *) NULL)
2197 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
2199 *q++=ScaleQuantumToLong(GetRedPixelComponent(p));
2200 *q++=ScaleQuantumToLong(GetGreenPixelComponent(p));
2201 *q++=ScaleQuantumToLong(GetBluePixelComponent(p));
2207 p=GetAuthenticPixelQueue(image);
2208 if (p == (const PixelPacket *) NULL)
2210 indexes=GetAuthenticIndexQueue(image);
2211 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
2213 for (i=0; i < (ssize_t) length; i++)
2216 switch (quantum_map[i])
2221 *q=ScaleQuantumToLong(GetRedPixelComponent(p));
2225 case MagentaQuantum:
2227 *q=ScaleQuantumToLong(GetGreenPixelComponent(p));
2233 *q=ScaleQuantumToLong(GetBluePixelComponent(p));
2238 *q=ScaleQuantumToLong((Quantum) (GetAlphaPixelComponent(p)));
2241 case OpacityQuantum:
2243 *q=ScaleQuantumToLong(GetOpacityPixelComponent(p));
2248 if (image->colorspace == CMYKColorspace)
2249 *q=ScaleQuantumToLong(indexes[x]);
2254 *q=ScaleQuantumToLong(PixelIntensityToQuantum(p));
2271 q=(Quantum *) stream_info->pixels;
2272 if (LocaleCompare(stream_info->map,"BGR") == 0)
2274 p=GetAuthenticPixelQueue(image);
2275 if (p == (const PixelPacket *) NULL)
2277 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
2279 *q++=GetBluePixelComponent(p);
2280 *q++=GetGreenPixelComponent(p);
2281 *q++=GetRedPixelComponent(p);
2286 if (LocaleCompare(stream_info->map,"BGRA") == 0)
2288 p=GetAuthenticPixelQueue(image);
2289 if (p == (const PixelPacket *) NULL)
2291 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
2293 *q++=GetBluePixelComponent(p);
2294 *q++=GetGreenPixelComponent(p);
2295 *q++=GetRedPixelComponent(p);
2296 *q++=(Quantum) (GetAlphaPixelComponent(p));
2301 if (LocaleCompare(stream_info->map,"BGRP") == 0)
2303 p=GetAuthenticPixelQueue(image);
2304 if (p == (const PixelPacket *) NULL)
2306 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
2308 *q++=GetBluePixelComponent(p);
2309 *q++=GetGreenPixelComponent(p);
2310 *q++=GetRedPixelComponent(p);
2316 if (LocaleCompare(stream_info->map,"I") == 0)
2318 p=GetAuthenticPixelQueue(image);
2319 if (p == (const PixelPacket *) NULL)
2321 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
2323 *q++=PixelIntensityToQuantum(p);
2328 if (LocaleCompare(stream_info->map,"RGB") == 0)
2330 p=GetAuthenticPixelQueue(image);
2331 if (p == (const PixelPacket *) NULL)
2333 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
2335 *q++=GetRedPixelComponent(p);
2336 *q++=GetGreenPixelComponent(p);
2337 *q++=GetBluePixelComponent(p);
2342 if (LocaleCompare(stream_info->map,"RGBA") == 0)
2344 p=GetAuthenticPixelQueue(image);
2345 if (p == (const PixelPacket *) NULL)
2347 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
2349 *q++=GetRedPixelComponent(p);
2350 *q++=GetGreenPixelComponent(p);
2351 *q++=GetBluePixelComponent(p);
2352 *q++=(Quantum) (GetAlphaPixelComponent(p));
2357 if (LocaleCompare(stream_info->map,"RGBP") == 0)
2359 p=GetAuthenticPixelQueue(image);
2360 if (p == (const PixelPacket *) NULL)
2362 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
2364 *q++=GetRedPixelComponent(p);
2365 *q++=GetGreenPixelComponent(p);
2366 *q++=GetBluePixelComponent(p);
2372 p=GetAuthenticPixelQueue(image);
2373 if (p == (const PixelPacket *) NULL)
2375 indexes=GetAuthenticIndexQueue(image);
2376 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
2378 for (i=0; i < (ssize_t) length; i++)
2381 switch (quantum_map[i])
2386 *q=GetRedPixelComponent(p);
2390 case MagentaQuantum:
2392 *q=GetGreenPixelComponent(p);
2398 *q=GetBluePixelComponent(p);
2403 *q=(Quantum) (GetAlphaPixelComponent(p));
2406 case OpacityQuantum:
2408 *q=GetOpacityPixelComponent(p);
2413 if (image->colorspace == CMYKColorspace)
2419 *q=(PixelIntensityToQuantum(p));
2433 register unsigned short
2436 q=(unsigned short *) stream_info->pixels;
2437 if (LocaleCompare(stream_info->map,"BGR") == 0)
2439 p=GetAuthenticPixelQueue(image);
2440 if (p == (const PixelPacket *) NULL)
2442 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
2444 *q++=ScaleQuantumToShort(GetBluePixelComponent(p));
2445 *q++=ScaleQuantumToShort(GetGreenPixelComponent(p));
2446 *q++=ScaleQuantumToShort(GetRedPixelComponent(p));
2451 if (LocaleCompare(stream_info->map,"BGRA") == 0)
2453 p=GetAuthenticPixelQueue(image);
2454 if (p == (const PixelPacket *) NULL)
2456 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
2458 *q++=ScaleQuantumToShort(GetBluePixelComponent(p));
2459 *q++=ScaleQuantumToShort(GetGreenPixelComponent(p));
2460 *q++=ScaleQuantumToShort(GetRedPixelComponent(p));
2461 *q++=ScaleQuantumToShort((Quantum) (GetAlphaPixelComponent(p)));
2466 if (LocaleCompare(stream_info->map,"BGRP") == 0)
2468 p=GetAuthenticPixelQueue(image);
2469 if (p == (const PixelPacket *) NULL)
2471 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
2473 *q++=ScaleQuantumToShort(GetBluePixelComponent(p));
2474 *q++=ScaleQuantumToShort(GetGreenPixelComponent(p));
2475 *q++=ScaleQuantumToShort(GetRedPixelComponent(p));
2481 if (LocaleCompare(stream_info->map,"I") == 0)
2483 p=GetAuthenticPixelQueue(image);
2484 if (p == (const PixelPacket *) NULL)
2486 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
2488 *q++=ScaleQuantumToShort(PixelIntensityToQuantum(p));
2493 if (LocaleCompare(stream_info->map,"RGB") == 0)
2495 p=GetAuthenticPixelQueue(image);
2496 if (p == (const PixelPacket *) NULL)
2498 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
2500 *q++=ScaleQuantumToShort(GetRedPixelComponent(p));
2501 *q++=ScaleQuantumToShort(GetGreenPixelComponent(p));
2502 *q++=ScaleQuantumToShort(GetBluePixelComponent(p));
2507 if (LocaleCompare(stream_info->map,"RGBA") == 0)
2509 p=GetAuthenticPixelQueue(image);
2510 if (p == (const PixelPacket *) NULL)
2512 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
2514 *q++=ScaleQuantumToShort(GetRedPixelComponent(p));
2515 *q++=ScaleQuantumToShort(GetGreenPixelComponent(p));
2516 *q++=ScaleQuantumToShort(GetBluePixelComponent(p));
2517 *q++=ScaleQuantumToShort((Quantum) (GetAlphaPixelComponent(p)));
2522 if (LocaleCompare(stream_info->map,"RGBP") == 0)
2524 p=GetAuthenticPixelQueue(image);
2525 if (p == (const PixelPacket *) NULL)
2527 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
2529 *q++=ScaleQuantumToShort(GetRedPixelComponent(p));
2530 *q++=ScaleQuantumToShort(GetGreenPixelComponent(p));
2531 *q++=ScaleQuantumToShort(GetBluePixelComponent(p));
2537 p=GetAuthenticPixelQueue(image);
2538 if (p == (const PixelPacket *) NULL)
2540 indexes=GetAuthenticIndexQueue(image);
2541 for (x=0; x < (ssize_t) GetImageExtent(image); x++)
2543 for (i=0; i < (ssize_t) length; i++)
2546 switch (quantum_map[i])
2551 *q=ScaleQuantumToShort(GetRedPixelComponent(p));
2555 case MagentaQuantum:
2557 *q=ScaleQuantumToShort(GetGreenPixelComponent(p));
2563 *q=ScaleQuantumToShort(GetBluePixelComponent(p));
2568 *q=ScaleQuantumToShort((Quantum) (GetAlphaPixelComponent(p)));
2571 case OpacityQuantum:
2573 *q=ScaleQuantumToShort(GetOpacityPixelComponent(p));
2578 if (image->colorspace == CMYKColorspace)
2579 *q=ScaleQuantumToShort(indexes[x]);
2584 *q=ScaleQuantumToShort(PixelIntensityToQuantum(p));
2598 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
2599 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
2600 "UnrecognizedPixelMap","`%s'",stream_info->map);
2604 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
2609 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2613 + 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 %
2617 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2619 % SyncAuthenticPixelsStream() calls the user supplied callback method with
2620 % the latest stream of pixels.
2622 % The format of the SyncAuthenticPixelsStream method is:
2624 % MagickBooleanType SyncAuthenticPixelsStream(Image *image,
2625 % ExceptionInfo *exception)
2627 % A description of each parameter follows:
2629 % o image: the image.
2631 % o exception: return any errors or warnings in this structure.
2634 static MagickBooleanType SyncAuthenticPixelsStream(Image *image,
2635 ExceptionInfo *exception)
2646 assert(image != (Image *) NULL);
2647 assert(image->signature == MagickSignature);
2648 if (image->debug != MagickFalse)
2649 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
2650 cache_info=(CacheInfo *) image->cache;
2651 assert(cache_info->signature == MagickSignature);
2652 stream_handler=GetBlobStreamHandler(image);
2653 if (stream_handler == (StreamHandler) NULL)
2655 (void) ThrowMagickException(exception,GetMagickModule(),StreamError,
2656 "NoStreamHandlerIsDefined","`%s'",image->filename);
2657 return(MagickFalse);
2659 length=stream_handler(image,cache_info->pixels,(size_t) cache_info->columns);
2660 return(length == cache_info->columns ? MagickTrue : MagickFalse);
2664 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2668 % W r i t e S t r e a m %
2672 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2674 % WriteStream() makes the image pixels available to a user supplied callback
2675 % method immediately upon writing pixel data with the WriteImage() method.
2677 % The format of the WriteStream() method is:
2679 % MagickBooleanType WriteStream(const ImageInfo *image_info,Image *,
2680 % StreamHandler stream)
2682 % A description of each parameter follows:
2684 % o image_info: the image info.
2686 % o stream: A callback method.
2689 MagickExport MagickBooleanType WriteStream(const ImageInfo *image_info,
2690 Image *image,StreamHandler stream)
2698 assert(image_info != (ImageInfo *) NULL);
2699 assert(image_info->signature == MagickSignature);
2700 if (image_info->debug != MagickFalse)
2701 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
2702 image_info->filename);
2703 assert(image != (Image *) NULL);
2704 assert(image->signature == MagickSignature);
2705 write_info=CloneImageInfo(image_info);
2706 write_info->stream=stream;
2707 status=WriteImage(write_info,image);
2708 write_info=DestroyImageInfo(write_info);