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