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:
parent
a14f2b4722
commit
08b438b076
@ -593,19 +593,33 @@ bool Image_AlienPixMap::Load (const Standard_Byte* theData,
|
||||
return false;
|
||||
}
|
||||
|
||||
Image_Format aFormat = Image_Format_UNKNOWN;
|
||||
if (FreeImage_GetBPP (anImage) == 1)
|
||||
{
|
||||
FIBITMAP* aTmpImage = FreeImage_ConvertTo8Bits (anImage);
|
||||
FreeImage_Unload (anImage);
|
||||
anImage = aTmpImage;
|
||||
}
|
||||
|
||||
Image_Format aFormat = convertFromFreeFormat (FreeImage_GetImageType(anImage),
|
||||
if (anImage != NULL)
|
||||
{
|
||||
aFormat = convertFromFreeFormat (FreeImage_GetImageType(anImage),
|
||||
FreeImage_GetColorType(anImage),
|
||||
FreeImage_GetBPP (anImage));
|
||||
if (aFormat == Image_Format_UNKNOWN)
|
||||
{
|
||||
//anImage = FreeImage_ConvertTo24Bits (anImage);
|
||||
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)
|
||||
{
|
||||
::Message::DefaultMessenger()->Send (TCollection_AsciiString ("Error: image '") + theImagePath + "' has unsupported pixel format.",
|
||||
Message_Fail);
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user