cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
| 6 | % RRRR GGGG BBBB % |
| 7 | % R R G B B % |
| 8 | % RRRR G GG BBBB % |
| 9 | % R R G G B B % |
| 10 | % R R GGG BBBB % |
| 11 | % % |
| 12 | % % |
| 13 | % Read/Write Raw RGB Image Format % |
| 14 | % % |
| 15 | % Software Design % |
| 16 | % John Cristy % |
| 17 | % July 1992 % |
| 18 | % % |
| 19 | % % |
| 20 | % Copyright 1999-2008 ImageMagick Studio LLC, a non-profit organization % |
| 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 | Include declarations. |
| 41 | */ |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 42 | #include "MagickCore/studio.h" |
| 43 | #include "MagickCore/blob.h" |
| 44 | #include "MagickCore/blob-private.h" |
| 45 | #include "MagickCore/cache.h" |
| 46 | #include "MagickCore/colorspace.h" |
cristy | 510d06a | 2011-07-06 23:43:54 +0000 | [diff] [blame] | 47 | #include "MagickCore/colorspace-private.h" |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 48 | #include "MagickCore/constitute.h" |
| 49 | #include "MagickCore/exception.h" |
| 50 | #include "MagickCore/exception-private.h" |
| 51 | #include "MagickCore/image.h" |
| 52 | #include "MagickCore/image-private.h" |
| 53 | #include "MagickCore/list.h" |
| 54 | #include "MagickCore/magick.h" |
| 55 | #include "MagickCore/memory_.h" |
| 56 | #include "MagickCore/monitor.h" |
| 57 | #include "MagickCore/monitor-private.h" |
| 58 | #include "MagickCore/pixel-accessor.h" |
| 59 | #include "MagickCore/quantum-private.h" |
| 60 | #include "MagickCore/static.h" |
| 61 | #include "MagickCore/statistic.h" |
| 62 | #include "MagickCore/string_.h" |
| 63 | #include "MagickCore/module.h" |
| 64 | #include "MagickCore/utility.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 65 | |
| 66 | /* |
| 67 | Forward declarations. |
| 68 | */ |
| 69 | static MagickBooleanType |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 70 | WriteRGBImage(const ImageInfo *,Image *,ExceptionInfo *); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 71 | |
| 72 | /* |
| 73 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 74 | % % |
| 75 | % % |
| 76 | % % |
| 77 | % R e a d R G B I m a g e % |
| 78 | % % |
| 79 | % % |
| 80 | % % |
| 81 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 82 | % |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 83 | % ReadRGBImage() reads an image of raw RGB, RGBA, or RGBO samples and returns |
| 84 | % it. It allocates the memory necessary for the new Image structure and |
| 85 | % returns a pointer to the new image. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 86 | % |
| 87 | % The format of the ReadRGBImage method is: |
| 88 | % |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 89 | % Image *ReadRGBImage(const ImageInfo *image_info, |
| 90 | % ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 91 | % |
| 92 | % A description of each parameter follows: |
| 93 | % |
| 94 | % o image_info: the image info. |
| 95 | % |
| 96 | % o exception: return any errors or warnings in this structure. |
| 97 | % |
| 98 | */ |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 99 | static Image *ReadRGBImage(const ImageInfo *image_info, |
| 100 | ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 101 | { |
| 102 | Image |
| 103 | *canvas_image, |
| 104 | *image; |
| 105 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 106 | MagickBooleanType |
| 107 | status; |
| 108 | |
| 109 | MagickOffsetType |
| 110 | scene; |
| 111 | |
| 112 | QuantumInfo |
| 113 | *quantum_info; |
| 114 | |
| 115 | QuantumType |
| 116 | quantum_type; |
| 117 | |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 118 | register ssize_t |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 119 | i; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 120 | |
cristy | c6da28e | 2011-04-28 01:41:35 +0000 | [diff] [blame] | 121 | size_t |
| 122 | length; |
| 123 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 124 | ssize_t |
cristy | a38675f | 2010-08-21 18:35:13 +0000 | [diff] [blame] | 125 | count, |
| 126 | y; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 127 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 128 | unsigned char |
| 129 | *pixels; |
| 130 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 131 | /* |
| 132 | Open image file. |
| 133 | */ |
| 134 | assert(image_info != (const ImageInfo *) NULL); |
| 135 | assert(image_info->signature == MagickSignature); |
| 136 | if (image_info->debug != MagickFalse) |
| 137 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 138 | image_info->filename); |
| 139 | assert(exception != (ExceptionInfo *) NULL); |
| 140 | assert(exception->signature == MagickSignature); |
| 141 | image=AcquireImage(image_info); |
| 142 | if ((image->columns == 0) || (image->rows == 0)) |
| 143 | ThrowReaderException(OptionError,"MustSpecifyImageSize"); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 144 | image->colorspace=RGBColorspace; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 145 | if (image_info->interlace != PartitionInterlace) |
| 146 | { |
| 147 | status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); |
| 148 | if (status == MagickFalse) |
| 149 | { |
| 150 | image=DestroyImageList(image); |
| 151 | return((Image *) NULL); |
| 152 | } |
cristy | d429702 | 2010-09-16 22:59:09 +0000 | [diff] [blame] | 153 | if (DiscardBlobBytes(image,image->offset) == MagickFalse) |
| 154 | ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile", |
| 155 | image->filename); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 156 | } |
| 157 | /* |
| 158 | Create virtual canvas to support cropping (i.e. image.rgb[100x100+10+20]). |
| 159 | */ |
| 160 | canvas_image=CloneImage(image,image->extract_info.width,1,MagickFalse, |
| 161 | exception); |
| 162 | (void) SetImageVirtualPixelMethod(canvas_image,BlackVirtualPixelMethod); |
| 163 | quantum_info=AcquireQuantumInfo(image_info,canvas_image); |
| 164 | if (quantum_info == (QuantumInfo *) NULL) |
| 165 | ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); |
| 166 | pixels=GetQuantumPixels(quantum_info); |
| 167 | quantum_type=RGBQuantum; |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 168 | if (LocaleCompare(image_info->magick,"RGBA") == 0) |
cristy | a38675f | 2010-08-21 18:35:13 +0000 | [diff] [blame] | 169 | { |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 170 | quantum_type=RGBAQuantum; |
| 171 | image->matte=MagickTrue; |
cristy | a38675f | 2010-08-21 18:35:13 +0000 | [diff] [blame] | 172 | } |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 173 | if (LocaleCompare(image_info->magick,"RGBO") == 0) |
| 174 | { |
| 175 | quantum_type=RGBOQuantum; |
| 176 | image->matte=MagickTrue; |
| 177 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 178 | if (image_info->number_scenes != 0) |
| 179 | while (image->scene < image_info->scene) |
| 180 | { |
| 181 | /* |
| 182 | Skip to next image. |
| 183 | */ |
| 184 | image->scene++; |
| 185 | length=GetQuantumExtent(canvas_image,quantum_info,quantum_type); |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 186 | for (y=0; y < (ssize_t) image->rows; y++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 187 | { |
| 188 | count=ReadBlob(image,length,pixels); |
| 189 | if (count != (ssize_t) length) |
| 190 | break; |
| 191 | } |
| 192 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 193 | count=0; |
| 194 | length=0; |
| 195 | scene=0; |
| 196 | do |
| 197 | { |
| 198 | /* |
| 199 | Read pixels to virtual canvas image then push to image. |
| 200 | */ |
| 201 | if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0)) |
| 202 | if (image->scene >= (image_info->scene+image_info->number_scenes-1)) |
| 203 | break; |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 204 | image->colorspace=RGBColorspace; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 205 | switch (image_info->interlace) |
| 206 | { |
| 207 | case NoInterlace: |
| 208 | default: |
| 209 | { |
| 210 | /* |
| 211 | No interlacing: RGBRGBRGBRGBRGBRGB... |
| 212 | */ |
| 213 | if (scene == 0) |
| 214 | { |
| 215 | length=GetQuantumExtent(canvas_image,quantum_info,quantum_type); |
| 216 | count=ReadBlob(image,length,pixels); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 217 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 218 | for (y=0; y < (ssize_t) image->extract_info.height; y++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 219 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 220 | register const Quantum |
cristy | c47d1f8 | 2009-11-26 01:44:43 +0000 | [diff] [blame] | 221 | *restrict p; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 222 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 223 | register Quantum |
cristy | c47d1f8 | 2009-11-26 01:44:43 +0000 | [diff] [blame] | 224 | *restrict q; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 225 | |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 226 | register ssize_t |
| 227 | x; |
| 228 | |
cristy | 21da32d | 2009-09-12 14:56:09 +0000 | [diff] [blame] | 229 | if (count != (ssize_t) length) |
| 230 | { |
| 231 | ThrowFileException(exception,CorruptImageError, |
| 232 | "UnexpectedEndOfFile",image->filename); |
| 233 | break; |
| 234 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 235 | q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1, |
| 236 | exception); |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 237 | if (q == (Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 238 | break; |
| 239 | length=ImportQuantumPixels(canvas_image,(CacheView *) NULL, |
| 240 | quantum_info,quantum_type,pixels,exception); |
| 241 | if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse) |
| 242 | break; |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 243 | if (((y-image->extract_info.y) >= 0) && |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 244 | ((y-image->extract_info.y) < (ssize_t) image->rows)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 245 | { |
| 246 | p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0, |
| 247 | canvas_image->columns,1,exception); |
| 248 | q=QueueAuthenticPixels(image,0,y-image->extract_info.y, |
| 249 | image->columns,1,exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 250 | if ((p == (const Quantum *) NULL) || |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 251 | (q == (Quantum *) NULL)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 252 | break; |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 253 | for (x=0; x < (ssize_t) image->columns; x++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 254 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 255 | SetPixelRed(image,GetPixelRed(canvas_image,p),q); |
| 256 | SetPixelGreen(image,GetPixelGreen(canvas_image,p),q); |
| 257 | SetPixelBlue(image,GetPixelBlue(canvas_image,p),q); |
| 258 | SetPixelAlpha(image,OpaqueAlpha,q); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 259 | if (image->matte != MagickFalse) |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 260 | SetPixelAlpha(image,GetPixelAlpha(canvas_image,p),q); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 261 | p+=GetPixelChannels(canvas_image); |
| 262 | q+=GetPixelChannels(image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 263 | } |
| 264 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
| 265 | break; |
| 266 | } |
| 267 | if (image->previous == (Image *) NULL) |
| 268 | { |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 269 | status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, |
| 270 | image->rows); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 271 | if (status == MagickFalse) |
| 272 | break; |
| 273 | } |
| 274 | count=ReadBlob(image,length,pixels); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 275 | } |
| 276 | break; |
| 277 | } |
| 278 | case LineInterlace: |
| 279 | { |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 280 | static QuantumType |
| 281 | quantum_types[4] = |
| 282 | { |
| 283 | RedQuantum, |
| 284 | GreenQuantum, |
| 285 | BlueQuantum, |
| 286 | AlphaQuantum |
| 287 | }; |
| 288 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 289 | /* |
| 290 | Line interlacing: RRR...GGG...BBB...RRR...GGG...BBB... |
| 291 | */ |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 292 | if (LocaleCompare(image_info->magick,"RGBO") == 0) |
| 293 | quantum_types[3]=OpacityQuantum; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 294 | if (scene == 0) |
| 295 | { |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 296 | length=GetQuantumExtent(canvas_image,quantum_info,RedQuantum); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 297 | count=ReadBlob(image,length,pixels); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 298 | } |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 299 | for (y=0; y < (ssize_t) image->extract_info.height; y++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 300 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 301 | register const Quantum |
cristy | c47d1f8 | 2009-11-26 01:44:43 +0000 | [diff] [blame] | 302 | *restrict p; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 303 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 304 | register Quantum |
cristy | c47d1f8 | 2009-11-26 01:44:43 +0000 | [diff] [blame] | 305 | *restrict q; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 306 | |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 307 | register ssize_t |
| 308 | x; |
| 309 | |
cristy | 21da32d | 2009-09-12 14:56:09 +0000 | [diff] [blame] | 310 | if (count != (ssize_t) length) |
| 311 | { |
| 312 | ThrowFileException(exception,CorruptImageError, |
| 313 | "UnexpectedEndOfFile",image->filename); |
| 314 | break; |
| 315 | } |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 316 | for (i=0; i < (ssize_t) (image->matte != MagickFalse ? 4 : 3); i++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 317 | { |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 318 | quantum_type=quantum_types[i]; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 319 | q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1, |
| 320 | exception); |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 321 | if (q == (Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 322 | break; |
| 323 | length=ImportQuantumPixels(canvas_image,(CacheView *) NULL, |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 324 | quantum_info,quantum_type,pixels,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 325 | if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse) |
| 326 | break; |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 327 | if (((y-image->extract_info.y) >= 0) && |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 328 | ((y-image->extract_info.y) < (ssize_t) image->rows)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 329 | { |
| 330 | p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x, |
| 331 | 0,canvas_image->columns,1,exception); |
| 332 | q=GetAuthenticPixels(image,0,y-image->extract_info.y, |
| 333 | image->columns,1,exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 334 | if ((p == (const Quantum *) NULL) || |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 335 | (q == (Quantum *) NULL)) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 336 | break; |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 337 | for (x=0; x < (ssize_t) image->columns; x++) |
| 338 | { |
| 339 | switch (quantum_type) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 340 | { |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 341 | case RedQuantum: |
| 342 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 343 | SetPixelRed(image,GetPixelRed(canvas_image,p),q); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 344 | break; |
| 345 | } |
| 346 | case GreenQuantum: |
| 347 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 348 | SetPixelGreen(image,GetPixelGreen(canvas_image,p),q); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 349 | break; |
| 350 | } |
| 351 | case BlueQuantum: |
| 352 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 353 | SetPixelBlue(image,GetPixelBlue(canvas_image,p),q); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 354 | break; |
| 355 | } |
| 356 | case OpacityQuantum: |
| 357 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 358 | SetPixelAlpha(image,GetPixelAlpha(canvas_image,p),q); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 359 | break; |
| 360 | } |
| 361 | case AlphaQuantum: |
| 362 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 363 | SetPixelAlpha(image,GetPixelAlpha(canvas_image,p),q); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 364 | break; |
| 365 | } |
| 366 | default: |
| 367 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 368 | } |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 369 | p+=GetPixelChannels(canvas_image); |
| 370 | q+=GetPixelChannels(image); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 371 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 372 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
| 373 | break; |
| 374 | } |
| 375 | count=ReadBlob(image,length,pixels); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 376 | } |
| 377 | if (image->previous == (Image *) NULL) |
| 378 | { |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 379 | status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, |
| 380 | image->rows); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 381 | if (status == MagickFalse) |
| 382 | break; |
| 383 | } |
| 384 | } |
| 385 | break; |
| 386 | } |
| 387 | case PlaneInterlace: |
| 388 | { |
| 389 | /* |
| 390 | Plane interlacing: RRRRRR...GGGGGG...BBBBBB... |
| 391 | */ |
| 392 | if (scene == 0) |
| 393 | { |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 394 | length=GetQuantumExtent(canvas_image,quantum_info,RedQuantum); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 395 | count=ReadBlob(image,length,pixels); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 396 | } |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 397 | for (y=0; y < (ssize_t) image->extract_info.height; y++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 398 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 399 | register const Quantum |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 400 | *restrict p; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 401 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 402 | register Quantum |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 403 | *restrict q; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 404 | |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 405 | register ssize_t |
| 406 | x; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 407 | |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 408 | if (count != (ssize_t) length) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 409 | { |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 410 | ThrowFileException(exception,CorruptImageError, |
| 411 | "UnexpectedEndOfFile",image->filename); |
| 412 | break; |
| 413 | } |
| 414 | q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1, |
| 415 | exception); |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 416 | if (q == (Quantum *) NULL) |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 417 | break; |
| 418 | length=ImportQuantumPixels(canvas_image,(CacheView *) NULL, |
| 419 | quantum_info,RedQuantum,pixels,exception); |
| 420 | if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse) |
| 421 | break; |
| 422 | if (((y-image->extract_info.y) >= 0) && |
| 423 | ((y-image->extract_info.y) < (ssize_t) image->rows)) |
| 424 | { |
| 425 | p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0, |
| 426 | canvas_image->columns,1,exception); |
| 427 | q=GetAuthenticPixels(image,0,y-image->extract_info.y, |
| 428 | image->columns,1,exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 429 | if ((p == (const Quantum *) NULL) || |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 430 | (q == (Quantum *) NULL)) |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 431 | break; |
| 432 | for (x=0; x < (ssize_t) image->columns; x++) |
| 433 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 434 | SetPixelRed(image,GetPixelRed(canvas_image,p),q); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 435 | p+=GetPixelChannels(canvas_image); |
| 436 | q+=GetPixelChannels(image); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 437 | } |
| 438 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 439 | break; |
| 440 | } |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 441 | count=ReadBlob(image,length,pixels); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 442 | } |
| 443 | if (image->previous == (Image *) NULL) |
| 444 | { |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 445 | status=SetImageProgress(image,LoadImageTag,1,6); |
| 446 | if (status == MagickFalse) |
| 447 | break; |
| 448 | } |
| 449 | for (y=0; y < (ssize_t) image->extract_info.height; y++) |
| 450 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 451 | register const Quantum |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 452 | *restrict p; |
| 453 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 454 | register Quantum |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 455 | *restrict q; |
| 456 | |
| 457 | register ssize_t |
| 458 | x; |
| 459 | |
| 460 | if (count != (ssize_t) length) |
| 461 | { |
| 462 | ThrowFileException(exception,CorruptImageError, |
| 463 | "UnexpectedEndOfFile",image->filename); |
| 464 | break; |
| 465 | } |
| 466 | q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1, |
| 467 | exception); |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 468 | if (q == (Quantum *) NULL) |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 469 | break; |
| 470 | length=ImportQuantumPixels(canvas_image,(CacheView *) NULL, |
| 471 | quantum_info,GreenQuantum,pixels,exception); |
| 472 | if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse) |
| 473 | break; |
| 474 | if (((y-image->extract_info.y) >= 0) && |
| 475 | ((y-image->extract_info.y) < (ssize_t) image->rows)) |
| 476 | { |
| 477 | p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0, |
| 478 | canvas_image->columns,1,exception); |
| 479 | q=GetAuthenticPixels(image,0,y-image->extract_info.y, |
| 480 | image->columns,1,exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 481 | if ((p == (const Quantum *) NULL) || |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 482 | (q == (Quantum *) NULL)) |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 483 | break; |
| 484 | for (x=0; x < (ssize_t) image->columns; x++) |
| 485 | { |
cristy | f27ee03 | 2011-09-29 17:51:41 +0000 | [diff] [blame^] | 486 | SetPixelGreen(image,GetPixelGreen(canvas_image,p),q); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 487 | p+=GetPixelChannels(canvas_image); |
| 488 | q+=GetPixelChannels(image); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 489 | } |
| 490 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
| 491 | break; |
| 492 | } |
| 493 | count=ReadBlob(image,length,pixels); |
| 494 | } |
| 495 | if (image->previous == (Image *) NULL) |
| 496 | { |
| 497 | status=SetImageProgress(image,LoadImageTag,2,6); |
| 498 | if (status == MagickFalse) |
| 499 | break; |
| 500 | } |
| 501 | for (y=0; y < (ssize_t) image->extract_info.height; y++) |
| 502 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 503 | register const Quantum |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 504 | *restrict p; |
| 505 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 506 | register Quantum |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 507 | *restrict q; |
| 508 | |
| 509 | register ssize_t |
| 510 | x; |
| 511 | |
| 512 | if (count != (ssize_t) length) |
| 513 | { |
| 514 | ThrowFileException(exception,CorruptImageError, |
| 515 | "UnexpectedEndOfFile",image->filename); |
| 516 | break; |
| 517 | } |
| 518 | q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1, |
| 519 | exception); |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 520 | if (q == (Quantum *) NULL) |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 521 | break; |
| 522 | length=ImportQuantumPixels(canvas_image,(CacheView *) NULL, |
| 523 | quantum_info,BlueQuantum,pixels,exception); |
| 524 | if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse) |
| 525 | break; |
| 526 | if (((y-image->extract_info.y) >= 0) && |
| 527 | ((y-image->extract_info.y) < (ssize_t) image->rows)) |
| 528 | { |
| 529 | p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0, |
| 530 | canvas_image->columns,1,exception); |
| 531 | q=GetAuthenticPixels(image,0,y-image->extract_info.y, |
| 532 | image->columns,1,exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 533 | if ((p == (const Quantum *) NULL) || |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 534 | (q == (Quantum *) NULL)) |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 535 | break; |
| 536 | for (x=0; x < (ssize_t) image->columns; x++) |
| 537 | { |
cristy | f27ee03 | 2011-09-29 17:51:41 +0000 | [diff] [blame^] | 538 | SetPixelBlue(image,GetPixelBlue(canvas_image,p),q); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 539 | p+=GetPixelChannels(canvas_image); |
| 540 | q+=GetPixelChannels(image); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 541 | } |
| 542 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
| 543 | break; |
| 544 | } |
| 545 | count=ReadBlob(image,length,pixels); |
| 546 | } |
| 547 | if (image->previous == (Image *) NULL) |
| 548 | { |
| 549 | status=SetImageProgress(image,LoadImageTag,3,6); |
| 550 | if (status == MagickFalse) |
| 551 | break; |
| 552 | } |
| 553 | if (image->previous == (Image *) NULL) |
| 554 | { |
| 555 | status=SetImageProgress(image,LoadImageTag,4,6); |
| 556 | if (status == MagickFalse) |
| 557 | break; |
| 558 | } |
| 559 | if (image->matte != MagickFalse) |
| 560 | { |
| 561 | for (y=0; y < (ssize_t) image->extract_info.height; y++) |
| 562 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 563 | register const Quantum |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 564 | *restrict p; |
| 565 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 566 | register Quantum |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 567 | *restrict q; |
| 568 | |
| 569 | register ssize_t |
| 570 | x; |
| 571 | |
| 572 | if (count != (ssize_t) length) |
| 573 | { |
| 574 | ThrowFileException(exception,CorruptImageError, |
| 575 | "UnexpectedEndOfFile",image->filename); |
| 576 | break; |
| 577 | } |
| 578 | q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1, |
| 579 | exception); |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 580 | if (q == (Quantum *) NULL) |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 581 | break; |
| 582 | length=ImportQuantumPixels(canvas_image,(CacheView *) NULL, |
| 583 | quantum_info,AlphaQuantum,pixels,exception); |
| 584 | if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse) |
| 585 | break; |
| 586 | if (((y-image->extract_info.y) >= 0) && |
| 587 | ((y-image->extract_info.y) < (ssize_t) image->rows)) |
| 588 | { |
| 589 | p=GetVirtualPixels(canvas_image, |
| 590 | canvas_image->extract_info.x,0,canvas_image->columns,1, |
| 591 | exception); |
| 592 | q=GetAuthenticPixels(image,0,y-image->extract_info.y, |
| 593 | image->columns,1,exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 594 | if ((p == (const Quantum *) NULL) || |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 595 | (q == (Quantum *) NULL)) |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 596 | break; |
| 597 | for (x=0; x < (ssize_t) image->columns; x++) |
| 598 | { |
cristy | f27ee03 | 2011-09-29 17:51:41 +0000 | [diff] [blame^] | 599 | SetPixelAlpha(image,GetPixelAlpha(canvas_image,p),q); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 600 | p+=GetPixelChannels(canvas_image); |
| 601 | q+=GetPixelChannels(image); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 602 | } |
| 603 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
| 604 | break; |
| 605 | } |
| 606 | count=ReadBlob(image,length,pixels); |
| 607 | } |
| 608 | if (image->previous == (Image *) NULL) |
| 609 | { |
| 610 | status=SetImageProgress(image,LoadImageTag,5,6); |
| 611 | if (status == MagickFalse) |
| 612 | break; |
| 613 | } |
| 614 | } |
| 615 | if (image->previous == (Image *) NULL) |
| 616 | { |
| 617 | status=SetImageProgress(image,LoadImageTag,6,6); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 618 | if (status == MagickFalse) |
| 619 | break; |
| 620 | } |
| 621 | break; |
| 622 | } |
| 623 | case PartitionInterlace: |
| 624 | { |
| 625 | /* |
| 626 | Partition interlacing: RRRRRR..., GGGGGG..., BBBBBB... |
| 627 | */ |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 628 | AppendImageFormat("R",image->filename); |
| 629 | status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); |
| 630 | if (status == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 631 | { |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 632 | canvas_image=DestroyImageList(canvas_image); |
| 633 | image=DestroyImageList(image); |
| 634 | return((Image *) NULL); |
| 635 | } |
cristy | d429702 | 2010-09-16 22:59:09 +0000 | [diff] [blame] | 636 | if (DiscardBlobBytes(image,image->offset) == MagickFalse) |
| 637 | ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile", |
| 638 | image->filename); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 639 | length=GetQuantumExtent(canvas_image,quantum_info,RedQuantum); |
| 640 | for (i=0; i < (ssize_t) scene; i++) |
| 641 | for (y=0; y < (ssize_t) image->extract_info.height; y++) |
| 642 | if (ReadBlob(image,length,pixels) != (ssize_t) length) |
cristy | 21da32d | 2009-09-12 14:56:09 +0000 | [diff] [blame] | 643 | { |
| 644 | ThrowFileException(exception,CorruptImageError, |
| 645 | "UnexpectedEndOfFile",image->filename); |
| 646 | break; |
| 647 | } |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 648 | count=ReadBlob(image,length,pixels); |
| 649 | for (y=0; y < (ssize_t) image->extract_info.height; y++) |
| 650 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 651 | register const Quantum |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 652 | *restrict p; |
| 653 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 654 | register Quantum |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 655 | *restrict q; |
| 656 | |
| 657 | register ssize_t |
| 658 | x; |
| 659 | |
| 660 | if (count != (ssize_t) length) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 661 | { |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 662 | ThrowFileException(exception,CorruptImageError, |
| 663 | "UnexpectedEndOfFile",image->filename); |
| 664 | break; |
| 665 | } |
| 666 | q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1, |
| 667 | exception); |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 668 | if (q == (Quantum *) NULL) |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 669 | break; |
| 670 | length=ImportQuantumPixels(canvas_image,(CacheView *) NULL, |
| 671 | quantum_info,RedQuantum,pixels,exception); |
| 672 | if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse) |
| 673 | break; |
| 674 | if (((y-image->extract_info.y) >= 0) && |
| 675 | ((y-image->extract_info.y) < (ssize_t) image->rows)) |
| 676 | { |
| 677 | p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0, |
| 678 | canvas_image->columns,1,exception); |
| 679 | q=GetAuthenticPixels(image,0,y-image->extract_info.y, |
| 680 | image->columns,1,exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 681 | if ((p == (const Quantum *) NULL) || |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 682 | (q == (Quantum *) NULL)) |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 683 | break; |
| 684 | for (x=0; x < (ssize_t) image->columns; x++) |
| 685 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 686 | SetPixelRed(image,GetPixelRed(canvas_image,p),q); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 687 | p+=GetPixelChannels(canvas_image); |
| 688 | q+=GetPixelChannels(image); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 689 | } |
| 690 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 691 | break; |
| 692 | } |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 693 | count=ReadBlob(image,length,pixels); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 694 | } |
| 695 | if (image->previous == (Image *) NULL) |
| 696 | { |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 697 | status=SetImageProgress(image,LoadImageTag,1,5); |
| 698 | if (status == MagickFalse) |
| 699 | break; |
| 700 | } |
| 701 | (void) CloseBlob(image); |
| 702 | AppendImageFormat("G",image->filename); |
| 703 | status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); |
| 704 | if (status == MagickFalse) |
| 705 | { |
| 706 | canvas_image=DestroyImageList(canvas_image); |
| 707 | image=DestroyImageList(image); |
| 708 | return((Image *) NULL); |
| 709 | } |
| 710 | length=GetQuantumExtent(canvas_image,quantum_info,GreenQuantum); |
| 711 | for (i=0; i < (ssize_t) scene; i++) |
| 712 | for (y=0; y < (ssize_t) image->extract_info.height; y++) |
| 713 | if (ReadBlob(image,length,pixels) != (ssize_t) length) |
| 714 | { |
| 715 | ThrowFileException(exception,CorruptImageError, |
| 716 | "UnexpectedEndOfFile",image->filename); |
| 717 | break; |
| 718 | } |
| 719 | count=ReadBlob(image,length,pixels); |
| 720 | for (y=0; y < (ssize_t) image->extract_info.height; y++) |
| 721 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 722 | register const Quantum |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 723 | *restrict p; |
| 724 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 725 | register Quantum |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 726 | *restrict q; |
| 727 | |
| 728 | register ssize_t |
| 729 | x; |
| 730 | |
| 731 | if (count != (ssize_t) length) |
| 732 | { |
| 733 | ThrowFileException(exception,CorruptImageError, |
| 734 | "UnexpectedEndOfFile",image->filename); |
| 735 | break; |
| 736 | } |
| 737 | q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1, |
| 738 | exception); |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 739 | if (q == (Quantum *) NULL) |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 740 | break; |
| 741 | length=ImportQuantumPixels(canvas_image,(CacheView *) NULL, |
| 742 | quantum_info,GreenQuantum,pixels,exception); |
| 743 | if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse) |
| 744 | break; |
| 745 | if (((y-image->extract_info.y) >= 0) && |
| 746 | ((y-image->extract_info.y) < (ssize_t) image->rows)) |
| 747 | { |
| 748 | p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0, |
| 749 | canvas_image->columns,1,exception); |
| 750 | q=GetAuthenticPixels(image,0,y-image->extract_info.y, |
| 751 | image->columns,1,exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 752 | if ((p == (const Quantum *) NULL) || |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 753 | (q == (Quantum *) NULL)) |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 754 | break; |
| 755 | for (x=0; x < (ssize_t) image->columns; x++) |
| 756 | { |
cristy | f27ee03 | 2011-09-29 17:51:41 +0000 | [diff] [blame^] | 757 | SetPixelGreen(image,GetPixelGreen(canvas_image,p),q); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 758 | p+=GetPixelChannels(canvas_image); |
| 759 | q+=GetPixelChannels(image); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 760 | } |
| 761 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
| 762 | break; |
| 763 | } |
| 764 | count=ReadBlob(image,length,pixels); |
| 765 | } |
| 766 | if (image->previous == (Image *) NULL) |
| 767 | { |
| 768 | status=SetImageProgress(image,LoadImageTag,2,5); |
| 769 | if (status == MagickFalse) |
| 770 | break; |
| 771 | } |
| 772 | (void) CloseBlob(image); |
| 773 | AppendImageFormat("B",image->filename); |
| 774 | status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); |
| 775 | if (status == MagickFalse) |
| 776 | { |
| 777 | canvas_image=DestroyImageList(canvas_image); |
| 778 | image=DestroyImageList(image); |
| 779 | return((Image *) NULL); |
| 780 | } |
| 781 | length=GetQuantumExtent(canvas_image,quantum_info,BlueQuantum); |
| 782 | for (i=0; i < (ssize_t) scene; i++) |
| 783 | for (y=0; y < (ssize_t) image->extract_info.height; y++) |
| 784 | if (ReadBlob(image,length,pixels) != (ssize_t) length) |
| 785 | { |
| 786 | ThrowFileException(exception,CorruptImageError, |
| 787 | "UnexpectedEndOfFile",image->filename); |
| 788 | break; |
| 789 | } |
| 790 | count=ReadBlob(image,length,pixels); |
| 791 | for (y=0; y < (ssize_t) image->extract_info.height; y++) |
| 792 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 793 | register const Quantum |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 794 | *restrict p; |
| 795 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 796 | register Quantum |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 797 | *restrict q; |
| 798 | |
| 799 | register ssize_t |
| 800 | x; |
| 801 | |
| 802 | if (count != (ssize_t) length) |
| 803 | { |
| 804 | ThrowFileException(exception,CorruptImageError, |
| 805 | "UnexpectedEndOfFile",image->filename); |
| 806 | break; |
| 807 | } |
| 808 | q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1, |
| 809 | exception); |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 810 | if (q == (Quantum *) NULL) |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 811 | break; |
| 812 | length=ImportQuantumPixels(canvas_image,(CacheView *) NULL, |
| 813 | quantum_info,BlueQuantum,pixels,exception); |
| 814 | if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse) |
| 815 | break; |
| 816 | if (((y-image->extract_info.y) >= 0) && |
| 817 | ((y-image->extract_info.y) < (ssize_t) image->rows)) |
| 818 | { |
| 819 | p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0, |
| 820 | canvas_image->columns,1,exception); |
| 821 | q=GetAuthenticPixels(image,0,y-image->extract_info.y, |
| 822 | image->columns,1,exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 823 | if ((p == (const Quantum *) NULL) || |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 824 | (q == (Quantum *) NULL)) |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 825 | break; |
| 826 | for (x=0; x < (ssize_t) image->columns; x++) |
| 827 | { |
cristy | f27ee03 | 2011-09-29 17:51:41 +0000 | [diff] [blame^] | 828 | SetPixelBlue(image,GetPixelBlue(canvas_image,p),q); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 829 | p+=GetPixelChannels(canvas_image); |
| 830 | q+=GetPixelChannels(image); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 831 | } |
| 832 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
| 833 | break; |
| 834 | } |
| 835 | count=ReadBlob(image,length,pixels); |
| 836 | } |
| 837 | if (image->previous == (Image *) NULL) |
| 838 | { |
| 839 | status=SetImageProgress(image,LoadImageTag,3,5); |
| 840 | if (status == MagickFalse) |
| 841 | break; |
| 842 | } |
| 843 | if (image->matte != MagickFalse) |
| 844 | { |
| 845 | (void) CloseBlob(image); |
| 846 | AppendImageFormat("A",image->filename); |
| 847 | status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); |
| 848 | if (status == MagickFalse) |
| 849 | { |
| 850 | canvas_image=DestroyImageList(canvas_image); |
| 851 | image=DestroyImageList(image); |
| 852 | return((Image *) NULL); |
| 853 | } |
| 854 | length=GetQuantumExtent(canvas_image,quantum_info,AlphaQuantum); |
| 855 | for (i=0; i < (ssize_t) scene; i++) |
| 856 | for (y=0; y < (ssize_t) image->extract_info.height; y++) |
| 857 | if (ReadBlob(image,length,pixels) != (ssize_t) length) |
| 858 | { |
| 859 | ThrowFileException(exception,CorruptImageError, |
| 860 | "UnexpectedEndOfFile",image->filename); |
| 861 | break; |
| 862 | } |
| 863 | count=ReadBlob(image,length,pixels); |
| 864 | for (y=0; y < (ssize_t) image->extract_info.height; y++) |
| 865 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 866 | register const Quantum |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 867 | *restrict p; |
| 868 | |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 869 | register Quantum |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 870 | *restrict q; |
| 871 | |
| 872 | register ssize_t |
| 873 | x; |
| 874 | |
| 875 | if (count != (ssize_t) length) |
| 876 | { |
| 877 | ThrowFileException(exception,CorruptImageError, |
| 878 | "UnexpectedEndOfFile",image->filename); |
| 879 | break; |
| 880 | } |
| 881 | q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1, |
| 882 | exception); |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 883 | if (q == (Quantum *) NULL) |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 884 | break; |
| 885 | length=ImportQuantumPixels(canvas_image,(CacheView *) NULL, |
| 886 | quantum_info,BlueQuantum,pixels,exception); |
| 887 | if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse) |
| 888 | break; |
| 889 | if (((y-image->extract_info.y) >= 0) && |
| 890 | ((y-image->extract_info.y) < (ssize_t) image->rows)) |
| 891 | { |
| 892 | p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x, |
| 893 | 0,canvas_image->columns,1,exception); |
| 894 | q=GetAuthenticPixels(image,0,y-image->extract_info.y, |
| 895 | image->columns,1,exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 896 | if ((p == (const Quantum *) NULL) || |
cristy | acd2ed2 | 2011-08-30 01:44:23 +0000 | [diff] [blame] | 897 | (q == (Quantum *) NULL)) |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 898 | break; |
| 899 | for (x=0; x < (ssize_t) image->columns; x++) |
| 900 | { |
cristy | f27ee03 | 2011-09-29 17:51:41 +0000 | [diff] [blame^] | 901 | SetPixelAlpha(image,GetPixelAlpha(canvas_image,p),q); |
cristy | ed23157 | 2011-07-14 02:18:59 +0000 | [diff] [blame] | 902 | p+=GetPixelChannels(canvas_image); |
| 903 | q+=GetPixelChannels(image); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 904 | } |
| 905 | if (SyncAuthenticPixels(image,exception) == MagickFalse) |
| 906 | break; |
| 907 | } |
| 908 | count=ReadBlob(image,length,pixels); |
| 909 | } |
| 910 | if (image->previous == (Image *) NULL) |
| 911 | { |
| 912 | status=SetImageProgress(image,LoadImageTag,4,5); |
| 913 | if (status == MagickFalse) |
| 914 | break; |
| 915 | } |
| 916 | } |
| 917 | (void) CloseBlob(image); |
| 918 | if (image->previous == (Image *) NULL) |
| 919 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 920 | status=SetImageProgress(image,LoadImageTag,5,5); |
| 921 | if (status == MagickFalse) |
| 922 | break; |
| 923 | } |
| 924 | break; |
| 925 | } |
| 926 | } |
| 927 | SetQuantumImageType(image,quantum_type); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 928 | /* |
| 929 | Proceed to next image. |
| 930 | */ |
| 931 | if (image_info->number_scenes != 0) |
| 932 | if (image->scene >= (image_info->scene+image_info->number_scenes-1)) |
| 933 | break; |
| 934 | if (count == (ssize_t) length) |
| 935 | { |
| 936 | /* |
| 937 | Allocate next image structure. |
| 938 | */ |
| 939 | AcquireNextImage(image_info,image); |
| 940 | if (GetNextImageInList(image) == (Image *) NULL) |
| 941 | { |
| 942 | image=DestroyImageList(image); |
| 943 | return((Image *) NULL); |
| 944 | } |
| 945 | image=SyncNextImageInList(image); |
| 946 | status=SetImageProgress(image,LoadImagesTag,TellBlob(image), |
| 947 | GetBlobSize(image)); |
| 948 | if (status == MagickFalse) |
| 949 | break; |
| 950 | } |
| 951 | scene++; |
| 952 | } while (count == (ssize_t) length); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 953 | quantum_info=DestroyQuantumInfo(quantum_info); |
cristy | 01a3f33 | 2009-10-27 14:17:37 +0000 | [diff] [blame] | 954 | InheritException(&image->exception,&canvas_image->exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 955 | canvas_image=DestroyImage(canvas_image); |
| 956 | (void) CloseBlob(image); |
| 957 | return(GetFirstImageInList(image)); |
| 958 | } |
| 959 | |
| 960 | /* |
| 961 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 962 | % % |
| 963 | % % |
| 964 | % % |
| 965 | % R e g i s t e r R G B I m a g e % |
| 966 | % % |
| 967 | % % |
| 968 | % % |
| 969 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 970 | % |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 971 | % RegisterRGBImage() adds attributes for the RGB image format to |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 972 | % the list of supported formats. The attributes include the image format |
| 973 | % tag, a method to read and/or write the format, whether the format |
| 974 | % supports the saving of more than one frame to the same file or blob, |
| 975 | % whether the format supports native in-memory I/O, and a brief |
| 976 | % description of the format. |
| 977 | % |
| 978 | % The format of the RegisterRGBImage method is: |
| 979 | % |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 980 | % size_t RegisterRGBImage(void) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 981 | % |
| 982 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 983 | ModuleExport size_t RegisterRGBImage(void) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 984 | { |
| 985 | MagickInfo |
| 986 | *entry; |
| 987 | |
| 988 | entry=SetMagickInfo("RGB"); |
| 989 | entry->decoder=(DecodeImageHandler *) ReadRGBImage; |
| 990 | entry->encoder=(EncodeImageHandler *) WriteRGBImage; |
| 991 | entry->raw=MagickTrue; |
| 992 | entry->endian_support=MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 993 | entry->description=ConstantString("Raw red, green, and blue samples"); |
| 994 | entry->module=ConstantString("RGB"); |
| 995 | (void) RegisterMagickInfo(entry); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 996 | entry=SetMagickInfo("RGBA"); |
| 997 | entry->decoder=(DecodeImageHandler *) ReadRGBImage; |
| 998 | entry->encoder=(EncodeImageHandler *) WriteRGBImage; |
| 999 | entry->raw=MagickTrue; |
| 1000 | entry->endian_support=MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1001 | entry->description=ConstantString("Raw red, green, blue, and alpha samples"); |
| 1002 | entry->module=ConstantString("RGB"); |
| 1003 | (void) RegisterMagickInfo(entry); |
| 1004 | entry=SetMagickInfo("RGBO"); |
| 1005 | entry->decoder=(DecodeImageHandler *) ReadRGBImage; |
| 1006 | entry->encoder=(EncodeImageHandler *) WriteRGBImage; |
| 1007 | entry->raw=MagickTrue; |
| 1008 | entry->endian_support=MagickTrue; |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1009 | entry->description=ConstantString("Raw red, green, blue, and opacity samples"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1010 | entry->module=ConstantString("RGB"); |
| 1011 | (void) RegisterMagickInfo(entry); |
| 1012 | return(MagickImageCoderSignature); |
| 1013 | } |
| 1014 | |
| 1015 | /* |
| 1016 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1017 | % % |
| 1018 | % % |
| 1019 | % % |
| 1020 | % U n r e g i s t e r R G B I m a g e % |
| 1021 | % % |
| 1022 | % % |
| 1023 | % % |
| 1024 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1025 | % |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1026 | % UnregisterRGBImage() removes format registrations made by the RGB module |
| 1027 | % from the list of supported formats. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1028 | % |
| 1029 | % The format of the UnregisterRGBImage method is: |
| 1030 | % |
| 1031 | % UnregisterRGBImage(void) |
| 1032 | % |
| 1033 | */ |
| 1034 | ModuleExport void UnregisterRGBImage(void) |
| 1035 | { |
| 1036 | (void) UnregisterMagickInfo("RGBO"); |
| 1037 | (void) UnregisterMagickInfo("RGBA"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1038 | (void) UnregisterMagickInfo("RGB"); |
| 1039 | } |
| 1040 | |
| 1041 | /* |
| 1042 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1043 | % % |
| 1044 | % % |
| 1045 | % % |
| 1046 | % W r i t e R G B I m a g e % |
| 1047 | % % |
| 1048 | % % |
| 1049 | % % |
| 1050 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1051 | % |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1052 | % WriteRGBImage() writes an image to a file in the RGB, RGBA, or RGBO |
| 1053 | % rasterfile format. |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1054 | % |
| 1055 | % The format of the WriteRGBImage method is: |
| 1056 | % |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1057 | % MagickBooleanType WriteRGBImage(const ImageInfo *image_info, |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1058 | % Image *image,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1059 | % |
| 1060 | % A description of each parameter follows. |
| 1061 | % |
| 1062 | % o image_info: the image info. |
| 1063 | % |
| 1064 | % o image: The image. |
| 1065 | % |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1066 | % o exception: return any errors or warnings in this structure. |
| 1067 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1068 | */ |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1069 | static MagickBooleanType WriteRGBImage(const ImageInfo *image_info, |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1070 | Image *image,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1071 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1072 | MagickBooleanType |
| 1073 | status; |
| 1074 | |
| 1075 | MagickOffsetType |
| 1076 | scene; |
| 1077 | |
| 1078 | QuantumInfo |
| 1079 | *quantum_info; |
| 1080 | |
| 1081 | QuantumType |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1082 | quantum_type; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1083 | |
cristy | c6da28e | 2011-04-28 01:41:35 +0000 | [diff] [blame] | 1084 | size_t |
| 1085 | length; |
| 1086 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1087 | ssize_t |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1088 | count, |
| 1089 | y; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1090 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1091 | unsigned char |
| 1092 | *pixels; |
| 1093 | |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1094 | /* |
| 1095 | Allocate memory for pixels. |
| 1096 | */ |
| 1097 | assert(image_info != (const ImageInfo *) NULL); |
| 1098 | assert(image_info->signature == MagickSignature); |
| 1099 | assert(image != (Image *) NULL); |
| 1100 | assert(image->signature == MagickSignature); |
| 1101 | if (image->debug != MagickFalse) |
| 1102 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
| 1103 | if (image_info->interlace != PartitionInterlace) |
| 1104 | { |
| 1105 | /* |
| 1106 | Open output image file. |
| 1107 | */ |
cristy | edf03fa | 2011-08-30 12:44:39 +0000 | [diff] [blame] | 1108 | status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1109 | if (status == MagickFalse) |
| 1110 | return(status); |
| 1111 | } |
| 1112 | quantum_type=RGBQuantum; |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1113 | if (LocaleCompare(image_info->magick,"RGBA") == 0) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1114 | { |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1115 | quantum_type=RGBAQuantum; |
| 1116 | image->matte=MagickTrue; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1117 | } |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1118 | if (LocaleCompare(image_info->magick,"RGBO") == 0) |
| 1119 | { |
| 1120 | quantum_type=RGBOQuantum; |
| 1121 | image->matte=MagickTrue; |
| 1122 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1123 | scene=0; |
| 1124 | do |
| 1125 | { |
| 1126 | /* |
| 1127 | Convert MIFF to RGB raster pixels. |
| 1128 | */ |
cristy | 510d06a | 2011-07-06 23:43:54 +0000 | [diff] [blame] | 1129 | if (IsRGBColorspace(image->colorspace) == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1130 | (void) TransformImageColorspace(image,RGBColorspace); |
| 1131 | if ((LocaleCompare(image_info->magick,"RGBA") == 0) && |
| 1132 | (image->matte == MagickFalse)) |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1133 | (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1134 | quantum_info=AcquireQuantumInfo(image_info,image); |
| 1135 | if (quantum_info == (QuantumInfo *) NULL) |
| 1136 | ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed"); |
| 1137 | pixels=GetQuantumPixels(quantum_info); |
| 1138 | switch (image_info->interlace) |
| 1139 | { |
| 1140 | case NoInterlace: |
| 1141 | default: |
| 1142 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1143 | /* |
| 1144 | No interlacing: RGBRGBRGBRGBRGBRGB... |
| 1145 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1146 | for (y=0; y < (ssize_t) image->rows; y++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1147 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1148 | register const Quantum |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1149 | *restrict p; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1150 | |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1151 | p=GetVirtualPixels(image,0,y,image->columns,1,exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1152 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1153 | break; |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1154 | length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info, |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1155 | quantum_type,pixels,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1156 | count=WriteBlob(image,length,pixels); |
| 1157 | if (count != (ssize_t) length) |
| 1158 | break; |
| 1159 | if (image->previous == (Image *) NULL) |
| 1160 | { |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 1161 | status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, |
| 1162 | image->rows); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1163 | if (status == MagickFalse) |
| 1164 | break; |
| 1165 | } |
| 1166 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1167 | break; |
| 1168 | } |
| 1169 | case LineInterlace: |
| 1170 | { |
| 1171 | /* |
| 1172 | Line interlacing: RRR...GGG...BBB...RRR...GGG...BBB... |
| 1173 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 1174 | for (y=0; y < (ssize_t) image->rows; y++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1175 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1176 | register const Quantum |
cristy | c47d1f8 | 2009-11-26 01:44:43 +0000 | [diff] [blame] | 1177 | *restrict p; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1178 | |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1179 | p=GetVirtualPixels(image,0,y,image->columns,1,exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1180 | if (p == (const Quantum *) NULL) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1181 | break; |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1182 | length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info, |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1183 | RedQuantum,pixels,exception); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1184 | count=WriteBlob(image,length,pixels); |
| 1185 | if (count != (ssize_t) length) |
| 1186 | break; |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1187 | length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info, |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1188 | GreenQuantum,pixels,exception); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1189 | count=WriteBlob(image,length,pixels); |
| 1190 | if (count != (ssize_t) length) |
| 1191 | break; |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1192 | length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info, |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1193 | BlueQuantum,pixels,exception); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1194 | count=WriteBlob(image,length,pixels); |
| 1195 | if (count != (ssize_t) length) |
| 1196 | break; |
| 1197 | if (quantum_type == RGBAQuantum) |
| 1198 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1199 | length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info, |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1200 | AlphaQuantum,pixels,exception); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1201 | count=WriteBlob(image,length,pixels); |
| 1202 | if (count != (ssize_t) length) |
| 1203 | break; |
| 1204 | } |
| 1205 | if (quantum_type == RGBOQuantum) |
| 1206 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1207 | length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info, |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1208 | OpacityQuantum,pixels,exception); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1209 | count=WriteBlob(image,length,pixels); |
| 1210 | if (count != (ssize_t) length) |
| 1211 | break; |
| 1212 | } |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1213 | if (image->previous == (Image *) NULL) |
| 1214 | { |
cristy | cee9711 | 2010-05-28 00:44:52 +0000 | [diff] [blame] | 1215 | status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, |
| 1216 | image->rows); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1217 | if (status == MagickFalse) |
| 1218 | break; |
| 1219 | } |
| 1220 | } |
| 1221 | break; |
| 1222 | } |
| 1223 | case PlaneInterlace: |
| 1224 | { |
| 1225 | /* |
| 1226 | Plane interlacing: RRRRRR...GGGGGG...BBBBBB... |
| 1227 | */ |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1228 | for (y=0; y < (ssize_t) image->rows; y++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1229 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1230 | register const Quantum |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1231 | *restrict p; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1232 | |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1233 | p=GetVirtualPixels(image,0,y,image->columns,1,exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1234 | if (p == (const Quantum *) NULL) |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1235 | break; |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1236 | length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info, |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1237 | RedQuantum,pixels,exception); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1238 | count=WriteBlob(image,length,pixels); |
| 1239 | if (count != (ssize_t) length) |
| 1240 | break; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1241 | } |
| 1242 | if (image->previous == (Image *) NULL) |
| 1243 | { |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1244 | status=SetImageProgress(image,SaveImageTag,1,6); |
| 1245 | if (status == MagickFalse) |
| 1246 | break; |
| 1247 | } |
| 1248 | for (y=0; y < (ssize_t) image->rows; y++) |
| 1249 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1250 | register const Quantum |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1251 | *restrict p; |
| 1252 | |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1253 | p=GetVirtualPixels(image,0,y,image->columns,1,exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1254 | if (p == (const Quantum *) NULL) |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1255 | break; |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1256 | length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info, |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1257 | GreenQuantum,pixels,exception); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1258 | count=WriteBlob(image,length,pixels); |
| 1259 | if (count != (ssize_t) length) |
| 1260 | break; |
| 1261 | } |
| 1262 | if (image->previous == (Image *) NULL) |
| 1263 | { |
| 1264 | status=SetImageProgress(image,SaveImageTag,2,6); |
| 1265 | if (status == MagickFalse) |
| 1266 | break; |
| 1267 | } |
| 1268 | for (y=0; y < (ssize_t) image->rows; y++) |
| 1269 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1270 | register const Quantum |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1271 | *restrict p; |
| 1272 | |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1273 | p=GetVirtualPixels(image,0,y,image->columns,1,exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1274 | if (p == (const Quantum *) NULL) |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1275 | break; |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1276 | length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info, |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1277 | BlueQuantum,pixels,exception); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1278 | count=WriteBlob(image,length,pixels); |
| 1279 | if (count != (ssize_t) length) |
| 1280 | break; |
| 1281 | } |
| 1282 | if (image->previous == (Image *) NULL) |
| 1283 | { |
| 1284 | status=SetImageProgress(image,SaveImageTag,3,6); |
| 1285 | if (status == MagickFalse) |
| 1286 | break; |
| 1287 | } |
| 1288 | if (quantum_type == RGBAQuantum) |
| 1289 | { |
| 1290 | for (y=0; y < (ssize_t) image->rows; y++) |
| 1291 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1292 | register const Quantum |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1293 | *restrict p; |
| 1294 | |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1295 | p=GetVirtualPixels(image,0,y,image->columns,1,exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1296 | if (p == (const Quantum *) NULL) |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1297 | break; |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1298 | length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info, |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1299 | AlphaQuantum,pixels,exception); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1300 | count=WriteBlob(image,length,pixels); |
| 1301 | if (count != (ssize_t) length) |
| 1302 | break; |
| 1303 | } |
| 1304 | if (image->previous == (Image *) NULL) |
| 1305 | { |
| 1306 | status=SetImageProgress(image,SaveImageTag,5,6); |
| 1307 | if (status == MagickFalse) |
| 1308 | break; |
| 1309 | } |
| 1310 | } |
| 1311 | if (image_info->interlace == PartitionInterlace) |
| 1312 | (void) CopyMagickString(image->filename,image_info->filename, |
| 1313 | MaxTextExtent); |
| 1314 | if (image->previous == (Image *) NULL) |
| 1315 | { |
| 1316 | status=SetImageProgress(image,SaveImageTag,6,6); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1317 | if (status == MagickFalse) |
| 1318 | break; |
| 1319 | } |
| 1320 | break; |
| 1321 | } |
| 1322 | case PartitionInterlace: |
| 1323 | { |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1324 | /* |
| 1325 | Partition interlacing: RRRRRR..., GGGGGG..., BBBBBB... |
| 1326 | */ |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1327 | AppendImageFormat("R",image->filename); |
| 1328 | status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode : |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1329 | AppendBinaryBlobMode,exception); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1330 | if (status == MagickFalse) |
| 1331 | return(status); |
| 1332 | for (y=0; y < (ssize_t) image->rows; y++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1333 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1334 | register const Quantum |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1335 | *restrict p; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1336 | |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1337 | p=GetVirtualPixels(image,0,y,image->columns,1,exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1338 | if (p == (const Quantum *) NULL) |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1339 | break; |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1340 | length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info, |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1341 | RedQuantum,pixels,exception); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1342 | count=WriteBlob(image,length,pixels); |
| 1343 | if (count != (ssize_t) length) |
| 1344 | break; |
| 1345 | } |
| 1346 | if (image->previous == (Image *) NULL) |
| 1347 | { |
| 1348 | status=SetImageProgress(image,SaveImageTag,1,6); |
| 1349 | if (status == MagickFalse) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1350 | break; |
| 1351 | } |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1352 | (void) CloseBlob(image); |
| 1353 | AppendImageFormat("G",image->filename); |
| 1354 | status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode : |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1355 | AppendBinaryBlobMode,exception); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1356 | if (status == MagickFalse) |
| 1357 | return(status); |
| 1358 | for (y=0; y < (ssize_t) image->rows; y++) |
| 1359 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1360 | register const Quantum |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1361 | *restrict p; |
| 1362 | |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1363 | p=GetVirtualPixels(image,0,y,image->columns,1,exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1364 | if (p == (const Quantum *) NULL) |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1365 | break; |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1366 | length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info, |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1367 | GreenQuantum,pixels,exception); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1368 | count=WriteBlob(image,length,pixels); |
| 1369 | if (count != (ssize_t) length) |
| 1370 | break; |
| 1371 | } |
| 1372 | if (image->previous == (Image *) NULL) |
| 1373 | { |
| 1374 | status=SetImageProgress(image,SaveImageTag,2,6); |
| 1375 | if (status == MagickFalse) |
| 1376 | break; |
| 1377 | } |
| 1378 | (void) CloseBlob(image); |
| 1379 | AppendImageFormat("B",image->filename); |
| 1380 | status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode : |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1381 | AppendBinaryBlobMode,exception); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1382 | if (status == MagickFalse) |
| 1383 | return(status); |
| 1384 | for (y=0; y < (ssize_t) image->rows; y++) |
| 1385 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1386 | register const Quantum |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1387 | *restrict p; |
| 1388 | |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1389 | p=GetVirtualPixels(image,0,y,image->columns,1,exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1390 | if (p == (const Quantum *) NULL) |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1391 | break; |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1392 | length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info, |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1393 | BlueQuantum,pixels,exception); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1394 | count=WriteBlob(image,length,pixels); |
| 1395 | if (count != (ssize_t) length) |
| 1396 | break; |
| 1397 | } |
| 1398 | if (image->previous == (Image *) NULL) |
| 1399 | { |
| 1400 | status=SetImageProgress(image,SaveImageTag,3,6); |
| 1401 | if (status == MagickFalse) |
| 1402 | break; |
| 1403 | } |
| 1404 | (void) CloseBlob(image); |
| 1405 | if (quantum_type == RGBAQuantum) |
| 1406 | { |
| 1407 | (void) CloseBlob(image); |
| 1408 | AppendImageFormat("A",image->filename); |
| 1409 | status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode : |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1410 | AppendBinaryBlobMode,exception); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1411 | if (status == MagickFalse) |
| 1412 | return(status); |
| 1413 | for (y=0; y < (ssize_t) image->rows; y++) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1414 | { |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1415 | register const Quantum |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1416 | *restrict p; |
| 1417 | |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1418 | p=GetVirtualPixels(image,0,y,image->columns,1,exception); |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1419 | if (p == (const Quantum *) NULL) |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1420 | break; |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 1421 | length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info, |
cristy | 3a37efd | 2011-08-28 20:31:03 +0000 | [diff] [blame] | 1422 | AlphaQuantum,pixels,exception); |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1423 | count=WriteBlob(image,length,pixels); |
| 1424 | if (count != (ssize_t) length) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1425 | break; |
| 1426 | } |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1427 | if (image->previous == (Image *) NULL) |
| 1428 | { |
| 1429 | status=SetImageProgress(image,SaveImageTag,5,6); |
| 1430 | if (status == MagickFalse) |
| 1431 | break; |
| 1432 | } |
| 1433 | } |
| 1434 | (void) CloseBlob(image); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1435 | (void) CopyMagickString(image->filename,image_info->filename, |
| 1436 | MaxTextExtent); |
| 1437 | if (image->previous == (Image *) NULL) |
| 1438 | { |
cristy | 90dbac7 | 2010-08-22 15:08:40 +0000 | [diff] [blame] | 1439 | status=SetImageProgress(image,SaveImageTag,6,6); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1440 | if (status == MagickFalse) |
| 1441 | break; |
| 1442 | } |
| 1443 | break; |
| 1444 | } |
| 1445 | } |
| 1446 | quantum_info=DestroyQuantumInfo(quantum_info); |
| 1447 | if (GetNextImageInList(image) == (Image *) NULL) |
| 1448 | break; |
| 1449 | image=SyncNextImageInList(image); |
| 1450 | status=SetImageProgress(image,SaveImagesTag,scene++, |
| 1451 | GetImageListLength(image)); |
| 1452 | if (status == MagickFalse) |
| 1453 | break; |
| 1454 | } while (image_info->adjoin != MagickFalse); |
| 1455 | (void) CloseBlob(image); |
| 1456 | return(MagickTrue); |
| 1457 | } |