]> granicus.if.org Git - imagemagick/blobdiff - coders/dib.c
(no commit message)
[imagemagick] / coders / dib.c
index c0325ec8a42c5517694fe7b64f7a3c1df3336759..d759cd9dfed88a6d3505cddddc8a354529620d73 100644 (file)
 %                   Read/Write Windows DIB Image Format                       %
 %                                                                             %
 %                              Software Design                                %
-%                                John Cristy                                  %
+%                                   Cristy                                    %
 %                                 July 1992                                   %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2012 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  %
@@ -154,7 +154,7 @@ static inline size_t MagickMin(const size_t x,const size_t y)
 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
@@ -463,6 +463,9 @@ static Image *ReadDIBImage(const ImageInfo *image_info,ExceptionInfo *exception)
   MagickBooleanType
     status;
 
+  MemoryInfo
+    *pixel_info;
+
   Quantum
     index;
 
@@ -535,7 +538,8 @@ static Image *ReadDIBImage(const ImageInfo *image_info,ExceptionInfo *exception)
       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;
@@ -607,10 +611,11 @@ static Image *ReadDIBImage(const ImageInfo *image_info,ExceptionInfo *exception)
     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))
     {
@@ -828,7 +833,7 @@ static Image *ReadDIBImage(const ImageInfo *image_info,ExceptionInfo *exception)
           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);
         }
@@ -847,7 +852,7 @@ static Image *ReadDIBImage(const ImageInfo *image_info,ExceptionInfo *exception)
     default:
       ThrowReaderException(CorruptImageError,"ImproperImageHeader");
   }
-  pixels=(unsigned char *) RelinquishMagickMemory(pixels);
+  pixel_info=RelinquishVirtualMemory(pixel_info);
   if (EOFBlob(image) != MagickFalse)
     ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
       image->filename);
@@ -1010,16 +1015,14 @@ static MagickBooleanType WriteDIBImage(const ImageInfo *image_info,Image *image,
   /*
     Initialize DIB raster file header.
   */
-  if ((IssRGBColorspace(image->colorspace) == MagickFalse) &&
-      (IsRGBColorspace(image->colorspace) == MagickFalse))
-    (void) TransformImageColorspace(image,sRGBColorspace,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
     {
@@ -1190,7 +1193,7 @@ static MagickBooleanType WriteDIBImage(const ImageInfo *image_info,Image *image,
           *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);
         }