cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
| 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 % |
| 9 | % SS T R R E A A M M % |
| 10 | % SSSSS T R R EEEEE A A M M % |
| 11 | % % |
| 12 | % % |
| 13 | % MagickCore Pixel Stream Methods % |
| 14 | % % |
| 15 | % Software Design % |
| 16 | % John Cristy % |
| 17 | % March 2000 % |
| 18 | % % |
| 19 | % % |
cristy | 1454be7 | 2011-12-19 01:52:48 +0000 | [diff] [blame] | 20 | % Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 21 | % dedicated to making software imaging solutions freely available. % |
| 22 | % % |
| 23 | % You may not use this file except in compliance with the License. You may % |
| 24 | % obtain a copy of the License at % |
| 25 | % % |
| 26 | % http://www.imagemagick.org/script/license.php % |
| 27 | % % |
| 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. % |
| 33 | % % |
| 34 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 35 | % |
| 36 | % |
| 37 | % |
| 38 | */ |
| 39 | |
| 40 | /* |
| 41 | Include declarations. |
| 42 | */ |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 43 | #include "MagickCore/studio.h" |
| 44 | #include "MagickCore/blob.h" |
| 45 | #include "MagickCore/blob-private.h" |
| 46 | #include "MagickCore/cache.h" |
| 47 | #include "MagickCore/cache-private.h" |
| 48 | #include "MagickCore/color-private.h" |
| 49 | #include "MagickCore/composite-private.h" |
| 50 | #include "MagickCore/constitute.h" |
| 51 | #include "MagickCore/exception.h" |
| 52 | #include "MagickCore/exception-private.h" |
| 53 | #include "MagickCore/geometry.h" |
| 54 | #include "MagickCore/memory_.h" |
| 55 | #include "MagickCore/pixel.h" |
| 56 | #include "MagickCore/pixel-accessor.h" |
| 57 | #include "MagickCore/quantum.h" |
| 58 | #include "MagickCore/quantum-private.h" |
| 59 | #include "MagickCore/semaphore.h" |
| 60 | #include "MagickCore/stream.h" |
| 61 | #include "MagickCore/stream-private.h" |
| 62 | #include "MagickCore/string_.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 63 | |
| 64 | /* |
| 65 | Typedef declaractions. |
| 66 | */ |
| 67 | struct _StreamInfo |
| 68 | { |
| 69 | const ImageInfo |
| 70 | *image_info; |
| 71 | |
| 72 | const Image |
| 73 | *image; |
| 74 | |
| 75 | Image |
| 76 | *stream; |
| 77 | |
| 78 | QuantumInfo |
| 79 | *quantum_info; |
| 80 | |
| 81 | char |
| 82 | *map; |
| 83 | |
| 84 | StorageType |
| 85 | storage_type; |
| 86 | |
| 87 | unsigned char |
| 88 | *pixels; |
| 89 | |
| 90 | RectangleInfo |
| 91 | extract_info; |
| 92 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 93 | ssize_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 94 | y; |
| 95 | |
| 96 | ExceptionInfo |
| 97 | *exception; |
| 98 | |
| 99 | const void |
| 100 | *client_data; |
| 101 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 102 | size_t |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 103 | signature; |
| 104 | }; |
| 105 | |
| 106 | /* |
| 107 | Declare pixel cache interfaces. |
| 108 | */ |
| 109 | #if defined(__cplusplus) || defined(c_plusplus) |
| 110 | extern "C" { |
| 111 | #endif |
| 112 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 113 | static const Quantum |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 114 | *GetVirtualPixelStream(const Image *,const VirtualPixelMethod,const ssize_t, |
| 115 | const ssize_t,const size_t,const size_t,ExceptionInfo *); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 116 | |
| 117 | static MagickBooleanType |
| 118 | StreamImagePixels(const StreamInfo *,const Image *,ExceptionInfo *), |
| 119 | SyncAuthenticPixelsStream(Image *,ExceptionInfo *); |
| 120 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 121 | static Quantum |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 122 | *QueueAuthenticPixelsStream(Image *,const ssize_t,const ssize_t,const size_t, |
| 123 | const size_t,ExceptionInfo *); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 124 | |
| 125 | #if defined(__cplusplus) || defined(c_plusplus) |
| 126 | } |
| 127 | #endif |
| 128 | |
| 129 | /* |
| 130 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 131 | % % |
| 132 | % % |
| 133 | % % |
| 134 | + A c q u i r e S t r e a m I n f o % |
| 135 | % % |
| 136 | % % |
| 137 | % % |
| 138 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 139 | % |
| 140 | % AcquireStreamInfo() allocates the StreamInfo structure. |
| 141 | % |
| 142 | % The format of the AcquireStreamInfo method is: |
| 143 | % |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 144 | % StreamInfo *AcquireStreamInfo(const ImageInfo *image_info, |
| 145 | % ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 146 | % |
| 147 | % A description of each parameter follows: |
| 148 | % |
| 149 | % o image_info: the image info. |
| 150 | % |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 151 | % o exception: return any errors or warnings in this structure. |
| 152 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 153 | */ |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 154 | MagickExport StreamInfo *AcquireStreamInfo(const ImageInfo *image_info, |
| 155 | ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 156 | { |
| 157 | StreamInfo |
| 158 | *stream_info; |
| 159 | |
cristy | 73bd4a5 | 2010-10-05 11:24:23 +0000 | [diff] [blame] | 160 | stream_info=(StreamInfo *) AcquireMagickMemory(sizeof(*stream_info)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 161 | if (stream_info == (StreamInfo *) NULL) |
| 162 | ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); |
| 163 | (void) ResetMagickMemory(stream_info,0,sizeof(*stream_info)); |
cristy | 39c2e21 | 2012-08-18 18:14:34 +0000 | [diff] [blame] | 164 | stream_info->pixels=(unsigned char *) AcquireAlignedMemory(1, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 165 | sizeof(*stream_info->pixels)); |
| 166 | if (stream_info->pixels == (unsigned char *) NULL) |
| 167 | ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); |
| 168 | stream_info->map=ConstantString("RGB"); |
| 169 | stream_info->storage_type=CharPixel; |
cristy | 9950d57 | 2011-10-01 18:22:35 +0000 | [diff] [blame] | 170 | stream_info->stream=AcquireImage(image_info,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 171 | stream_info->signature=MagickSignature; |
| 172 | return(stream_info); |
| 173 | } |
| 174 | |
| 175 | /* |
| 176 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 177 | % % |
| 178 | % % |
| 179 | % % |
| 180 | + D e s t r o y P i x e l S t r e a m % |
| 181 | % % |
| 182 | % % |
| 183 | % % |
| 184 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 185 | % |
| 186 | % DestroyPixelStream() deallocates memory associated with the pixel stream. |
| 187 | % |
| 188 | % The format of the DestroyPixelStream() method is: |
| 189 | % |
| 190 | % void DestroyPixelStream(Image *image) |
| 191 | % |
| 192 | % A description of each parameter follows: |
| 193 | % |
| 194 | % o image: the image. |
| 195 | % |
| 196 | */ |
| 197 | |
| 198 | static inline void RelinquishStreamPixels(CacheInfo *cache_info) |
| 199 | { |
| 200 | assert(cache_info != (CacheInfo *) NULL); |
| 201 | if (cache_info->mapped == MagickFalse) |
cristy | 39c2e21 | 2012-08-18 18:14:34 +0000 | [diff] [blame] | 202 | (void) RelinquishAlignedMemory(cache_info->pixels); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 203 | else |
| 204 | (void) UnmapBlob(cache_info->pixels,(size_t) cache_info->length); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 205 | cache_info->pixels=(Quantum *) NULL; |
| 206 | cache_info->metacontent=(void *) NULL; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 207 | cache_info->length=0; |
| 208 | cache_info->mapped=MagickFalse; |
| 209 | } |
| 210 | |
| 211 | static void DestroyPixelStream(Image *image) |
| 212 | { |
| 213 | CacheInfo |
| 214 | *cache_info; |
| 215 | |
| 216 | MagickBooleanType |
| 217 | destroy; |
| 218 | |
| 219 | assert(image != (Image *) NULL); |
| 220 | assert(image->signature == MagickSignature); |
| 221 | if (image->debug != MagickFalse) |
| 222 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 223 | cache_info=(CacheInfo *) image->cache; |
| 224 | assert(cache_info->signature == MagickSignature); |
| 225 | destroy=MagickFalse; |
cristy | f84a193 | 2010-01-03 18:00:18 +0000 | [diff] [blame] | 226 | LockSemaphoreInfo(cache_info->semaphore); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 227 | cache_info->reference_count--; |
| 228 | if (cache_info->reference_count == 0) |
| 229 | destroy=MagickTrue; |
cristy | f84a193 | 2010-01-03 18:00:18 +0000 | [diff] [blame] | 230 | UnlockSemaphoreInfo(cache_info->semaphore); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 231 | if (destroy == MagickFalse) |
| 232 | return; |
| 233 | RelinquishStreamPixels(cache_info); |
| 234 | if (cache_info->nexus_info != (NexusInfo **) NULL) |
| 235 | cache_info->nexus_info=DestroyPixelCacheNexus(cache_info->nexus_info, |
| 236 | cache_info->number_threads); |
| 237 | if (cache_info->disk_semaphore != (SemaphoreInfo *) NULL) |
| 238 | DestroySemaphoreInfo(&cache_info->disk_semaphore); |
| 239 | if (cache_info->semaphore != (SemaphoreInfo *) NULL) |
| 240 | DestroySemaphoreInfo(&cache_info->semaphore); |
| 241 | cache_info=(CacheInfo *) RelinquishMagickMemory(cache_info); |
| 242 | } |
| 243 | |
| 244 | /* |
| 245 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 246 | % % |
| 247 | % % |
| 248 | % % |
| 249 | + D e s t r o y S t r e a m I n f o % |
| 250 | % % |
| 251 | % % |
| 252 | % % |
| 253 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 254 | % |
| 255 | % DestroyStreamInfo() destroys memory associated with the StreamInfo |
| 256 | % structure. |
| 257 | % |
| 258 | % The format of the DestroyStreamInfo method is: |
| 259 | % |
| 260 | % StreamInfo *DestroyStreamInfo(StreamInfo *stream_info) |
| 261 | % |
| 262 | % A description of each parameter follows: |
| 263 | % |
| 264 | % o stream_info: the stream info. |
| 265 | % |
| 266 | */ |
| 267 | MagickExport StreamInfo *DestroyStreamInfo(StreamInfo *stream_info) |
| 268 | { |
| 269 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); |
| 270 | assert(stream_info != (StreamInfo *) NULL); |
| 271 | assert(stream_info->signature == MagickSignature); |
| 272 | if (stream_info->map != (char *) NULL) |
| 273 | stream_info->map=DestroyString(stream_info->map); |
| 274 | if (stream_info->pixels != (unsigned char *) NULL) |
cristy | 39c2e21 | 2012-08-18 18:14:34 +0000 | [diff] [blame] | 275 | stream_info->pixels=(unsigned char *) RelinquishAlignedMemory( |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 276 | stream_info->pixels); |
| 277 | if (stream_info->stream != (Image *) NULL) |
| 278 | { |
| 279 | (void) CloseBlob(stream_info->stream); |
| 280 | stream_info->stream=DestroyImage(stream_info->stream); |
| 281 | } |
| 282 | if (stream_info->quantum_info != (QuantumInfo *) NULL) |
| 283 | stream_info->quantum_info=DestroyQuantumInfo(stream_info->quantum_info); |
| 284 | stream_info->signature=(~MagickSignature); |
| 285 | stream_info=(StreamInfo *) RelinquishMagickMemory(stream_info); |
| 286 | return(stream_info); |
| 287 | } |
| 288 | |
| 289 | /* |
| 290 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 291 | % % |
| 292 | % % |
| 293 | % % |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 294 | + G e t A u t h e n t i c M e t a c o n t e n t F r o m S t r e a m % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 295 | % % |
| 296 | % % |
| 297 | % % |
| 298 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 299 | % |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 300 | % GetAuthenticMetacontentFromStream() returns the metacontent corresponding |
| 301 | % with the last call to QueueAuthenticPixelsStream() or |
| 302 | % GetAuthenticPixelsStream(). |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 303 | % |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 304 | % The format of the GetAuthenticMetacontentFromStream() method is: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 305 | % |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 306 | % void *GetAuthenticMetacontentFromStream(const Image *image) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 307 | % |
| 308 | % A description of each parameter follows: |
| 309 | % |
| 310 | % o image: the image. |
| 311 | % |
| 312 | */ |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 313 | static void *GetAuthenticMetacontentFromStream(const Image *image) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 314 | { |
| 315 | CacheInfo |
| 316 | *cache_info; |
| 317 | |
| 318 | assert(image != (Image *) NULL); |
| 319 | assert(image->signature == MagickSignature); |
| 320 | if (image->debug != MagickFalse) |
| 321 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 322 | cache_info=(CacheInfo *) image->cache; |
| 323 | assert(cache_info->signature == MagickSignature); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 324 | return(cache_info->metacontent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | /* |
| 328 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 329 | % % |
| 330 | % % |
| 331 | % % |
| 332 | + G e t A u t h e n t i c P i x e l S t r e a m % |
| 333 | % % |
| 334 | % % |
| 335 | % % |
| 336 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 337 | % |
| 338 | % GetAuthenticPixelsStream() gets pixels from the in-memory or disk pixel |
| 339 | % cache as defined by the geometry parameters. A pointer to the pixels is |
| 340 | % returned if the pixels are transferred, otherwise a NULL is returned. For |
| 341 | % streams this method is a no-op. |
| 342 | % |
| 343 | % The format of the GetAuthenticPixelsStream() method is: |
| 344 | % |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 345 | % Quantum *GetAuthenticPixelsStream(Image *image,const ssize_t x, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 346 | % const ssize_t y,const size_t columns,const size_t rows, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 347 | % ExceptionInfo *exception) |
| 348 | % |
| 349 | % A description of each parameter follows: |
| 350 | % |
| 351 | % o image: the image. |
| 352 | % |
| 353 | % o x,y,columns,rows: These values define the perimeter of a region of |
| 354 | % pixels. |
| 355 | % |
| 356 | % o exception: return any errors or warnings in this structure. |
| 357 | % |
| 358 | */ |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 359 | static Quantum *GetAuthenticPixelsStream(Image *image,const ssize_t x, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 360 | const ssize_t y,const size_t columns,const size_t rows, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 361 | ExceptionInfo *exception) |
| 362 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 363 | Quantum |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 364 | *pixels; |
| 365 | |
| 366 | assert(image != (Image *) NULL); |
| 367 | assert(image->signature == MagickSignature); |
| 368 | if (image->debug != MagickFalse) |
| 369 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 370 | pixels=QueueAuthenticPixelsStream(image,x,y,columns,rows,exception); |
| 371 | return(pixels); |
| 372 | } |
| 373 | |
| 374 | /* |
| 375 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 376 | % % |
| 377 | % % |
| 378 | % % |
| 379 | + 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 % |
| 380 | % % |
| 381 | % % |
| 382 | % % |
| 383 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 384 | % |
| 385 | % GetAuthenticPixelsFromStream() returns the pixels associated with the last |
| 386 | % call to QueueAuthenticPixelsStream() or GetAuthenticPixelsStream(). |
| 387 | % |
| 388 | % The format of the GetAuthenticPixelsFromStream() method is: |
| 389 | % |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 390 | % Quantum *GetAuthenticPixelsFromStream(const Image image) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 391 | % |
| 392 | % A description of each parameter follows: |
| 393 | % |
| 394 | % o image: the image. |
| 395 | % |
| 396 | */ |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 397 | static Quantum *GetAuthenticPixelsFromStream(const Image *image) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 398 | { |
| 399 | CacheInfo |
| 400 | *cache_info; |
| 401 | |
| 402 | assert(image != (Image *) NULL); |
| 403 | assert(image->signature == MagickSignature); |
| 404 | if (image->debug != MagickFalse) |
| 405 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 406 | cache_info=(CacheInfo *) image->cache; |
| 407 | assert(cache_info->signature == MagickSignature); |
| 408 | return(cache_info->pixels); |
| 409 | } |
| 410 | |
| 411 | /* |
| 412 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 413 | % % |
| 414 | % % |
| 415 | % % |
| 416 | + 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 % |
| 417 | % % |
| 418 | % % |
| 419 | % % |
| 420 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 421 | % |
| 422 | % GetOneAuthenticPixelFromStream() returns a single pixel at the specified |
| 423 | % (x,y) location. The image background color is returned if an error occurs. |
| 424 | % |
| 425 | % The format of the GetOneAuthenticPixelFromStream() method is: |
| 426 | % |
| 427 | % MagickBooleanType GetOneAuthenticPixelFromStream(const Image image, |
cristy | 2ed42f6 | 2011-10-02 19:49:57 +0000 | [diff] [blame] | 428 | % const ssize_t x,const ssize_t y,Quantum *pixel, |
cristy | cfae90a | 2010-10-04 14:43:33 +0000 | [diff] [blame] | 429 | % ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 430 | % |
| 431 | % A description of each parameter follows: |
| 432 | % |
| 433 | % o image: the image. |
| 434 | % |
| 435 | % o pixel: return a pixel at the specified (x,y) location. |
| 436 | % |
| 437 | % o x,y: These values define the location of the pixel to return. |
| 438 | % |
| 439 | % o exception: return any errors or warnings in this structure. |
| 440 | % |
| 441 | */ |
| 442 | static MagickBooleanType GetOneAuthenticPixelFromStream(Image *image, |
cristy | 2ed42f6 | 2011-10-02 19:49:57 +0000 | [diff] [blame] | 443 | const ssize_t x,const ssize_t y,Quantum *pixel,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 444 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 445 | register Quantum |
| 446 | *q; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 447 | |
cristy | 2ed42f6 | 2011-10-02 19:49:57 +0000 | [diff] [blame] | 448 | register ssize_t |
| 449 | i; |
| 450 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 451 | assert(image != (Image *) NULL); |
| 452 | assert(image->signature == MagickSignature); |
cristy | 2ed42f6 | 2011-10-02 19:49:57 +0000 | [diff] [blame] | 453 | (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel)); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 454 | q=GetAuthenticPixelsStream(image,x,y,1,1,exception); |
| 455 | if (q != (Quantum *) NULL) |
cristy | 2ed42f6 | 2011-10-02 19:49:57 +0000 | [diff] [blame] | 456 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 457 | pixel[RedPixelChannel]=ClampToQuantum(image->background_color.red); |
| 458 | pixel[GreenPixelChannel]=ClampToQuantum(image->background_color.green); |
| 459 | pixel[BluePixelChannel]=ClampToQuantum(image->background_color.blue); |
cristy | d09f880 | 2012-02-04 16:44:10 +0000 | [diff] [blame] | 460 | pixel[BlackPixelChannel]=ClampToQuantum(image->background_color.black); |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 461 | pixel[AlphaPixelChannel]=ClampToQuantum(image->background_color.alpha); |
cristy | 2ed42f6 | 2011-10-02 19:49:57 +0000 | [diff] [blame] | 462 | return(MagickFalse); |
| 463 | } |
| 464 | for (i=0; i < (ssize_t) GetPixelChannels(image); i++) |
| 465 | { |
| 466 | PixelChannel |
| 467 | channel; |
| 468 | |
cristy | e2a912b | 2011-12-05 20:02:07 +0000 | [diff] [blame] | 469 | channel=GetPixelChannelMapChannel(image,i); |
cristy | 2ed42f6 | 2011-10-02 19:49:57 +0000 | [diff] [blame] | 470 | pixel[channel]=q[i]; |
| 471 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 472 | return(MagickTrue); |
| 473 | } |
| 474 | |
| 475 | /* |
| 476 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 477 | % % |
| 478 | % % |
| 479 | % % |
| 480 | + 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 % |
| 481 | % % |
| 482 | % % |
| 483 | % % |
| 484 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 485 | % |
| 486 | % GetOneVirtualPixelFromStream() returns a single pixel at the specified |
| 487 | % (x.y) location. The image background color is returned if an error occurs. |
| 488 | % |
| 489 | % The format of the GetOneVirtualPixelFromStream() method is: |
| 490 | % |
| 491 | % MagickBooleanType GetOneVirtualPixelFromStream(const Image image, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 492 | % const VirtualPixelMethod virtual_pixel_method,const ssize_t x, |
cristy | 2ed42f6 | 2011-10-02 19:49:57 +0000 | [diff] [blame] | 493 | % const ssize_t y,Quantum *pixel,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 494 | % |
| 495 | % A description of each parameter follows: |
| 496 | % |
| 497 | % o image: the image. |
| 498 | % |
| 499 | % o virtual_pixel_method: the virtual pixel method. |
| 500 | % |
| 501 | % o x,y: These values define the location of the pixel to return. |
| 502 | % |
| 503 | % o pixel: return a pixel at the specified (x,y) location. |
| 504 | % |
| 505 | % o exception: return any errors or warnings in this structure. |
| 506 | % |
| 507 | */ |
| 508 | static MagickBooleanType GetOneVirtualPixelFromStream(const Image *image, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 509 | const VirtualPixelMethod virtual_pixel_method,const ssize_t x,const ssize_t y, |
cristy | 2ed42f6 | 2011-10-02 19:49:57 +0000 | [diff] [blame] | 510 | Quantum *pixel,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 511 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 512 | const Quantum |
cristy | 01cdc90 | 2011-08-31 01:05:44 +0000 | [diff] [blame] | 513 | *p; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 514 | |
cristy | 2ed42f6 | 2011-10-02 19:49:57 +0000 | [diff] [blame] | 515 | register ssize_t |
| 516 | i; |
| 517 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 518 | assert(image != (Image *) NULL); |
| 519 | assert(image->signature == MagickSignature); |
cristy | 2ed42f6 | 2011-10-02 19:49:57 +0000 | [diff] [blame] | 520 | (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel)); |
cristy | 01cdc90 | 2011-08-31 01:05:44 +0000 | [diff] [blame] | 521 | p=GetVirtualPixelStream(image,virtual_pixel_method,x,y,1,1,exception); |
| 522 | if (p == (const Quantum *) NULL) |
cristy | 2ed42f6 | 2011-10-02 19:49:57 +0000 | [diff] [blame] | 523 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 524 | pixel[RedPixelChannel]=ClampToQuantum(image->background_color.red); |
| 525 | pixel[GreenPixelChannel]=ClampToQuantum(image->background_color.green); |
| 526 | pixel[BluePixelChannel]=ClampToQuantum(image->background_color.blue); |
cristy | d09f880 | 2012-02-04 16:44:10 +0000 | [diff] [blame] | 527 | pixel[BlackPixelChannel]=ClampToQuantum(image->background_color.black); |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 528 | pixel[AlphaPixelChannel]=ClampToQuantum(image->background_color.alpha); |
cristy | 2ed42f6 | 2011-10-02 19:49:57 +0000 | [diff] [blame] | 529 | return(MagickFalse); |
| 530 | } |
| 531 | for (i=0; i < (ssize_t) GetPixelChannels(image); i++) |
| 532 | { |
| 533 | PixelChannel |
| 534 | channel; |
| 535 | |
cristy | e2a912b | 2011-12-05 20:02:07 +0000 | [diff] [blame] | 536 | channel=GetPixelChannelMapChannel(image,i); |
cristy | 2ed42f6 | 2011-10-02 19:49:57 +0000 | [diff] [blame] | 537 | pixel[channel]=p[i]; |
| 538 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 539 | return(MagickTrue); |
| 540 | } |
| 541 | |
| 542 | /* |
| 543 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 544 | % % |
| 545 | % % |
| 546 | % % |
| 547 | + G e t S t r e a m I n f o C l i e n t D a t a % |
| 548 | % % |
| 549 | % % |
| 550 | % % |
| 551 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 552 | % |
| 553 | % GetStreamInfoClientData() gets the stream info client data. |
| 554 | % |
cristy | 7832dc2 | 2011-09-05 01:21:53 +0000 | [diff] [blame] | 555 | % The format of the GetStreamInfoClientData method is: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 556 | % |
| 557 | % const void *GetStreamInfoClientData(StreamInfo *stream_info) |
| 558 | % |
| 559 | % A description of each parameter follows: |
| 560 | % |
| 561 | % o stream_info: the stream info. |
| 562 | % |
| 563 | */ |
cristy | 7832dc2 | 2011-09-05 01:21:53 +0000 | [diff] [blame] | 564 | MagickPrivate const void *GetStreamInfoClientData(StreamInfo *stream_info) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 565 | { |
| 566 | assert(stream_info != (StreamInfo *) NULL); |
| 567 | assert(stream_info->signature == MagickSignature); |
| 568 | return(stream_info->client_data); |
| 569 | } |
| 570 | |
| 571 | /* |
| 572 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 573 | % % |
| 574 | % % |
| 575 | % % |
| 576 | + 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 % |
| 577 | % % |
| 578 | % % |
| 579 | % % |
| 580 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 581 | % |
| 582 | % GetVirtualPixelsStream() returns the pixels associated with the last |
| 583 | % call to QueueAuthenticPixelsStream() or GetVirtualPixelStream(). |
| 584 | % |
| 585 | % The format of the GetVirtualPixelsStream() method is: |
| 586 | % |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 587 | % const Quantum *GetVirtualPixelsStream(const Image *image) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 588 | % |
| 589 | % A description of each parameter follows: |
| 590 | % |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 591 | % o pixels: return the pixels associated corresponding with the last call to |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 592 | % QueueAuthenticPixelsStream() or GetVirtualPixelStream(). |
| 593 | % |
| 594 | % o image: the image. |
| 595 | % |
| 596 | */ |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 597 | static const Quantum *GetVirtualPixelsStream(const Image *image) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 598 | { |
| 599 | CacheInfo |
| 600 | *cache_info; |
| 601 | |
| 602 | assert(image != (Image *) NULL); |
| 603 | assert(image->signature == MagickSignature); |
| 604 | if (image->debug != MagickFalse) |
| 605 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 606 | cache_info=(CacheInfo *) image->cache; |
| 607 | assert(cache_info->signature == MagickSignature); |
| 608 | return(cache_info->pixels); |
| 609 | } |
| 610 | |
| 611 | /* |
| 612 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 613 | % % |
| 614 | % % |
| 615 | % % |
| 616 | + 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 % |
| 617 | % % |
| 618 | % % |
| 619 | % % |
| 620 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 621 | % |
cristy | 20cc087 | 2012-08-20 00:01:19 +0000 | [diff] [blame] | 622 | % GetVirtualMetacontentFromStream() returns the associated pixel channels |
| 623 | % corresponding with the last call to QueueAuthenticPixelsStream() or |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 624 | % GetVirtualPixelStream(). |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 625 | % |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 626 | % The format of the GetVirtualMetacontentFromStream() method is: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 627 | % |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 628 | % const void *GetVirtualMetacontentFromStream(const Image *image) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 629 | % |
| 630 | % A description of each parameter follows: |
| 631 | % |
| 632 | % o image: the image. |
| 633 | % |
| 634 | */ |
cristy | 20cc087 | 2012-08-20 00:01:19 +0000 | [diff] [blame] | 635 | static const void *GetVirtualMetacontentFromStream(const Image *image) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 636 | { |
| 637 | CacheInfo |
| 638 | *cache_info; |
| 639 | |
| 640 | assert(image != (Image *) NULL); |
| 641 | assert(image->signature == MagickSignature); |
| 642 | if (image->debug != MagickFalse) |
| 643 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 644 | cache_info=(CacheInfo *) image->cache; |
| 645 | assert(cache_info->signature == MagickSignature); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 646 | return(cache_info->metacontent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 647 | } |
| 648 | |
| 649 | /* |
| 650 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 651 | % % |
| 652 | % % |
| 653 | % % |
| 654 | + G e t V i r t u a l P i x e l S t r e a m % |
| 655 | % % |
| 656 | % % |
| 657 | % % |
| 658 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 659 | % |
| 660 | % GetVirtualPixelStream() gets pixels from the in-memory or disk pixel cache as |
| 661 | % defined by the geometry parameters. A pointer to the pixels is returned if |
| 662 | % the pixels are transferred, otherwise a NULL is returned. For streams this |
| 663 | % method is a no-op. |
| 664 | % |
| 665 | % The format of the GetVirtualPixelStream() method is: |
| 666 | % |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 667 | % const Quantum *GetVirtualPixelStream(const Image *image, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 668 | % const VirtualPixelMethod virtual_pixel_method,const ssize_t x, |
| 669 | % const ssize_t y,const size_t columns,const size_t rows, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 670 | % ExceptionInfo *exception) |
| 671 | % |
| 672 | % A description of each parameter follows: |
| 673 | % |
| 674 | % o image: the image. |
| 675 | % |
| 676 | % o virtual_pixel_method: the virtual pixel method. |
| 677 | % |
| 678 | % o x,y,columns,rows: These values define the perimeter of a region of |
| 679 | % pixels. |
| 680 | % |
| 681 | % o exception: return any errors or warnings in this structure. |
| 682 | % |
| 683 | */ |
| 684 | |
| 685 | static inline MagickBooleanType AcquireStreamPixels(CacheInfo *cache_info, |
| 686 | ExceptionInfo *exception) |
| 687 | { |
| 688 | if (cache_info->length != (MagickSizeType) ((size_t) cache_info->length)) |
| 689 | return(MagickFalse); |
| 690 | cache_info->mapped=MagickFalse; |
cristy | 39c2e21 | 2012-08-18 18:14:34 +0000 | [diff] [blame] | 691 | cache_info->pixels=(Quantum *) AcquireAlignedMemory(1,(size_t) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 692 | cache_info->length); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 693 | if (cache_info->pixels == (Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 694 | { |
| 695 | cache_info->mapped=MagickTrue; |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 696 | cache_info->pixels=(Quantum *) MapBlob(-1,IOMode,0,(size_t) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 697 | cache_info->length); |
| 698 | } |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 699 | if (cache_info->pixels == (Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 700 | { |
| 701 | (void) ThrowMagickException(exception,GetMagickModule(), |
cristy | 20cc087 | 2012-08-20 00:01:19 +0000 | [diff] [blame] | 702 | ResourceLimitError,"MemoryAllocationFailed","'%s'", |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 703 | cache_info->filename); |
| 704 | return(MagickFalse); |
| 705 | } |
| 706 | return(MagickTrue); |
| 707 | } |
| 708 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 709 | static const Quantum *GetVirtualPixelStream(const Image *image, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 710 | const VirtualPixelMethod magick_unused(virtual_pixel_method),const ssize_t x, |
| 711 | const ssize_t y,const size_t columns,const size_t rows, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 712 | ExceptionInfo *exception) |
| 713 | { |
| 714 | CacheInfo |
| 715 | *cache_info; |
| 716 | |
| 717 | MagickBooleanType |
| 718 | status; |
| 719 | |
| 720 | MagickSizeType |
| 721 | number_pixels; |
| 722 | |
| 723 | size_t |
| 724 | length; |
| 725 | |
| 726 | /* |
| 727 | Validate pixel cache geometry. |
| 728 | */ |
| 729 | assert(image != (const Image *) NULL); |
| 730 | assert(image->signature == MagickSignature); |
| 731 | if (image->debug != MagickFalse) |
| 732 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
cristy | 5dd7188 | 2010-08-01 20:53:13 +0000 | [diff] [blame] | 733 | if ((x < 0) || (y < 0) || |
| 734 | ((x+(ssize_t) columns) > (ssize_t) image->columns) || |
| 735 | ((y+(ssize_t) rows) > (ssize_t) image->rows) || |
| 736 | (columns == 0) || (rows == 0)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 737 | { |
| 738 | (void) ThrowMagickException(exception,GetMagickModule(),StreamError, |
cristy | 20cc087 | 2012-08-20 00:01:19 +0000 | [diff] [blame] | 739 | "ImageDoesNotContainTheStreamGeometry","'%s'",image->filename); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 740 | return((Quantum *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 741 | } |
| 742 | cache_info=(CacheInfo *) image->cache; |
| 743 | assert(cache_info->signature == MagickSignature); |
| 744 | /* |
| 745 | Pixels are stored in a temporary buffer until they are synced to the cache. |
| 746 | */ |
| 747 | number_pixels=(MagickSizeType) columns*rows; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 748 | length=(size_t) number_pixels*cache_info->number_channels*sizeof(Quantum); |
cristy | a13b07a | 2012-08-21 17:01:05 +0000 | [diff] [blame^] | 749 | if (cache_info->number_channels == 0) |
| 750 | length=number_pixels*sizeof(Quantum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 751 | if (cache_info->metacontent_extent != 0) |
| 752 | length+=number_pixels*cache_info->metacontent_extent; |
| 753 | if (cache_info->pixels == (Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 754 | { |
| 755 | cache_info->length=length; |
| 756 | status=AcquireStreamPixels(cache_info,exception); |
| 757 | if (status == MagickFalse) |
cristy | 33503f5 | 2010-10-04 17:32:27 +0000 | [diff] [blame] | 758 | { |
| 759 | cache_info->length=0; |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 760 | return((Quantum *) NULL); |
cristy | 33503f5 | 2010-10-04 17:32:27 +0000 | [diff] [blame] | 761 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 762 | } |
| 763 | else |
| 764 | if (cache_info->length != length) |
| 765 | { |
| 766 | RelinquishStreamPixels(cache_info); |
| 767 | cache_info->length=length; |
| 768 | status=AcquireStreamPixels(cache_info,exception); |
| 769 | if (status == MagickFalse) |
cristy | 33503f5 | 2010-10-04 17:32:27 +0000 | [diff] [blame] | 770 | { |
| 771 | cache_info->length=0; |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 772 | return((Quantum *) NULL); |
cristy | 33503f5 | 2010-10-04 17:32:27 +0000 | [diff] [blame] | 773 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 774 | } |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 775 | cache_info->metacontent=(void *) NULL; |
| 776 | if (cache_info->metacontent_extent != 0) |
| 777 | cache_info->metacontent=(void *) (cache_info->pixels+number_pixels* |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 778 | cache_info->number_channels); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 779 | return(cache_info->pixels); |
| 780 | } |
| 781 | |
| 782 | /* |
| 783 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 784 | % % |
| 785 | % % |
| 786 | % % |
| 787 | + O p e n S t r e a m % |
| 788 | % % |
| 789 | % % |
| 790 | % % |
| 791 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 792 | % |
| 793 | % OpenStream() opens a stream for writing by the StreamImage() method. |
| 794 | % |
| 795 | % The format of the OpenStream method is: |
| 796 | % |
| 797 | % MagickBooleanType OpenStream(const ImageInfo *image_info, |
| 798 | % StreamInfo *stream_info,const char *filename,ExceptionInfo *exception) |
| 799 | % |
| 800 | % A description of each parameter follows: |
| 801 | % |
| 802 | % o image_info: the image info. |
| 803 | % |
| 804 | % o stream_info: the stream info. |
| 805 | % |
| 806 | % o filename: the stream filename. |
| 807 | % |
| 808 | % o exception: return any errors or warnings in this structure. |
| 809 | % |
| 810 | */ |
| 811 | MagickExport MagickBooleanType OpenStream(const ImageInfo *image_info, |
| 812 | StreamInfo *stream_info,const char *filename,ExceptionInfo *exception) |
| 813 | { |
| 814 | MagickBooleanType |
| 815 | status; |
| 816 | |
| 817 | (void) CopyMagickString(stream_info->stream->filename,filename,MaxTextExtent); |
| 818 | status=OpenBlob(image_info,stream_info->stream,WriteBinaryBlobMode,exception); |
| 819 | return(status); |
| 820 | } |
| 821 | |
| 822 | /* |
| 823 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 824 | % % |
| 825 | % % |
| 826 | % % |
| 827 | + 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 % |
| 828 | % % |
| 829 | % % |
| 830 | % % |
| 831 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 832 | % |
| 833 | % QueueAuthenticPixelsStream() allocates an area to store image pixels as |
| 834 | % defined by the region rectangle and returns a pointer to the area. This |
| 835 | % area is subsequently transferred from the pixel cache with method |
| 836 | % SyncAuthenticPixelsStream(). A pointer to the pixels is returned if the |
| 837 | % pixels are transferred, otherwise a NULL is returned. |
| 838 | % |
| 839 | % The format of the QueueAuthenticPixelsStream() method is: |
| 840 | % |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 841 | % Quantum *QueueAuthenticPixelsStream(Image *image,const ssize_t x, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 842 | % const ssize_t y,const size_t columns,const size_t rows, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 843 | % ExceptionInfo *exception) |
| 844 | % |
| 845 | % A description of each parameter follows: |
| 846 | % |
| 847 | % o image: the image. |
| 848 | % |
| 849 | % o x,y,columns,rows: These values define the perimeter of a region of |
| 850 | % pixels. |
| 851 | % |
| 852 | */ |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 853 | static Quantum *QueueAuthenticPixelsStream(Image *image,const ssize_t x, |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 854 | const ssize_t y,const size_t columns,const size_t rows, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 855 | ExceptionInfo *exception) |
| 856 | { |
| 857 | CacheInfo |
| 858 | *cache_info; |
| 859 | |
cristy | 20cc087 | 2012-08-20 00:01:19 +0000 | [diff] [blame] | 860 | MagickBooleanType |
| 861 | status; |
| 862 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 863 | MagickSizeType |
| 864 | number_pixels; |
| 865 | |
| 866 | size_t |
| 867 | length; |
| 868 | |
| 869 | StreamHandler |
| 870 | stream_handler; |
| 871 | |
| 872 | /* |
| 873 | Validate pixel cache geometry. |
| 874 | */ |
| 875 | assert(image != (Image *) NULL); |
cristy | cfae90a | 2010-10-04 14:43:33 +0000 | [diff] [blame] | 876 | if ((x < 0) || (y < 0) || |
| 877 | ((x+(ssize_t) columns) > (ssize_t) image->columns) || |
| 878 | ((y+(ssize_t) rows) > (ssize_t) image->rows) || |
| 879 | (columns == 0) || (rows == 0)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 880 | { |
| 881 | (void) ThrowMagickException(exception,GetMagickModule(),StreamError, |
cristy | 20cc087 | 2012-08-20 00:01:19 +0000 | [diff] [blame] | 882 | "ImageDoesNotContainTheStreamGeometry","'%s'",image->filename); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 883 | return((Quantum *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 884 | } |
| 885 | stream_handler=GetBlobStreamHandler(image); |
| 886 | if (stream_handler == (StreamHandler) NULL) |
| 887 | { |
| 888 | (void) ThrowMagickException(exception,GetMagickModule(),StreamError, |
cristy | 20cc087 | 2012-08-20 00:01:19 +0000 | [diff] [blame] | 889 | "NoStreamHandlerIsDefined","'%s'",image->filename); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 890 | return((Quantum *) NULL); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 891 | } |
| 892 | cache_info=(CacheInfo *) image->cache; |
| 893 | assert(cache_info->signature == MagickSignature); |
| 894 | if ((image->storage_class != GetPixelCacheStorageClass(image->cache)) || |
| 895 | (image->colorspace != GetPixelCacheColorspace(image->cache))) |
| 896 | { |
| 897 | if (GetPixelCacheStorageClass(image->cache) == UndefinedClass) |
| 898 | (void) stream_handler(image,(const void *) NULL,(size_t) |
| 899 | cache_info->columns); |
| 900 | cache_info->storage_class=image->storage_class; |
| 901 | cache_info->colorspace=image->colorspace; |
| 902 | cache_info->columns=image->columns; |
| 903 | cache_info->rows=image->rows; |
| 904 | image->cache=cache_info; |
| 905 | } |
| 906 | /* |
| 907 | Pixels are stored in a temporary buffer until they are synced to the cache. |
| 908 | */ |
| 909 | cache_info->columns=columns; |
| 910 | cache_info->rows=rows; |
| 911 | number_pixels=(MagickSizeType) columns*rows; |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 912 | length=(size_t) number_pixels*cache_info->number_channels*sizeof(Quantum); |
cristy | d62370b | 2012-08-20 00:22:14 +0000 | [diff] [blame] | 913 | if (cache_info->number_channels == 0) |
cristy | 20cc087 | 2012-08-20 00:01:19 +0000 | [diff] [blame] | 914 | length=number_pixels*sizeof(Quantum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 915 | if (cache_info->metacontent_extent != 0) |
| 916 | length+=number_pixels*cache_info->metacontent_extent; |
| 917 | if (cache_info->pixels == (Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 918 | { |
cristy | 20cc087 | 2012-08-20 00:01:19 +0000 | [diff] [blame] | 919 | cache_info->length=length; |
| 920 | status=AcquireStreamPixels(cache_info,exception); |
| 921 | if (status == MagickFalse) |
| 922 | { |
| 923 | cache_info->length=0; |
| 924 | return((Quantum *) NULL); |
| 925 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 926 | } |
| 927 | else |
cristy | 20cc087 | 2012-08-20 00:01:19 +0000 | [diff] [blame] | 928 | if (cache_info->length < length) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 929 | { |
cristy | 20cc087 | 2012-08-20 00:01:19 +0000 | [diff] [blame] | 930 | RelinquishStreamPixels(cache_info); |
| 931 | cache_info->length=length; |
| 932 | status=AcquireStreamPixels(cache_info,exception); |
| 933 | if (status == MagickFalse) |
| 934 | { |
| 935 | cache_info->length=0; |
| 936 | return((Quantum *) NULL); |
| 937 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 938 | } |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 939 | cache_info->metacontent=(void *) NULL; |
| 940 | if (cache_info->metacontent_extent != 0) |
| 941 | cache_info->metacontent=(void *) (cache_info->pixels+number_pixels* |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 942 | cache_info->number_channels); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 943 | return(cache_info->pixels); |
| 944 | } |
| 945 | |
| 946 | /* |
| 947 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 948 | % % |
| 949 | % % |
| 950 | % % |
| 951 | % R e a d S t r e a m % |
| 952 | % % |
| 953 | % % |
| 954 | % % |
| 955 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 956 | % |
| 957 | % ReadStream() makes the image pixels available to a user supplied callback |
| 958 | % method immediately upon reading a scanline with the ReadImage() method. |
| 959 | % |
| 960 | % The format of the ReadStream() method is: |
| 961 | % |
| 962 | % Image *ReadStream(const ImageInfo *image_info,StreamHandler stream, |
| 963 | % ExceptionInfo *exception) |
| 964 | % |
| 965 | % A description of each parameter follows: |
| 966 | % |
| 967 | % o image_info: the image info. |
| 968 | % |
| 969 | % o stream: a callback method. |
| 970 | % |
| 971 | % o exception: return any errors or warnings in this structure. |
| 972 | % |
| 973 | */ |
| 974 | MagickExport Image *ReadStream(const ImageInfo *image_info,StreamHandler stream, |
| 975 | ExceptionInfo *exception) |
| 976 | { |
| 977 | CacheMethods |
| 978 | cache_methods; |
| 979 | |
| 980 | Image |
| 981 | *image; |
| 982 | |
| 983 | ImageInfo |
| 984 | *read_info; |
| 985 | |
| 986 | /* |
| 987 | Stream image pixels. |
| 988 | */ |
| 989 | assert(image_info != (ImageInfo *) NULL); |
| 990 | assert(image_info->signature == MagickSignature); |
| 991 | if (image_info->debug != MagickFalse) |
| 992 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 993 | image_info->filename); |
| 994 | assert(exception != (ExceptionInfo *) NULL); |
| 995 | assert(exception->signature == MagickSignature); |
| 996 | read_info=CloneImageInfo(image_info); |
| 997 | read_info->cache=AcquirePixelCache(0); |
| 998 | GetPixelCacheMethods(&cache_methods); |
| 999 | cache_methods.get_virtual_pixel_handler=GetVirtualPixelStream; |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1000 | cache_methods.get_virtual_metacontent_from_handler= |
| 1001 | GetVirtualMetacontentFromStream; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1002 | cache_methods.get_virtual_pixels_handler=GetVirtualPixelsStream; |
| 1003 | cache_methods.get_authentic_pixels_handler=GetAuthenticPixelsStream; |
| 1004 | cache_methods.queue_authentic_pixels_handler=QueueAuthenticPixelsStream; |
| 1005 | cache_methods.sync_authentic_pixels_handler=SyncAuthenticPixelsStream; |
| 1006 | cache_methods.get_authentic_pixels_from_handler=GetAuthenticPixelsFromStream; |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1007 | cache_methods.get_authentic_metacontent_from_handler= |
| 1008 | GetAuthenticMetacontentFromStream; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1009 | cache_methods.get_one_virtual_pixel_from_handler=GetOneVirtualPixelFromStream; |
| 1010 | cache_methods.get_one_authentic_pixel_from_handler= |
| 1011 | GetOneAuthenticPixelFromStream; |
| 1012 | cache_methods.destroy_pixel_handler=DestroyPixelStream; |
| 1013 | SetPixelCacheMethods(read_info->cache,&cache_methods); |
| 1014 | read_info->stream=stream; |
| 1015 | image=ReadImage(read_info,exception); |
| 1016 | read_info=DestroyImageInfo(read_info); |
| 1017 | return(image); |
| 1018 | } |
| 1019 | |
| 1020 | /* |
| 1021 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1022 | % % |
| 1023 | % % |
| 1024 | % % |
| 1025 | + S e t S t r e a m I n f o C l i e n t D a t a % |
| 1026 | % % |
| 1027 | % % |
| 1028 | % % |
| 1029 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1030 | % |
| 1031 | % SetStreamInfoClientData() sets the stream info client data. |
| 1032 | % |
| 1033 | % The format of the SetStreamInfoClientData method is: |
| 1034 | % |
| 1035 | % void SetStreamInfoClientData(StreamInfo *stream_info, |
| 1036 | % const void *client_data) |
| 1037 | % |
| 1038 | % A description of each parameter follows: |
| 1039 | % |
| 1040 | % o stream_info: the stream info. |
| 1041 | % |
| 1042 | % o client_data: the client data. |
| 1043 | % |
| 1044 | */ |
cristy | 7832dc2 | 2011-09-05 01:21:53 +0000 | [diff] [blame] | 1045 | MagickPrivate void SetStreamInfoClientData(StreamInfo *stream_info, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1046 | const void *client_data) |
| 1047 | { |
| 1048 | assert(stream_info != (StreamInfo *) NULL); |
| 1049 | assert(stream_info->signature == MagickSignature); |
| 1050 | stream_info->client_data=client_data; |
| 1051 | } |
| 1052 | |
| 1053 | /* |
| 1054 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1055 | % % |
| 1056 | % % |
| 1057 | % % |
| 1058 | + S e t S t r e a m I n f o M a p % |
| 1059 | % % |
| 1060 | % % |
| 1061 | % % |
| 1062 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1063 | % |
| 1064 | % SetStreamInfoMap() sets the stream info map member. |
| 1065 | % |
| 1066 | % The format of the SetStreamInfoMap method is: |
| 1067 | % |
| 1068 | % void SetStreamInfoMap(StreamInfo *stream_info,const char *map) |
| 1069 | % |
| 1070 | % A description of each parameter follows: |
| 1071 | % |
| 1072 | % o stream_info: the stream info. |
| 1073 | % |
| 1074 | % o map: the map. |
| 1075 | % |
| 1076 | */ |
| 1077 | MagickExport void SetStreamInfoMap(StreamInfo *stream_info,const char *map) |
| 1078 | { |
| 1079 | assert(stream_info != (StreamInfo *) NULL); |
| 1080 | assert(stream_info->signature == MagickSignature); |
| 1081 | (void) CloneString(&stream_info->map,map); |
| 1082 | } |
| 1083 | |
| 1084 | /* |
| 1085 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1086 | % % |
| 1087 | % % |
| 1088 | % % |
| 1089 | + S e t S t r e a m I n f o S t o r a g e T y p e % |
| 1090 | % % |
| 1091 | % % |
| 1092 | % % |
| 1093 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1094 | % |
| 1095 | % SetStreamInfoStorageType() sets the stream info storage type member. |
| 1096 | % |
| 1097 | % The format of the SetStreamInfoStorageType method is: |
| 1098 | % |
| 1099 | % void SetStreamInfoStorageType(StreamInfo *stream_info, |
| 1100 | % const StoreageType *storage_type) |
| 1101 | % |
| 1102 | % A description of each parameter follows: |
| 1103 | % |
| 1104 | % o stream_info: the stream info. |
| 1105 | % |
| 1106 | % o storage_type: the storage type. |
| 1107 | % |
| 1108 | */ |
| 1109 | MagickExport void SetStreamInfoStorageType(StreamInfo *stream_info, |
| 1110 | const StorageType storage_type) |
| 1111 | { |
| 1112 | assert(stream_info != (StreamInfo *) NULL); |
| 1113 | assert(stream_info->signature == MagickSignature); |
| 1114 | stream_info->storage_type=storage_type; |
| 1115 | } |
| 1116 | |
| 1117 | /* |
| 1118 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1119 | % % |
| 1120 | % % |
| 1121 | % % |
| 1122 | + S t r e a m I m a g e % |
| 1123 | % % |
| 1124 | % % |
| 1125 | % % |
| 1126 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1127 | % |
| 1128 | % StreamImage() streams pixels from an image and writes them in a user |
| 1129 | % defined format and storage type (e.g. RGBA as 8-bit unsigned char). |
| 1130 | % |
cristy | d212bd0 | 2011-02-13 17:08:57 +0000 | [diff] [blame] | 1131 | % The format of the StreamImage() method is: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1132 | % |
| 1133 | % Image *StreamImage(const ImageInfo *image_info, |
| 1134 | % StreamInfo *stream_info,ExceptionInfo *exception) |
| 1135 | % |
| 1136 | % A description of each parameter follows: |
| 1137 | % |
| 1138 | % o image_info: the image info. |
| 1139 | % |
| 1140 | % o stream_info: the stream info. |
| 1141 | % |
| 1142 | % o exception: return any errors or warnings in this structure. |
| 1143 | % |
| 1144 | */ |
| 1145 | |
| 1146 | #if defined(__cplusplus) || defined(c_plusplus) |
| 1147 | extern "C" { |
| 1148 | #endif |
| 1149 | |
| 1150 | static size_t WriteStreamImage(const Image *image,const void *pixels, |
| 1151 | const size_t columns) |
| 1152 | { |
cristy | e3664f4 | 2010-05-14 00:59:57 +0000 | [diff] [blame] | 1153 | CacheInfo |
| 1154 | *cache_info; |
| 1155 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1156 | RectangleInfo |
| 1157 | extract_info; |
| 1158 | |
| 1159 | size_t |
| 1160 | length, |
| 1161 | packet_size; |
| 1162 | |
| 1163 | ssize_t |
| 1164 | count; |
| 1165 | |
| 1166 | StreamInfo |
| 1167 | *stream_info; |
| 1168 | |
cristy | 654fdaf | 2011-02-24 15:24:33 +0000 | [diff] [blame] | 1169 | (void) pixels; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1170 | stream_info=(StreamInfo *) image->client_data; |
| 1171 | switch (stream_info->storage_type) |
| 1172 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1173 | default: packet_size=sizeof(unsigned char); break; |
| 1174 | case CharPixel: packet_size=sizeof(unsigned char); break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1175 | case DoublePixel: packet_size=sizeof(double); break; |
| 1176 | case FloatPixel: packet_size=sizeof(float); break; |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1177 | case LongPixel: packet_size=sizeof(unsigned int); break; |
| 1178 | case LongLongPixel: packet_size=sizeof(MagickSizeType); break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1179 | case QuantumPixel: packet_size=sizeof(Quantum); break; |
| 1180 | case ShortPixel: packet_size=sizeof(unsigned short); break; |
| 1181 | } |
cristy | e3664f4 | 2010-05-14 00:59:57 +0000 | [diff] [blame] | 1182 | cache_info=(CacheInfo *) image->cache; |
| 1183 | assert(cache_info->signature == MagickSignature); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1184 | packet_size*=strlen(stream_info->map); |
cristy | e3664f4 | 2010-05-14 00:59:57 +0000 | [diff] [blame] | 1185 | length=packet_size*cache_info->columns*cache_info->rows; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1186 | if (image != stream_info->image) |
| 1187 | { |
| 1188 | ImageInfo |
| 1189 | *write_info; |
| 1190 | |
| 1191 | /* |
| 1192 | Prepare stream for writing. |
| 1193 | */ |
cristy | 39c2e21 | 2012-08-18 18:14:34 +0000 | [diff] [blame] | 1194 | (void) RelinquishAlignedMemory(stream_info->pixels); |
cristy | 20cc087 | 2012-08-20 00:01:19 +0000 | [diff] [blame] | 1195 | stream_info->pixels=(unsigned char *) AcquireAlignedMemory(1,length); |
cristy | 5dd7188 | 2010-08-01 20:53:13 +0000 | [diff] [blame] | 1196 | if (stream_info->pixels == (unsigned char *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1197 | return(0); |
cristy | 39c2e21 | 2012-08-18 18:14:34 +0000 | [diff] [blame] | 1198 | (void) ResetMagickMemory(stream_info->pixels,0,length); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1199 | stream_info->image=image; |
| 1200 | write_info=CloneImageInfo(stream_info->image_info); |
cristy | d965a42 | 2010-03-03 17:47:35 +0000 | [diff] [blame] | 1201 | (void) SetImageInfo(write_info,1,stream_info->exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1202 | if (write_info->extract != (char *) NULL) |
| 1203 | (void) ParseAbsoluteGeometry(write_info->extract, |
| 1204 | &stream_info->extract_info); |
| 1205 | stream_info->y=0; |
| 1206 | write_info=DestroyImageInfo(write_info); |
| 1207 | } |
| 1208 | extract_info=stream_info->extract_info; |
cristy | d212bd0 | 2011-02-13 17:08:57 +0000 | [diff] [blame] | 1209 | if ((extract_info.width == 0) || (extract_info.height == 0)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1210 | { |
| 1211 | /* |
| 1212 | Write all pixels to stream. |
| 1213 | */ |
| 1214 | (void) StreamImagePixels(stream_info,image,stream_info->exception); |
| 1215 | count=WriteBlob(stream_info->stream,length,stream_info->pixels); |
| 1216 | stream_info->y++; |
| 1217 | return(count == 0 ? 0 : columns); |
| 1218 | } |
| 1219 | if ((stream_info->y < extract_info.y) || |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1220 | (stream_info->y >= (ssize_t) (extract_info.y+extract_info.height))) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1221 | { |
| 1222 | stream_info->y++; |
| 1223 | return(columns); |
| 1224 | } |
| 1225 | /* |
| 1226 | Write a portion of the pixel row to the stream. |
| 1227 | */ |
| 1228 | (void) StreamImagePixels(stream_info,image,stream_info->exception); |
| 1229 | length=packet_size*extract_info.width; |
cristy | 5dd7188 | 2010-08-01 20:53:13 +0000 | [diff] [blame] | 1230 | count=WriteBlob(stream_info->stream,length,stream_info->pixels+packet_size* |
| 1231 | extract_info.x); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1232 | stream_info->y++; |
| 1233 | return(count == 0 ? 0 : columns); |
| 1234 | } |
| 1235 | |
| 1236 | #if defined(__cplusplus) || defined(c_plusplus) |
| 1237 | } |
| 1238 | #endif |
| 1239 | |
| 1240 | MagickExport Image *StreamImage(const ImageInfo *image_info, |
| 1241 | StreamInfo *stream_info,ExceptionInfo *exception) |
| 1242 | { |
| 1243 | Image |
| 1244 | *image; |
| 1245 | |
| 1246 | ImageInfo |
| 1247 | *read_info; |
| 1248 | |
| 1249 | assert(image_info != (const ImageInfo *) NULL); |
| 1250 | assert(image_info->signature == MagickSignature); |
| 1251 | if (image_info->debug != MagickFalse) |
| 1252 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 1253 | image_info->filename); |
| 1254 | assert(stream_info != (StreamInfo *) NULL); |
| 1255 | assert(stream_info->signature == MagickSignature); |
| 1256 | assert(exception != (ExceptionInfo *) NULL); |
| 1257 | read_info=CloneImageInfo(image_info); |
| 1258 | stream_info->image_info=image_info; |
| 1259 | stream_info->exception=exception; |
| 1260 | read_info->client_data=(void *) stream_info; |
| 1261 | image=ReadStream(read_info,&WriteStreamImage,exception); |
| 1262 | read_info=DestroyImageInfo(read_info); |
| 1263 | stream_info->quantum_info=AcquireQuantumInfo(image_info,image); |
| 1264 | if (stream_info->quantum_info == (QuantumInfo *) NULL) |
| 1265 | image=DestroyImage(image); |
| 1266 | return(image); |
| 1267 | } |
| 1268 | |
| 1269 | /* |
| 1270 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1271 | % % |
| 1272 | % % |
| 1273 | % % |
| 1274 | + S t r e a m I m a g e P i x e l s % |
| 1275 | % % |
| 1276 | % % |
| 1277 | % % |
| 1278 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1279 | % |
| 1280 | % StreamImagePixels() extracts pixel data from an image and returns it in the |
| 1281 | % stream_info->pixels structure in the format as defined by |
| 1282 | % stream_info->quantum_info->map and stream_info->quantum_info->storage_type. |
| 1283 | % |
| 1284 | % The format of the StreamImagePixels method is: |
| 1285 | % |
| 1286 | % MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, |
| 1287 | % const Image *image,ExceptionInfo *exception) |
| 1288 | % |
| 1289 | % A description of each parameter follows: |
| 1290 | % |
| 1291 | % o stream_info: the stream info. |
| 1292 | % |
| 1293 | % o image: the image. |
| 1294 | % |
| 1295 | % o exception: return any errors or warnings in this structure. |
| 1296 | % |
| 1297 | */ |
| 1298 | static MagickBooleanType StreamImagePixels(const StreamInfo *stream_info, |
| 1299 | const Image *image,ExceptionInfo *exception) |
| 1300 | { |
| 1301 | QuantumInfo |
| 1302 | *quantum_info; |
| 1303 | |
| 1304 | QuantumType |
| 1305 | *quantum_map; |
| 1306 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1307 | register const Quantum |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1308 | *p; |
| 1309 | |
cristy | d212bd0 | 2011-02-13 17:08:57 +0000 | [diff] [blame] | 1310 | register ssize_t |
| 1311 | i, |
| 1312 | x; |
| 1313 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1314 | size_t |
| 1315 | length; |
| 1316 | |
| 1317 | assert(stream_info != (StreamInfo *) NULL); |
| 1318 | assert(stream_info->signature == MagickSignature); |
| 1319 | assert(image != (Image *) NULL); |
| 1320 | assert(image->signature == MagickSignature); |
| 1321 | if (image->debug != MagickFalse) |
| 1322 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 1323 | length=strlen(stream_info->map); |
| 1324 | quantum_map=(QuantumType *) AcquireQuantumMemory(length,sizeof(*quantum_map)); |
| 1325 | if (quantum_map == (QuantumType *) NULL) |
| 1326 | { |
| 1327 | (void) ThrowMagickException(exception,GetMagickModule(), |
cristy | 20cc087 | 2012-08-20 00:01:19 +0000 | [diff] [blame] | 1328 | ResourceLimitError,"MemoryAllocationFailed","'%s'",image->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1329 | return(MagickFalse); |
| 1330 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1331 | for (i=0; i < (ssize_t) length; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1332 | { |
| 1333 | switch (stream_info->map[i]) |
| 1334 | { |
| 1335 | case 'A': |
| 1336 | case 'a': |
| 1337 | { |
| 1338 | quantum_map[i]=AlphaQuantum; |
| 1339 | break; |
| 1340 | } |
| 1341 | case 'B': |
| 1342 | case 'b': |
| 1343 | { |
| 1344 | quantum_map[i]=BlueQuantum; |
| 1345 | break; |
| 1346 | } |
| 1347 | case 'C': |
| 1348 | case 'c': |
| 1349 | { |
| 1350 | quantum_map[i]=CyanQuantum; |
| 1351 | if (image->colorspace == CMYKColorspace) |
| 1352 | break; |
| 1353 | quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map); |
| 1354 | (void) ThrowMagickException(exception,GetMagickModule(),ImageError, |
cristy | 20cc087 | 2012-08-20 00:01:19 +0000 | [diff] [blame] | 1355 | "ColorSeparatedImageRequired","'%s'",stream_info->map); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1356 | return(MagickFalse); |
| 1357 | } |
| 1358 | case 'g': |
| 1359 | case 'G': |
| 1360 | { |
| 1361 | quantum_map[i]=GreenQuantum; |
| 1362 | break; |
| 1363 | } |
| 1364 | case 'I': |
| 1365 | case 'i': |
| 1366 | { |
| 1367 | quantum_map[i]=IndexQuantum; |
| 1368 | break; |
| 1369 | } |
| 1370 | case 'K': |
| 1371 | case 'k': |
| 1372 | { |
| 1373 | quantum_map[i]=BlackQuantum; |
| 1374 | if (image->colorspace == CMYKColorspace) |
| 1375 | break; |
| 1376 | quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map); |
| 1377 | (void) ThrowMagickException(exception,GetMagickModule(),ImageError, |
cristy | 20cc087 | 2012-08-20 00:01:19 +0000 | [diff] [blame] | 1378 | "ColorSeparatedImageRequired","'%s'",stream_info->map); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1379 | return(MagickFalse); |
| 1380 | } |
| 1381 | case 'M': |
| 1382 | case 'm': |
| 1383 | { |
| 1384 | quantum_map[i]=MagentaQuantum; |
| 1385 | if (image->colorspace == CMYKColorspace) |
| 1386 | break; |
| 1387 | quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map); |
| 1388 | (void) ThrowMagickException(exception,GetMagickModule(),ImageError, |
cristy | 20cc087 | 2012-08-20 00:01:19 +0000 | [diff] [blame] | 1389 | "ColorSeparatedImageRequired","'%s'",stream_info->map); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1390 | return(MagickFalse); |
| 1391 | } |
| 1392 | case 'o': |
| 1393 | case 'O': |
| 1394 | { |
| 1395 | quantum_map[i]=OpacityQuantum; |
| 1396 | break; |
| 1397 | } |
| 1398 | case 'P': |
| 1399 | case 'p': |
| 1400 | { |
| 1401 | quantum_map[i]=UndefinedQuantum; |
| 1402 | break; |
| 1403 | } |
| 1404 | case 'R': |
| 1405 | case 'r': |
| 1406 | { |
| 1407 | quantum_map[i]=RedQuantum; |
| 1408 | break; |
| 1409 | } |
| 1410 | case 'Y': |
| 1411 | case 'y': |
| 1412 | { |
| 1413 | quantum_map[i]=YellowQuantum; |
| 1414 | if (image->colorspace == CMYKColorspace) |
| 1415 | break; |
| 1416 | quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map); |
| 1417 | (void) ThrowMagickException(exception,GetMagickModule(),ImageError, |
cristy | 20cc087 | 2012-08-20 00:01:19 +0000 | [diff] [blame] | 1418 | "ColorSeparatedImageRequired","'%s'",stream_info->map); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1419 | return(MagickFalse); |
| 1420 | } |
| 1421 | default: |
| 1422 | { |
| 1423 | quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map); |
| 1424 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
cristy | 20cc087 | 2012-08-20 00:01:19 +0000 | [diff] [blame] | 1425 | "UnrecognizedPixelMap","'%s'",stream_info->map); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1426 | return(MagickFalse); |
| 1427 | } |
| 1428 | } |
| 1429 | } |
| 1430 | quantum_info=stream_info->quantum_info; |
| 1431 | switch (stream_info->storage_type) |
| 1432 | { |
| 1433 | case CharPixel: |
| 1434 | { |
| 1435 | register unsigned char |
| 1436 | *q; |
| 1437 | |
| 1438 | q=(unsigned char *) stream_info->pixels; |
| 1439 | if (LocaleCompare(stream_info->map,"BGR") == 0) |
| 1440 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1441 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1442 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1443 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1444 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1445 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1446 | *q++=ScaleQuantumToChar(GetPixelBlue(image,p)); |
| 1447 | *q++=ScaleQuantumToChar(GetPixelGreen(image,p)); |
| 1448 | *q++=ScaleQuantumToChar(GetPixelRed(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1449 | p++; |
| 1450 | } |
| 1451 | break; |
| 1452 | } |
| 1453 | if (LocaleCompare(stream_info->map,"BGRA") == 0) |
| 1454 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1455 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1456 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1457 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1458 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1459 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1460 | *q++=ScaleQuantumToChar(GetPixelBlue(image,p)); |
| 1461 | *q++=ScaleQuantumToChar(GetPixelGreen(image,p)); |
| 1462 | *q++=ScaleQuantumToChar(GetPixelRed(image,p)); |
| 1463 | *q++=ScaleQuantumToChar(GetPixelAlpha(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1464 | p++; |
| 1465 | } |
| 1466 | break; |
| 1467 | } |
| 1468 | if (LocaleCompare(stream_info->map,"BGRP") == 0) |
| 1469 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1470 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1471 | if (p == (const Quantum *) NULL) |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1472 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1473 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1474 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1475 | *q++=ScaleQuantumToChar(GetPixelBlue(image,p)); |
| 1476 | *q++=ScaleQuantumToChar(GetPixelGreen(image,p)); |
| 1477 | *q++=ScaleQuantumToChar(GetPixelRed(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1478 | *q++=ScaleQuantumToChar((Quantum) 0); |
| 1479 | p++; |
| 1480 | } |
| 1481 | break; |
| 1482 | } |
| 1483 | if (LocaleCompare(stream_info->map,"I") == 0) |
| 1484 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1485 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1486 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1487 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1488 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1489 | { |
cristy | f13c594 | 2012-08-08 23:50:11 +0000 | [diff] [blame] | 1490 | *q++=ScaleQuantumToChar(ClampToQuantum(GetPixelIntensity(image,p))); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1491 | p++; |
| 1492 | } |
| 1493 | break; |
| 1494 | } |
| 1495 | if (LocaleCompare(stream_info->map,"RGB") == 0) |
| 1496 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1497 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1498 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1499 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1500 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1501 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1502 | *q++=ScaleQuantumToChar(GetPixelRed(image,p)); |
| 1503 | *q++=ScaleQuantumToChar(GetPixelGreen(image,p)); |
| 1504 | *q++=ScaleQuantumToChar(GetPixelBlue(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1505 | p++; |
| 1506 | } |
| 1507 | break; |
| 1508 | } |
| 1509 | if (LocaleCompare(stream_info->map,"RGBA") == 0) |
| 1510 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1511 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1512 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1513 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1514 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1515 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1516 | *q++=ScaleQuantumToChar(GetPixelRed(image,p)); |
| 1517 | *q++=ScaleQuantumToChar(GetPixelGreen(image,p)); |
| 1518 | *q++=ScaleQuantumToChar(GetPixelBlue(image,p)); |
| 1519 | *q++=ScaleQuantumToChar((Quantum) (GetPixelAlpha(image,p))); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1520 | p++; |
| 1521 | } |
| 1522 | break; |
| 1523 | } |
| 1524 | if (LocaleCompare(stream_info->map,"RGBP") == 0) |
| 1525 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1526 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1527 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1528 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1529 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1530 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1531 | *q++=ScaleQuantumToChar(GetPixelRed(image,p)); |
| 1532 | *q++=ScaleQuantumToChar(GetPixelGreen(image,p)); |
| 1533 | *q++=ScaleQuantumToChar(GetPixelBlue(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1534 | *q++=ScaleQuantumToChar((Quantum) 0); |
| 1535 | p++; |
| 1536 | } |
| 1537 | break; |
| 1538 | } |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1539 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1540 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1541 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1542 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1543 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1544 | for (i=0; i < (ssize_t) length; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1545 | { |
| 1546 | *q=0; |
| 1547 | switch (quantum_map[i]) |
| 1548 | { |
| 1549 | case RedQuantum: |
| 1550 | case CyanQuantum: |
| 1551 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1552 | *q=ScaleQuantumToChar(GetPixelRed(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1553 | break; |
| 1554 | } |
| 1555 | case GreenQuantum: |
| 1556 | case MagentaQuantum: |
| 1557 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1558 | *q=ScaleQuantumToChar(GetPixelGreen(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1559 | break; |
| 1560 | } |
| 1561 | case BlueQuantum: |
| 1562 | case YellowQuantum: |
| 1563 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1564 | *q=ScaleQuantumToChar(GetPixelBlue(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1565 | break; |
| 1566 | } |
| 1567 | case AlphaQuantum: |
| 1568 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1569 | *q=ScaleQuantumToChar((Quantum) (GetPixelAlpha(image,p))); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1570 | break; |
| 1571 | } |
| 1572 | case OpacityQuantum: |
| 1573 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1574 | *q=ScaleQuantumToChar(GetPixelAlpha(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1575 | break; |
| 1576 | } |
| 1577 | case BlackQuantum: |
| 1578 | { |
| 1579 | if (image->colorspace == CMYKColorspace) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1580 | *q=ScaleQuantumToChar(GetPixelBlack(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1581 | break; |
| 1582 | } |
| 1583 | case IndexQuantum: |
| 1584 | { |
cristy | f13c594 | 2012-08-08 23:50:11 +0000 | [diff] [blame] | 1585 | *q=ScaleQuantumToChar(ClampToQuantum(GetPixelIntensity(image,p))); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1586 | break; |
| 1587 | } |
| 1588 | default: |
| 1589 | break; |
| 1590 | } |
| 1591 | q++; |
| 1592 | } |
| 1593 | p++; |
| 1594 | } |
| 1595 | break; |
| 1596 | } |
| 1597 | case DoublePixel: |
| 1598 | { |
| 1599 | register double |
| 1600 | *q; |
| 1601 | |
| 1602 | q=(double *) stream_info->pixels; |
| 1603 | if (LocaleCompare(stream_info->map,"BGR") == 0) |
| 1604 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1605 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1606 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1607 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1608 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1609 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1610 | *q++=(double) ((QuantumScale*GetPixelBlue(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1611 | quantum_info->scale+quantum_info->minimum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1612 | *q++=(double) ((QuantumScale*GetPixelGreen(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1613 | quantum_info->scale+quantum_info->minimum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1614 | *q++=(double) ((QuantumScale*GetPixelRed(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1615 | quantum_info->scale+quantum_info->minimum); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1616 | p++; |
| 1617 | } |
| 1618 | break; |
| 1619 | } |
| 1620 | if (LocaleCompare(stream_info->map,"BGRA") == 0) |
| 1621 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1622 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1623 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1624 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1625 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1626 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1627 | *q++=(double) ((QuantumScale*GetPixelBlue(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1628 | quantum_info->scale+quantum_info->minimum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1629 | *q++=(double) ((QuantumScale*GetPixelGreen(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1630 | quantum_info->scale+quantum_info->minimum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1631 | *q++=(double) ((QuantumScale*GetPixelRed(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1632 | quantum_info->scale+quantum_info->minimum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1633 | *q++=(double) ((QuantumScale*GetPixelAlpha(image,p))* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1634 | quantum_info->scale+quantum_info->minimum); |
| 1635 | p++; |
| 1636 | } |
| 1637 | break; |
| 1638 | } |
| 1639 | if (LocaleCompare(stream_info->map,"BGRP") == 0) |
| 1640 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1641 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1642 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1643 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1644 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1645 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1646 | *q++=(double) ((QuantumScale*GetPixelBlue(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1647 | quantum_info->scale+quantum_info->minimum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1648 | *q++=(double) ((QuantumScale*GetPixelGreen(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1649 | quantum_info->scale+quantum_info->minimum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1650 | *q++=(double) ((QuantumScale*GetPixelRed(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1651 | quantum_info->scale+quantum_info->minimum); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1652 | *q++=0.0; |
| 1653 | p++; |
| 1654 | } |
| 1655 | break; |
| 1656 | } |
| 1657 | if (LocaleCompare(stream_info->map,"I") == 0) |
| 1658 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1659 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1660 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1661 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1662 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1663 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1664 | *q++=(double) ((QuantumScale*GetPixelIntensity(image,p))* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1665 | quantum_info->scale+quantum_info->minimum); |
| 1666 | p++; |
| 1667 | } |
| 1668 | break; |
| 1669 | } |
| 1670 | if (LocaleCompare(stream_info->map,"RGB") == 0) |
| 1671 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1672 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1673 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1674 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1675 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1676 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1677 | *q++=(double) ((QuantumScale*GetPixelRed(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1678 | quantum_info->scale+quantum_info->minimum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1679 | *q++=(double) ((QuantumScale*GetPixelGreen(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1680 | quantum_info->scale+quantum_info->minimum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1681 | *q++=(double) ((QuantumScale*GetPixelBlue(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1682 | quantum_info->scale+quantum_info->minimum); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1683 | p++; |
| 1684 | } |
| 1685 | break; |
| 1686 | } |
| 1687 | if (LocaleCompare(stream_info->map,"RGBA") == 0) |
| 1688 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1689 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1690 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1691 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1692 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1693 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1694 | *q++=(double) ((QuantumScale*GetPixelRed(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1695 | quantum_info->scale+quantum_info->minimum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1696 | *q++=(double) ((QuantumScale*GetPixelGreen(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1697 | quantum_info->scale+quantum_info->minimum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1698 | *q++=(double) ((QuantumScale*GetPixelBlue(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1699 | quantum_info->scale+quantum_info->minimum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1700 | *q++=(double) ((QuantumScale*GetPixelAlpha(image,p))* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1701 | quantum_info->scale+quantum_info->minimum); |
| 1702 | p++; |
| 1703 | } |
| 1704 | break; |
| 1705 | } |
| 1706 | if (LocaleCompare(stream_info->map,"RGBP") == 0) |
| 1707 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1708 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1709 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1710 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1711 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1712 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1713 | *q++=(double) ((QuantumScale*GetPixelRed(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1714 | quantum_info->scale+quantum_info->minimum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1715 | *q++=(double) ((QuantumScale*GetPixelGreen(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1716 | quantum_info->scale+quantum_info->minimum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1717 | *q++=(double) ((QuantumScale*GetPixelBlue(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1718 | quantum_info->scale+quantum_info->minimum); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1719 | *q++=0.0; |
| 1720 | p++; |
| 1721 | } |
| 1722 | break; |
| 1723 | } |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1724 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1725 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1726 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1727 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1728 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1729 | for (i=0; i < (ssize_t) length; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1730 | { |
| 1731 | *q=0; |
| 1732 | switch (quantum_map[i]) |
| 1733 | { |
| 1734 | case RedQuantum: |
| 1735 | case CyanQuantum: |
| 1736 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1737 | *q=(double) ((QuantumScale*GetPixelRed(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1738 | quantum_info->scale+quantum_info->minimum); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1739 | break; |
| 1740 | } |
| 1741 | case GreenQuantum: |
| 1742 | case MagentaQuantum: |
| 1743 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1744 | *q=(double) ((QuantumScale*GetPixelGreen(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1745 | quantum_info->scale+quantum_info->minimum); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1746 | break; |
| 1747 | } |
| 1748 | case BlueQuantum: |
| 1749 | case YellowQuantum: |
| 1750 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1751 | *q=(double) ((QuantumScale*GetPixelBlue(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1752 | quantum_info->scale+quantum_info->minimum); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1753 | break; |
| 1754 | } |
| 1755 | case AlphaQuantum: |
| 1756 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1757 | *q=(double) ((QuantumScale*GetPixelAlpha(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1758 | quantum_info->scale+quantum_info->minimum); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1759 | break; |
| 1760 | } |
| 1761 | case OpacityQuantum: |
| 1762 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1763 | *q=(double) ((QuantumScale*GetPixelAlpha(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1764 | quantum_info->scale+quantum_info->minimum); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1765 | break; |
| 1766 | } |
| 1767 | case BlackQuantum: |
| 1768 | { |
| 1769 | if (image->colorspace == CMYKColorspace) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1770 | *q=(double) ((QuantumScale*GetPixelBlack(image,p))* |
cristy | fba5a8b | 2011-05-03 17:12:12 +0000 | [diff] [blame] | 1771 | quantum_info->scale+quantum_info->minimum); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1772 | break; |
| 1773 | } |
| 1774 | case IndexQuantum: |
| 1775 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1776 | *q=(double) ((QuantumScale*GetPixelIntensity(image,p))* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1777 | quantum_info->scale+quantum_info->minimum); |
| 1778 | break; |
| 1779 | } |
| 1780 | default: |
| 1781 | *q=0; |
| 1782 | } |
| 1783 | q++; |
| 1784 | } |
| 1785 | p++; |
| 1786 | } |
| 1787 | break; |
| 1788 | } |
| 1789 | case FloatPixel: |
| 1790 | { |
| 1791 | register float |
| 1792 | *q; |
| 1793 | |
| 1794 | q=(float *) stream_info->pixels; |
| 1795 | if (LocaleCompare(stream_info->map,"BGR") == 0) |
| 1796 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1797 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1798 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1799 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1800 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1801 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1802 | *q++=(float) ((QuantumScale*GetPixelBlue(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1803 | quantum_info->scale+quantum_info->minimum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1804 | *q++=(float) ((QuantumScale*GetPixelGreen(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1805 | quantum_info->scale+quantum_info->minimum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1806 | *q++=(float) ((QuantumScale*GetPixelRed(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1807 | quantum_info->scale+quantum_info->minimum); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1808 | p++; |
| 1809 | } |
| 1810 | break; |
| 1811 | } |
| 1812 | if (LocaleCompare(stream_info->map,"BGRA") == 0) |
| 1813 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1814 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1815 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1816 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1817 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1818 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1819 | *q++=(float) ((QuantumScale*GetPixelBlue(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1820 | quantum_info->scale+quantum_info->minimum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1821 | *q++=(float) ((QuantumScale*GetPixelGreen(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1822 | quantum_info->scale+quantum_info->minimum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1823 | *q++=(float) ((QuantumScale*GetPixelRed(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1824 | quantum_info->scale+quantum_info->minimum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1825 | *q++=(float) ((QuantumScale*(Quantum) (GetPixelAlpha(image,p)))* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1826 | quantum_info->scale+quantum_info->minimum); |
| 1827 | p++; |
| 1828 | } |
| 1829 | break; |
| 1830 | } |
| 1831 | if (LocaleCompare(stream_info->map,"BGRP") == 0) |
| 1832 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1833 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1834 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1835 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1836 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1837 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1838 | *q++=(float) ((QuantumScale*GetPixelBlue(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1839 | quantum_info->scale+quantum_info->minimum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1840 | *q++=(float) ((QuantumScale*GetPixelGreen(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1841 | quantum_info->scale+quantum_info->minimum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1842 | *q++=(float) ((QuantumScale*GetPixelRed(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1843 | quantum_info->scale+quantum_info->minimum); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1844 | *q++=0.0; |
| 1845 | p++; |
| 1846 | } |
| 1847 | break; |
| 1848 | } |
| 1849 | if (LocaleCompare(stream_info->map,"I") == 0) |
| 1850 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1851 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1852 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1853 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1854 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1855 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1856 | *q++=(float) ((QuantumScale*GetPixelIntensity(image,p))* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1857 | quantum_info->scale+quantum_info->minimum); |
| 1858 | p++; |
| 1859 | } |
| 1860 | break; |
| 1861 | } |
| 1862 | if (LocaleCompare(stream_info->map,"RGB") == 0) |
| 1863 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1864 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1865 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1866 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1867 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1868 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1869 | *q++=(float) ((QuantumScale*GetPixelRed(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1870 | quantum_info->scale+quantum_info->minimum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1871 | *q++=(float) ((QuantumScale*GetPixelGreen(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1872 | quantum_info->scale+quantum_info->minimum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1873 | *q++=(float) ((QuantumScale*GetPixelBlue(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1874 | quantum_info->scale+quantum_info->minimum); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1875 | p++; |
| 1876 | } |
| 1877 | break; |
| 1878 | } |
| 1879 | if (LocaleCompare(stream_info->map,"RGBA") == 0) |
| 1880 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1881 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1882 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1883 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1884 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1885 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1886 | *q++=(float) ((QuantumScale*GetPixelRed(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1887 | quantum_info->scale+quantum_info->minimum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1888 | *q++=(float) ((QuantumScale*GetPixelGreen(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1889 | quantum_info->scale+quantum_info->minimum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1890 | *q++=(float) ((QuantumScale*GetPixelBlue(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1891 | quantum_info->scale+quantum_info->minimum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1892 | *q++=(float) ((QuantumScale*GetPixelAlpha(image,p))* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1893 | quantum_info->scale+quantum_info->minimum); |
| 1894 | p++; |
| 1895 | } |
| 1896 | break; |
| 1897 | } |
| 1898 | if (LocaleCompare(stream_info->map,"RGBP") == 0) |
| 1899 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1900 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1901 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1902 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1903 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1904 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1905 | *q++=(float) ((QuantumScale*GetPixelRed(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1906 | quantum_info->scale+quantum_info->minimum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1907 | *q++=(float) ((QuantumScale*GetPixelGreen(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1908 | quantum_info->scale+quantum_info->minimum); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1909 | *q++=(float) ((QuantumScale*GetPixelBlue(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1910 | quantum_info->scale+quantum_info->minimum); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1911 | *q++=0.0; |
| 1912 | p++; |
| 1913 | } |
| 1914 | break; |
| 1915 | } |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1916 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1917 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1918 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1919 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1920 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1921 | for (i=0; i < (ssize_t) length; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1922 | { |
| 1923 | *q=0; |
| 1924 | switch (quantum_map[i]) |
| 1925 | { |
| 1926 | case RedQuantum: |
| 1927 | case CyanQuantum: |
| 1928 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1929 | *q=(float) ((QuantumScale*GetPixelRed(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1930 | quantum_info->scale+quantum_info->minimum); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1931 | break; |
| 1932 | } |
| 1933 | case GreenQuantum: |
| 1934 | case MagentaQuantum: |
| 1935 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1936 | *q=(float) ((QuantumScale*GetPixelGreen(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1937 | quantum_info->scale+quantum_info->minimum); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1938 | break; |
| 1939 | } |
| 1940 | case BlueQuantum: |
| 1941 | case YellowQuantum: |
| 1942 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1943 | *q=(float) ((QuantumScale*GetPixelBlue(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1944 | quantum_info->scale+quantum_info->minimum); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1945 | break; |
| 1946 | } |
| 1947 | case AlphaQuantum: |
| 1948 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1949 | *q=(float) ((QuantumScale*GetPixelAlpha(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1950 | quantum_info->scale+quantum_info->minimum); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1951 | break; |
| 1952 | } |
| 1953 | case OpacityQuantum: |
| 1954 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1955 | *q=(float) ((QuantumScale*GetPixelAlpha(image,p))* |
cristy | 46f0820 | 2010-01-10 04:04:21 +0000 | [diff] [blame] | 1956 | quantum_info->scale+quantum_info->minimum); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1957 | break; |
| 1958 | } |
| 1959 | case BlackQuantum: |
| 1960 | { |
| 1961 | if (image->colorspace == CMYKColorspace) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1962 | *q=(float) ((QuantumScale*GetPixelBlack(image,p))* |
cristy | fba5a8b | 2011-05-03 17:12:12 +0000 | [diff] [blame] | 1963 | quantum_info->scale+quantum_info->minimum); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1964 | break; |
| 1965 | } |
| 1966 | case IndexQuantum: |
| 1967 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1968 | *q=(float) ((QuantumScale*GetPixelIntensity(image,p))* |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1969 | quantum_info->scale+quantum_info->minimum); |
| 1970 | break; |
| 1971 | } |
| 1972 | default: |
| 1973 | *q=0; |
| 1974 | } |
| 1975 | q++; |
| 1976 | } |
| 1977 | p++; |
| 1978 | } |
| 1979 | break; |
| 1980 | } |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1981 | case LongPixel: |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1982 | { |
| 1983 | register unsigned int |
| 1984 | *q; |
| 1985 | |
| 1986 | q=(unsigned int *) stream_info->pixels; |
| 1987 | if (LocaleCompare(stream_info->map,"BGR") == 0) |
| 1988 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 1989 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1990 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1991 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1992 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1993 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1994 | *q++=ScaleQuantumToLong(GetPixelBlue(image,p)); |
| 1995 | *q++=ScaleQuantumToLong(GetPixelGreen(image,p)); |
| 1996 | *q++=ScaleQuantumToLong(GetPixelRed(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1997 | p++; |
| 1998 | } |
| 1999 | break; |
| 2000 | } |
| 2001 | if (LocaleCompare(stream_info->map,"BGRA") == 0) |
| 2002 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 2003 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2004 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2005 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2006 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2007 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2008 | *q++=ScaleQuantumToLong(GetPixelBlue(image,p)); |
| 2009 | *q++=ScaleQuantumToLong(GetPixelGreen(image,p)); |
| 2010 | *q++=ScaleQuantumToLong(GetPixelRed(image,p)); |
| 2011 | *q++=ScaleQuantumToLong((Quantum) (GetPixelAlpha(image,p))); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2012 | p++; |
| 2013 | } |
| 2014 | break; |
| 2015 | } |
| 2016 | if (LocaleCompare(stream_info->map,"BGRP") == 0) |
| 2017 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 2018 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2019 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2020 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2021 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2022 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2023 | *q++=ScaleQuantumToLong(GetPixelBlue(image,p)); |
| 2024 | *q++=ScaleQuantumToLong(GetPixelGreen(image,p)); |
| 2025 | *q++=ScaleQuantumToLong(GetPixelRed(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2026 | *q++=0; |
| 2027 | p++; |
| 2028 | } |
| 2029 | break; |
| 2030 | } |
| 2031 | if (LocaleCompare(stream_info->map,"I") == 0) |
| 2032 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 2033 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2034 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2035 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2036 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2037 | { |
cristy | f13c594 | 2012-08-08 23:50:11 +0000 | [diff] [blame] | 2038 | *q++=ScaleQuantumToLong(ClampToQuantum(GetPixelIntensity(image,p))); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2039 | p++; |
| 2040 | } |
| 2041 | break; |
| 2042 | } |
| 2043 | if (LocaleCompare(stream_info->map,"RGB") == 0) |
| 2044 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 2045 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2046 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2047 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2048 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2049 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2050 | *q++=ScaleQuantumToLong(GetPixelRed(image,p)); |
| 2051 | *q++=ScaleQuantumToLong(GetPixelGreen(image,p)); |
| 2052 | *q++=ScaleQuantumToLong(GetPixelBlue(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2053 | p++; |
| 2054 | } |
| 2055 | break; |
| 2056 | } |
| 2057 | if (LocaleCompare(stream_info->map,"RGBA") == 0) |
| 2058 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 2059 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2060 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2061 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2062 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2063 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2064 | *q++=ScaleQuantumToLong(GetPixelRed(image,p)); |
| 2065 | *q++=ScaleQuantumToLong(GetPixelGreen(image,p)); |
| 2066 | *q++=ScaleQuantumToLong(GetPixelBlue(image,p)); |
| 2067 | *q++=ScaleQuantumToLong((Quantum) (GetPixelAlpha(image,p))); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2068 | p++; |
| 2069 | } |
| 2070 | break; |
| 2071 | } |
| 2072 | if (LocaleCompare(stream_info->map,"RGBP") == 0) |
| 2073 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 2074 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2075 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2076 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2077 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2078 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2079 | *q++=ScaleQuantumToLong(GetPixelRed(image,p)); |
| 2080 | *q++=ScaleQuantumToLong(GetPixelGreen(image,p)); |
| 2081 | *q++=ScaleQuantumToLong(GetPixelBlue(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2082 | *q++=0; |
| 2083 | p++; |
| 2084 | } |
| 2085 | break; |
| 2086 | } |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 2087 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2088 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2089 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2090 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2091 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2092 | for (i=0; i < (ssize_t) length; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2093 | { |
| 2094 | *q=0; |
| 2095 | switch (quantum_map[i]) |
| 2096 | { |
| 2097 | case RedQuantum: |
| 2098 | case CyanQuantum: |
| 2099 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2100 | *q=ScaleQuantumToLong(GetPixelRed(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2101 | break; |
| 2102 | } |
| 2103 | case GreenQuantum: |
| 2104 | case MagentaQuantum: |
| 2105 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2106 | *q=ScaleQuantumToLong(GetPixelGreen(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2107 | break; |
| 2108 | } |
| 2109 | case BlueQuantum: |
| 2110 | case YellowQuantum: |
| 2111 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2112 | *q=ScaleQuantumToLong(GetPixelBlue(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2113 | break; |
| 2114 | } |
| 2115 | case AlphaQuantum: |
| 2116 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2117 | *q=ScaleQuantumToLong((Quantum) (GetPixelAlpha(image,p))); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2118 | break; |
| 2119 | } |
| 2120 | case OpacityQuantum: |
| 2121 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2122 | *q=ScaleQuantumToLong(GetPixelAlpha(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2123 | break; |
| 2124 | } |
| 2125 | case BlackQuantum: |
| 2126 | { |
| 2127 | if (image->colorspace == CMYKColorspace) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2128 | *q=ScaleQuantumToLong(GetPixelBlack(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2129 | break; |
| 2130 | } |
| 2131 | case IndexQuantum: |
| 2132 | { |
cristy | f13c594 | 2012-08-08 23:50:11 +0000 | [diff] [blame] | 2133 | *q=ScaleQuantumToLong(ClampToQuantum(GetPixelIntensity(image,p))); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2134 | break; |
| 2135 | } |
| 2136 | default: |
| 2137 | break; |
| 2138 | } |
| 2139 | q++; |
| 2140 | } |
| 2141 | p++; |
| 2142 | } |
| 2143 | break; |
| 2144 | } |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 2145 | case LongLongPixel: |
| 2146 | { |
| 2147 | register MagickSizeType |
| 2148 | *q; |
| 2149 | |
| 2150 | q=(MagickSizeType *) stream_info->pixels; |
| 2151 | if (LocaleCompare(stream_info->map,"BGR") == 0) |
| 2152 | { |
| 2153 | p=GetVirtualPixelQueue(image); |
| 2154 | if (p == (const Quantum *) NULL) |
| 2155 | break; |
| 2156 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
| 2157 | { |
| 2158 | *q++=ScaleQuantumToLongLong(GetPixelBlue(image,p)); |
| 2159 | *q++=ScaleQuantumToLongLong(GetPixelGreen(image,p)); |
| 2160 | *q++=ScaleQuantumToLongLong(GetPixelRed(image,p)); |
| 2161 | p++; |
| 2162 | } |
| 2163 | break; |
| 2164 | } |
| 2165 | if (LocaleCompare(stream_info->map,"BGRA") == 0) |
| 2166 | { |
| 2167 | p=GetVirtualPixelQueue(image); |
| 2168 | if (p == (const Quantum *) NULL) |
| 2169 | break; |
| 2170 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
| 2171 | { |
| 2172 | *q++=ScaleQuantumToLongLong(GetPixelBlue(image,p)); |
| 2173 | *q++=ScaleQuantumToLongLong(GetPixelGreen(image,p)); |
| 2174 | *q++=ScaleQuantumToLongLong(GetPixelRed(image,p)); |
| 2175 | *q++=ScaleQuantumToLongLong(GetPixelAlpha(image,p)); |
| 2176 | p++; |
| 2177 | } |
| 2178 | break; |
| 2179 | } |
| 2180 | if (LocaleCompare(stream_info->map,"BGRP") == 0) |
| 2181 | { |
| 2182 | p=GetVirtualPixelQueue(image); |
| 2183 | if (p == (const Quantum *) NULL) |
| 2184 | break; |
| 2185 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
| 2186 | { |
| 2187 | *q++=ScaleQuantumToLongLong(GetPixelBlue(image,p)); |
| 2188 | *q++=ScaleQuantumToLongLong(GetPixelGreen(image,p)); |
| 2189 | *q++=ScaleQuantumToLongLong(GetPixelRed(image,p)); |
| 2190 | *q++=0U; |
| 2191 | p++; |
| 2192 | } |
| 2193 | break; |
| 2194 | } |
| 2195 | if (LocaleCompare(stream_info->map,"I") == 0) |
| 2196 | { |
| 2197 | p=GetVirtualPixelQueue(image); |
| 2198 | if (p == (const Quantum *) NULL) |
| 2199 | break; |
| 2200 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
| 2201 | { |
cristy | f13c594 | 2012-08-08 23:50:11 +0000 | [diff] [blame] | 2202 | *q++=ScaleQuantumToLongLong(ClampToQuantum( |
| 2203 | GetPixelIntensity(image,p))); |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 2204 | p++; |
| 2205 | } |
| 2206 | break; |
| 2207 | } |
| 2208 | if (LocaleCompare(stream_info->map,"RGB") == 0) |
| 2209 | { |
| 2210 | p=GetVirtualPixelQueue(image); |
| 2211 | if (p == (const Quantum *) NULL) |
| 2212 | break; |
| 2213 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
| 2214 | { |
| 2215 | *q++=ScaleQuantumToLongLong(GetPixelRed(image,p)); |
| 2216 | *q++=ScaleQuantumToLongLong(GetPixelGreen(image,p)); |
| 2217 | *q++=ScaleQuantumToLongLong(GetPixelBlue(image,p)); |
| 2218 | p++; |
| 2219 | } |
| 2220 | break; |
| 2221 | } |
| 2222 | if (LocaleCompare(stream_info->map,"RGBA") == 0) |
| 2223 | { |
| 2224 | p=GetVirtualPixelQueue(image); |
| 2225 | if (p == (const Quantum *) NULL) |
| 2226 | break; |
| 2227 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
| 2228 | { |
| 2229 | *q++=ScaleQuantumToLongLong(GetPixelRed(image,p)); |
| 2230 | *q++=ScaleQuantumToLongLong(GetPixelGreen(image,p)); |
| 2231 | *q++=ScaleQuantumToLongLong(GetPixelBlue(image,p)); |
| 2232 | *q++=ScaleQuantumToLongLong(GetPixelAlpha(image,p)); |
| 2233 | p++; |
| 2234 | } |
| 2235 | break; |
| 2236 | } |
| 2237 | if (LocaleCompare(stream_info->map,"RGBP") == 0) |
| 2238 | { |
| 2239 | p=GetVirtualPixelQueue(image); |
| 2240 | if (p == (const Quantum *) NULL) |
| 2241 | break; |
| 2242 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
| 2243 | { |
| 2244 | *q++=ScaleQuantumToLongLong(GetPixelRed(image,p)); |
| 2245 | *q++=ScaleQuantumToLongLong(GetPixelGreen(image,p)); |
| 2246 | *q++=ScaleQuantumToLongLong(GetPixelBlue(image,p)); |
| 2247 | *q++=0U; |
| 2248 | p++; |
| 2249 | } |
| 2250 | break; |
| 2251 | } |
| 2252 | p=GetVirtualPixelQueue(image); |
| 2253 | if (p == (const Quantum *) NULL) |
| 2254 | break; |
| 2255 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
| 2256 | { |
| 2257 | for (i=0; i < (ssize_t) length; i++) |
| 2258 | { |
| 2259 | *q=0; |
| 2260 | switch (quantum_map[i]) |
| 2261 | { |
| 2262 | case RedQuantum: |
| 2263 | case CyanQuantum: |
| 2264 | { |
| 2265 | *q=ScaleQuantumToLongLong(GetPixelRed(image,p)); |
| 2266 | break; |
| 2267 | } |
| 2268 | case GreenQuantum: |
| 2269 | case MagentaQuantum: |
| 2270 | { |
| 2271 | *q=ScaleQuantumToLongLong(GetPixelGreen(image,p)); |
| 2272 | break; |
| 2273 | } |
| 2274 | case BlueQuantum: |
| 2275 | case YellowQuantum: |
| 2276 | { |
| 2277 | *q=ScaleQuantumToLongLong(GetPixelBlue(image,p)); |
| 2278 | break; |
| 2279 | } |
| 2280 | case AlphaQuantum: |
| 2281 | { |
| 2282 | *q=ScaleQuantumToLongLong(GetPixelAlpha(image,p)); |
| 2283 | break; |
| 2284 | } |
| 2285 | case OpacityQuantum: |
| 2286 | { |
| 2287 | *q=ScaleQuantumToLongLong(GetPixelAlpha(image,p)); |
| 2288 | break; |
| 2289 | } |
| 2290 | case BlackQuantum: |
| 2291 | { |
| 2292 | if (image->colorspace == CMYKColorspace) |
| 2293 | *q=ScaleQuantumToLongLong(GetPixelBlack(image,p)); |
| 2294 | break; |
| 2295 | } |
| 2296 | case IndexQuantum: |
| 2297 | { |
cristy | f13c594 | 2012-08-08 23:50:11 +0000 | [diff] [blame] | 2298 | *q=ScaleQuantumToLongLong(ClampToQuantum( |
| 2299 | GetPixelIntensity(image,p))); |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 2300 | break; |
| 2301 | } |
| 2302 | default: |
| 2303 | *q=0; |
| 2304 | } |
| 2305 | q++; |
| 2306 | } |
| 2307 | p++; |
| 2308 | } |
| 2309 | break; |
| 2310 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2311 | case QuantumPixel: |
| 2312 | { |
| 2313 | register Quantum |
| 2314 | *q; |
| 2315 | |
| 2316 | q=(Quantum *) stream_info->pixels; |
| 2317 | if (LocaleCompare(stream_info->map,"BGR") == 0) |
| 2318 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 2319 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2320 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2321 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2322 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2323 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2324 | *q++=GetPixelBlue(image,p); |
| 2325 | *q++=GetPixelGreen(image,p); |
| 2326 | *q++=GetPixelRed(image,p); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2327 | p++; |
| 2328 | } |
| 2329 | break; |
| 2330 | } |
| 2331 | if (LocaleCompare(stream_info->map,"BGRA") == 0) |
| 2332 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 2333 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2334 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2335 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2336 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2337 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2338 | *q++=GetPixelBlue(image,p); |
| 2339 | *q++=GetPixelGreen(image,p); |
| 2340 | *q++=GetPixelRed(image,p); |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 2341 | *q++=GetPixelAlpha(image,p); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2342 | p++; |
| 2343 | } |
| 2344 | break; |
| 2345 | } |
| 2346 | if (LocaleCompare(stream_info->map,"BGRP") == 0) |
| 2347 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 2348 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2349 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2350 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2351 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2352 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2353 | *q++=GetPixelBlue(image,p); |
| 2354 | *q++=GetPixelGreen(image,p); |
| 2355 | *q++=GetPixelRed(image,p); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2356 | *q++=0; |
| 2357 | p++; |
| 2358 | } |
| 2359 | break; |
| 2360 | } |
| 2361 | if (LocaleCompare(stream_info->map,"I") == 0) |
| 2362 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 2363 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2364 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2365 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2366 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2367 | { |
cristy | f13c594 | 2012-08-08 23:50:11 +0000 | [diff] [blame] | 2368 | *q++=ClampToQuantum(GetPixelIntensity(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2369 | p++; |
| 2370 | } |
| 2371 | break; |
| 2372 | } |
| 2373 | if (LocaleCompare(stream_info->map,"RGB") == 0) |
| 2374 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 2375 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2376 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2377 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2378 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2379 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2380 | *q++=GetPixelRed(image,p); |
| 2381 | *q++=GetPixelGreen(image,p); |
| 2382 | *q++=GetPixelBlue(image,p); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2383 | p++; |
| 2384 | } |
| 2385 | break; |
| 2386 | } |
| 2387 | if (LocaleCompare(stream_info->map,"RGBA") == 0) |
| 2388 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 2389 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2390 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2391 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2392 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2393 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2394 | *q++=GetPixelRed(image,p); |
| 2395 | *q++=GetPixelGreen(image,p); |
| 2396 | *q++=GetPixelBlue(image,p); |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 2397 | *q++=GetPixelAlpha(image,p); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2398 | p++; |
| 2399 | } |
| 2400 | break; |
| 2401 | } |
| 2402 | if (LocaleCompare(stream_info->map,"RGBP") == 0) |
| 2403 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 2404 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2405 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2406 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2407 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2408 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2409 | *q++=GetPixelRed(image,p); |
| 2410 | *q++=GetPixelGreen(image,p); |
| 2411 | *q++=GetPixelBlue(image,p); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2412 | *q++=0U; |
| 2413 | p++; |
| 2414 | } |
| 2415 | break; |
| 2416 | } |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 2417 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2418 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2419 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2420 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2421 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2422 | for (i=0; i < (ssize_t) length; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2423 | { |
| 2424 | *q=(Quantum) 0; |
| 2425 | switch (quantum_map[i]) |
| 2426 | { |
| 2427 | case RedQuantum: |
| 2428 | case CyanQuantum: |
| 2429 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2430 | *q=GetPixelRed(image,p); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2431 | break; |
| 2432 | } |
| 2433 | case GreenQuantum: |
| 2434 | case MagentaQuantum: |
| 2435 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2436 | *q=GetPixelGreen(image,p); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2437 | break; |
| 2438 | } |
| 2439 | case BlueQuantum: |
| 2440 | case YellowQuantum: |
| 2441 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2442 | *q=GetPixelBlue(image,p); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2443 | break; |
| 2444 | } |
| 2445 | case AlphaQuantum: |
| 2446 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2447 | *q=(Quantum) (GetPixelAlpha(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2448 | break; |
| 2449 | } |
| 2450 | case OpacityQuantum: |
| 2451 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2452 | *q=GetPixelAlpha(image,p); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2453 | break; |
| 2454 | } |
| 2455 | case BlackQuantum: |
| 2456 | { |
| 2457 | if (image->colorspace == CMYKColorspace) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2458 | *q=GetPixelBlack(image,p); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2459 | break; |
| 2460 | } |
| 2461 | case IndexQuantum: |
| 2462 | { |
cristy | f13c594 | 2012-08-08 23:50:11 +0000 | [diff] [blame] | 2463 | *q=ClampToQuantum(GetPixelIntensity(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2464 | break; |
| 2465 | } |
| 2466 | default: |
| 2467 | *q=0; |
| 2468 | } |
| 2469 | q++; |
| 2470 | } |
| 2471 | p++; |
| 2472 | } |
| 2473 | break; |
| 2474 | } |
| 2475 | case ShortPixel: |
| 2476 | { |
| 2477 | register unsigned short |
| 2478 | *q; |
| 2479 | |
| 2480 | q=(unsigned short *) stream_info->pixels; |
| 2481 | if (LocaleCompare(stream_info->map,"BGR") == 0) |
| 2482 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 2483 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2484 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2485 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2486 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2487 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2488 | *q++=ScaleQuantumToShort(GetPixelBlue(image,p)); |
| 2489 | *q++=ScaleQuantumToShort(GetPixelGreen(image,p)); |
| 2490 | *q++=ScaleQuantumToShort(GetPixelRed(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2491 | p++; |
| 2492 | } |
| 2493 | break; |
| 2494 | } |
| 2495 | if (LocaleCompare(stream_info->map,"BGRA") == 0) |
| 2496 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 2497 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2498 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2499 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2500 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2501 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2502 | *q++=ScaleQuantumToShort(GetPixelBlue(image,p)); |
| 2503 | *q++=ScaleQuantumToShort(GetPixelGreen(image,p)); |
| 2504 | *q++=ScaleQuantumToShort(GetPixelRed(image,p)); |
| 2505 | *q++=ScaleQuantumToShort((Quantum) (GetPixelAlpha(image,p))); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2506 | p++; |
| 2507 | } |
| 2508 | break; |
| 2509 | } |
| 2510 | if (LocaleCompare(stream_info->map,"BGRP") == 0) |
| 2511 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 2512 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2513 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2514 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2515 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2516 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2517 | *q++=ScaleQuantumToShort(GetPixelBlue(image,p)); |
| 2518 | *q++=ScaleQuantumToShort(GetPixelGreen(image,p)); |
| 2519 | *q++=ScaleQuantumToShort(GetPixelRed(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2520 | *q++=0; |
| 2521 | p++; |
| 2522 | } |
| 2523 | break; |
| 2524 | } |
| 2525 | if (LocaleCompare(stream_info->map,"I") == 0) |
| 2526 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 2527 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2528 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2529 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2530 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2531 | { |
cristy | f13c594 | 2012-08-08 23:50:11 +0000 | [diff] [blame] | 2532 | *q++=ScaleQuantumToShort(ClampToQuantum( |
| 2533 | GetPixelIntensity(image,p))); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2534 | p++; |
| 2535 | } |
| 2536 | break; |
| 2537 | } |
| 2538 | if (LocaleCompare(stream_info->map,"RGB") == 0) |
| 2539 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 2540 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2541 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2542 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2543 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2544 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2545 | *q++=ScaleQuantumToShort(GetPixelRed(image,p)); |
| 2546 | *q++=ScaleQuantumToShort(GetPixelGreen(image,p)); |
| 2547 | *q++=ScaleQuantumToShort(GetPixelBlue(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2548 | p++; |
| 2549 | } |
| 2550 | break; |
| 2551 | } |
| 2552 | if (LocaleCompare(stream_info->map,"RGBA") == 0) |
| 2553 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 2554 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2555 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2556 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2557 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2558 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2559 | *q++=ScaleQuantumToShort(GetPixelRed(image,p)); |
| 2560 | *q++=ScaleQuantumToShort(GetPixelGreen(image,p)); |
| 2561 | *q++=ScaleQuantumToShort(GetPixelBlue(image,p)); |
| 2562 | *q++=ScaleQuantumToShort((Quantum) (GetPixelAlpha(image,p))); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2563 | p++; |
| 2564 | } |
| 2565 | break; |
| 2566 | } |
| 2567 | if (LocaleCompare(stream_info->map,"RGBP") == 0) |
| 2568 | { |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 2569 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2570 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2571 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2572 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2573 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2574 | *q++=ScaleQuantumToShort(GetPixelRed(image,p)); |
| 2575 | *q++=ScaleQuantumToShort(GetPixelGreen(image,p)); |
| 2576 | *q++=ScaleQuantumToShort(GetPixelBlue(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2577 | *q++=0; |
| 2578 | p++; |
| 2579 | } |
| 2580 | break; |
| 2581 | } |
cristy | 100b8d9 | 2012-01-08 00:32:49 +0000 | [diff] [blame] | 2582 | p=GetVirtualPixelQueue(image); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2583 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2584 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2585 | for (x=0; x < (ssize_t) GetImageExtent(image); x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2586 | { |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 2587 | for (i=0; i < (ssize_t) length; i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2588 | { |
| 2589 | *q=0; |
| 2590 | switch (quantum_map[i]) |
| 2591 | { |
| 2592 | case RedQuantum: |
| 2593 | case CyanQuantum: |
| 2594 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2595 | *q=ScaleQuantumToShort(GetPixelRed(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2596 | break; |
| 2597 | } |
| 2598 | case GreenQuantum: |
| 2599 | case MagentaQuantum: |
| 2600 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2601 | *q=ScaleQuantumToShort(GetPixelGreen(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2602 | break; |
| 2603 | } |
| 2604 | case BlueQuantum: |
| 2605 | case YellowQuantum: |
| 2606 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2607 | *q=ScaleQuantumToShort(GetPixelBlue(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2608 | break; |
| 2609 | } |
| 2610 | case AlphaQuantum: |
| 2611 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2612 | *q=ScaleQuantumToShort(GetPixelAlpha(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2613 | break; |
| 2614 | } |
| 2615 | case OpacityQuantum: |
| 2616 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2617 | *q=ScaleQuantumToShort(GetPixelAlpha(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2618 | break; |
| 2619 | } |
| 2620 | case BlackQuantum: |
| 2621 | { |
| 2622 | if (image->colorspace == CMYKColorspace) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 2623 | *q=ScaleQuantumToShort(GetPixelBlack(image,p)); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2624 | break; |
| 2625 | } |
| 2626 | case IndexQuantum: |
| 2627 | { |
cristy | f13c594 | 2012-08-08 23:50:11 +0000 | [diff] [blame] | 2628 | *q=ScaleQuantumToShort(ClampToQuantum( |
| 2629 | GetPixelIntensity(image,p))); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2630 | break; |
| 2631 | } |
| 2632 | default: |
| 2633 | break; |
| 2634 | } |
| 2635 | q++; |
| 2636 | } |
| 2637 | p++; |
| 2638 | } |
| 2639 | break; |
| 2640 | } |
| 2641 | default: |
| 2642 | { |
| 2643 | quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map); |
| 2644 | (void) ThrowMagickException(exception,GetMagickModule(),OptionError, |
cristy | 20cc087 | 2012-08-20 00:01:19 +0000 | [diff] [blame] | 2645 | "UnrecognizedPixelMap","'%s'",stream_info->map); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2646 | break; |
| 2647 | } |
| 2648 | } |
| 2649 | quantum_map=(QuantumType *) RelinquishMagickMemory(quantum_map); |
| 2650 | return(MagickTrue); |
| 2651 | } |
| 2652 | |
| 2653 | /* |
| 2654 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2655 | % % |
| 2656 | % % |
| 2657 | % % |
| 2658 | + 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 % |
| 2659 | % % |
| 2660 | % % |
| 2661 | % % |
| 2662 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2663 | % |
| 2664 | % SyncAuthenticPixelsStream() calls the user supplied callback method with |
| 2665 | % the latest stream of pixels. |
| 2666 | % |
| 2667 | % The format of the SyncAuthenticPixelsStream method is: |
| 2668 | % |
| 2669 | % MagickBooleanType SyncAuthenticPixelsStream(Image *image, |
| 2670 | % ExceptionInfo *exception) |
| 2671 | % |
| 2672 | % A description of each parameter follows: |
| 2673 | % |
| 2674 | % o image: the image. |
| 2675 | % |
| 2676 | % o exception: return any errors or warnings in this structure. |
| 2677 | % |
| 2678 | */ |
| 2679 | static MagickBooleanType SyncAuthenticPixelsStream(Image *image, |
| 2680 | ExceptionInfo *exception) |
| 2681 | { |
| 2682 | CacheInfo |
| 2683 | *cache_info; |
| 2684 | |
| 2685 | size_t |
| 2686 | length; |
| 2687 | |
| 2688 | StreamHandler |
| 2689 | stream_handler; |
| 2690 | |
| 2691 | assert(image != (Image *) NULL); |
| 2692 | assert(image->signature == MagickSignature); |
| 2693 | if (image->debug != MagickFalse) |
| 2694 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 2695 | cache_info=(CacheInfo *) image->cache; |
| 2696 | assert(cache_info->signature == MagickSignature); |
| 2697 | stream_handler=GetBlobStreamHandler(image); |
| 2698 | if (stream_handler == (StreamHandler) NULL) |
| 2699 | { |
| 2700 | (void) ThrowMagickException(exception,GetMagickModule(),StreamError, |
cristy | 20cc087 | 2012-08-20 00:01:19 +0000 | [diff] [blame] | 2701 | "NoStreamHandlerIsDefined","'%s'",image->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2702 | return(MagickFalse); |
| 2703 | } |
| 2704 | length=stream_handler(image,cache_info->pixels,(size_t) cache_info->columns); |
| 2705 | return(length == cache_info->columns ? MagickTrue : MagickFalse); |
| 2706 | } |
| 2707 | |
| 2708 | /* |
| 2709 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2710 | % % |
| 2711 | % % |
| 2712 | % % |
| 2713 | % W r i t e S t r e a m % |
| 2714 | % % |
| 2715 | % % |
| 2716 | % % |
| 2717 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2718 | % |
| 2719 | % WriteStream() makes the image pixels available to a user supplied callback |
| 2720 | % method immediately upon writing pixel data with the WriteImage() method. |
| 2721 | % |
| 2722 | % The format of the WriteStream() method is: |
| 2723 | % |
| 2724 | % MagickBooleanType WriteStream(const ImageInfo *image_info,Image *, |
cristy | c82a27b | 2011-10-21 01:07:16 +0000 | [diff] [blame] | 2725 | % StreamHandler stream,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2726 | % |
| 2727 | % A description of each parameter follows: |
| 2728 | % |
| 2729 | % o image_info: the image info. |
| 2730 | % |
| 2731 | % o stream: A callback method. |
| 2732 | % |
cristy | c82a27b | 2011-10-21 01:07:16 +0000 | [diff] [blame] | 2733 | % o exception: return any errors or warnings in this structure. |
| 2734 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2735 | */ |
| 2736 | MagickExport MagickBooleanType WriteStream(const ImageInfo *image_info, |
cristy | c82a27b | 2011-10-21 01:07:16 +0000 | [diff] [blame] | 2737 | Image *image,StreamHandler stream,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2738 | { |
| 2739 | ImageInfo |
| 2740 | *write_info; |
| 2741 | |
| 2742 | MagickBooleanType |
| 2743 | status; |
| 2744 | |
| 2745 | assert(image_info != (ImageInfo *) NULL); |
| 2746 | assert(image_info->signature == MagickSignature); |
| 2747 | if (image_info->debug != MagickFalse) |
| 2748 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 2749 | image_info->filename); |
| 2750 | assert(image != (Image *) NULL); |
| 2751 | assert(image->signature == MagickSignature); |
| 2752 | write_info=CloneImageInfo(image_info); |
| 2753 | write_info->stream=stream; |
cristy | c82a27b | 2011-10-21 01:07:16 +0000 | [diff] [blame] | 2754 | status=WriteImage(write_info,image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 2755 | write_info=DestroyImageInfo(write_info); |
| 2756 | return(status); |
| 2757 | } |