mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0024534: Improve design of Image_PixMap class
Remove template methods Image_PixMap::EditData(), ::ReadData(). Add template method Image_PixMap::ChangeValue(). Remove redundant parameter for Image_PixMap::Clear() method. Make Image_PixMapData non-template class. Introduce NCollection_Buffer.
This commit is contained in:
@@ -201,18 +201,17 @@ bool Image_AlienPixMap::InitCopy (const Image_PixMap& theCopy)
|
||||
|
||||
if (myImgFormat == theCopy.Format())
|
||||
{
|
||||
if (myData.mySizeRowBytes == theCopy.SizeRowBytes()
|
||||
&& myData.myTopToDown == theCopy.TopDownInc())
|
||||
if (SizeRowBytes() == theCopy.SizeRowBytes()
|
||||
&& TopDownInc() == theCopy.TopDownInc())
|
||||
{
|
||||
// copy with one call
|
||||
memcpy (myData.myDataPtr, theCopy.Data(), theCopy.SizeBytes());
|
||||
memcpy (ChangeData(), theCopy.Data(), std::min (SizeBytes(), theCopy.SizeBytes()));
|
||||
return true;
|
||||
}
|
||||
|
||||
// copy row-by-row
|
||||
const Standard_Size aRowSizeBytes = (myData.mySizeRowBytes > theCopy.SizeRowBytes())
|
||||
? theCopy.SizeRowBytes() : myData.mySizeRowBytes;
|
||||
for (Standard_Size aRow = 0; aRow < myData.mySizeY; ++aRow)
|
||||
const Standard_Size aRowSizeBytes = std::min (SizeRowBytes(), theCopy.SizeRowBytes());
|
||||
for (Standard_Size aRow = 0; aRow < myData.SizeY; ++aRow)
|
||||
{
|
||||
memcpy (ChangeRow (aRow), theCopy.Row (aRow), aRowSizeBytes);
|
||||
}
|
||||
@@ -228,9 +227,9 @@ bool Image_AlienPixMap::InitCopy (const Image_PixMap& theCopy)
|
||||
// function : Clear
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void Image_AlienPixMap::Clear (ImgFormat thePixelFormat)
|
||||
void Image_AlienPixMap::Clear()
|
||||
{
|
||||
Image_PixMap::Clear (thePixelFormat);
|
||||
Image_PixMap::Clear();
|
||||
#ifdef HAVE_FREEIMAGE
|
||||
if (myLibImage != NULL)
|
||||
{
|
||||
@@ -383,12 +382,11 @@ bool Image_AlienPixMap::Save (const TCollection_AsciiString& theFileName)
|
||||
|| Format() == Image_PixMap::ImgRGB32)
|
||||
{
|
||||
// stupid FreeImage treats reserved byte as alpha if some bytes not set to 0xFF
|
||||
Image_PixMapData<Image_ColorRGB32>& aData = Image_PixMap::EditData<Image_ColorRGB32>();
|
||||
for (Standard_Size aRow = 0; aRow < SizeY(); ++aRow)
|
||||
{
|
||||
for (Standard_Size aCol = 0; aCol < SizeX(); ++aCol)
|
||||
{
|
||||
aData.ChangeValue (aRow, aCol).a_() = 0xFF;
|
||||
myData.ChangeValue (aRow, aCol)[3] = 0xFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user