% Read/Write Windows DIB Image Format %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% July 1992 %
% %
% %
-% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
static MagickBooleanType DecodeImage(Image *image,
const MagickBooleanType compression,unsigned char *pixels)
{
-#if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__MINGW32__)
+#if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__MINGW32__) || defined(__MINGW64__)
#define BI_RGB 0
#define BI_RLE8 1
#define BI_RLE4 2
MagickBooleanType
status;
+ MemoryInfo
+ *pixel_info;
+
Quantum
index;
dib_info.green_mask=ReadBlobLSBLong(image);
dib_info.blue_mask=ReadBlobLSBLong(image);
}
- image->matte=dib_info.bits_per_pixel == 32 ? MagickTrue : MagickFalse;
+ image->alpha_trait=dib_info.bits_per_pixel == 32 ? BlendPixelTrait :
+ UndefinedPixelTrait;
image->columns=(size_t) MagickAbsoluteValue(dib_info.width);
image->rows=(size_t) MagickAbsoluteValue(dib_info.height);
image->depth=8;
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;
- pixels=(unsigned char *) AcquireQuantumMemory((size_t) image->rows,
- MagickMax(bytes_per_line,image->columns+256UL)*sizeof(*pixels));
- if (pixels == (unsigned char *) NULL)
+ pixel_info=AcquireVirtualMemory((size_t) image->rows,MagickMax(
+ bytes_per_line,image->columns+256UL)*sizeof(*pixels));
+ 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))
{
Initialize image structure.
*/
image->units=PixelsPerCentimeterResolution;
- image->x_resolution=(double) dib_info.x_pixels/100.0;
- image->y_resolution=(double) dib_info.y_pixels/100.0;
+ image->resolution.x=(double) dib_info.x_pixels/100.0;
+ image->resolution.y=(double) dib_info.y_pixels/100.0;
/*
Convert DIB raster image to pixel packets.
*/
break;
for (x=0; x < ((ssize_t) image->columns-1); x+=2)
{
- index=ConstrainColormapIndex(image,(*p >> 4) & 0xf);
+ index=ConstrainColormapIndex(image,(*p >> 4) & 0xf,exception);
SetPixelIndex(image,index,q);
q+=GetPixelChannels(image);
- index=ConstrainColormapIndex(image,*p & 0xf);
+ index=ConstrainColormapIndex(image,*p & 0xf,exception);
SetPixelIndex(image,index,q);
p++;
q+=GetPixelChannels(image);
}
if ((image->columns % 2) != 0)
{
- index=ConstrainColormapIndex(image,(*p >> 4) & 0xf);
+ index=ConstrainColormapIndex(image,(*p >> 4) & 0xf,exception);
SetPixelIndex(image,index,q);
q+=GetPixelChannels(image);
p++;
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
- index=ConstrainColormapIndex(image,*p);
+ index=ConstrainColormapIndex(image,*p,exception);
SetPixelIndex(image,index,q);
p++;
q+=GetPixelChannels(image);
SetPixelBlue(image,ScaleCharToQuantum(*p++),q);
SetPixelGreen(image,ScaleCharToQuantum(*p++),q);
SetPixelRed(image,ScaleCharToQuantum(*p++),q);
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
SetPixelAlpha(image,ScaleCharToQuantum(*p++),q);
q+=GetPixelChannels(image);
}
default:
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
}
- pixels=(unsigned char *) RelinquishMagickMemory(pixels);
+ pixel_info=RelinquishVirtualMemory(pixel_info);
if (EOFBlob(image) != MagickFalse)
ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
image->filename);
/*
Initialize DIB raster file header.
*/
- if (IsRGBColorspace(image->colorspace) == MagickFalse)
- (void) TransformImageColorspace(image,RGBColorspace,exception);
+ (void) TransformImageColorspace(image,sRGBColorspace,exception);
if (image->storage_class == DirectClass)
{
/*
Full color DIB raster.
*/
dib_info.number_colors=0;
- dib_info.bits_per_pixel=(unsigned short) (image->matte ? 32 : 24);
+ dib_info.bits_per_pixel=(unsigned short) (image->alpha_trait ? 32 : 24);
}
else
{
case UndefinedResolution:
case PixelsPerInchResolution:
{
- dib_info.x_pixels=(size_t) (100.0*image->x_resolution/2.54);
- dib_info.y_pixels=(size_t) (100.0*image->y_resolution/2.54);
+ dib_info.x_pixels=(size_t) (100.0*image->resolution.x/2.54);
+ dib_info.y_pixels=(size_t) (100.0*image->resolution.y/2.54);
break;
}
case PixelsPerCentimeterResolution:
{
- dib_info.x_pixels=(size_t) (100.0*image->x_resolution);
- dib_info.y_pixels=(size_t) (100.0*image->y_resolution);
+ dib_info.x_pixels=(size_t) (100.0*image->resolution.x);
+ dib_info.y_pixels=(size_t) (100.0*image->resolution.y);
break;
}
}
*q++=ScaleQuantumToChar(GetPixelBlue(image,p));
*q++=ScaleQuantumToChar(GetPixelGreen(image,p));
*q++=ScaleQuantumToChar(GetPixelRed(image,p));
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
*q++=ScaleQuantumToChar(GetPixelAlpha(image,p));
p+=GetPixelChannels(image);
}