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