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