From c5de69967ea7758f3204962a84c780c82d824ca7 Mon Sep 17 00:00:00 2001 From: cristy Date: Tue, 6 Oct 2009 19:19:48 +0000 Subject: [PATCH] --- coders/dcm.c | 14 ++--- coders/dds.c | 78 ++++++++++++------------- coders/ipl.c | 26 ++++----- coders/mat.c | 162 +++++++++++++++++++++++++-------------------------- coders/pdb.c | 64 ++++++++++---------- 5 files changed, 172 insertions(+), 172 deletions(-) diff --git a/coders/dcm.c b/coders/dcm.c index 111530a69..00a7c8379 100644 --- a/coders/dcm.c +++ b/coders/dcm.c @@ -3470,8 +3470,8 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception) { if (samples_per_pixel == 1) { - long - pixel_value; + long + pixel_value; if (bytes_per_pixel == 1) pixel_value=polarity != MagickFalse ? (long) (max_value- @@ -3503,13 +3503,13 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception) } i++; } - index=pixel_value; + index=pixel_value; if (window_width == 0) - { + { if (signed_data == 1) - index=pixel_value-32767; - } - else + index=pixel_value-32767; + } + else { long window_max, diff --git a/coders/dds.c b/coders/dds.c index 63859fa54..bb6dd370b 100644 --- a/coders/dds.c +++ b/coders/dds.c @@ -128,13 +128,13 @@ typedef struct _DDSPixelFormat typedef struct _DDSInfo { - unsigned long - flags, - height, - width, - pitchOrLinearSize, - depth, - mipmapcount, + unsigned long + flags, + height, + width, + pitchOrLinearSize, + depth, + mipmapcount, ddscaps1, ddscaps2; @@ -247,7 +247,7 @@ static Image *ReadDDSImage(const ImageInfo *image_info,ExceptionInfo *exception) compression; DDSInfo - dds_info; + dds_info; DDSDecoder *decoder; @@ -277,7 +277,7 @@ static Image *ReadDDSImage(const ImageInfo *image_info,ExceptionInfo *exception) Initialize image structure. */ if (ReadDDSInfo(image, &dds_info) != MagickTrue) { - ThrowReaderException(CorruptImageError,"ImproperImageHeader"); + ThrowReaderException(CorruptImageError,"ImproperImageHeader"); } if (dds_info.ddscaps2 & DDSCAPS2_CUBEMAP) @@ -408,33 +408,33 @@ static Image *ReadDDSImage(const ImageInfo *image_info,ExceptionInfo *exception) static MagickBooleanType ReadDDSInfo(Image *image, DDSInfo *dds_info) { - unsigned long + unsigned long hdr_size, required; - - /* Seek to start of header */ - (void) SeekBlob(image, 4, SEEK_SET); - - /* Check header field */ - hdr_size = ReadBlobLSBLong(image); - if (hdr_size != 124) - return MagickFalse; - - /* Fill in DDS info struct */ - dds_info->flags = ReadBlobLSBLong(image); - - /* Check required flags */ - required=(unsigned long) (DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT); + + /* Seek to start of header */ + (void) SeekBlob(image, 4, SEEK_SET); + + /* Check header field */ + hdr_size = ReadBlobLSBLong(image); + if (hdr_size != 124) + return MagickFalse; + + /* Fill in DDS info struct */ + dds_info->flags = ReadBlobLSBLong(image); + + /* Check required flags */ + required=(unsigned long) (DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT); if ((dds_info->flags & required) != required) - return MagickFalse; + return MagickFalse; - dds_info->height = ReadBlobLSBLong(image); - dds_info->width = ReadBlobLSBLong(image); - dds_info->pitchOrLinearSize = ReadBlobLSBLong(image); - dds_info->depth = ReadBlobLSBLong(image); - dds_info->mipmapcount = ReadBlobLSBLong(image); + dds_info->height = ReadBlobLSBLong(image); + dds_info->width = ReadBlobLSBLong(image); + dds_info->pitchOrLinearSize = ReadBlobLSBLong(image); + dds_info->depth = ReadBlobLSBLong(image); + dds_info->mipmapcount = ReadBlobLSBLong(image); - (void) SeekBlob(image, 44, SEEK_CUR); /* reserved region of 11 DWORDs */ + (void) SeekBlob(image, 44, SEEK_CUR); /* reserved region of 11 DWORDs */ /* Read pixel format structure */ hdr_size = ReadBlobLSBLong(image); @@ -449,11 +449,11 @@ static MagickBooleanType ReadDDSInfo(Image *image, DDSInfo *dds_info) dds_info->pixelformat.b_bitmask = ReadBlobLSBLong(image); dds_info->pixelformat.alpha_bitmask = ReadBlobLSBLong(image); - dds_info->ddscaps1 = ReadBlobLSBLong(image); - dds_info->ddscaps2 = ReadBlobLSBLong(image); - (void) SeekBlob(image, 12, SEEK_CUR); /* 3 reserved DWORDs */ + dds_info->ddscaps1 = ReadBlobLSBLong(image); + dds_info->ddscaps2 = ReadBlobLSBLong(image); + (void) SeekBlob(image, 12, SEEK_CUR); /* 3 reserved DWORDs */ - return MagickTrue; + return MagickTrue; } static void CalculateColors(unsigned short c0, unsigned short c1, @@ -501,7 +501,7 @@ static MagickBooleanType ReadDXT1(Image *image, DDSInfo *dds_info) long j, y; - + PixelPacket *q; @@ -512,10 +512,10 @@ static MagickBooleanType ReadDXT1(Image *image, DDSInfo *dds_info) unsigned char code; - unsigned short + unsigned short c0, c1; - + unsigned long bits; @@ -526,7 +526,7 @@ static MagickBooleanType ReadDXT1(Image *image, DDSInfo *dds_info) { /* Get 4x4 patch of pixels to write on */ q = QueueAuthenticPixels(image, x, y, Min(4, dds_info->width - x), - Min(4, dds_info->height - y),exception); + Min(4, dds_info->height - y),exception); if (q == (PixelPacket *) NULL) return MagickFalse; diff --git a/coders/ipl.c b/coders/ipl.c index 05b685a7a..8659fb97f 100644 --- a/coders/ipl.c +++ b/coders/ipl.c @@ -161,11 +161,11 @@ static MagickBooleanType IsIPL(const unsigned char *magick,const size_t length) */ void SetHeaderFromIPL(Image *image, IPLInfo *ipl){ - image->columns = ipl->width; - image->rows = ipl->height; - image->depth = ipl->depth; - image->x_resolution = 1; - image->y_resolution = 1; + image->columns = ipl->width; + image->rows = ipl->height; + image->depth = ipl->depth; + image->x_resolution = 1; + image->y_resolution = 1; } @@ -325,8 +325,8 @@ static Image *ReadIPLImage(const ImageInfo *image_info,ExceptionInfo *exception) pixels=GetQuantumPixels(quantum_info); if(image->columns != ipl_info.width){ /* - printf("Columns not set correctly! Wanted: %lu, got: %lu\n", - ipl_info.width, image->columns); + printf("Columns not set correctly! Wanted: %lu, got: %lu\n", + ipl_info.width, image->columns); */ } @@ -340,11 +340,11 @@ static Image *ReadIPLImage(const ImageInfo *image_info,ExceptionInfo *exception) q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); if (q == (PixelPacket *) NULL) break; - (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info, + (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info, GrayQuantum,pixels,exception); if (SyncAuthenticPixels(image,exception) == MagickFalse) break; - } + } } else{ for(y = 0; y < (long) image->rows; y++){ @@ -352,8 +352,8 @@ static Image *ReadIPLImage(const ImageInfo *image_info,ExceptionInfo *exception) q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); if (q == (PixelPacket *) NULL) break; - (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info, - RedQuantum,pixels,exception); + (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info, + RedQuantum,pixels,exception); if (SyncAuthenticPixels(image,exception) == MagickFalse) break; } @@ -362,7 +362,7 @@ static Image *ReadIPLImage(const ImageInfo *image_info,ExceptionInfo *exception) q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); if (q == (PixelPacket *) NULL) break; - (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info, + (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info, GreenQuantum,pixels,exception); if (SyncAuthenticPixels(image,exception) == MagickFalse) break; @@ -372,7 +372,7 @@ static Image *ReadIPLImage(const ImageInfo *image_info,ExceptionInfo *exception) q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); if (q == (PixelPacket *) NULL) break; - (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info, + (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info, BlueQuantum,pixels,exception); if (SyncAuthenticPixels(image,exception) == MagickFalse) break; diff --git a/coders/mat.c b/coders/mat.c index d20001148..3d12d23e5 100644 --- a/coders/mat.c +++ b/coders/mat.c @@ -125,43 +125,43 @@ static const char *OsDesc= typedef enum { - miINT8 = 1, /* 8 bit signed */ - miUINT8, /* 8 bit unsigned */ - miINT16, /* 16 bit signed */ - miUINT16, /* 16 bit unsigned */ - miINT32, /* 32 bit signed */ - miUINT32, /* 32 bit unsigned */ - miSINGLE, /* IEEE 754 single precision float */ + miINT8 = 1, /* 8 bit signed */ + miUINT8, /* 8 bit unsigned */ + miINT16, /* 16 bit signed */ + miUINT16, /* 16 bit unsigned */ + miINT32, /* 32 bit signed */ + miUINT32, /* 32 bit unsigned */ + miSINGLE, /* IEEE 754 single precision float */ miRESERVE1, - miDOUBLE, /* IEEE 754 double precision float */ + miDOUBLE, /* IEEE 754 double precision float */ miRESERVE2, miRESERVE3, - miINT64, /* 64 bit signed */ - miUINT64, /* 64 bit unsigned */ - miMATRIX, /* MATLAB array */ - miCOMPRESSED, /* Compressed Data */ - miUTF8, /* Unicode UTF-8 Encoded Character Data */ - miUTF16, /* Unicode UTF-16 Encoded Character Data */ - miUTF32 /* Unicode UTF-32 Encoded Character Data */ + miINT64, /* 64 bit signed */ + miUINT64, /* 64 bit unsigned */ + miMATRIX, /* MATLAB array */ + miCOMPRESSED, /* Compressed Data */ + miUTF8, /* Unicode UTF-8 Encoded Character Data */ + miUTF16, /* Unicode UTF-16 Encoded Character Data */ + miUTF32 /* Unicode UTF-32 Encoded Character Data */ } mat5_data_type; typedef enum { - mxCELL_CLASS=1, /* cell array */ - mxSTRUCT_CLASS, /* structure */ - mxOBJECT_CLASS, /* object */ - mxCHAR_CLASS, /* character array */ - mxSPARSE_CLASS, /* sparse array */ - mxDOUBLE_CLASS, /* double precision array */ - mxSINGLE_CLASS, /* single precision floating point */ - mxINT8_CLASS, /* 8 bit signed integer */ - mxUINT8_CLASS, /* 8 bit unsigned integer */ - mxINT16_CLASS, /* 16 bit signed integer */ - mxUINT16_CLASS, /* 16 bit unsigned integer */ - mxINT32_CLASS, /* 32 bit signed integer */ - mxUINT32_CLASS, /* 32 bit unsigned integer */ - mxINT64_CLASS, /* 64 bit signed integer */ - mxUINT64_CLASS, /* 64 bit unsigned integer */ + mxCELL_CLASS=1, /* cell array */ + mxSTRUCT_CLASS, /* structure */ + mxOBJECT_CLASS, /* object */ + mxCHAR_CLASS, /* character array */ + mxSPARSE_CLASS, /* sparse array */ + mxDOUBLE_CLASS, /* double precision array */ + mxSINGLE_CLASS, /* single precision floating point */ + mxINT8_CLASS, /* 8 bit signed integer */ + mxUINT8_CLASS, /* 8 bit unsigned integer */ + mxINT16_CLASS, /* 16 bit signed integer */ + mxUINT16_CLASS, /* 16 bit unsigned integer */ + mxINT32_CLASS, /* 32 bit signed integer */ + mxUINT32_CLASS, /* 32 bit unsigned integer */ + mxINT64_CLASS, /* 64 bit signed integer */ + mxUINT64_CLASS, /* 64 bit unsigned integer */ mxFUNCTION_CLASS /* Function handle */ } arrayclasstype; @@ -349,13 +349,13 @@ float *fltrow; ReadBlobDoublesXXX = ReadBlobDoublesLSB; ReadBlobFloatsXXX = ReadBlobFloatsLSB; } - else /* MI */ + else /* MI */ { ReadBlobDoublesXXX = ReadBlobDoublesMSB; ReadBlobFloatsXXX = ReadBlobFloatsMSB; } - filepos = TellBlob(image); /* Please note that file seeking occurs only in the case of doubles */ + filepos = TellBlob(image); /* Please note that file seeking occurs only in the case of doubles */ for (i = 0; i < SizeY; i++) { if (CellType==miDOUBLE) @@ -403,7 +403,7 @@ static void FixSignedValues(PixelPacket *q, int y) { /* Please note that negative values will overflow Q=8; QuantumRange=255: <0;127> + 127+1 = <128; 255> - <-1;-128> + 127+1 = <0; 127> */ + <-1;-128> + 127+1 = <0; 127> */ q->red += QuantumRange/2 + 1; q->green += QuantumRange/ + 1; q->blue += QuantumRange/ + 1; @@ -465,7 +465,7 @@ size_t magick_size; int status; if(clone_info==NULL) return NULL; - if(clone_info->file) /* Close file opened from previous transaction. */ + if(clone_info->file) /* Close file opened from previous transaction. */ { fclose(clone_info->file); clone_info->file = NULL; @@ -697,7 +697,7 @@ MATLAB_KO: ThrowReaderException(CorruptImageError,"ImproperImageHeader"); MATLAB_HDR.unknown3 = ReadBlobXXXLong(image2); if(image!=image2) - MATLAB_HDR.unknown4 = ReadBlobXXXLong(image2); /* ??? don't understand why ?? */ + MATLAB_HDR.unknown4 = ReadBlobXXXLong(image2); /* ??? don't understand why ?? */ MATLAB_HDR.unknown4 = ReadBlobXXXLong(image2); MATLAB_HDR.DimFlag = ReadBlobXXXLong(image2); MATLAB_HDR.SizeX = ReadBlobXXXLong(image2); @@ -706,11 +706,11 @@ MATLAB_KO: ThrowReaderException(CorruptImageError,"ImproperImageHeader"); switch(MATLAB_HDR.DimFlag) { - case 8: z=1; break; /* 2D matrix*/ - case 12: z = ReadBlobXXXLong(image2); /* 3D matrix RGB*/ - Unknown6 = ReadBlobXXXLong(image2); - if(z!=3) ThrowReaderException(CoderError, "MultidimensionalMatricesAreNotSupported"); - break; + case 8: z=1; break; /* 2D matrix*/ + case 12: z = ReadBlobXXXLong(image2); /* 3D matrix RGB*/ + Unknown6 = ReadBlobXXXLong(image2); + if(z!=3) ThrowReaderException(CoderError, "MultidimensionalMatricesAreNotSupported"); + break; default: ThrowReaderException(CoderError, "MultidimensionalMatricesAreNotSupported"); } @@ -720,22 +720,22 @@ MATLAB_KO: ThrowReaderException(CorruptImageError,"ImproperImageHeader"); if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), "MATLAB_HDR.StructureClass %d",MATLAB_HDR.StructureClass); if (MATLAB_HDR.StructureClass != mxCHAR_CLASS && - MATLAB_HDR.StructureClass != mxSINGLE_CLASS && /* float + complex float */ - MATLAB_HDR.StructureClass != mxDOUBLE_CLASS && /* double + complex double */ + MATLAB_HDR.StructureClass != mxSINGLE_CLASS && /* float + complex float */ + MATLAB_HDR.StructureClass != mxDOUBLE_CLASS && /* double + complex double */ MATLAB_HDR.StructureClass != mxINT8_CLASS && - MATLAB_HDR.StructureClass != mxUINT8_CLASS && /* uint8 + uint8 3D */ + MATLAB_HDR.StructureClass != mxUINT8_CLASS && /* uint8 + uint8 3D */ MATLAB_HDR.StructureClass != mxINT16_CLASS && - MATLAB_HDR.StructureClass != mxUINT16_CLASS && /* uint16 + uint16 3D */ + MATLAB_HDR.StructureClass != mxUINT16_CLASS && /* uint16 + uint16 3D */ MATLAB_HDR.StructureClass != mxINT32_CLASS && - MATLAB_HDR.StructureClass != mxUINT32_CLASS && /* uint32 + uint32 3D */ + MATLAB_HDR.StructureClass != mxUINT32_CLASS && /* uint32 + uint32 3D */ MATLAB_HDR.StructureClass != mxINT64_CLASS && - MATLAB_HDR.StructureClass != mxUINT64_CLASS) /* uint64 + uint64 3D */ + MATLAB_HDR.StructureClass != mxUINT64_CLASS) /* uint64 + uint64 3D */ ThrowReaderException(CoderError,"UnsupportedCellTypeInTheMatrix"); switch (MATLAB_HDR.NameFlag) { case 0: - size = ReadBlobXXXLong(image2); /* Object name string size */ + size = ReadBlobXXXLong(image2); /* Object name string size */ size = 4 * (long) ((size + 3 + 1) / 4); (void) SeekBlob(image2, size, SEEK_CUR); break; @@ -794,8 +794,8 @@ MATLAB_KO: ThrowReaderException(CorruptImageError,"ImproperImageHeader"); image->depth = 32; /* double type cell */ (void) SetImageOption(clone_info,"quantum:format","floating-point"); if (MATLAB_HDR.StructureFlag & FLAG_COMPLEX) - { /* complex float type cell */ - } + { /* complex float type cell */ + } ldblk = (long) (4 * MATLAB_HDR.SizeX); break; case miDOUBLE: @@ -805,8 +805,8 @@ MATLAB_KO: ThrowReaderException(CorruptImageError,"ImproperImageHeader"); if (sizeof(double) != 8) ThrowReaderException(CoderError, "IncompatibleSizeOfDouble"); if (MATLAB_HDR.StructureFlag & FLAG_COMPLEX) - { /* complex double type cell */ - } + { /* complex double type cell */ + } ldblk = (long) (8 * MATLAB_HDR.SizeX); break; default: @@ -858,52 +858,52 @@ MATLAB_KO: ThrowReaderException(CorruptImageError,"ImproperImageHeader"); /* Main loop for reading all scanlines */ if(z==1) z=0; /* read grey scanlines */ - /* else read color scanlines */ + /* else read color scanlines */ do { for (i = 0; i < (long) MATLAB_HDR.SizeY; i++) { q=QueueAuthenticPixels(image,0,MATLAB_HDR.SizeY-i-1,image->columns,1,exception); if (q == (PixelPacket *)NULL) - { - if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), + { + if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), " MAT set image pixels returns unexpected NULL on a row %u.", (unsigned)(MATLAB_HDR.SizeY-i-1)); - goto done_reading; /* Skip image rotation, when cannot set image pixels */ - } + goto done_reading; /* Skip image rotation, when cannot set image pixels */ + } if(ReadBlob(image2,ldblk,(unsigned char *)BImgBuff) != (ssize_t) ldblk) - { - if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), + { + if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), " MAT cannot read scanrow %u from a file.", (unsigned)(MATLAB_HDR.SizeY-i-1)); - goto ExitLoop; - } + goto ExitLoop; + } if((CellType==miINT8 || CellType==miUINT8) && (MATLAB_HDR.StructureFlag & FLAG_LOGICAL)) { FixLogical((unsigned char *)BImgBuff,ldblk); if(ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,z2qtype[z],BImgBuff,exception) <= 0) - { + { ImportQuantumPixelsFailed: - if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), + if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), " MAT failed to ImportQuantumPixels for a row %u", (unsigned)(MATLAB_HDR.SizeY-i-1)); - break; - } + break; + } } else { if(ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,z2qtype[z],BImgBuff,exception) <= 0) - goto ImportQuantumPixelsFailed; + goto ImportQuantumPixelsFailed; - if (z<=1 && /* fix only during a last pass z==0 || z==1 */ - (CellType==miINT8 || CellType==miINT16 || CellType==miINT32 || CellType==miINT64)) - FixSignedValues(q,MATLAB_HDR.SizeX); + if (z<=1 && /* fix only during a last pass z==0 || z==1 */ + (CellType==miINT8 || CellType==miINT16 || CellType==miINT32 || CellType==miINT64)) + FixSignedValues(q,MATLAB_HDR.SizeX); } if (!SyncAuthenticPixels(image,exception)) - { - if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), + { + if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(), " MAT failed to sync image pixels for a row %u", (unsigned)(MATLAB_HDR.SizeY-i-1)); - goto ExitLoop; - } + goto ExitLoop; + } } } while(z-- >= 2); ExitLoop: @@ -922,17 +922,17 @@ ExitLoop: if (CellType==miDOUBLE) for (i = 0; i < (long) MATLAB_HDR.SizeY; i++) - { + { ReadBlobDoublesXXX(image2, ldblk, (double *)BImgBuff); InsertComplexDoubleRow((double *)BImgBuff, i, image, MinVal, MaxVal); - } + } if (CellType==miSINGLE) for (i = 0; i < (long) MATLAB_HDR.SizeY; i++) - { + { ReadBlobFloatsXXX(image2, ldblk, (float *)BImgBuff); InsertComplexFloatRow((float *)BImgBuff, i, image, MinVal, MaxVal); - } + } } /* Image is gray when no complex flag is set and 2D Matrix AGAIN!!! */ @@ -967,14 +967,14 @@ done_reading: if(image2!=image) { DeleteImageFromList(&image2); - if(clone_info) - { + if(clone_info) + { if(clone_info->file) - { + { fclose(clone_info->file); clone_info->file = NULL; (void) unlink(clone_info->filename); - } + } } } @@ -1023,7 +1023,7 @@ done_reading: p->scene=scene++; } - if(clone_info != NULL) /* cleanup garbage file from compression */ + if(clone_info != NULL) /* cleanup garbage file from compression */ { if(clone_info->file) { diff --git a/coders/pdb.c b/coders/pdb.c index 365acd490..e6a1d3834 100644 --- a/coders/pdb.c +++ b/coders/pdb.c @@ -37,9 +37,9 @@ 20071202 TS * rewrote RLE decoder - old version could cause buffer overflows * failure of RLE decoding now thows error RLEDecoderError * fixed bug in RLE decoding - now all rows are decoded, not just - the first one - * fixed bug in reader - record offsets now handled correctly - * fixed bug in reader - only bits 0..2 indicate compression type + the first one + * fixed bug in reader - record offsets now handled correctly + * fixed bug in reader - only bits 0..2 indicate compression type * in writer: now using image color count instead of depth */ @@ -168,33 +168,33 @@ static MagickBooleanType DecodeImage(Image *image, unsigned char *pixels, #define RLE_MODE_COPY 0 #define RLE_MODE_RUN 1 - int data = 0, count = 0; - unsigned char *p; - int mode = RLE_MODE_NONE; - - for (p = pixels; p < pixels + length; p++) { - if (0 == count) { - data = ReadBlobByte( image ); - if (-1 == data) return MagickFalse; - if (data > 128) { - mode = RLE_MODE_RUN; - count = data - 128 + 1; - data = ReadBlobByte( image ); - if (-1 == data) return MagickFalse; - } else { - mode = RLE_MODE_COPY; - count = data + 1; - } - } - - if (RLE_MODE_COPY == mode) { - data = ReadBlobByte( image ); - if (-1 == data) return MagickFalse; - } - *p = (unsigned char)data; - --count; - } - return MagickTrue; + int data = 0, count = 0; + unsigned char *p; + int mode = RLE_MODE_NONE; + + for (p = pixels; p < pixels + length; p++) { + if (0 == count) { + data = ReadBlobByte( image ); + if (-1 == data) return MagickFalse; + if (data > 128) { + mode = RLE_MODE_RUN; + count = data - 128 + 1; + data = ReadBlobByte( image ); + if (-1 == data) return MagickFalse; + } else { + mode = RLE_MODE_COPY; + count = data + 1; + } + } + + if (RLE_MODE_COPY == mode) { + data = ReadBlobByte( image ); + if (-1 == data) return MagickFalse; + } + *p = (unsigned char)data; + --count; + } + return MagickTrue; } /* @@ -413,12 +413,12 @@ static Image *ReadPDBImage(const ImageInfo *image_info,ExceptionInfo *exception) { image->compression=RLECompression; if (!DecodeImage(image, pixels, packets * image -> rows)) - ThrowReaderException( CorruptImageError, "RLEDecoderError" ); /* TS */ + ThrowReaderException( CorruptImageError, "RLEDecoderError" ); /* TS */ break; } default: ThrowReaderException(CorruptImageError, - "UnrecognizedImageCompressionType" ); + "UnrecognizedImageCompressionType" ); } p=pixels; switch (bits_per_pixel) -- 2.40.0