1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-05-26 11:05:31 +03:00

0031138: Visualization - Image_AlienPixMap fails to load PNG image with palette

Added fallback code converting unsupported pixel format into RGB24 using FreeImage itself.
This commit is contained in:
kgv 2019-11-06 23:53:53 +03:00 committed by bugmaster
parent a14f2b4722
commit 08b438b076

View File

@ -593,20 +593,34 @@ bool Image_AlienPixMap::Load (const Standard_Byte* theData,
return false; return false;
} }
Image_Format aFormat = Image_Format_UNKNOWN;
if (FreeImage_GetBPP (anImage) == 1) if (FreeImage_GetBPP (anImage) == 1)
{ {
FIBITMAP* aTmpImage = FreeImage_ConvertTo8Bits (anImage); FIBITMAP* aTmpImage = FreeImage_ConvertTo8Bits (anImage);
FreeImage_Unload (anImage); FreeImage_Unload (anImage);
anImage = aTmpImage; anImage = aTmpImage;
} }
if (anImage != NULL)
Image_Format aFormat = convertFromFreeFormat (FreeImage_GetImageType(anImage), {
FreeImage_GetColorType(anImage), aFormat = convertFromFreeFormat (FreeImage_GetImageType(anImage),
FreeImage_GetBPP (anImage)); FreeImage_GetColorType(anImage),
FreeImage_GetBPP (anImage));
if (aFormat == Image_Format_UNKNOWN)
{
FIBITMAP* aTmpImage = FreeImage_ConvertTo24Bits (anImage);
FreeImage_Unload (anImage);
anImage = aTmpImage;
if (anImage != NULL)
{
aFormat = convertFromFreeFormat (FreeImage_GetImageType(anImage),
FreeImage_GetColorType(anImage),
FreeImage_GetBPP (anImage));
}
}
}
if (aFormat == Image_Format_UNKNOWN) if (aFormat == Image_Format_UNKNOWN)
{ {
//anImage = FreeImage_ConvertTo24Bits (anImage); ::Message::DefaultMessenger()->Send (TCollection_AsciiString ("Error: image '") + theImagePath + "' has unsupported pixel format.",
::Message::DefaultMessenger()->Send ( TCollection_AsciiString ("Error: image '") + theImagePath + "' has unsupported pixel format.",
Message_Fail); Message_Fail);
return false; return false;
} }