| 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/property.h" |
|---|
| 44 | #include "magick/blob.h" |
|---|
| 45 | #include "magick/blob-private.h" |
|---|
| 46 | #include "magick/exception.h" |
|---|
| 47 | #include "magick/exception-private.h" |
|---|
| 48 | #include "magick/image.h" |
|---|
| 49 | #include "magick/image-private.h" |
|---|
| 50 | #include "magick/list.h" |
|---|
| 51 | #include "magick/magick.h" |
|---|
| 52 | #include "magick/memory_.h" |
|---|
| 53 | #include "magick/monitor.h" |
|---|
| 54 | #include "magick/monitor-private.h" |
|---|
| 55 | #include "magick/quantum-private.h" |
|---|
| 56 | #include "magick/static.h" |
|---|
| 57 | #include "magick/string_.h" |
|---|
| 58 | #include "magick/module.h" |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | |
|---|
| 81 | |
|---|
| 82 | |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | |
|---|
| 87 | static MagickBooleanType IsRLE(const unsigned char *magick,const size_t length) |
|---|
| 88 | { |
|---|
| 89 | if (length < 2) |
|---|
| 90 | return(MagickFalse); |
|---|
| 91 | if (memcmp(magick,"\122\314",2) == 0) |
|---|
| 92 | return(MagickTrue); |
|---|
| 93 | return(MagickFalse); |
|---|
| 94 | } |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | |
|---|
| 98 | |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | |
|---|
| 102 | |
|---|
| 103 | |
|---|
| 104 | |
|---|
| 105 | |
|---|
| 106 | |
|---|
| 107 | |
|---|
| 108 | |
|---|
| 109 | |
|---|
| 110 | |
|---|
| 111 | |
|---|
| 112 | |
|---|
| 113 | |
|---|
| 114 | |
|---|
| 115 | |
|---|
| 116 | |
|---|
| 117 | |
|---|
| 118 | |
|---|
| 119 | |
|---|
| 120 | |
|---|
| 121 | |
|---|
| 122 | |
|---|
| 123 | static Image *ReadRLEImage(const ImageInfo *image_info,ExceptionInfo *exception) |
|---|
| 124 | { |
|---|
| 125 | #define SkipLinesOp 0x01 |
|---|
| 126 | #define SetColorOp 0x02 |
|---|
| 127 | #define SkipPixelsOp 0x03 |
|---|
| 128 | #define ByteDataOp 0x05 |
|---|
| 129 | #define RunDataOp 0x06 |
|---|
| 130 | #define EOFOp 0x07 |
|---|
| 131 | |
|---|
| 132 | char |
|---|
| 133 | magick[12]; |
|---|
| 134 | |
|---|
| 135 | Image |
|---|
| 136 | *image; |
|---|
| 137 | |
|---|
| 138 | int |
|---|
| 139 | opcode, |
|---|
| 140 | operand, |
|---|
| 141 | status; |
|---|
| 142 | |
|---|
| 143 | long |
|---|
| 144 | y; |
|---|
| 145 | |
|---|
| 146 | MagickStatusType |
|---|
| 147 | flags; |
|---|
| 148 | |
|---|
| 149 | MagickSizeType |
|---|
| 150 | number_pixels; |
|---|
| 151 | |
|---|
| 152 | register IndexPacket |
|---|
| 153 | *indexes; |
|---|
| 154 | |
|---|
| 155 | register long |
|---|
| 156 | x; |
|---|
| 157 | |
|---|
| 158 | register PixelPacket |
|---|
| 159 | *q; |
|---|
| 160 | |
|---|
| 161 | register long |
|---|
| 162 | i; |
|---|
| 163 | |
|---|
| 164 | register unsigned char |
|---|
| 165 | *p; |
|---|
| 166 | |
|---|
| 167 | ssize_t |
|---|
| 168 | count; |
|---|
| 169 | |
|---|
| 170 | unsigned char |
|---|
| 171 | background_color[256], |
|---|
| 172 | *colormap, |
|---|
| 173 | pixel, |
|---|
| 174 | plane, |
|---|
| 175 | *rle_pixels; |
|---|
| 176 | |
|---|
| 177 | unsigned long |
|---|
| 178 | bits_per_pixel, |
|---|
| 179 | map_length, |
|---|
| 180 | number_colormaps, |
|---|
| 181 | number_planes; |
|---|
| 182 | |
|---|
| 183 | |
|---|
| 184 | |
|---|
| 185 | |
|---|
| 186 | assert(image_info != (const ImageInfo *) NULL); |
|---|
| 187 | assert(image_info->signature == MagickSignature); |
|---|
| 188 | if (image_info->debug != MagickFalse) |
|---|
| 189 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
|---|
| 190 | image_info->filename); |
|---|
| 191 | assert(exception != (ExceptionInfo *) NULL); |
|---|
| 192 | assert(exception->signature == MagickSignature); |
|---|
| 193 | image=AcquireImage(image_info); |
|---|
| 194 | status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); |
|---|
| 195 | if (status == MagickFalse) |
|---|
| 196 | { |
|---|
| 197 | image=DestroyImageList(image); |
|---|
| 198 | return((Image *) NULL); |
|---|
| 199 | } |
|---|
| 200 | |
|---|
| 201 | |
|---|
| 202 | |
|---|
| 203 | count=ReadBlob(image,2,(unsigned char *) magick); |
|---|
| 204 | if ((count == 0) || (memcmp(magick,"\122\314",2) != 0)) |
|---|
| 205 | ThrowReaderException(CorruptImageError,"ImproperImageHeader"); |
|---|
| 206 | do |
|---|
| 207 | { |
|---|
| 208 | |
|---|
| 209 | |
|---|
| 210 | |
|---|
| 211 | (void) ReadBlobLSBShort(image); |
|---|
| 212 | (void) ReadBlobLSBShort(image); |
|---|
| 213 | image->columns=ReadBlobLSBShort(image); |
|---|
| 214 | image->rows=ReadBlobLSBShort(image); |
|---|
| 215 | flags=(MagickStatusType) ReadBlobByte(image); |
|---|
| 216 | image->matte=flags & 0x04 ? MagickTrue : MagickFalse; |
|---|
| 217 | number_planes=1UL*ReadBlobByte(image); |
|---|
| 218 | bits_per_pixel=1UL*ReadBlobByte(image); |
|---|
| 219 | number_colormaps=1UL*ReadBlobByte(image); |
|---|
| 220 | map_length=1UL << ReadBlobByte(image); |
|---|
| 221 | if ((number_planes == 0) || (number_planes == 2) || (bits_per_pixel != 8) || |
|---|
| 222 | (image->columns == 0)) |
|---|
| 223 | ThrowReaderException(CorruptImageError,"ImproperImageHeader"); |
|---|
| 224 | if (flags & 0x02) |
|---|
| 225 | { |
|---|
| 226 | |
|---|
| 227 | |
|---|
| 228 | |
|---|
| 229 | for (i=0; i < (long) number_planes; i++) |
|---|
| 230 | background_color[i]=0; |
|---|
| 231 | (void) ReadBlobByte(image); |
|---|
| 232 | } |
|---|
| 233 | else |
|---|
| 234 | { |
|---|
| 235 | |
|---|
| 236 | |
|---|
| 237 | |
|---|
| 238 | p=background_color; |
|---|
| 239 | for (i=0; i < (long) number_planes; i++) |
|---|
| 240 | *p++=(unsigned char) ReadBlobByte(image); |
|---|
| 241 | } |
|---|
| 242 | if ((number_planes & 0x01) == 0) |
|---|
| 243 | (void) ReadBlobByte(image); |
|---|
| 244 | colormap=(unsigned char *) NULL; |
|---|
| 245 | if (number_colormaps != 0) |
|---|
| 246 | { |
|---|
| 247 | |
|---|
| 248 | |
|---|
| 249 | |
|---|
| 250 | colormap=(unsigned char *) AcquireQuantumMemory(number_colormaps, |
|---|
| 251 | map_length*sizeof(*colormap)); |
|---|
| 252 | if (colormap == (unsigned char *) NULL) |
|---|
| 253 | ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); |
|---|
| 254 | p=colormap; |
|---|
| 255 | for (i=0; i < (long) number_colormaps; i++) |
|---|
| 256 | for (x=0; x < (long) map_length; x++) |
|---|
| 257 | *p++=(unsigned char) ScaleShortToQuantum(ReadBlobLSBShort(image)); |
|---|
| 258 | } |
|---|
| 259 | if ((flags & 0x08) != 0) |
|---|
| 260 | { |
|---|
| 261 | char |
|---|
| 262 | *comment; |
|---|
| 263 | |
|---|
| 264 | unsigned long |
|---|
| 265 | length; |
|---|
| 266 | |
|---|
| 267 | |
|---|
| 268 | |
|---|
| 269 | |
|---|
| 270 | length=ReadBlobLSBShort(image); |
|---|
| 271 | if (length != 0) |
|---|
| 272 | { |
|---|
| 273 | comment=(char *) AcquireQuantumMemory(length,sizeof(*comment)); |
|---|
| 274 | if (comment == (char *) NULL) |
|---|
| 275 | ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); |
|---|
| 276 | count=ReadBlob(image,length-1,(unsigned char *) comment); |
|---|
| 277 | comment[length-1]='\0'; |
|---|
| 278 | (void) SetImageProperty(image,"comment",comment); |
|---|
| 279 | comment=DestroyString(comment); |
|---|
| 280 | if ((length & 0x01) == 0) |
|---|
| 281 | (void) ReadBlobByte(image); |
|---|
| 282 | } |
|---|
| 283 | } |
|---|
| 284 | if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0)) |
|---|
| 285 | if (image->scene >= (image_info->scene+image_info->number_scenes-1)) |
|---|
| 286 | break; |
|---|
| 287 | if (SetImageExtent(image,0,0) == MagickFalse) |
|---|
| 288 | { |
|---|
| 289 | InheritException(exception,&image->exception); |
|---|
| 290 | return(DestroyImageList(image)); |
|---|
| 291 | } |
|---|
| 292 | |
|---|
| 293 | |
|---|
| 294 | |
|---|
| 295 | if (image->matte != MagickFalse) |
|---|
| 296 | number_planes++; |
|---|
| 297 | number_pixels=(MagickSizeType) image->columns*image->rows; |
|---|
| 298 | if ((number_pixels*number_planes) != (size_t) (number_pixels*number_planes)) |
|---|
| 299 | ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); |
|---|
| 300 | rle_pixels=(unsigned char *) AcquireQuantumMemory(image->columns, |
|---|
| 301 | image->rows*number_planes*sizeof(*rle_pixels)); |
|---|
| 302 | if (rle_pixels == (unsigned char *) NULL) |
|---|
| 303 | ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); |
|---|
| 304 | if ((flags & 0x01) && !(flags & 0x02)) |
|---|
| 305 | { |
|---|
| 306 | long |
|---|
| 307 | j; |
|---|
| 308 | |
|---|
| 309 | |
|---|
| 310 | |
|---|
| 311 | |
|---|
| 312 | p=rle_pixels; |
|---|
| 313 | for (i=0; i < (long) number_pixels; i++) |
|---|
| 314 | { |
|---|
| 315 | if (image->matte == MagickFalse) |
|---|
| 316 | for (j=0; j < (long) number_planes; j++) |
|---|
| 317 | *p++=background_color[j]; |
|---|
| 318 | else |
|---|
| 319 | { |
|---|
| 320 | for (j=0; j < (long) (number_planes-1); j++) |
|---|
| 321 | *p++=background_color[j]; |
|---|
| 322 | *p++=0; |
|---|
| 323 | } |
|---|
| 324 | } |
|---|
| 325 | } |
|---|
| 326 | |
|---|
| 327 | |
|---|
| 328 | |
|---|
| 329 | plane=0; |
|---|
| 330 | x=0; |
|---|
| 331 | y=0; |
|---|
| 332 | opcode=ReadBlobByte(image); |
|---|
| 333 | do |
|---|
| 334 | { |
|---|
| 335 | switch (opcode & 0x3f) |
|---|
| 336 | { |
|---|
| 337 | case SkipLinesOp: |
|---|
| 338 | { |
|---|
| 339 | operand=ReadBlobByte(image); |
|---|
| 340 | if (opcode & 0x40) |
|---|
| 341 | operand=(int) ReadBlobLSBShort(image); |
|---|
| 342 | x=0; |
|---|
| 343 | y+=operand; |
|---|
| 344 | break; |
|---|
| 345 | } |
|---|
| 346 | case SetColorOp: |
|---|
| 347 | { |
|---|
| 348 | operand=ReadBlobByte(image); |
|---|
| 349 | plane=(unsigned char) operand; |
|---|
| 350 | if (plane == 255) |
|---|
| 351 | plane=(unsigned char) (number_planes-1); |
|---|
| 352 | x=0; |
|---|
| 353 | break; |
|---|
| 354 | } |
|---|
| 355 | case SkipPixelsOp: |
|---|
| 356 | { |
|---|
| 357 | operand=ReadBlobByte(image); |
|---|
| 358 | if (opcode & 0x40) |
|---|
| 359 | operand=(int) ReadBlobLSBShort(image); |
|---|
| 360 | x+=operand; |
|---|
| 361 | break; |
|---|
| 362 | } |
|---|
| 363 | case ByteDataOp: |
|---|
| 364 | { |
|---|
| 365 | operand=ReadBlobByte(image); |
|---|
| 366 | if (opcode & 0x40) |
|---|
| 367 | operand=(int) ReadBlobLSBShort(image); |
|---|
| 368 | p=rle_pixels+((image->rows-y-1)*image->columns*number_planes)+ |
|---|
| 369 | x*number_planes+plane; |
|---|
| 370 | operand++; |
|---|
| 371 | for (i=0; i < (long) operand; i++) |
|---|
| 372 | { |
|---|
| 373 | pixel=(unsigned char) ReadBlobByte(image); |
|---|
| 374 | if ((y < (long) image->rows) && ((x+i) < (long) image->columns)) |
|---|
| 375 | *p=pixel; |
|---|
| 376 | p+=number_planes; |
|---|
| 377 | } |
|---|
| 378 | if (operand & 0x01) |
|---|
| 379 | (void) ReadBlobByte(image); |
|---|
| 380 | x+=operand; |
|---|
| 381 | break; |
|---|
| 382 | } |
|---|
| 383 | case RunDataOp: |
|---|
| 384 | { |
|---|
| 385 | operand=ReadBlobByte(image); |
|---|
| 386 | if (opcode & 0x40) |
|---|
| 387 | operand=(int) ReadBlobLSBShort(image); |
|---|
| 388 | pixel=(unsigned char) ReadBlobByte(image); |
|---|
| 389 | (void) ReadBlobByte(image); |
|---|
| 390 | operand++; |
|---|
| 391 | p=rle_pixels+((image->rows-y-1)*image->columns*number_planes)+ |
|---|
| 392 | x*number_planes+plane; |
|---|
| 393 | for (i=0; i < (long) operand; i++) |
|---|
| 394 | { |
|---|
| 395 | if ((y < (long) image->rows) && ((x+i) < (long) image->columns)) |
|---|
| 396 | *p=pixel; |
|---|
| 397 | p+=number_planes; |
|---|
| 398 | } |
|---|
| 399 | x+=operand; |
|---|
| 400 | break; |
|---|
| 401 | } |
|---|
| 402 | default: |
|---|
| 403 | break; |
|---|
| 404 | } |
|---|
| 405 | opcode=ReadBlobByte(image); |
|---|
| 406 | } while (((opcode & 0x3f) != EOFOp) && (opcode != EOF)); |
|---|
| 407 | if (number_colormaps != 0) |
|---|
| 408 | { |
|---|
| 409 | MagickStatusType |
|---|
| 410 | mask; |
|---|
| 411 | |
|---|
| 412 | |
|---|
| 413 | |
|---|
| 414 | |
|---|
| 415 | mask=(MagickStatusType) (map_length-1); |
|---|
| 416 | p=rle_pixels; |
|---|
| 417 | if (number_colormaps == 1) |
|---|
| 418 | for (i=0; i < (long) number_pixels; i++) |
|---|
| 419 | { |
|---|
| 420 | *p=colormap[*p & mask]; |
|---|
| 421 | p++; |
|---|
| 422 | } |
|---|
| 423 | else |
|---|
| 424 | if ((number_planes >= 3) && (number_colormaps >= 3)) |
|---|
| 425 | for (i=0; i < (long) number_pixels; i++) |
|---|
| 426 | for (x=0; x < (long) number_planes; x++) |
|---|
| 427 | { |
|---|
| 428 | *p=colormap[x*map_length+(*p & mask)]; |
|---|
| 429 | p++; |
|---|
| 430 | } |
|---|
| 431 | } |
|---|
| 432 | |
|---|
| 433 | |
|---|
| 434 | |
|---|
| 435 | if (number_planes >= 3) |
|---|
| 436 | { |
|---|
| 437 | |
|---|
| 438 | |
|---|
| 439 | |
|---|
| 440 | p=rle_pixels; |
|---|
| 441 | for (y=0; y < (long) image->rows; y++) |
|---|
| 442 | { |
|---|
| 443 | q=SetImagePixels(image,0,y,image->columns,1); |
|---|
| 444 | if (q == (PixelPacket *) NULL) |
|---|
| 445 | break; |
|---|
| 446 | for (x=0; x < (long) image->columns; x++) |
|---|
| 447 | { |
|---|
| 448 | q->red=ScaleCharToQuantum(*p++); |
|---|
| 449 | q->green=ScaleCharToQuantum(*p++); |
|---|
| 450 | q->blue=ScaleCharToQuantum(*p++); |
|---|
| 451 | if (image->matte != MagickFalse) |
|---|
| 452 | q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(*p++)); |
|---|
| 453 | q++; |
|---|
| 454 | } |
|---|
| 455 | if (SyncImagePixels(image) == MagickFalse) |
|---|
| 456 | break; |
|---|
| 457 | if (image->previous == (Image *) NULL) |
|---|
| 458 | { |
|---|
| 459 | status=SetImageProgress(image,LoadImageTag,y,image->rows); |
|---|
| 460 | if (status == MagickFalse) |
|---|
| 461 | break; |
|---|
| 462 | } |
|---|
| 463 | } |
|---|
| 464 | } |
|---|
| 465 | else |
|---|
| 466 | { |
|---|
| 467 | |
|---|
| 468 | |
|---|
| 469 | |
|---|
| 470 | if (number_colormaps == 0) |
|---|
| 471 | map_length=256; |
|---|
| 472 | if (AcquireImageColormap(image,map_length) == MagickFalse) |
|---|
| 473 | ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); |
|---|
| 474 | p=colormap; |
|---|
| 475 | if (number_colormaps == 1) |
|---|
| 476 | for (i=0; i < (long) image->colors; i++) |
|---|
| 477 | { |
|---|
| 478 | |
|---|
| 479 | |
|---|
| 480 | |
|---|
| 481 | image->colormap[i].red=ScaleCharToQuantum((unsigned char) i); |
|---|
| 482 | image->colormap[i].green=ScaleCharToQuantum((unsigned char) i); |
|---|
| 483 | image->colormap[i].blue=ScaleCharToQuantum((unsigned char) i); |
|---|
| 484 | } |
|---|
| 485 | else |
|---|
| 486 | if (number_colormaps > 1) |
|---|
| 487 | for (i=0; i < (long) image->colors; i++) |
|---|
| 488 | { |
|---|
| 489 | image->colormap[i].red=ScaleCharToQuantum(*p); |
|---|
| 490 | image->colormap[i].green=ScaleCharToQuantum(*(p+map_length)); |
|---|
| 491 | image->colormap[i].blue=ScaleCharToQuantum(*(p+map_length*2)); |
|---|
| 492 | p++; |
|---|
| 493 | } |
|---|
| 494 | p=rle_pixels; |
|---|
| 495 | if (image->matte == MagickFalse) |
|---|
| 496 | { |
|---|
| 497 | |
|---|
| 498 | |
|---|
| 499 | |
|---|
| 500 | for (y=0; y < (long) image->rows; y++) |
|---|
| 501 | { |
|---|
| 502 | q=SetImagePixels(image,0,y,image->columns,1); |
|---|
| 503 | if (q == (PixelPacket *) NULL) |
|---|
| 504 | break; |
|---|
| 505 | indexes=GetIndexes(image); |
|---|
| 506 | for (x=0; x < (long) image->columns; x++) |
|---|
| 507 | indexes[x]=(IndexPacket) (*p++); |
|---|
| 508 | if (SyncImagePixels(image) == MagickFalse) |
|---|
| 509 | break; |
|---|
| 510 | if (image->previous == (Image *) NULL) |
|---|
| 511 | { |
|---|
| 512 | status=SetImageProgress(image,LoadImageTag,y,image->rows); |
|---|
| 513 | if (status == MagickFalse) |
|---|
| 514 | break; |
|---|
| 515 | } |
|---|
| 516 | } |
|---|
| 517 | (void) SyncImage(image); |
|---|
| 518 | } |
|---|
| 519 | else |
|---|
| 520 | { |
|---|
| 521 | |
|---|
| 522 | |
|---|
| 523 | |
|---|
| 524 | for (y=0; y < (long) image->rows; y++) |
|---|
| 525 | { |
|---|
| 526 | q=SetImagePixels(image,0,y,image->columns,1); |
|---|
| 527 | if (q == (PixelPacket *) NULL) |
|---|
| 528 | break; |
|---|
| 529 | for (x=0; x < (long) image->columns; x++) |
|---|
| 530 | { |
|---|
| 531 | q->red=image->colormap[*p++].red; |
|---|
| 532 | q->green=image->colormap[*p++].green; |
|---|
| 533 | q->blue=image->colormap[*p++].blue; |
|---|
| 534 | q->opacity=(Quantum) (QuantumRange-ScaleCharToQuantum(*p++)); |
|---|
| 535 | q++; |
|---|
| 536 | } |
|---|
| 537 | if (SyncImagePixels(image) == MagickFalse) |
|---|
| 538 | break; |
|---|
| 539 | if (image->previous == (Image *) NULL) |
|---|
| 540 | { |
|---|
| 541 | status=SetImageProgress(image,LoadImageTag,y,image->rows); |
|---|
| 542 | if (status == MagickFalse) |
|---|
| 543 | break; |
|---|
| 544 | } |
|---|
| 545 | } |
|---|
| 546 | image->colormap=(PixelPacket *) |
|---|
| 547 | RelinquishMagickMemory(image->colormap); |
|---|
| 548 | image->storage_class=DirectClass; |
|---|
| 549 | image->colors=0; |
|---|
| 550 | } |
|---|
| 551 | } |
|---|
| 552 | if (number_colormaps != 0) |
|---|
| 553 | colormap=(unsigned char *) RelinquishMagickMemory(colormap); |
|---|
| 554 | rle_pixels=(unsigned char *) RelinquishMagickMemory(rle_pixels); |
|---|
| 555 | if (EOFBlob(image) != MagickFalse) |
|---|
| 556 | { |
|---|
| 557 | ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile", |
|---|
| 558 | image->filename); |
|---|
| 559 | break; |
|---|
| 560 | } |
|---|
| 561 | |
|---|
| 562 | |
|---|
| 563 | |
|---|
| 564 | if (image_info->number_scenes != 0) |
|---|
| 565 | if (image->scene >= (image_info->scene+image_info->number_scenes-1)) |
|---|
| 566 | break; |
|---|
| 567 | (void) ReadBlobByte(image); |
|---|
| 568 | count=ReadBlob(image,2,(unsigned char *) magick); |
|---|
| 569 | if ((count != 0) && (memcmp(magick,"\122\314",2) == 0)) |
|---|
| 570 | { |
|---|
| 571 | |
|---|
| 572 | |
|---|
| 573 | |
|---|
| 574 | AcquireNextImage(image_info,image); |
|---|
| 575 | if (GetNextImageInList(image) == (Image *) NULL) |
|---|
| 576 | { |
|---|
| 577 | image=DestroyImageList(image); |
|---|
| 578 | return((Image *) NULL); |
|---|
| 579 | } |
|---|
| 580 | image=SyncNextImageInList(image); |
|---|
| 581 | status=SetImageProgress(image,LoadImagesTag,TellBlob(image), |
|---|
| 582 | GetBlobSize(image)); |
|---|
| 583 | if (status == MagickFalse) |
|---|
| 584 | break; |
|---|
| 585 | } |
|---|
| 586 | } while ((count != 0) && (memcmp(magick,"\122\314",2) == 0)); |
|---|
| 587 | (void) CloseBlob(image); |
|---|
| 588 | return(GetFirstImageInList(image)); |
|---|
| 589 | } |
|---|
| 590 | |
|---|
| 591 | |
|---|
| 592 | |
|---|
| 593 | |
|---|
| 594 | |
|---|
| 595 | |
|---|
| 596 | |
|---|
| 597 | |
|---|
| 598 | |
|---|
| 599 | |
|---|
| 600 | |
|---|
| 601 | |
|---|
| 602 | |
|---|
| 603 | |
|---|
| 604 | |
|---|
| 605 | |
|---|
| 606 | |
|---|
| 607 | |
|---|
| 608 | |
|---|
| 609 | |
|---|
| 610 | |
|---|
| 611 | |
|---|
| 612 | |
|---|
| 613 | |
|---|
| 614 | ModuleExport unsigned long RegisterRLEImage(void) |
|---|
| 615 | { |
|---|
| 616 | MagickInfo |
|---|
| 617 | *entry; |
|---|
| 618 | |
|---|
| 619 | entry=SetMagickInfo("RLE"); |
|---|
| 620 | entry->decoder=(DecodeImageHandler *) ReadRLEImage; |
|---|
| 621 | entry->magick=(IsImageFormatHandler *) IsRLE; |
|---|
| 622 | entry->adjoin=MagickFalse; |
|---|
| 623 | entry->description=ConstantString("Utah Run length encoded image"); |
|---|
| 624 | entry->module=ConstantString("RLE"); |
|---|
| 625 | (void) RegisterMagickInfo(entry); |
|---|
| 626 | return(MagickImageCoderSignature); |
|---|
| 627 | } |
|---|
| 628 | |
|---|
| 629 | |
|---|
| 630 | |
|---|
| 631 | |
|---|
| 632 | |
|---|
| 633 | |
|---|
| 634 | |
|---|
| 635 | |
|---|
| 636 | |
|---|
| 637 | |
|---|
| 638 | |
|---|
| 639 | |
|---|
| 640 | |
|---|
| 641 | |
|---|
| 642 | |
|---|
| 643 | |
|---|
| 644 | |
|---|
| 645 | |
|---|
| 646 | |
|---|
| 647 | |
|---|
| 648 | ModuleExport void UnregisterRLEImage(void) |
|---|
| 649 | { |
|---|
| 650 | (void) UnregisterMagickInfo("RLE"); |
|---|
| 651 | } |
|---|