Skip to content

Commit

Permalink
Fix various redefinition warnings in mingw (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
Biswa96 authored May 11, 2022
1 parent 1481259 commit 281f3b2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 40 deletions.
55 changes: 26 additions & 29 deletions coders/dib.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,13 @@ static MagickBooleanType DecodeImage(Image *image,
const MagickBooleanType compression,unsigned char *pixels,
const size_t number_pixels)
{
#if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__MINGW32__)
#define BI_RGB 0
#define BI_RLE8 1
#define BI_RLE4 2
#define BI_BITFIELDS 3
#undef BI_JPEG
#define BI_JPEG 4
#undef BI_PNG
#define BI_PNG 5
#endif

#define DibRgbCompression 0
#define DibRle8Compression 1
#define DibRle4Compression 2
#define DibBitfieldsCompression 3
#define DibJpegCompression 4
#define DibPngCompression 5

int
byte,
Expand Down Expand Up @@ -207,7 +204,7 @@ static MagickBooleanType DecodeImage(Image *image,
byte=ReadBlobByte(image);
if (byte == EOF)
break;
if (compression == BI_RLE8)
if (compression == DibRle8Compression)
{
for (i=0; i < (ssize_t) count; i++)
*p++=(unsigned char) byte;
Expand Down Expand Up @@ -258,7 +255,7 @@ static MagickBooleanType DecodeImage(Image *image,
Absolute mode.
*/
count=(int) MagickMin((size_t) count,(size_t) (q-p));
if (compression == BI_RLE8)
if (compression == DibRle8Compression)
for (i=0; i < (ssize_t) count; i++)
{
byte=ReadBlobByte(image);
Expand All @@ -282,7 +279,7 @@ static MagickBooleanType DecodeImage(Image *image,
/*
Read pad byte.
*/
if (compression == BI_RLE8)
if (compression == DibRle8Compression)
{
if ((count & 0x01) != 0)
if (ReadBlobByte(image) == EOF)
Expand Down Expand Up @@ -543,7 +540,7 @@ static Image *ReadDIBImage(const ImageInfo *image_info,ExceptionInfo *exception)
(dib_info.bits_per_pixel != 8) && (dib_info.bits_per_pixel != 16) &&
(dib_info.bits_per_pixel != 24) && (dib_info.bits_per_pixel != 32))
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
if ((dib_info.compression == BI_BITFIELDS) &&
if ((dib_info.compression == DibBitfieldsCompression) &&
((dib_info.bits_per_pixel == 16) || (dib_info.bits_per_pixel == 32)))
{
dib_info.red_mask=(unsigned short) ReadBlobLSBLong(image);
Expand Down Expand Up @@ -573,14 +570,14 @@ static Image *ReadDIBImage(const ImageInfo *image_info,ExceptionInfo *exception)
ThrowReaderException(CorruptImageError,"UnsupportedBitsPerPixel");
switch (dib_info.compression)
{
case BI_RGB:
case BI_RLE8:
case BI_RLE4:
case BI_BITFIELDS:
case DibRgbCompression:
case DibRle8Compression:
case DibRle4Compression:
case DibBitfieldsCompression:
break;
case BI_JPEG:
case DibJpegCompression:
ThrowReaderException(CoderError,"JPEGCompressNotSupported");
case BI_PNG:
case DibPngCompression:
ThrowReaderException(CoderError,"PNGCompressNotSupported");
default:
ThrowReaderException(CorruptImageError,"UnrecognizedImageCompression");
Expand Down Expand Up @@ -668,7 +665,7 @@ static Image *ReadDIBImage(const ImageInfo *image_info,ExceptionInfo *exception)
/*
Read image data.
*/
if (dib_info.compression == BI_RLE4)
if (dib_info.compression == DibRle4Compression)
dib_info.bits_per_pixel<<=1;
bytes_per_line=4*((image->columns*dib_info.bits_per_pixel+31)/32);
length=bytes_per_line*image->rows;
Expand All @@ -679,8 +676,8 @@ static Image *ReadDIBImage(const ImageInfo *image_info,ExceptionInfo *exception)
if (pixel_info == (MemoryInfo *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info);
if ((dib_info.compression == BI_RGB) ||
(dib_info.compression == BI_BITFIELDS))
if ((dib_info.compression == DibRgbCompression) ||
(dib_info.compression == DibBitfieldsCompression))
{
count=ReadBlob(image,length,pixels);
if (count != (ssize_t) (length))
Expand Down Expand Up @@ -801,8 +798,8 @@ static Image *ReadDIBImage(const ImageInfo *image_info,ExceptionInfo *exception)
/*
Convert PseudoColor scanline.
*/
if ((dib_info.compression == BI_RLE8) ||
(dib_info.compression == BI_RLE4))
if ((dib_info.compression == DibRle8Compression) ||
(dib_info.compression == DibRle4Compression))
bytes_per_line=image->columns;
for (y=(ssize_t) image->rows-1; y >= 0; y--)
{
Expand Down Expand Up @@ -840,7 +837,7 @@ static Image *ReadDIBImage(const ImageInfo *image_info,ExceptionInfo *exception)
Convert PseudoColor scanline.
*/
image->storage_class=DirectClass;
if (dib_info.compression == BI_RLE8)
if (dib_info.compression == DibRle8Compression)
bytes_per_line=2*image->columns;
for (y=(ssize_t) image->rows-1; y >= 0; y--)
{
Expand Down Expand Up @@ -1177,7 +1174,7 @@ static MagickBooleanType WriteDIBImage(const ImageInfo *image_info,Image *image)
dib_info.height=(int) image->rows;
dib_info.planes=1;
dib_info.compression=(unsigned int) (dib_info.bits_per_pixel == 16 ?
BI_BITFIELDS : BI_RGB);
DibBitfieldsCompression : DibRgbCompression);
dib_info.image_size=(unsigned int) (bytes_per_line*image->rows);
dib_info.x_pixels=75*39;
dib_info.y_pixels=75*39;
Expand Down Expand Up @@ -1363,7 +1360,7 @@ static MagickBooleanType WriteDIBImage(const ImageInfo *image_info,Image *image)
pixels,dib_data);
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
pixels=dib_data;
dib_info.compression = BI_RLE8;
dib_info.compression = DibRle8Compression;
}
/*
Write DIB header.
Expand Down Expand Up @@ -1417,7 +1414,7 @@ static MagickBooleanType WriteDIBImage(const ImageInfo *image_info,Image *image)
}
else
if ((dib_info.bits_per_pixel == 16) &&
(dib_info.compression == BI_BITFIELDS))
(dib_info.compression == DibBitfieldsCompression))
{
(void) WriteBlobLSBLong(image,0xf800);
(void) WriteBlobLSBLong(image,0x07e0);
Expand Down
6 changes: 3 additions & 3 deletions coders/djvu.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,6 @@ process_message(ddjvu_message_t *message)
}
#endif


#define RGB 1

/*
* DjVu advertised readiness to provide bitmap: So get it!
* we use the RGB format!
Expand Down Expand Up @@ -460,6 +457,9 @@ get_page_image(LoadContext *lc, ddjvu_page_t *page, int x, int y, int w, int h,
#if defined(MAGICKCORE_DJVU_DELEGATE)

#if 0

#define RGB 1

static int
get_page_line(LoadContext *lc, int row, QuantumInfo* quantum_info)
{
Expand Down
12 changes: 4 additions & 8 deletions coders/icon.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@
/*
Define declarations.
*/
#if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__MINGW32__)
#define BI_RGB 0
#define BI_RLE8 1
#define BI_BITFIELDS 3
#endif
#define IconRgbCompression (size_t) 0
#define MaxIcons 1024

/*
Expand Down Expand Up @@ -1033,7 +1029,7 @@ static MagickBooleanType WriteICONImage(const ImageInfo *image_info,
(void) TransformImageColorspace(image,sRGBColorspace);
icon_info.file_size=14+12+28;
icon_info.offset_bits=icon_info.file_size;
icon_info.compression=BI_RGB;
icon_info.compression=IconRgbCompression;
if ((next->storage_class != DirectClass) && (next->colors > 256))
(void) SetImageStorageClass(next,DirectClass);
if (next->storage_class == DirectClass)
Expand All @@ -1043,7 +1039,7 @@ static MagickBooleanType WriteICONImage(const ImageInfo *image_info,
*/
icon_info.number_colors=0;
icon_info.bits_per_pixel=32;
icon_info.compression=(size_t) BI_RGB;
icon_info.compression=IconRgbCompression;
}
else
{
Expand All @@ -1065,7 +1061,7 @@ static MagickBooleanType WriteICONImage(const ImageInfo *image_info,
(void) SetImageStorageClass(next,DirectClass);
icon_info.number_colors=0;
icon_info.bits_per_pixel=(unsigned short) 24;
icon_info.compression=(size_t) BI_RGB;
icon_info.compression=IconRgbCompression;
}
else
{
Expand Down

0 comments on commit 281f3b2

Please sign in to comment.