0030946: Visualization - Image_AlienPixMap ignores 1-bit pixelformat when using FreeImage
[occt.git] / src / Image / Image_AlienPixMap.cxx
index ba166a5..b381901 100644 (file)
     #pragma comment( lib, "FreeImage.lib" )
   #endif
 #elif defined(HAVE_WINCODEC)
-  //#include <initguid.h>
   #include <wincodec.h>
+  // prevent warnings on MSVC10
+  #include <Standard_WarningsDisable.hxx>
+  #include <Standard_TypeDef.hxx>
+  #include <Standard_WarningsRestore.hxx>
   #undef min
   #undef max
 #endif
@@ -39,6 +42,7 @@
 #include <TCollection_AsciiString.hxx>
 #include <TCollection_ExtendedString.hxx>
 #include <OSD_OpenFile.hxx>
+
 #include <fstream>
 #include <algorithm>
 
@@ -585,6 +589,13 @@ bool Image_AlienPixMap::Load (const Standard_Byte* theData,
     return false;
   }
 
+  if (FreeImage_GetBPP (anImage) == 1)
+  {
+    FIBITMAP* aTmpImage = FreeImage_ConvertTo8Bits (anImage);
+    FreeImage_Unload (anImage);
+    anImage = aTmpImage;
+  }
+
   Image_Format aFormat = convertFromFreeFormat (FreeImage_GetImageType(anImage),
                                                 FreeImage_GetColorType(anImage),
                                                 FreeImage_GetBPP      (anImage));