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