1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0028095: Draw Harness, ViewerTest - use RGBA format instead of BGRA within vreadpixel

OpenGl_Workspace::BufferDump() now implicitly converts RGBA dump
into requested BGR, BGRA and RGB image.

DRAW command dversion is improved to report OpenGL variant used (desktop or ES); reporting of version of MSVC is corrected for VC14 and above; reporting of HAVE_OPENCL option is removed.

Usage of command vdump is corrected in some tests to specify extension .png for an image file.

Compiler warning is eliminated in OpenGl_Text.cxx (OpenGL ES mode only).
This commit is contained in:
kgv
2016-11-17 15:39:52 +03:00
committed by apn
parent 564c82b4f2
commit f9f740d6b0
14 changed files with 241 additions and 99 deletions

View File

@@ -338,3 +338,73 @@ Quantity_Color Image_PixMap::PixelColor (const Standard_Integer theX,
theAlpha = 0.0; // transparent
return Quantity_Color (0.0, 0.0, 0.0, Quantity_TOC_RGB);
}
// =======================================================================
// function : SwapRgbaBgra
// purpose :
// =======================================================================
bool Image_PixMap::SwapRgbaBgra (Image_PixMap& theImage)
{
switch (theImage.Format())
{
case Image_PixMap::ImgBGR32:
case Image_PixMap::ImgRGB32:
case Image_PixMap::ImgBGRA:
case Image_PixMap::ImgRGBA:
{
const bool toResetAlpha = theImage.Format() == Image_PixMap::ImgBGR32
|| theImage.Format() == Image_PixMap::ImgRGB32;
for (Standard_Size aRow = 0; aRow < theImage.SizeY(); ++aRow)
{
for (Standard_Size aCol = 0; aCol < theImage.SizeX(); ++aCol)
{
Image_ColorRGBA& aPixel = theImage.ChangeValue<Image_ColorRGBA> (aRow, aCol);
Image_ColorBGRA aPixelCopy = theImage.Value <Image_ColorBGRA> (aRow, aCol);
aPixel.r() = aPixelCopy.r();
aPixel.g() = aPixelCopy.g();
aPixel.b() = aPixelCopy.b();
if (toResetAlpha)
{
aPixel.a() = 255;
}
}
}
return true;
}
case Image_PixMap::ImgBGR:
case Image_PixMap::ImgRGB:
{
for (Standard_Size aRow = 0; aRow < theImage.SizeY(); ++aRow)
{
for (Standard_Size aCol = 0; aCol < theImage.SizeX(); ++aCol)
{
Image_ColorRGB& aPixel = theImage.ChangeValue<Image_ColorRGB> (aRow, aCol);
Image_ColorBGR aPixelCopy = theImage.Value <Image_ColorBGR> (aRow, aCol);
aPixel.r() = aPixelCopy.r();
aPixel.g() = aPixelCopy.g();
aPixel.b() = aPixelCopy.b();
}
}
return true;
}
case Image_PixMap::ImgBGRF:
case Image_PixMap::ImgRGBF:
case Image_PixMap::ImgBGRAF:
case Image_PixMap::ImgRGBAF:
{
for (Standard_Size aRow = 0; aRow < theImage.SizeY(); ++aRow)
{
for (Standard_Size aCol = 0; aCol < theImage.SizeX(); ++aCol)
{
Image_ColorRGBF& aPixel = theImage.ChangeValue<Image_ColorRGBF> (aRow, aCol);
Image_ColorBGRF aPixelCopy = theImage.Value <Image_ColorBGRF> (aRow, aCol);
aPixel.r() = aPixelCopy.r();
aPixel.g() = aPixelCopy.g();
aPixel.b() = aPixelCopy.b();
}
}
return true;
}
default: return false;
}
}

View File

@@ -53,6 +53,16 @@ public:
return !aUnion.myChar[0];
}
//! Auxiliary method for swapping bytes between RGB and BGR formats.
//! This method modifies the image data but does not change pixel format!
//! Method will fail if pixel format is not one of the following:
//! - ImgRGB32 / ImgBGR32
//! - ImgRGBA / ImgBGRA
//! - ImgRGB / ImgBGR
//! - ImgRGBF / ImgBGRF
//! - ImgRGBAF / ImgBGRAF
Standard_EXPORT static bool SwapRgbaBgra (Image_PixMap& theImage);
public: // high-level API
inline ImgFormat Format() const