00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #include "magick/studio.h"
00044 #include "magick/blob.h"
00045 #include "magick/blob-private.h"
00046 #include "magick/cache.h"
00047 #include "magick/cache-private.h"
00048 #include "magick/color-private.h"
00049 #include "magick/composite-private.h"
00050 #include "magick/constitute.h"
00051 #include "magick/exception.h"
00052 #include "magick/exception-private.h"
00053 #include "magick/geometry.h"
00054 #include "magick/memory_.h"
00055 #include "magick/quantum.h"
00056 #include "magick/quantum-private.h"
00057 #include "magick/semaphore.h"
00058 #include "magick/stream.h"
00059 #include "magick/stream-private.h"
00060 #include "magick/string_.h"
00061
00062
00063
00064
00065 struct _StreamInfo
00066 {
00067 const ImageInfo
00068 *image_info;
00069
00070 const Image
00071 *image;
00072
00073 Image
00074 *stream;
00075
00076 QuantumInfo
00077 *quantum_info;
00078
00079 char
00080 *map;
00081
00082 StorageType
00083 storage_type;
00084
00085 unsigned char
00086 *pixels;
00087
00088 RectangleInfo
00089 extract_info;
00090
00091 long
00092 y;
00093
00094 ExceptionInfo
00095 *exception;
00096
00097 const void
00098 *client_data;
00099
00100 unsigned long
00101 signature;
00102 };
00103
00104
00105
00106
00107 #if defined(__cplusplus) || defined(c_plusplus)
00108 extern "C" {
00109 #endif
00110
00111 static const PixelPacket
00112 *GetVirtualPixelStream(const Image *,const VirtualPixelMethod,const long,
00113 const long,const unsigned long,const unsigned long,ExceptionInfo *);
00114
00115 static MagickBooleanType
00116 StreamImagePixels(const StreamInfo *,const Image *,ExceptionInfo *),
00117 SyncAuthenticPixelsStream(Image *,ExceptionInfo *);
00118
00119 static PixelPacket
00120 *QueueAuthenticPixelsStream(Image *,const long,const long,const unsigned long,
00121 const unsigned long,ExceptionInfo *);
00122
00123 #if defined(__cplusplus) || defined(c_plusplus)
00124 }
00125 #endif
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149 MagickExport StreamInfo *AcquireStreamInfo(const ImageInfo *image_info)
00150 {
00151 StreamInfo
00152 *stream_info;
00153
00154 stream_info=(StreamInfo *) AcquireMagickMemory(sizeof(*stream_info));
00155 if (stream_info == (StreamInfo *) NULL)
00156 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
00157 (void) ResetMagickMemory(stream_info,0,sizeof(*stream_info));
00158 stream_info->pixels=(unsigned char *) AcquireMagickMemory(
00159 sizeof(*stream_info->pixels));
00160 if (stream_info->pixels == (unsigned char *) NULL)
00161 ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
00162 stream_info->map=ConstantString("RGB");
00163 stream_info->storage_type=CharPixel;
00164 stream_info->stream=AcquireImage(image_info);
00165 stream_info->signature=MagickSignature;
00166 return(stream_info);
00167 }
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192 static inline void RelinquishStreamPixels(CacheInfo *cache_info)
00193 {
00194 assert(cache_info != (CacheInfo *) NULL);
00195 if (cache_info->mapped == MagickFalse)
00196 (void) RelinquishMagickMemory(cache_info->pixels);
00197 else
00198 (void) UnmapBlob(cache_info->pixels,(size_t) cache_info->length);
00199 cache_info->pixels=(PixelPacket *) NULL;
00200 cache_info->indexes=(IndexPacket *) NULL;
00201 cache_info->length=0;
00202 cache_info->mapped=MagickFalse;
00203 }
00204
00205 static void DestroyPixelStream(Image *image)
00206 {
00207 CacheInfo
00208 *cache_info;
00209
00210 MagickBooleanType
00211 destroy;
00212
00213 assert(image != (Image *) NULL);
00214 assert(image->signature == MagickSignature);
00215 if (image->debug != MagickFalse)
00216 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
00217 cache_info=(CacheInfo *) image->cache;
00218 assert(cache_info->signature == MagickSignature);
00219 destroy=MagickFalse;
00220 (void) LockSemaphoreInfo(cache_info->semaphore);
00221 cache_info->reference_count--;
00222 if (cache_info->reference_count == 0)
00223 destroy=MagickTrue;
00224 (void) UnlockSemaphoreInfo(cache_info->semaphore);
00225 if (destroy == MagickFalse)
00226 return;
00227 RelinquishStreamPixels(cache_info);
00228 if (cache_info->nexus_info != (NexusInfo **) NULL)
00229 cache_info->nexus_info=DestroyPixelCacheNexus(cache_info->nexus_info,
00230 cache_info->number_threads);
00231 if (cache_info->disk_semaphore != (SemaphoreInfo *) NULL)
00232 DestroySemaphoreInfo(&cache_info->disk_semaphore);
00233 if (cache_info->semaphore != (SemaphoreInfo *) NULL)
00234 DestroySemaphoreInfo(&cache_info->semaphore);
00235 cache_info=(CacheInfo *) RelinquishMagickMemory(cache_info);
00236 }
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261 MagickExport StreamInfo *DestroyStreamInfo(StreamInfo *stream_info)
00262 {
00263 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
00264 assert(stream_info != (StreamInfo *) NULL);
00265 assert(stream_info->signature == MagickSignature);
00266 if (stream_info->map != (char *) NULL)
00267 stream_info->map=DestroyString(stream_info->map);
00268 if (stream_info->pixels != (unsigned char *) NULL)
00269 stream_info->pixels=(unsigned char *) RelinquishMagickMemory(
00270 stream_info->pixels);
00271 if (stream_info->stream != (Image *) NULL)
00272 {
00273 (void) CloseBlob(stream_info->stream);
00274 stream_info->stream=DestroyImage(stream_info->stream);
00275 }
00276 if (stream_info->quantum_info != (QuantumInfo *) NULL)
00277 stream_info->quantum_info=DestroyQuantumInfo(stream_info->quantum_info);
00278 stream_info->signature=(~MagickSignature);
00279 stream_info=(StreamInfo *) RelinquishMagickMemory(stream_info);
00280 return(stream_info);
00281 }
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306 static IndexPacket *GetAuthenticIndexesFromStream(const Image *image)
00307 {
00308 CacheInfo
00309 *cache_info;
00310
00311 assert(image != (Image *) NULL);
00312 assert(image->signature == MagickSignature);
00313 if (image->debug != MagickFalse)
00314 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
00315 cache_info=(CacheInfo *) image->cache;
00316 assert(cache_info->signature == MagickSignature);
00317 return(cache_info->indexes);
00318 }
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352 static PixelPacket *GetAuthenticPixelsStream(Image *image,const long x,
00353 const long y,const unsigned long columns,const unsigned long rows,
00354 ExceptionInfo *exception)
00355 {
00356 PixelPacket
00357 *pixels;
00358
00359 assert(image != (Image *) NULL);
00360 assert(image->signature == MagickSignature);
00361 if (image->debug != MagickFalse)
00362 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
00363 pixels=QueueAuthenticPixelsStream(image,x,y,columns,rows,exception);
00364 return(pixels);
00365 }
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390 static PixelPacket *GetAuthenticPixelsFromStream(const Image *image)
00391 {
00392 CacheInfo
00393 *cache_info;
00394
00395 assert(image != (Image *) NULL);
00396 assert(image->signature == MagickSignature);
00397 if (image->debug != MagickFalse)
00398 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
00399 cache_info=(CacheInfo *) image->cache;
00400 assert(cache_info->signature == MagickSignature);
00401 return(cache_info->pixels);
00402 }
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434 static MagickBooleanType GetOneAuthenticPixelFromStream(Image *image,
00435 const long x,const long y,PixelPacket *pixel,ExceptionInfo *exception)
00436 {
00437 register PixelPacket
00438 *pixels;
00439
00440 assert(image != (Image *) NULL);
00441 assert(image->signature == MagickSignature);
00442 *pixel=image->background_color;
00443 pixels=GetAuthenticPixelsStream(image,x,y,1,1,exception);
00444 if (pixels != (PixelPacket *) NULL)
00445 return(MagickFalse);
00446 *pixel=(*pixels);
00447 return(MagickTrue);
00448 }
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483 static MagickBooleanType GetOneVirtualPixelFromStream(const Image *image,
00484 const VirtualPixelMethod virtual_pixel_method,const long x,const long y,
00485 PixelPacket *pixel,ExceptionInfo *exception)
00486 {
00487 const PixelPacket
00488 *pixels;
00489
00490 assert(image != (Image *) NULL);
00491 assert(image->signature == MagickSignature);
00492 *pixel=image->background_color;
00493 pixels=GetVirtualPixelStream(image,virtual_pixel_method,x,y,1,1,exception);
00494 if (pixels != (const PixelPacket *) NULL)
00495 return(MagickFalse);
00496 *pixel=(*pixels);
00497 return(MagickTrue);
00498 }
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522 MagickExport const void *GetStreamInfoClientData(StreamInfo *stream_info)
00523 {
00524 assert(stream_info != (StreamInfo *) NULL);
00525 assert(stream_info->signature == MagickSignature);
00526 return(stream_info->client_data);
00527 }
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555 static const PixelPacket *GetVirtualPixelsStream(const Image *image)
00556 {
00557 CacheInfo
00558 *cache_info;
00559
00560 assert(image != (Image *) NULL);
00561 assert(image->signature == MagickSignature);
00562 if (image->debug != MagickFalse)
00563 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
00564 cache_info=(CacheInfo *) image->cache;
00565 assert(cache_info->signature == MagickSignature);
00566 return(cache_info->pixels);
00567 }
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592 static const IndexPacket *GetVirtualIndexesFromStream(const Image *image)
00593 {
00594 CacheInfo
00595 *cache_info;
00596
00597 assert(image != (Image *) NULL);
00598 assert(image->signature == MagickSignature);
00599 if (image->debug != MagickFalse)
00600 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
00601 cache_info=(CacheInfo *) image->cache;
00602 assert(cache_info->signature == MagickSignature);
00603 return(cache_info->indexes);
00604 }
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642 static inline MagickBooleanType AcquireStreamPixels(CacheInfo *cache_info,
00643 ExceptionInfo *exception)
00644 {
00645 if (cache_info->length != (MagickSizeType) ((size_t) cache_info->length))
00646 return(MagickFalse);
00647 cache_info->mapped=MagickFalse;
00648 cache_info->pixels=(PixelPacket *) AcquireMagickMemory((size_t)
00649 cache_info->length);
00650 if (cache_info->pixels == (PixelPacket *) NULL)
00651 {
00652 cache_info->mapped=MagickTrue;
00653 cache_info->pixels=(PixelPacket *) MapBlob(-1,IOMode,0,(size_t)
00654 cache_info->length);
00655 }
00656 if (cache_info->pixels == (PixelPacket *) NULL)
00657 {
00658 (void) ThrowMagickException(exception,GetMagickModule(),
00659 ResourceLimitError,"MemoryAllocationFailed","`%s'",
00660 cache_info->filename);
00661 return(MagickFalse);
00662 }
00663 return(MagickTrue);
00664 }
00665
00666 static const PixelPacket *GetVirtualPixelStream(const Image *image,
00667 const VirtualPixelMethod magick_unused(virtual_pixel_method),const long x,
00668 const long y,const unsigned long columns,const unsigned long rows,
00669 ExceptionInfo *exception)
00670 {
00671 CacheInfo
00672 *cache_info;
00673
00674 MagickBooleanType
00675 status;
00676
00677 MagickSizeType
00678 number_pixels;
00679
00680 size_t
00681 length;
00682
00683
00684
00685
00686 assert(image != (const Image *) NULL);
00687 assert(image->signature == MagickSignature);
00688 if (image->debug != MagickFalse)
00689 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
00690 if ((x < 0) || (y < 0) || ((x+(long) columns) > (long) image->columns) ||
00691 ((y+(long) rows) > (long) image->rows) || (columns == 0) || (rows == 0))
00692 {
00693 (void) ThrowMagickException(exception,GetMagickModule(),StreamError,
00694 "ImageDoesNotContainTheStreamGeometry","`%s'",image->filename);
00695 return((PixelPacket *) NULL);
00696 }
00697 cache_info=(CacheInfo *) image->cache;
00698 assert(cache_info->signature == MagickSignature);
00699
00700
00701
00702 number_pixels=(MagickSizeType) columns*rows;
00703 length=(size_t) number_pixels*sizeof(PixelPacket);
00704 if ((image->storage_class == PseudoClass) ||
00705 (image->colorspace == CMYKColorspace))
00706 length+=number_pixels*sizeof(IndexPacket);
00707 if (cache_info->pixels == (PixelPacket *) NULL)
00708 {
00709 cache_info->length=length;
00710 status=AcquireStreamPixels(cache_info,exception);
00711 if (status == MagickFalse)
00712 return((PixelPacket *) NULL);
00713 }
00714 else
00715 if (cache_info->length != length)
00716 {
00717 RelinquishStreamPixels(cache_info);
00718 cache_info->length=length;
00719 status=AcquireStreamPixels(cache_info,exception);
00720 if (status == MagickFalse)
00721 return((PixelPacket *) NULL);
00722 }
00723 cache_info->indexes=(IndexPacket *) NULL;
00724 if ((image->storage_class == PseudoClass) ||
00725 (image->colorspace == CMYKColorspace))
00726 cache_info->indexes=(IndexPacket *) (cache_info->pixels+number_pixels);
00727 return(cache_info->pixels);
00728 }
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759 MagickExport MagickBooleanType OpenStream(const ImageInfo *image_info,
00760 StreamInfo *stream_info,const char *filename,ExceptionInfo *exception)
00761 {
00762 MagickBooleanType
00763 status;
00764
00765 (void) CopyMagickString(stream_info->stream->filename,filename,MaxTextExtent);
00766 status=OpenBlob(image_info,stream_info->stream,WriteBinaryBlobMode,exception);
00767 return(status);
00768 }
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801 static PixelPacket *QueueAuthenticPixelsStream(Image *image,const long x,
00802 const long y,const unsigned long columns,const unsigned long rows,
00803 ExceptionInfo *exception)
00804 {
00805 CacheInfo
00806 *cache_info;
00807
00808 MagickSizeType
00809 number_pixels;
00810
00811 size_t
00812 length;
00813
00814 StreamHandler
00815 stream_handler;
00816
00817
00818
00819
00820 assert(image != (Image *) NULL);
00821 if ((x < 0) || (y < 0) || ((x+(long) columns) > (long) image->columns) ||
00822 ((y+(long) rows) > (long) image->rows) || (columns == 0) || (rows == 0))
00823 {
00824 (void) ThrowMagickException(exception,GetMagickModule(),StreamError,
00825 "ImageDoesNotContainTheStreamGeometry","`%s'",image->filename);
00826 return((PixelPacket *) NULL);
00827 }
00828 stream_handler=GetBlobStreamHandler(image);
00829 if (stream_handler == (StreamHandler) NULL)
00830 {
00831 (void) ThrowMagickException(exception,GetMagickModule(),StreamError,
00832 "NoStreamHandlerIsDefined","`%s'",image->filename);
00833 return((PixelPacket *) NULL);
00834 }
00835 cache_info=(CacheInfo *) image->cache;
00836 assert(cache_info->signature == MagickSignature);
00837 if ((image->storage_class != GetPixelCacheStorageClass(image->cache)) ||
00838 (image->colorspace != GetPixelCacheColorspace(image->cache)))
00839 {
00840 if (GetPixelCacheStorageClass(image->cache) == UndefinedClass)
00841 (void) stream_handler(image,(const void *) NULL,(size_t)
00842 cache_info->columns);
00843 cache_info->storage_class=image->storage_class;
00844 cache_info->colorspace=image->colorspace;
00845 cache_info->columns=image->columns;
00846 cache_info->rows=image->rows;
00847 image->cache=cache_info;
00848 }
00849
00850
00851
00852 cache_info->columns=columns;
00853 cache_info->rows=rows;
00854 number_pixels=(MagickSizeType) columns*rows;
00855 length=(size_t) number_pixels*sizeof(PixelPacket);
00856 if ((image->storage_class == PseudoClass) ||
00857 (image->colorspace == CMYKColorspace))
00858 length+=number_pixels*sizeof(IndexPacket);
00859 if (cache_info->pixels == (PixelPacket *) NULL)
00860 {
00861 cache_info->pixels=(PixelPacket *) AcquireMagickMemory(length);
00862 cache_info->length=(MagickSizeType) length;
00863 }
00864 else
00865 if (cache_info->length < (MagickSizeType) length)
00866 {
00867 cache_info->pixels=(PixelPacket *) ResizeMagickMemory(
00868 cache_info->pixels,length);
00869 cache_info->length=(MagickSizeType) length;
00870 }
00871 if (cache_info->pixels == (void *) NULL)
00872 return((PixelPacket *) NULL);
00873 cache_info->indexes=(IndexPacket *) NULL;
00874 if ((image->storage_class == PseudoClass) ||
00875 (image->colorspace == CMYKColorspace))
00876 cache_info->indexes=(IndexPacket *) (cache_info->pixels+number_pixels);
00877 return(cache_info->pixels);
00878 }
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908 MagickExport Image *ReadStream(const ImageInfo *image_info,StreamHandler stream,
00909 ExceptionInfo *exception)
00910 {
00911 CacheMethods
00912 cache_methods;
00913
00914 Image
00915 *image;
00916
00917 ImageInfo
00918 *read_info;
00919
00920
00921
00922
00923 assert(image_info != (ImageInfo *) NULL);
00924 assert(image_info->signature == MagickSignature);
00925 if (image_info->debug != MagickFalse)
00926 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
00927 image_info->filename);
00928 assert(exception != (ExceptionInfo *) NULL);
00929 assert(exception->signature == MagickSignature);
00930 read_info=CloneImageInfo(image_info);
00931 read_info->cache=AcquirePixelCache(0);
00932 GetPixelCacheMethods(&cache_methods);
00933 cache_methods.get_virtual_pixel_handler=GetVirtualPixelStream;
00934 cache_methods.get_virtual_indexes_from_handler=GetVirtualIndexesFromStream;
00935 cache_methods.get_virtual_pixels_handler=GetVirtualPixelsStream;
00936 cache_methods.get_authentic_pixels_handler=GetAuthenticPixelsStream;
00937 cache_methods.queue_authentic_pixels_handler=QueueAuthenticPixelsStream;
00938 cache_methods.sync_authentic_pixels_handler=SyncAuthenticPixelsStream;
00939 cache_methods.get_authentic_pixels_from_handler=GetAuthenticPixelsFromStream;
00940 cache_methods.get_authentic_indexes_from_handler=
00941 GetAuthenticIndexesFromStream;
00942 cache_methods.get_one_virtual_pixel_from_handler=GetOneVirtualPixelFromStream;
00943 cache_methods.get_one_authentic_pixel_from_handler=
00944 GetOneAuthenticPixelFromStream;
00945 cache_methods.destroy_pixel_handler=DestroyPixelStream;
00946 SetPixelCacheMethods(read_info->cache,&cache_methods);
00947 read_info->stream=stream;
00948 image=ReadImage(read_info,exception);
00949 read_info=DestroyImageInfo(read_info);
00950 return(image);
00951 }
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978 MagickExport void SetStreamInfoClientData(StreamInfo *stream_info,
00979 const void *client_data)
00980 {
00981 assert(stream_info != (StreamInfo *) NULL);
00982 assert(stream_info->signature == MagickSignature);
00983 stream_info->client_data=client_data;
00984 }
00985
00986
00987
00988
00989
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010 MagickExport void SetStreamInfoMap(StreamInfo *stream_info,const char *map)
01011 {
01012 assert(stream_info != (StreamInfo *) NULL);
01013 assert(stream_info->signature == MagickSignature);
01014 (void) CloneString(&stream_info->map,map);
01015 }
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042 MagickExport void SetStreamInfoStorageType(StreamInfo *stream_info,
01043 const StorageType storage_type)
01044 {
01045 assert(stream_info != (StreamInfo *) NULL);
01046 assert(stream_info->signature == MagickSignature);
01047 stream_info->storage_type=storage_type;
01048 }
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064
01065
01066
01067
01068
01069
01070
01071
01072
01073
01074
01075
01076
01077
01078
01079 #if defined(__cplusplus) || defined(c_plusplus)
01080 extern "C" {
01081 #endif
01082
01083 static size_t WriteStreamImage(const Image *image,const void *pixels,
01084 const size_t columns)
01085 {
01086 RectangleInfo
01087 extract_info;
01088
01089 size_t
01090 length,
01091 packet_size;
01092
01093 ssize_t
01094 count;
01095
01096 StreamInfo
01097 *stream_info;
01098
01099 stream_info=(StreamInfo *) image->client_data;
01100 switch (stream_info->storage_type)
01101 {
01102 default: packet_size=sizeof(char); break;
01103 case CharPixel: packet_size=sizeof(char); break;
01104 case DoublePixel: packet_size=sizeof(double); break;
01105 case FloatPixel: packet_size=sizeof(float); break;
01106 case IntegerPixel: packet_size=sizeof(int); break;
01107 case LongPixel: packet_size=sizeof(long); break;
01108 case QuantumPixel: packet_size=sizeof(Quantum); break;
01109 case ShortPixel: packet_size=sizeof(unsigned short); break;
01110 }
01111 packet_size*=strlen(stream_info->map);
01112 length=packet_size*image->columns;
01113 if (image != stream_info->image)
01114 {
01115 ImageInfo
01116 *write_info;
01117
01118
01119
01120
01121 stream_info->pixels=(unsigned char *) ResizeQuantumMemory(
01122 stream_info->pixels,length,sizeof(*stream_info->pixels));
01123 if (pixels == (unsigned char *) NULL)
01124 return(0);
01125 stream_info->image=image;
01126 write_info=CloneImageInfo(stream_info->image_info);
01127 (void) SetImageInfo(write_info,MagickFalse,stream_info->exception);
01128 if (write_info->extract != (char *) NULL)
01129 (void) ParseAbsoluteGeometry(write_info->extract,
01130 &stream_info->extract_info);
01131 stream_info->y=0;
01132 write_info=DestroyImageInfo(write_info);
01133 }
01134 extract_info=stream_info->extract_info;
01135 if ((extract_info.width == 0) ||
01136 (extract_info.height == 0))
01137 {
01138
01139
01140
01141 (void) StreamImagePixels(stream_info,image,stream_info->exception);
01142 count=WriteBlob(stream_info->stream,length,stream_info->pixels);
01143 stream_info->y++;
01144 return(count == 0 ? 0 : columns);
01145 }
01146 if ((stream_info->y < extract_info.y) ||
01147 (stream_info->y >= (long) (extract_info.y+extract_info.height)))
01148 {
01149 stream_info->y++;
01150 return(columns);
01151 }
01152
01153
01154
01155 (void) StreamImagePixels(stream_info,image,stream_info->exception);
01156 length=packet_size*extract_info.width;
01157 count=WriteBlob(stream_info->stream,length,stream_info->pixels+
01158 packet_size*extract_info.x);
01159 stream_info->y++;
01160 return(count == 0 ? 0 : columns);
01161 }
01162
01163 #if defined(__cplusplus) || defined(c_plusplus)
01164 }
01165 #endif
01166
01167 MagickExport Image *StreamImage(const ImageInfo *image_info,
01168 StreamInfo *stream_info,ExceptionInfo *exception)
01169 {
01170 Image
01171 *image;
01172
01173 ImageInfo
01174 *read_info;
01175
01176 assert(image_info != (const ImageInfo *) NULL);
01177 assert(image_info->signature == MagickSignature);
01178 if (image_info->debug != MagickFalse)
01179 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
01180 image_info->filename);
01181 assert(stream_info != (StreamInfo *) NULL);
01182 assert(stream_info->signature == MagickSignature);
01183 assert(exception != (ExceptionInfo *) NULL);
01184 read_info=CloneImageInfo(image_info);
01185 stream_info->image_info=image_info;
01186 stream_info->exception=exception;
01187 read_info->client_data=(void *) stream_info;
01188 image=ReadStream(read_info,&WriteStreamImage,exception);
01189 read_info=DestroyImageInfo(read_info);
01190 stream_info->quantum_info=AcquireQuantumInfo(image_info,image);
01191 if (stream_info->quantum_info == (QuantumInfo *) NULL)
01192 image=DestroyImage(image);
01193 return(image);
01194 }
01195
01196
01197
01198
01199
01200
01201
01202
01203
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222
01223
01224
01225 static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info,
01226 const Image *image,ExceptionInfo *exception)
01227 {
01228 QuantumInfo
01229 *quantum_info;
01230
01231 QuantumType
01232 *quantum_map;
01233
01234 register long
01235 i,
01236 x;
01237
01238 register const PixelPacket
01239 *p;
01240
01241 register IndexPacket
01242 *indexes;
01243
01244 size_t
01245 length;
01246
01247 assert(stream_info != (StreamInfo *) NULL);
01248 assert(stream_info->signature == MagickSignature);
01249 assert(image != (Image *) NULL);
01250 assert(image->signature == MagickSignature);
01251 if (image->debug != MagickFalse)
01252 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
01253 length=strlen(stream_info->map);
01254 quantum_map=(QuantumType *) AcquireQuantumMemory(length,sizeof(*quantum_map));
01255 if (quantum_map == (QuantumType *) NULL)
01256 {
01257 (void) ThrowMagickException(exception,GetMagickModule(),
01258 ResourceLimitError,"MemoryAllocationFailed","`%s'",image->filename);
01259 return(MagickFalse);
01260 }
01261 for (i=0; i < (long) length; i++)
01262 {
01263 switch (stream_info->map[i])
01264 {
01265 case 'A':
01266 case 'a':
01267 {
01268 quantum_map[i]=AlphaQuantum;
01269 break;
01270 }
01271 case 'B':
01272 case 'b':
01273 {
01274 quantum_map[i]=BlueQuantum;
01275 break;
01276 }
01277 case 'C':
01278 case 'c':
01279 {
01280 quantum_map[i]=CyanQuantum;
01281 if (image->colorspace == CMYKColorspace)
01282 break;
01283 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
01284 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
01285 "ColorSeparatedImageRequired","`%s'",stream_info->map);
01286 return(MagickFalse);
01287 }
01288 case 'g':
01289 case 'G':
01290 {
01291 quantum_map[i]=GreenQuantum;
01292 break;
01293 }
01294 case 'I':
01295 case 'i':
01296 {
01297 quantum_map[i]=IndexQuantum;
01298 break;
01299 }
01300 case 'K':
01301 case 'k':
01302 {
01303 quantum_map[i]=BlackQuantum;
01304 if (image->colorspace == CMYKColorspace)
01305 break;
01306 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
01307 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
01308 "ColorSeparatedImageRequired","`%s'",stream_info->map);
01309 return(MagickFalse);
01310 }
01311 case 'M':
01312 case 'm':
01313 {
01314 quantum_map[i]=MagentaQuantum;
01315 if (image->colorspace == CMYKColorspace)
01316 break;
01317 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
01318 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
01319 "ColorSeparatedImageRequired","`%s'",stream_info->map);
01320 return(MagickFalse);
01321 }
01322 case 'o':
01323 case 'O':
01324 {
01325 quantum_map[i]=OpacityQuantum;
01326 break;
01327 }
01328 case 'P':
01329 case 'p':
01330 {
01331 quantum_map[i]=UndefinedQuantum;
01332 break;
01333 }
01334 case 'R':
01335 case 'r':
01336 {
01337 quantum_map[i]=RedQuantum;
01338 break;
01339 }
01340 case 'Y':
01341 case 'y':
01342 {
01343 quantum_map[i]=YellowQuantum;
01344 if (image->colorspace == CMYKColorspace)
01345 break;
01346 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
01347 (void) ThrowMagickException(exception,GetMagickModule(),ImageError,
01348 "ColorSeparatedImageRequired","`%s'",stream_info->map);
01349 return(MagickFalse);
01350 }
01351 default:
01352 {
01353 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
01354 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
01355 "UnrecognizedPixelMap","`%s'",stream_info->map);
01356 return(MagickFalse);
01357 }
01358 }
01359 }
01360 quantum_info=stream_info->quantum_info;
01361 switch (stream_info->storage_type)
01362 {
01363 case CharPixel:
01364 {
01365 register unsigned char
01366 *q;
01367
01368 q=(unsigned char *) stream_info->pixels;
01369 if (LocaleCompare(stream_info->map,"BGR") == 0)
01370 {
01371 p=GetAuthenticPixelQueue(image);
01372 if (p == (const PixelPacket *) NULL)
01373 break;
01374 for (x=0; x < (long) GetImageExtent(image); x++)
01375 {
01376 *q++=ScaleQuantumToChar(p->blue);
01377 *q++=ScaleQuantumToChar(p->green);
01378 *q++=ScaleQuantumToChar(p->red);
01379 p++;
01380 }
01381 break;
01382 }
01383 if (LocaleCompare(stream_info->map,"BGRA") == 0)
01384 {
01385 p=GetAuthenticPixelQueue(image);
01386 if (p == (const PixelPacket *) NULL)
01387 break;
01388 for (x=0; x < (long) GetImageExtent(image); x++)
01389 {
01390 *q++=ScaleQuantumToChar(p->blue);
01391 *q++=ScaleQuantumToChar(p->green);
01392 *q++=ScaleQuantumToChar(p->red);
01393 *q++=ScaleQuantumToChar((Quantum) (QuantumRange-p->opacity));
01394 p++;
01395 }
01396 break;
01397 }
01398 if (LocaleCompare(stream_info->map,"BGRP") == 0)
01399 {
01400 p=GetAuthenticPixelQueue(image);
01401 if (p == (const PixelPacket *) NULL)
01402 break;
01403 for (x=0; x < (long) GetImageExtent(image); x++)
01404 {
01405 *q++=ScaleQuantumToChar(p->blue);
01406 *q++=ScaleQuantumToChar(p->green);
01407 *q++=ScaleQuantumToChar(p->red);
01408 *q++=ScaleQuantumToChar((Quantum) 0);
01409 p++;
01410 }
01411 break;
01412 }
01413 if (LocaleCompare(stream_info->map,"I") == 0)
01414 {
01415 p=GetAuthenticPixelQueue(image);
01416 if (p == (const PixelPacket *) NULL)
01417 break;
01418 for (x=0; x < (long) GetImageExtent(image); x++)
01419 {
01420 *q++=ScaleQuantumToChar(PixelIntensityToQuantum(p));
01421 p++;
01422 }
01423 break;
01424 }
01425 if (LocaleCompare(stream_info->map,"RGB") == 0)
01426 {
01427 p=GetAuthenticPixelQueue(image);
01428 if (p == (const PixelPacket *) NULL)
01429 break;
01430 for (x=0; x < (long) GetImageExtent(image); x++)
01431 {
01432 *q++=ScaleQuantumToChar(p->red);
01433 *q++=ScaleQuantumToChar(p->green);
01434 *q++=ScaleQuantumToChar(p->blue);
01435 p++;
01436 }
01437 break;
01438 }
01439 if (LocaleCompare(stream_info->map,"RGBA") == 0)
01440 {
01441 p=GetAuthenticPixelQueue(image);
01442 if (p == (const PixelPacket *) NULL)
01443 break;
01444 for (x=0; x < (long) GetImageExtent(image); x++)
01445 {
01446 *q++=ScaleQuantumToChar(p->red);
01447 *q++=ScaleQuantumToChar(p->green);
01448 *q++=ScaleQuantumToChar(p->blue);
01449 *q++=ScaleQuantumToChar((Quantum) (QuantumRange-p->opacity));
01450 p++;
01451 }
01452 break;
01453 }
01454 if (LocaleCompare(stream_info->map,"RGBP") == 0)
01455 {
01456 p=GetAuthenticPixelQueue(image);
01457 if (p == (const PixelPacket *) NULL)
01458 break;
01459 for (x=0; x < (long) GetImageExtent(image); x++)
01460 {
01461 *q++=ScaleQuantumToChar(p->red);
01462 *q++=ScaleQuantumToChar(p->green);
01463 *q++=ScaleQuantumToChar(p->blue);
01464 *q++=ScaleQuantumToChar((Quantum) 0);
01465 p++;
01466 }
01467 break;
01468 }
01469 p=GetAuthenticPixelQueue(image);
01470 if (p == (const PixelPacket *) NULL)
01471 break;
01472 indexes=GetAuthenticIndexQueue(image);
01473 for (x=0; x < (long) GetImageExtent(image); x++)
01474 {
01475 for (i=0; i < (long) length; i++)
01476 {
01477 *q=0;
01478 switch (quantum_map[i])
01479 {
01480 case RedQuantum:
01481 case CyanQuantum:
01482 {
01483 *q=ScaleQuantumToChar(p->red);
01484 break;
01485 }
01486 case GreenQuantum:
01487 case MagentaQuantum:
01488 {
01489 *q=ScaleQuantumToChar(p->green);
01490 break;
01491 }
01492 case BlueQuantum:
01493 case YellowQuantum:
01494 {
01495 *q=ScaleQuantumToChar(p->blue);
01496 break;
01497 }
01498 case AlphaQuantum:
01499 {
01500 *q=ScaleQuantumToChar((Quantum) (QuantumRange-p->opacity));
01501 break;
01502 }
01503 case OpacityQuantum:
01504 {
01505 *q=ScaleQuantumToChar(p->opacity);
01506 break;
01507 }
01508 case BlackQuantum:
01509 {
01510 if (image->colorspace == CMYKColorspace)
01511 *q=ScaleQuantumToChar(indexes[x]);
01512 break;
01513 }
01514 case IndexQuantum:
01515 {
01516 *q=ScaleQuantumToChar(PixelIntensityToQuantum(p));
01517 break;
01518 }
01519 default:
01520 break;
01521 }
01522 q++;
01523 }
01524 p++;
01525 }
01526 break;
01527 }
01528 case DoublePixel:
01529 {
01530 register double
01531 *q;
01532
01533 q=(double *) stream_info->pixels;
01534 if (LocaleCompare(stream_info->map,"BGR") == 0)
01535 {
01536 p=GetAuthenticPixelQueue(image);
01537 if (p == (const PixelPacket *) NULL)
01538 break;
01539 for (x=0; x < (long) GetImageExtent(image); x++)
01540 {
01541 *q++=(double) ((QuantumScale*p->blue)*quantum_info->scale+
01542 quantum_info->minimum);
01543 *q++=(double) ((QuantumScale*p->green)*quantum_info->scale+
01544 quantum_info->minimum);
01545 *q++=(double) ((QuantumScale*p->red)*quantum_info->scale+
01546 quantum_info->minimum);
01547 p++;
01548 }
01549 break;
01550 }
01551 if (LocaleCompare(stream_info->map,"BGRA") == 0)
01552 {
01553 p=GetAuthenticPixelQueue(image);
01554 if (p == (const PixelPacket *) NULL)
01555 break;
01556 for (x=0; x < (long) GetImageExtent(image); x++)
01557 {
01558 *q++=(double) ((QuantumScale*p->blue)*quantum_info->scale+
01559 quantum_info->minimum);
01560 *q++=(double) ((QuantumScale*p->green)*quantum_info->scale+
01561 quantum_info->minimum);
01562 *q++=(double) ((QuantumScale*p->red)*quantum_info->scale+
01563 quantum_info->minimum);
01564 *q++=(double) ((QuantumScale*((Quantum) (QuantumRange-p->opacity)))*
01565 quantum_info->scale+quantum_info->minimum);
01566 p++;
01567 }
01568 break;
01569 }
01570 if (LocaleCompare(stream_info->map,"BGRP") == 0)
01571 {
01572 p=GetAuthenticPixelQueue(image);
01573 if (p == (const PixelPacket *) NULL)
01574 break;
01575 for (x=0; x < (long) GetImageExtent(image); x++)
01576 {
01577 *q++=(double) ((QuantumScale*p->blue)*quantum_info->scale+
01578 quantum_info->minimum);
01579 *q++=(double) ((QuantumScale*p->green)*quantum_info->scale+
01580 quantum_info->minimum);
01581 *q++=(double) ((QuantumScale*p->red)*quantum_info->scale+
01582 quantum_info->minimum);
01583 *q++=0.0;
01584 p++;
01585 }
01586 break;
01587 }
01588 if (LocaleCompare(stream_info->map,"I") == 0)
01589 {
01590 p=GetAuthenticPixelQueue(image);
01591 if (p == (const PixelPacket *) NULL)
01592 break;
01593 for (x=0; x < (long) GetImageExtent(image); x++)
01594 {
01595 *q++=(double) ((QuantumScale*PixelIntensityToQuantum(p))*
01596 quantum_info->scale+quantum_info->minimum);
01597 p++;
01598 }
01599 break;
01600 }
01601 if (LocaleCompare(stream_info->map,"RGB") == 0)
01602 {
01603 p=GetAuthenticPixelQueue(image);
01604 if (p == (const PixelPacket *) NULL)
01605 break;
01606 for (x=0; x < (long) GetImageExtent(image); x++)
01607 {
01608 *q++=(double) ((QuantumScale*p->red)*quantum_info->scale+
01609 quantum_info->minimum);
01610 *q++=(double) ((QuantumScale*p->green)*quantum_info->scale+
01611 quantum_info->minimum);
01612 *q++=(double) ((QuantumScale*p->blue)*quantum_info->scale+
01613 quantum_info->minimum);
01614 p++;
01615 }
01616 break;
01617 }
01618 if (LocaleCompare(stream_info->map,"RGBA") == 0)
01619 {
01620 p=GetAuthenticPixelQueue(image);
01621 if (p == (const PixelPacket *) NULL)
01622 break;
01623 for (x=0; x < (long) GetImageExtent(image); x++)
01624 {
01625 *q++=(double) ((QuantumScale*p->red)*quantum_info->scale+
01626 quantum_info->minimum);
01627 *q++=(double) ((QuantumScale*p->green)*quantum_info->scale+
01628 quantum_info->minimum);
01629 *q++=(double) ((QuantumScale*p->blue)*quantum_info->scale+
01630 quantum_info->minimum);
01631 *q++=(double) ((QuantumScale*((Quantum) (QuantumRange-p->opacity)))*
01632 quantum_info->scale+quantum_info->minimum);
01633 p++;
01634 }
01635 break;
01636 }
01637 if (LocaleCompare(stream_info->map,"RGBP") == 0)
01638 {
01639 p=GetAuthenticPixelQueue(image);
01640 if (p == (const PixelPacket *) NULL)
01641 break;
01642 for (x=0; x < (long) GetImageExtent(image); x++)
01643 {
01644 *q++=(double) ((QuantumScale*p->red)*quantum_info->scale+
01645 quantum_info->minimum);
01646 *q++=(double) ((QuantumScale*p->green)*quantum_info->scale+
01647 quantum_info->minimum);
01648 *q++=(double) ((QuantumScale*p->blue)*quantum_info->scale+
01649 quantum_info->minimum);
01650 *q++=0.0;
01651 p++;
01652 }
01653 break;
01654 }
01655 p=GetAuthenticPixelQueue(image);
01656 if (p == (const PixelPacket *) NULL)
01657 break;
01658 indexes=GetAuthenticIndexQueue(image);
01659 for (x=0; x < (long) GetImageExtent(image); x++)
01660 {
01661 for (i=0; i < (long) length; i++)
01662 {
01663 *q=0;
01664 switch (quantum_map[i])
01665 {
01666 case RedQuantum:
01667 case CyanQuantum:
01668 {
01669 *q=(double) ((QuantumScale*p->red)*quantum_info->scale+
01670 quantum_info->minimum);
01671 break;
01672 }
01673 case GreenQuantum:
01674 case MagentaQuantum:
01675 {
01676 *q=(double) ((QuantumScale*p->green)*quantum_info->scale+
01677 quantum_info->minimum);
01678 break;
01679 }
01680 case BlueQuantum:
01681 case YellowQuantum:
01682 {
01683 *q=(double) ((QuantumScale*p->blue)*quantum_info->scale+
01684 quantum_info->minimum);
01685 break;
01686 }
01687 case AlphaQuantum:
01688 {
01689 *q=(double) ((QuantumScale*((Quantum) (QuantumRange-
01690 p->opacity)))*quantum_info->scale+quantum_info->minimum);
01691 break;
01692 }
01693 case OpacityQuantum:
01694 {
01695 *q=(double) ((QuantumScale*p->opacity)*quantum_info->scale+
01696 quantum_info->minimum);
01697 break;
01698 }
01699 case BlackQuantum:
01700 {
01701 if (image->colorspace == CMYKColorspace)
01702 *q=(double) ((QuantumScale*indexes[x])*quantum_info->scale+
01703 quantum_info->minimum);
01704 break;
01705 }
01706 case IndexQuantum:
01707 {
01708 *q=(double) ((QuantumScale*PixelIntensityToQuantum(p))*
01709 quantum_info->scale+quantum_info->minimum);
01710 break;
01711 }
01712 default:
01713 *q=0;
01714 }
01715 q++;
01716 }
01717 p++;
01718 }
01719 break;
01720 }
01721 case FloatPixel:
01722 {
01723 register float
01724 *q;
01725
01726 q=(float *) stream_info->pixels;
01727 if (LocaleCompare(stream_info->map,"BGR") == 0)
01728 {
01729 p=GetAuthenticPixelQueue(image);
01730 if (p == (const PixelPacket *) NULL)
01731 break;
01732 for (x=0; x < (long) GetImageExtent(image); x++)
01733 {
01734 *q++=(float) ((QuantumScale*p->blue)*quantum_info->scale+
01735 quantum_info->minimum);
01736 *q++=(float) ((QuantumScale*p->green)*quantum_info->scale+
01737 quantum_info->minimum);
01738 *q++=(float) ((QuantumScale*p->red)*quantum_info->scale+
01739 quantum_info->minimum);
01740 p++;
01741 }
01742 break;
01743 }
01744 if (LocaleCompare(stream_info->map,"BGRA") == 0)
01745 {
01746 p=GetAuthenticPixelQueue(image);
01747 if (p == (const PixelPacket *) NULL)
01748 break;
01749 for (x=0; x < (long) GetImageExtent(image); x++)
01750 {
01751 *q++=(float) ((QuantumScale*p->blue)*quantum_info->scale+
01752 quantum_info->minimum);
01753 *q++=(float) ((QuantumScale*p->green)*quantum_info->scale+
01754 quantum_info->minimum);
01755 *q++=(float) ((QuantumScale*p->red)*quantum_info->scale+
01756 quantum_info->minimum);
01757 *q++=(float) ((QuantumScale*(Quantum) (QuantumRange-p->opacity))*
01758 quantum_info->scale+quantum_info->minimum);
01759 p++;
01760 }
01761 break;
01762 }
01763 if (LocaleCompare(stream_info->map,"BGRP") == 0)
01764 {
01765 p=GetAuthenticPixelQueue(image);
01766 if (p == (const PixelPacket *) NULL)
01767 break;
01768 for (x=0; x < (long) GetImageExtent(image); x++)
01769 {
01770 *q++=(float) ((QuantumScale*p->blue)*quantum_info->scale+
01771 quantum_info->minimum);
01772 *q++=(float) ((QuantumScale*p->green)*quantum_info->scale+
01773 quantum_info->minimum);
01774 *q++=(float) ((QuantumScale*p->red)*quantum_info->scale+
01775 quantum_info->minimum);
01776 *q++=0.0;
01777 p++;
01778 }
01779 break;
01780 }
01781 if (LocaleCompare(stream_info->map,"I") == 0)
01782 {
01783 p=GetAuthenticPixelQueue(image);
01784 if (p == (const PixelPacket *) NULL)
01785 break;
01786 for (x=0; x < (long) GetImageExtent(image); x++)
01787 {
01788 *q++=(float) ((QuantumScale*PixelIntensityToQuantum(p))*
01789 quantum_info->scale+quantum_info->minimum);
01790 p++;
01791 }
01792 break;
01793 }
01794 if (LocaleCompare(stream_info->map,"RGB") == 0)
01795 {
01796 p=GetAuthenticPixelQueue(image);
01797 if (p == (const PixelPacket *) NULL)
01798 break;
01799 for (x=0; x < (long) GetImageExtent(image); x++)
01800 {
01801 *q++=(float) ((QuantumScale*p->red)*quantum_info->scale+
01802 quantum_info->minimum);
01803 *q++=(float) ((QuantumScale*p->green)*quantum_info->scale+
01804 quantum_info->minimum);
01805 *q++=(float) ((QuantumScale*p->blue)*quantum_info->scale+
01806 quantum_info->minimum);
01807 p++;
01808 }
01809 break;
01810 }
01811 if (LocaleCompare(stream_info->map,"RGBA") == 0)
01812 {
01813 p=GetAuthenticPixelQueue(image);
01814 if (p == (const PixelPacket *) NULL)
01815 break;
01816 for (x=0; x < (long) GetImageExtent(image); x++)
01817 {
01818 *q++=(float) ((QuantumScale*p->red)*quantum_info->scale+
01819 quantum_info->minimum);
01820 *q++=(float) ((QuantumScale*p->green)*quantum_info->scale+
01821 quantum_info->minimum);
01822 *q++=(float) ((QuantumScale*p->blue)*quantum_info->scale+
01823 quantum_info->minimum);
01824 *q++=(float) ((QuantumScale*((Quantum) (QuantumRange-p->opacity)))*
01825 quantum_info->scale+quantum_info->minimum);
01826 p++;
01827 }
01828 break;
01829 }
01830 if (LocaleCompare(stream_info->map,"RGBP") == 0)
01831 {
01832 p=GetAuthenticPixelQueue(image);
01833 if (p == (const PixelPacket *) NULL)
01834 break;
01835 for (x=0; x < (long) GetImageExtent(image); x++)
01836 {
01837 *q++=(float) ((QuantumScale*p->red)*quantum_info->scale+
01838 quantum_info->minimum);
01839 *q++=(float) ((QuantumScale*p->green)*quantum_info->scale+
01840 quantum_info->minimum);
01841 *q++=(float) ((QuantumScale*p->blue)*quantum_info->scale+
01842 quantum_info->minimum);
01843 *q++=0.0;
01844 p++;
01845 }
01846 break;
01847 }
01848 p=GetAuthenticPixelQueue(image);
01849 if (p == (const PixelPacket *) NULL)
01850 break;
01851 indexes=GetAuthenticIndexQueue(image);
01852 for (x=0; x < (long) GetImageExtent(image); x++)
01853 {
01854 for (i=0; i < (long) length; i++)
01855 {
01856 *q=0;
01857 switch (quantum_map[i])
01858 {
01859 case RedQuantum:
01860 case CyanQuantum:
01861 {
01862 *q=(float) ((QuantumScale*p->red)*quantum_info->scale+
01863 quantum_info->minimum);
01864 break;
01865 }
01866 case GreenQuantum:
01867 case MagentaQuantum:
01868 {
01869 *q=(float) ((QuantumScale*p->green)*quantum_info->scale+
01870 quantum_info->minimum);
01871 break;
01872 }
01873 case BlueQuantum:
01874 case YellowQuantum:
01875 {
01876 *q=(float) ((QuantumScale*p->blue)*quantum_info->scale+
01877 quantum_info->minimum);
01878 break;
01879 }
01880 case AlphaQuantum:
01881 {
01882 *q=(float) ((QuantumScale*((Quantum) (QuantumRange-
01883 p->opacity)))*quantum_info->scale+quantum_info->minimum);
01884 break;
01885 }
01886 case OpacityQuantum:
01887 {
01888 *q=(float) ((QuantumScale*p->opacity)*quantum_info->scale+
01889 quantum_info->minimum);
01890 break;
01891 }
01892 case BlackQuantum:
01893 {
01894 if (image->colorspace == CMYKColorspace)
01895 *q=(float) ((QuantumScale*indexes[x])*quantum_info->scale+
01896 quantum_info->minimum);
01897 break;
01898 }
01899 case IndexQuantum:
01900 {
01901 *q=(float) ((QuantumScale*PixelIntensityToQuantum(p))*
01902 quantum_info->scale+quantum_info->minimum);
01903 break;
01904 }
01905 default:
01906 *q=0;
01907 }
01908 q++;
01909 }
01910 p++;
01911 }
01912 break;
01913 }
01914 case IntegerPixel:
01915 {
01916 register unsigned int
01917 *q;
01918
01919 q=(unsigned int *) stream_info->pixels;
01920 if (LocaleCompare(stream_info->map,"BGR") == 0)
01921 {
01922 p=GetAuthenticPixelQueue(image);
01923 if (p == (const PixelPacket *) NULL)
01924 break;
01925 for (x=0; x < (long) GetImageExtent(image); x++)
01926 {
01927 *q++=(unsigned int) ScaleQuantumToLong(p->blue);
01928 *q++=(unsigned int) ScaleQuantumToLong(p->green);
01929 *q++=(unsigned int) ScaleQuantumToLong(p->red);
01930 p++;
01931 }
01932 break;
01933 }
01934 if (LocaleCompare(stream_info->map,"BGRA") == 0)
01935 {
01936 p=GetAuthenticPixelQueue(image);
01937 if (p == (const PixelPacket *) NULL)
01938 break;
01939 for (x=0; x < (long) GetImageExtent(image); x++)
01940 {
01941 *q++=(unsigned int) ScaleQuantumToLong(p->blue);
01942 *q++=(unsigned int) ScaleQuantumToLong(p->green);
01943 *q++=(unsigned int) ScaleQuantumToLong(p->red);
01944 *q++=(unsigned int) ScaleQuantumToLong((Quantum) (QuantumRange-
01945 p->opacity));
01946 p++;
01947 }
01948 break;
01949 }
01950 if (LocaleCompare(stream_info->map,"BGRP") == 0)
01951 {
01952 p=GetAuthenticPixelQueue(image);
01953 if (p == (const PixelPacket *) NULL)
01954 break;
01955 for (x=0; x < (long) GetImageExtent(image); x++)
01956 {
01957 *q++=(unsigned int) ScaleQuantumToLong(p->blue);
01958 *q++=(unsigned int) ScaleQuantumToLong(p->green);
01959 *q++=(unsigned int) ScaleQuantumToLong(p->red);
01960 *q++=0U;
01961 p++;
01962 }
01963 break;
01964 }
01965 if (LocaleCompare(stream_info->map,"I") == 0)
01966 {
01967 p=GetAuthenticPixelQueue(image);
01968 if (p == (const PixelPacket *) NULL)
01969 break;
01970 for (x=0; x < (long) GetImageExtent(image); x++)
01971 {
01972 *q++=(unsigned int) ScaleQuantumToLong(
01973 PixelIntensityToQuantum(p));
01974 p++;
01975 }
01976 break;
01977 }
01978 if (LocaleCompare(stream_info->map,"RGB") == 0)
01979 {
01980 p=GetAuthenticPixelQueue(image);
01981 if (p == (const PixelPacket *) NULL)
01982 break;
01983 for (x=0; x < (long) GetImageExtent(image); x++)
01984 {
01985 *q++=(unsigned int) ScaleQuantumToLong(p->red);
01986 *q++=(unsigned int) ScaleQuantumToLong(p->green);
01987 *q++=(unsigned int) ScaleQuantumToLong(p->blue);
01988 p++;
01989 }
01990 break;
01991 }
01992 if (LocaleCompare(stream_info->map,"RGBA") == 0)
01993 {
01994 p=GetAuthenticPixelQueue(image);
01995 if (p == (const PixelPacket *) NULL)
01996 break;
01997 for (x=0; x < (long) GetImageExtent(image); x++)
01998 {
01999 *q++=(unsigned int) ScaleQuantumToLong(p->red);
02000 *q++=(unsigned int) ScaleQuantumToLong(p->green);
02001 *q++=(unsigned int) ScaleQuantumToLong(p->blue);
02002 *q++=(unsigned int) ScaleQuantumToLong((Quantum)
02003 (QuantumRange-p->opacity));
02004 p++;
02005 }
02006 break;
02007 }
02008 if (LocaleCompare(stream_info->map,"RGBP") == 0)
02009 {
02010 p=GetAuthenticPixelQueue(image);
02011 if (p == (const PixelPacket *) NULL)
02012 break;
02013 for (x=0; x < (long) GetImageExtent(image); x++)
02014 {
02015 *q++=(unsigned int) ScaleQuantumToLong(p->red);
02016 *q++=(unsigned int) ScaleQuantumToLong(p->green);
02017 *q++=(unsigned int) ScaleQuantumToLong(p->blue);
02018 *q++=0U;
02019 p++;
02020 }
02021 break;
02022 }
02023 p=GetAuthenticPixelQueue(image);
02024 if (p == (const PixelPacket *) NULL)
02025 break;
02026 indexes=GetAuthenticIndexQueue(image);
02027 for (x=0; x < (long) GetImageExtent(image); x++)
02028 {
02029 for (i=0; i < (long) length; i++)
02030 {
02031 *q=0;
02032 switch (quantum_map[i])
02033 {
02034 case RedQuantum:
02035 case CyanQuantum:
02036 {
02037 *q=(unsigned int) ScaleQuantumToLong(p->red);
02038 break;
02039 }
02040 case GreenQuantum:
02041 case MagentaQuantum:
02042 {
02043 *q=(unsigned int) ScaleQuantumToLong(p->green);
02044 break;
02045 }
02046 case BlueQuantum:
02047 case YellowQuantum:
02048 {
02049 *q=(unsigned int) ScaleQuantumToLong(p->blue);
02050 break;
02051 }
02052 case AlphaQuantum:
02053 {
02054 *q=(unsigned int) ScaleQuantumToLong((Quantum) (QuantumRange-
02055 p->opacity));
02056 break;
02057 }
02058 case OpacityQuantum:
02059 {
02060 *q=(unsigned int) ScaleQuantumToLong(p->opacity);
02061 break;
02062 }
02063 case BlackQuantum:
02064 {
02065 if (image->colorspace == CMYKColorspace)
02066 *q=(unsigned int) ScaleQuantumToLong(indexes[x]);
02067 break;
02068 }
02069 case IndexQuantum:
02070 {
02071 *q=(unsigned int)
02072 ScaleQuantumToLong(PixelIntensityToQuantum(p));
02073 break;
02074 }
02075 default:
02076 *q=0;
02077 }
02078 q++;
02079 }
02080 p++;
02081 }
02082 break;
02083 }
02084 case LongPixel:
02085 {
02086 register unsigned long
02087 *q;
02088
02089 q=(unsigned long *) stream_info->pixels;
02090 if (LocaleCompare(stream_info->map,"BGR") == 0)
02091 {
02092 p=GetAuthenticPixelQueue(image);
02093 if (p == (const PixelPacket *) NULL)
02094 break;
02095 for (x=0; x < (long) GetImageExtent(image); x++)
02096 {
02097 *q++=ScaleQuantumToLong(p->blue);
02098 *q++=ScaleQuantumToLong(p->green);
02099 *q++=ScaleQuantumToLong(p->red);
02100 p++;
02101 }
02102 break;
02103 }
02104 if (LocaleCompare(stream_info->map,"BGRA") == 0)
02105 {
02106 p=GetAuthenticPixelQueue(image);
02107 if (p == (const PixelPacket *) NULL)
02108 break;
02109 for (x=0; x < (long) GetImageExtent(image); x++)
02110 {
02111 *q++=ScaleQuantumToLong(p->blue);
02112 *q++=ScaleQuantumToLong(p->green);
02113 *q++=ScaleQuantumToLong(p->red);
02114 *q++=ScaleQuantumToLong((Quantum) (QuantumRange-p->opacity));
02115 p++;
02116 }
02117 break;
02118 }
02119 if (LocaleCompare(stream_info->map,"BGRP") == 0)
02120 {
02121 p=GetAuthenticPixelQueue(image);
02122 if (p == (const PixelPacket *) NULL)
02123 break;
02124 for (x=0; x < (long) GetImageExtent(image); x++)
02125 {
02126 *q++=ScaleQuantumToLong(p->blue);
02127 *q++=ScaleQuantumToLong(p->green);
02128 *q++=ScaleQuantumToLong(p->red);
02129 *q++=0;
02130 p++;
02131 }
02132 break;
02133 }
02134 if (LocaleCompare(stream_info->map,"I") == 0)
02135 {
02136 p=GetAuthenticPixelQueue(image);
02137 if (p == (const PixelPacket *) NULL)
02138 break;
02139 for (x=0; x < (long) GetImageExtent(image); x++)
02140 {
02141 *q++=ScaleQuantumToLong(PixelIntensityToQuantum(p));
02142 p++;
02143 }
02144 break;
02145 }
02146 if (LocaleCompare(stream_info->map,"RGB") == 0)
02147 {
02148 p=GetAuthenticPixelQueue(image);
02149 if (p == (const PixelPacket *) NULL)
02150 break;
02151 for (x=0; x < (long) GetImageExtent(image); x++)
02152 {
02153 *q++=ScaleQuantumToLong(p->red);
02154 *q++=ScaleQuantumToLong(p->green);
02155 *q++=ScaleQuantumToLong(p->blue);
02156 p++;
02157 }
02158 break;
02159 }
02160 if (LocaleCompare(stream_info->map,"RGBA") == 0)
02161 {
02162 p=GetAuthenticPixelQueue(image);
02163 if (p == (const PixelPacket *) NULL)
02164 break;
02165 for (x=0; x < (long) GetImageExtent(image); x++)
02166 {
02167 *q++=ScaleQuantumToLong(p->red);
02168 *q++=ScaleQuantumToLong(p->green);
02169 *q++=ScaleQuantumToLong(p->blue);
02170 *q++=ScaleQuantumToLong((Quantum) (QuantumRange-p->opacity));
02171 p++;
02172 }
02173 break;
02174 }
02175 if (LocaleCompare(stream_info->map,"RGBP") == 0)
02176 {
02177 p=GetAuthenticPixelQueue(image);
02178 if (p == (const PixelPacket *) NULL)
02179 break;
02180 for (x=0; x < (long) GetImageExtent(image); x++)
02181 {
02182 *q++=ScaleQuantumToLong(p->red);
02183 *q++=ScaleQuantumToLong(p->green);
02184 *q++=ScaleQuantumToLong(p->blue);
02185 *q++=0;
02186 p++;
02187 }
02188 break;
02189 }
02190 p=GetAuthenticPixelQueue(image);
02191 if (p == (const PixelPacket *) NULL)
02192 break;
02193 indexes=GetAuthenticIndexQueue(image);
02194 for (x=0; x < (long) GetImageExtent(image); x++)
02195 {
02196 for (i=0; i < (long) length; i++)
02197 {
02198 *q=0;
02199 switch (quantum_map[i])
02200 {
02201 case RedQuantum:
02202 case CyanQuantum:
02203 {
02204 *q=ScaleQuantumToLong(p->red);
02205 break;
02206 }
02207 case GreenQuantum:
02208 case MagentaQuantum:
02209 {
02210 *q=ScaleQuantumToLong(p->green);
02211 break;
02212 }
02213 case BlueQuantum:
02214 case YellowQuantum:
02215 {
02216 *q=ScaleQuantumToLong(p->blue);
02217 break;
02218 }
02219 case AlphaQuantum:
02220 {
02221 *q=ScaleQuantumToLong((Quantum) (QuantumRange-p->opacity));
02222 break;
02223 }
02224 case OpacityQuantum:
02225 {
02226 *q=ScaleQuantumToLong(p->opacity);
02227 break;
02228 }
02229 case BlackQuantum:
02230 {
02231 if (image->colorspace == CMYKColorspace)
02232 *q=ScaleQuantumToLong(indexes[x]);
02233 break;
02234 }
02235 case IndexQuantum:
02236 {
02237 *q=ScaleQuantumToLong(PixelIntensityToQuantum(p));
02238 break;
02239 }
02240 default:
02241 break;
02242 }
02243 q++;
02244 }
02245 p++;
02246 }
02247 break;
02248 }
02249 case QuantumPixel:
02250 {
02251 register Quantum
02252 *q;
02253
02254 q=(Quantum *) stream_info->pixels;
02255 if (LocaleCompare(stream_info->map,"BGR") == 0)
02256 {
02257 p=GetAuthenticPixelQueue(image);
02258 if (p == (const PixelPacket *) NULL)
02259 break;
02260 for (x=0; x < (long) GetImageExtent(image); x++)
02261 {
02262 *q++=p->blue;
02263 *q++=p->green;
02264 *q++=p->red;
02265 p++;
02266 }
02267 break;
02268 }
02269 if (LocaleCompare(stream_info->map,"BGRA") == 0)
02270 {
02271 p=GetAuthenticPixelQueue(image);
02272 if (p == (const PixelPacket *) NULL)
02273 break;
02274 for (x=0; x < (long) GetImageExtent(image); x++)
02275 {
02276 *q++=p->blue;
02277 *q++=p->green;
02278 *q++=p->red;
02279 *q++=(Quantum) (QuantumRange-p->opacity);
02280 p++;
02281 }
02282 break;
02283 }
02284 if (LocaleCompare(stream_info->map,"BGRP") == 0)
02285 {
02286 p=GetAuthenticPixelQueue(image);
02287 if (p == (const PixelPacket *) NULL)
02288 break;
02289 for (x=0; x < (long) GetImageExtent(image); x++)
02290 {
02291 *q++=p->blue;
02292 *q++=p->green;
02293 *q++=p->red;
02294 *q++=0;
02295 p++;
02296 }
02297 break;
02298 }
02299 if (LocaleCompare(stream_info->map,"I") == 0)
02300 {
02301 p=GetAuthenticPixelQueue(image);
02302 if (p == (const PixelPacket *) NULL)
02303 break;
02304 for (x=0; x < (long) GetImageExtent(image); x++)
02305 {
02306 *q++=PixelIntensityToQuantum(p);
02307 p++;
02308 }
02309 break;
02310 }
02311 if (LocaleCompare(stream_info->map,"RGB") == 0)
02312 {
02313 p=GetAuthenticPixelQueue(image);
02314 if (p == (const PixelPacket *) NULL)
02315 break;
02316 for (x=0; x < (long) GetImageExtent(image); x++)
02317 {
02318 *q++=p->red;
02319 *q++=p->green;
02320 *q++=p->blue;
02321 p++;
02322 }
02323 break;
02324 }
02325 if (LocaleCompare(stream_info->map,"RGBA") == 0)
02326 {
02327 p=GetAuthenticPixelQueue(image);
02328 if (p == (const PixelPacket *) NULL)
02329 break;
02330 for (x=0; x < (long) GetImageExtent(image); x++)
02331 {
02332 *q++=p->red;
02333 *q++=p->green;
02334 *q++=p->blue;
02335 *q++=(Quantum) (QuantumRange-p->opacity);
02336 p++;
02337 }
02338 break;
02339 }
02340 if (LocaleCompare(stream_info->map,"RGBP") == 0)
02341 {
02342 p=GetAuthenticPixelQueue(image);
02343 if (p == (const PixelPacket *) NULL)
02344 break;
02345 for (x=0; x < (long) GetImageExtent(image); x++)
02346 {
02347 *q++=p->red;
02348 *q++=p->green;
02349 *q++=p->blue;
02350 *q++=0U;
02351 p++;
02352 }
02353 break;
02354 }
02355 p=GetAuthenticPixelQueue(image);
02356 if (p == (const PixelPacket *) NULL)
02357 break;
02358 indexes=GetAuthenticIndexQueue(image);
02359 for (x=0; x < (long) GetImageExtent(image); x++)
02360 {
02361 for (i=0; i < (long) length; i++)
02362 {
02363 *q=(Quantum) 0;
02364 switch (quantum_map[i])
02365 {
02366 case RedQuantum:
02367 case CyanQuantum:
02368 {
02369 *q=p->red;
02370 break;
02371 }
02372 case GreenQuantum:
02373 case MagentaQuantum:
02374 {
02375 *q=p->green;
02376 break;
02377 }
02378 case BlueQuantum:
02379 case YellowQuantum:
02380 {
02381 *q=p->blue;
02382 break;
02383 }
02384 case AlphaQuantum:
02385 {
02386 *q=(Quantum) (QuantumRange-p->opacity);
02387 break;
02388 }
02389 case OpacityQuantum:
02390 {
02391 *q=p->opacity;
02392 break;
02393 }
02394 case BlackQuantum:
02395 {
02396 if (image->colorspace == CMYKColorspace)
02397 *q=indexes[x];
02398 break;
02399 }
02400 case IndexQuantum:
02401 {
02402 *q=(PixelIntensityToQuantum(p));
02403 break;
02404 }
02405 default:
02406 *q=0;
02407 }
02408 q++;
02409 }
02410 p++;
02411 }
02412 break;
02413 }
02414 case ShortPixel:
02415 {
02416 register unsigned short
02417 *q;
02418
02419 q=(unsigned short *) stream_info->pixels;
02420 if (LocaleCompare(stream_info->map,"BGR") == 0)
02421 {
02422 p=GetAuthenticPixelQueue(image);
02423 if (p == (const PixelPacket *) NULL)
02424 break;
02425 for (x=0; x < (long) GetImageExtent(image); x++)
02426 {
02427 *q++=ScaleQuantumToShort(p->blue);
02428 *q++=ScaleQuantumToShort(p->green);
02429 *q++=ScaleQuantumToShort(p->red);
02430 p++;
02431 }
02432 break;
02433 }
02434 if (LocaleCompare(stream_info->map,"BGRA") == 0)
02435 {
02436 p=GetAuthenticPixelQueue(image);
02437 if (p == (const PixelPacket *) NULL)
02438 break;
02439 for (x=0; x < (long) GetImageExtent(image); x++)
02440 {
02441 *q++=ScaleQuantumToShort(p->blue);
02442 *q++=ScaleQuantumToShort(p->green);
02443 *q++=ScaleQuantumToShort(p->red);
02444 *q++=ScaleQuantumToShort((Quantum) (QuantumRange-p->opacity));
02445 p++;
02446 }
02447 break;
02448 }
02449 if (LocaleCompare(stream_info->map,"BGRP") == 0)
02450 {
02451 p=GetAuthenticPixelQueue(image);
02452 if (p == (const PixelPacket *) NULL)
02453 break;
02454 for (x=0; x < (long) GetImageExtent(image); x++)
02455 {
02456 *q++=ScaleQuantumToShort(p->blue);
02457 *q++=ScaleQuantumToShort(p->green);
02458 *q++=ScaleQuantumToShort(p->red);
02459 *q++=0;
02460 p++;
02461 }
02462 break;
02463 }
02464 if (LocaleCompare(stream_info->map,"I") == 0)
02465 {
02466 p=GetAuthenticPixelQueue(image);
02467 if (p == (const PixelPacket *) NULL)
02468 break;
02469 for (x=0; x < (long) GetImageExtent(image); x++)
02470 {
02471 *q++=ScaleQuantumToShort(PixelIntensityToQuantum(p));
02472 p++;
02473 }
02474 break;
02475 }
02476 if (LocaleCompare(stream_info->map,"RGB") == 0)
02477 {
02478 p=GetAuthenticPixelQueue(image);
02479 if (p == (const PixelPacket *) NULL)
02480 break;
02481 for (x=0; x < (long) GetImageExtent(image); x++)
02482 {
02483 *q++=ScaleQuantumToShort(p->red);
02484 *q++=ScaleQuantumToShort(p->green);
02485 *q++=ScaleQuantumToShort(p->blue);
02486 p++;
02487 }
02488 break;
02489 }
02490 if (LocaleCompare(stream_info->map,"RGBA") == 0)
02491 {
02492 p=GetAuthenticPixelQueue(image);
02493 if (p == (const PixelPacket *) NULL)
02494 break;
02495 for (x=0; x < (long) GetImageExtent(image); x++)
02496 {
02497 *q++=ScaleQuantumToShort(p->red);
02498 *q++=ScaleQuantumToShort(p->green);
02499 *q++=ScaleQuantumToShort(p->blue);
02500 *q++=ScaleQuantumToShort((Quantum) (QuantumRange-p->opacity));
02501 p++;
02502 }
02503 break;
02504 }
02505 if (LocaleCompare(stream_info->map,"RGBP") == 0)
02506 {
02507 p=GetAuthenticPixelQueue(image);
02508 if (p == (const PixelPacket *) NULL)
02509 break;
02510 for (x=0; x < (long) GetImageExtent(image); x++)
02511 {
02512 *q++=ScaleQuantumToShort(p->red);
02513 *q++=ScaleQuantumToShort(p->green);
02514 *q++=ScaleQuantumToShort(p->blue);
02515 *q++=0;
02516 p++;
02517 }
02518 break;
02519 }
02520 p=GetAuthenticPixelQueue(image);
02521 if (p == (const PixelPacket *) NULL)
02522 break;
02523 indexes=GetAuthenticIndexQueue(image);
02524 for (x=0; x < (long) GetImageExtent(image); x++)
02525 {
02526 for (i=0; i < (long) length; i++)
02527 {
02528 *q=0;
02529 switch (quantum_map[i])
02530 {
02531 case RedQuantum:
02532 case CyanQuantum:
02533 {
02534 *q=ScaleQuantumToShort(p->red);
02535 break;
02536 }
02537 case GreenQuantum:
02538 case MagentaQuantum:
02539 {
02540 *q=ScaleQuantumToShort(p->green);
02541 break;
02542 }
02543 case BlueQuantum:
02544 case YellowQuantum:
02545 {
02546 *q=ScaleQuantumToShort(p->blue);
02547 break;
02548 }
02549 case AlphaQuantum:
02550 {
02551 *q=ScaleQuantumToShort((Quantum) (QuantumRange-p->opacity));
02552 break;
02553 }
02554 case OpacityQuantum:
02555 {
02556 *q=ScaleQuantumToShort(p->opacity);
02557 break;
02558 }
02559 case BlackQuantum:
02560 {
02561 if (image->colorspace == CMYKColorspace)
02562 *q=ScaleQuantumToShort(indexes[x]);
02563 break;
02564 }
02565 case IndexQuantum:
02566 {
02567 *q=ScaleQuantumToShort(PixelIntensityToQuantum(p));
02568 break;
02569 }
02570 default:
02571 break;
02572 }
02573 q++;
02574 }
02575 p++;
02576 }
02577 break;
02578 }
02579 default:
02580 {
02581 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
02582 (void) ThrowMagickException(exception,GetMagickModule(),OptionError,
02583 "UnrecognizedPixelMap","`%s'",stream_info->map);
02584 break;
02585 }
02586 }
02587 quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map);
02588 return(MagickTrue);
02589 }
02590
02591
02592
02593
02594
02595
02596
02597
02598
02599
02600
02601
02602
02603
02604
02605
02606
02607
02608
02609
02610
02611
02612
02613
02614
02615
02616
02617 static MagickBooleanType SyncAuthenticPixelsStream(Image *image,
02618 ExceptionInfo *exception)
02619 {
02620 CacheInfo
02621 *cache_info;
02622
02623 size_t
02624 length;
02625
02626 StreamHandler
02627 stream_handler;
02628
02629 assert(image != (Image *) NULL);
02630 assert(image->signature == MagickSignature);
02631 if (image->debug != MagickFalse)
02632 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
02633 cache_info=(CacheInfo *) image->cache;
02634 assert(cache_info->signature == MagickSignature);
02635 stream_handler=GetBlobStreamHandler(image);
02636 if (stream_handler == (StreamHandler) NULL)
02637 {
02638 (void) ThrowMagickException(exception,GetMagickModule(),StreamError,
02639 "NoStreamHandlerIsDefined","`%s'",image->filename);
02640 return(MagickFalse);
02641 }
02642 length=stream_handler(image,cache_info->pixels,(size_t) cache_info->columns);
02643 return(length == cache_info->columns ? MagickTrue : MagickFalse);
02644 }
02645
02646
02647
02648
02649
02650
02651
02652
02653
02654
02655
02656
02657
02658
02659
02660
02661
02662
02663
02664
02665
02666
02667
02668
02669
02670
02671
02672 MagickExport MagickBooleanType WriteStream(const ImageInfo *image_info,
02673 Image *image,StreamHandler stream)
02674 {
02675 ImageInfo
02676 *write_info;
02677
02678 MagickBooleanType
02679 status;
02680
02681 assert(image_info != (ImageInfo *) NULL);
02682 assert(image_info->signature == MagickSignature);
02683 if (image_info->debug != MagickFalse)
02684 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
02685 image_info->filename);
02686 assert(image != (Image *) NULL);
02687 assert(image->signature == MagickSignature);
02688 write_info=CloneImageInfo(image_info);
02689 write_info->stream=stream;
02690 status=WriteImage(write_info,image);
02691 write_info=DestroyImageInfo(write_info);
02692 return(status);
02693 }