typedef struct
{
unsigned int Width;
- unsigned int Heigth;
+ unsigned int Height;
unsigned int Depth;
unsigned int HorzRes;
unsigned int VertRes;
typedef struct
{
unsigned int Width;
- unsigned int Heigth;
+ unsigned int Height;
unsigned char Depth;
unsigned char Compression;
} WPG2BitmapType1;
unsigned int UpRightX;
unsigned int UpRightY;
unsigned int Width;
- unsigned int Heigth;
+ unsigned int Height;
unsigned int Depth;
unsigned int HorzRes;
unsigned int VertRes;
*/
Image
- *image,
- *rotated_image;
+ *image;
unsigned int
status;
{
case 0x0B: /* bitmap type 1 */
BitmapHeader1.Width=ReadBlobLSBShort(image);
- BitmapHeader1.Heigth=ReadBlobLSBShort(image);
+ BitmapHeader1.Height=ReadBlobLSBShort(image);
+ if ((BitmapHeader1.Width == 0) || (BitmapHeader1.Height == 0))
+ ThrowReaderException(CorruptImageError,"ImproperImageHeader");
BitmapHeader1.Depth=ReadBlobLSBShort(image);
BitmapHeader1.HorzRes=ReadBlobLSBShort(image);
BitmapHeader1.VertRes=ReadBlobLSBShort(image);
image->resolution.y=BitmapHeader1.VertRes/470.0;
}
image->columns=BitmapHeader1.Width;
- image->rows=BitmapHeader1.Heigth;
+ image->rows=BitmapHeader1.Height;
bpp=BitmapHeader1.Depth;
goto UnpackRaster;
BitmapHeader2.UpRightX=ReadBlobLSBShort(image);
BitmapHeader2.UpRightY=ReadBlobLSBShort(image);
BitmapHeader2.Width=ReadBlobLSBShort(image);
- BitmapHeader2.Heigth=ReadBlobLSBShort(image);
+ BitmapHeader2.Height=ReadBlobLSBShort(image);
+ if ((BitmapHeader2.Width == 0) || (BitmapHeader2.Height == 0))
+ ThrowReaderException(CorruptImageError,"ImproperImageHeader");
BitmapHeader2.Depth=ReadBlobLSBShort(image);
BitmapHeader2.HorzRes=ReadBlobLSBShort(image);
BitmapHeader2.VertRes=ReadBlobLSBShort(image);
image->resolution.y=BitmapHeader2.VertRes/470.0;
}
image->columns=BitmapHeader2.Width;
- image->rows=BitmapHeader2.Heigth;
+ image->rows=BitmapHeader2.Height;
bpp=BitmapHeader2.Depth;
UnpackRaster:
/* flop command */
if(BitmapHeader2.RotAngle & 0x8000)
{
- rotated_image = FlopImage(image, exception);
- rotated_image->blob = image->blob;
- DuplicateBlob(rotated_image,image);
- (void) RemoveLastImageFromList(&image);
- AppendImageToList(&image,rotated_image);
+ Image
+ *flop_image;
+
+ flop_image = FlopImage(image, exception);
+ if (flop_image != (Image *) NULL) {
+ DuplicateBlob(flop_image,image);
+ (void) RemoveLastImageFromList(&image);
+ AppendImageToList(&image,flop_image);
+ }
}
/* flip command */
if(BitmapHeader2.RotAngle & 0x2000)
{
- rotated_image = FlipImage(image, exception);
- rotated_image->blob = image->blob;
- DuplicateBlob(rotated_image,image);
- (void) RemoveLastImageFromList(&image);
- AppendImageToList(&image,rotated_image);
+ Image
+ *flip_image;
+
+ flip_image = FlipImage(image, exception);
+ if (flip_image != (Image *) NULL) {
+ DuplicateBlob(flip_image,image);
+ (void) RemoveLastImageFromList(&image);
+ AppendImageToList(&image,flip_image);
+ }
}
/* rotate command */
if(BitmapHeader2.RotAngle & 0x0FFF)
{
- rotated_image = RotateImage(image, (BitmapHeader2.RotAngle & 0x0FFF), exception);
- rotated_image->blob = image->blob;
- DuplicateBlob(rotated_image,image);
- (void) RemoveLastImageFromList(&image);
- AppendImageToList(&image,rotated_image);
+ Image
+ *rotate_image;
+
+ rotate_image=RotateImage(image,(BitmapHeader2.RotAngle &
+ 0x0FFF), exception);
+ if (rotate_image != (Image *) NULL) {
+ DuplicateBlob(rotate_image,image);
+ (void) RemoveLastImageFromList(&image);
+ AppendImageToList(&image,rotate_image);
+ }
}
}
break;
case 0x0E:
Bitmap2Header1.Width=ReadBlobLSBShort(image);
- Bitmap2Header1.Heigth=ReadBlobLSBShort(image);
+ Bitmap2Header1.Height=ReadBlobLSBShort(image);
+ if ((Bitmap2Header1.Width == 0) || (Bitmap2Header1.Height == 0))
+ ThrowReaderException(CorruptImageError,"ImproperImageHeader");
Bitmap2Header1.Depth=ReadBlobByte(image);
Bitmap2Header1.Compression=ReadBlobByte(image);
continue; /*Ignore raster with unknown depth*/
}
image->columns=Bitmap2Header1.Width;
- image->rows=Bitmap2Header1.Heigth;
+ image->rows=Bitmap2Header1.Height;
if ((image->colors == 0) && (bpp != 24))
{
}
if(CTM[0][0]<0 && !image_info->ping)
- { /*?? RotAngle=360-RotAngle;*/
- rotated_image = FlopImage(image, exception);
- rotated_image->blob = image->blob;
- DuplicateBlob(rotated_image,image);
- (void) RemoveLastImageFromList(&image);
- AppendImageToList(&image,rotated_image);
+ { /*?? RotAngle=360-RotAngle;*/
+ Image
+ *flop_image;
+
+ flop_image = FlopImage(image, exception);
+ if (flop_image != (Image *) NULL) {
+ DuplicateBlob(flop_image,image);
+ (void) RemoveLastImageFromList(&image);
+ AppendImageToList(&image,flop_image);
+ }
/* Try to change CTM according to Flip - I am not sure, must be checked.
Tx(0,0)=-1; Tx(1,0)=0; Tx(2,0)=0;
Tx(0,1)= 0; Tx(1,1)=1; Tx(2,1)=0;
Tx(1,2)=0; Tx(2,2)=1; */
}
if(CTM[1][1]<0 && !image_info->ping)
- { /*?? RotAngle=360-RotAngle;*/
- rotated_image = FlipImage(image, exception);
- rotated_image->blob = image->blob;
- DuplicateBlob(rotated_image,image);
- (void) RemoveLastImageFromList(&image);
- AppendImageToList(&image,rotated_image);
+ { /*?? RotAngle=360-RotAngle;*/
+ Image
+ *flip_image;
+
+ flip_image = FlipImage(image, exception);
+ if (flip_image != (Image *) NULL) {
+ DuplicateBlob(flip_image,image);
+ (void) RemoveLastImageFromList(&image);
+ AppendImageToList(&image,flip_image);
+ }
/* Try to change CTM according to Flip - I am not sure, must be checked.
float_matrix Tx(3,3);
Tx(0,0)= 1; Tx(1,0)= 0; Tx(2,0)=0;
Tx(0,1)= 0; Tx(1,1)=-1; Tx(2,1)=0;
Tx(0,2)= 0; Tx(1,2)=(WPG._2Rect.Y_ur+WPG._2Rect.Y_ll);
Tx(2,2)=1; */
- }
+ }
/* Allocate next image structure. */