]> granicus.if.org Git - imagemagick/blobdiff - coders/dib.c
(no commit message)
[imagemagick] / coders / dib.c
index db30efd9b26a0c6fc00999e0864c9420e96dfc79..96f2b982502cae8ec0bac017d92c1f6e42b86b96 100644 (file)
@@ -150,7 +150,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(__WINDOWS__) || defined(__MINGW32__)
+#if !defined(MAGICKCORE_WINDOWS_SUPPORT) || defined(__MINGW32__)
 #define BI_RGB  0
 #define BI_RLE8  1
 #define BI_RLE4  2
@@ -859,14 +859,12 @@ static Image *ReadDIBImage(const ImageInfo *image_info,ExceptionInfo *exception)
         Correct image orientation.
       */
       flipped_image=FlipImage(image,exception);
-      if (flipped_image == (Image *) NULL)
+      if (flipped_image != (Image *) NULL)
         {
-          image=DestroyImageList(image);
-          return((Image *) NULL);
+          DuplicateBlob(flipped_image,image);
+          image=DestroyImage(image);
+          image=flipped_image;
         }
-      DuplicateBlob(flipped_image,image);
-      image=DestroyImage(image);
-      image=flipped_image;
     }
   (void) CloseBlob(image);
   return(GetFirstImageInList(image));
@@ -1150,9 +1148,9 @@ static MagickBooleanType WriteDIBImage(const ImageInfo *image_info,Image *image)
         for (x=0; x < (long) image->columns; x++)
         {
           word=(unsigned short) ((ScaleColor8to5((unsigned char)
-            ScaleQuantumToChar(p->red)) << 11) | (ScaleColor8to6((unsigned char)
-            ScaleQuantumToChar(p->green)) << 5) | (ScaleColor8to5(
-            (unsigned char) ScaleQuantumToChar((unsigned char) p->blue) << 0)));
+            ScaleQuantumToChar(GetRedPixelComponent(p))) << 11) | (ScaleColor8to6((unsigned char)
+            ScaleQuantumToChar(GetGreenPixelComponent(p))) << 5) | (ScaleColor8to5(
+            (unsigned char) ScaleQuantumToChar((unsigned char) GetBluePixelComponent(p)) << 0)));
           *q++=(unsigned char)(word & 0xff);
           *q++=(unsigned char)(word >> 8);
           p++;
@@ -1179,11 +1177,11 @@ static MagickBooleanType WriteDIBImage(const ImageInfo *image_info,Image *image)
         q=pixels+(image->rows-y-1)*bytes_per_line;
         for (x=0; x < (long) image->columns; x++)
         {
-          *q++=ScaleQuantumToChar(p->blue);
-          *q++=ScaleQuantumToChar(p->green);
-          *q++=ScaleQuantumToChar(p->red);
+          *q++=ScaleQuantumToChar(GetBluePixelComponent(p));
+          *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
+          *q++=ScaleQuantumToChar(GetRedPixelComponent(p));
           if (image->matte != MagickFalse)
-            *q++=ScaleQuantumToChar(p->opacity);
+            *q++=ScaleQuantumToChar(GetOpacityPixelComponent(p));
           p++;
         }
         if (dib_info.bits_per_pixel == 24)