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