From fdae2107d9340f575aa6f663d5332544969efeba Mon Sep 17 00:00:00 2001 From: mzernova Date: Tue, 10 Sep 2019 17:10:25 +0300 Subject: [PATCH] 0030946: Visualization - Image_AlienPixMap ignores 1-bit pixelformat when using FreeImage Convert 1-bit image to 8-bit one during its loading because only greyscale images are supported by visualization --- src/Image/Image_AlienPixMap.cxx | 7 +++++++ tests/bugs/vis/bug30946 | 14 ++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 tests/bugs/vis/bug30946 diff --git a/src/Image/Image_AlienPixMap.cxx b/src/Image/Image_AlienPixMap.cxx index 0cbd6534d2..b38190195a 100644 --- a/src/Image/Image_AlienPixMap.cxx +++ b/src/Image/Image_AlienPixMap.cxx @@ -589,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)); diff --git a/tests/bugs/vis/bug30946 b/tests/bugs/vis/bug30946 new file mode 100644 index 0000000000..605662c64c --- /dev/null +++ b/tests/bugs/vis/bug30946 @@ -0,0 +1,14 @@ +puts "=============" +puts "0030946: Visualization - Image_AlienPixMap ignores 1-bit pixelformat when using FreeImage" +puts "=============" + +pload VISUALIZATION +vinit View + +vbackground -image [locate_data_file bug30946_img_1bit_256px.png] +if { [vreadpixel 120 315 rgb name] != "WHITE" } { puts "Error: background image was loaded incorrectly" } + +vpoint p0 0 0 0 +vaspects p0 -setMarkerType [locate_data_file bug30946_img_1bit_32px.png] + +vdump $imagedir/${casename}.png