From b7cf7d0474fa96a432600912bf9cf504d9094d30 Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Fri, 24 May 2024 10:23:00 +0200 Subject: [PATCH] Removed width and height from IconInfo. --- coders/icon.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/coders/icon.c b/coders/icon.c index cfbf2a2e6..9f9ee109d 100644 --- a/coders/icon.c +++ b/coders/icon.c @@ -111,10 +111,6 @@ typedef struct _IconInfo ba_offset, offset_bits; - ssize_t - width, - height; - size_t compression, image_size, @@ -402,6 +398,10 @@ static Image *ReadICONImage(const ImageInfo *image_info, size_t size; + ssize_t + width, + height; + unsigned short bits_per_pixel, planes; @@ -414,8 +414,8 @@ static Image *ReadICONImage(const ImageInfo *image_info, if (offset < 0) ThrowReaderException(CorruptImageError,"ImproperImageHeader"); size=ReadBlobLSBLong(image); - icon_info.width=(unsigned char) ReadBlobLSBSignedLong(image); - icon_info.height=(unsigned char) (ReadBlobLSBSignedLong(image)/2); + width=(unsigned char) ReadBlobLSBSignedLong(image); + height=(unsigned char) (ReadBlobLSBSignedLong(image)/2); planes=ReadBlobLSBShort(image); bits_per_pixel=ReadBlobLSBShort(image); if (EOFBlob(image) != MagickFalse) @@ -489,13 +489,13 @@ static Image *ReadICONImage(const ImageInfo *image_info, (void) ReadBlobLSBLong(image); /* colors_important */ image->matte=MagickTrue; image->columns=(size_t) icon_file.directory[i].width; - if ((ssize_t) image->columns > icon_info.width) - image->columns=(size_t) icon_info.width; + if ((ssize_t) image->columns > width) + image->columns=(size_t) width; if (image->columns == 0) image->columns=256; image->rows=(size_t) icon_file.directory[i].height; - if ((ssize_t) image->rows > icon_info.height) - image->rows=(size_t) icon_info.height; + if ((ssize_t) image->rows > height) + image->rows=(size_t) height; if (image->rows == 0) image->rows=256; image->depth=bits_per_pixel; @@ -508,9 +508,9 @@ static Image *ReadICONImage(const ImageInfo *image_info, (void) LogMagickEvent(CoderEvent,GetMagickModule(), " size = %.20g",(double) size); (void) LogMagickEvent(CoderEvent,GetMagickModule(), - " width = %.20g",(double) icon_file.directory[i].width); + " width = %.20g",(double) width); (void) LogMagickEvent(CoderEvent,GetMagickModule(), - " height = %.20g",(double) icon_file.directory[i].height); + " height = %.20g",(double) height); (void) LogMagickEvent(CoderEvent,GetMagickModule(), " colors = %.20g",(double ) number_colors); (void) LogMagickEvent(CoderEvent,GetMagickModule(), @@ -1115,6 +1115,10 @@ static MagickBooleanType WriteICONImage(const ImageInfo *image_info, size_t number_colors; + ssize_t + width, + height; + /* Initialize ICON raster file header. */ @@ -1171,14 +1175,14 @@ static MagickBooleanType WriteICONImage(const ImageInfo *image_info, bytes_per_line=(((next->columns*bits_per_pixel)+31) & ~31) >> 3; icon_info.ba_offset=0; - icon_info.width=(ssize_t) next->columns; - icon_info.height=(ssize_t) next->rows; + width=(ssize_t) next->columns; + height=(ssize_t) next->rows; planes=1; icon_info.image_size=bytes_per_line*next->rows; size=40; size+=(4*number_colors); size+=icon_info.image_size; - size+=(((icon_info.width+31) & ~31) >> 3)*icon_info.height; + size+=(((width+31) & ~31) >> 3)*height; icon_info.file_size+=icon_info.image_size; icon_info.x_pixels=0; icon_info.y_pixels=0; @@ -1355,8 +1359,8 @@ static MagickBooleanType WriteICONImage(const ImageInfo *image_info, /* Write 40-byte version 3+ bitmap header. */ - icon_file.directory[scene].width=(unsigned char) icon_info.width; - icon_file.directory[scene].height=(unsigned char) icon_info.height; + icon_file.directory[scene].width=(unsigned char) width; + icon_file.directory[scene].height=(unsigned char) height; icon_file.directory[scene].colors=(unsigned char) number_colors; icon_file.directory[scene].reserved=0; icon_file.directory[scene].planes=planes; @@ -1364,8 +1368,8 @@ static MagickBooleanType WriteICONImage(const ImageInfo *image_info, icon_file.directory[scene].size=size; icon_file.directory[scene].offset=(size_t) TellBlob(image); (void) WriteBlobLSBLong(image,(unsigned int) 40); - (void) WriteBlobLSBLong(image,(unsigned int) icon_info.width); - (void) WriteBlobLSBLong(image,(unsigned int) icon_info.height*2); + (void) WriteBlobLSBLong(image,(unsigned int) width); + (void) WriteBlobLSBLong(image,(unsigned int) height*2); (void) WriteBlobLSBShort(image,planes); (void) WriteBlobLSBShort(image,bits_per_pixel); (void) WriteBlobLSBLong(image,(unsigned int) icon_info.compression);