BitmapEx->Bitmap in GeoTexSvx

now that Bitmap supports transparency

Change-Id: Icb6dad0921079144e3c6b76014f129e205a0f27c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189455
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
This commit is contained in:
Noel Grandin
2025-08-13 14:30:28 +02:00
parent 37d1cc071b
commit 805ef97f52
3 changed files with 14 additions and 30 deletions
+3 -6
View File
@@ -52,11 +52,8 @@ namespace drawinglayer::texture
class GeoTexSvxBitmapEx : public GeoTexSvx
{
protected:
BitmapEx maBitmapEx;
Bitmap maBitmap; // Bitmap held within maBitmapEx, to exist during mpReadBitmap scope
Bitmap maBitmap;
BitmapScopedReadAccess mpReadBitmap;
Bitmap maTransparence;
BitmapScopedReadAccess mpReadTransparence;
basegfx::B2DPoint maTopLeft;
basegfx::B2DVector maSize;
double mfMulX;
@@ -68,7 +65,7 @@ namespace drawinglayer::texture
public:
GeoTexSvxBitmapEx(
const BitmapEx& rBitmapEx,
const Bitmap& rBitmap,
const basegfx::B2DRange& rRange);
virtual ~GeoTexSvxBitmapEx() override;
@@ -93,7 +90,7 @@ namespace drawinglayer::texture
public:
GeoTexSvxBitmapExTiled(
const BitmapEx& rBitmapEx,
const Bitmap& rBitmap,
const basegfx::B2DRange& rRange,
double fOffsetX,
double fOffsetY);
@@ -246,7 +246,7 @@ namespace drawinglayer::processor3d
{
mpGeoTexSvx =
std::make_shared<texture::GeoTexSvxBitmapExTiled>(
aBitmapEx,
Bitmap(aBitmapEx),
aGraphicRange,
rFillGraphicAttribute.getOffsetX(),
rFillGraphicAttribute.getOffsetY());
@@ -255,7 +255,7 @@ namespace drawinglayer::processor3d
{
mpGeoTexSvx =
std::make_shared<texture::GeoTexSvxBitmapEx>(
aBitmapEx,
Bitmap(aBitmapEx),
aGraphicRange);
}
+9 -22
View File
@@ -59,27 +59,14 @@ namespace drawinglayer::texture
GeoTexSvxBitmapEx::GeoTexSvxBitmapEx(
const BitmapEx& rBitmapEx,
const Bitmap& rBitmap,
const basegfx::B2DRange& rRange)
: maBitmapEx(rBitmapEx),
: maBitmap(rBitmap),
maTopLeft(rRange.getMinimum()),
maSize(rRange.getRange()),
mfMulX(0.0),
mfMulY(0.0)
{
bool bIsAlpha(maBitmapEx.IsAlpha());
if(vcl::bitmap::convertBitmap32To24Plus8(maBitmapEx,maBitmapEx))
bIsAlpha = maBitmapEx.IsAlpha();
// #121194# Todo: use alpha channel, too (for 3d)
maBitmap = maBitmapEx.GetBitmap();
if (bIsAlpha)
{
maTransparence = rBitmapEx.GetAlphaMask().GetBitmap();
mpReadTransparence = maTransparence;
OSL_ENSURE(mpReadTransparence, "OOps, transparence type Bitmap, but no read access created in the constructor (?)");
}
if (!maBitmap.IsEmpty())
mpReadBitmap = maBitmap;
SAL_WARN_IF(!mpReadBitmap, "drawinglayer", "GeoTexSvxBitmapEx: Got no read access to Bitmap");
@@ -143,10 +130,10 @@ namespace drawinglayer::texture
rBColor = aBSource;
if (mpReadTransparence)
if (maBitmap.HasAlpha())
{
// when we have alpha, make use of it
const sal_uInt8 aAlpha(impGetAlpha(*mpReadTransparence, nX, nY));
const sal_uInt8 aAlpha(aBMCol.GetAlpha());
rfOpacity = (static_cast<double>(aAlpha) * (1.0 / 255.0));
}
@@ -167,10 +154,11 @@ namespace drawinglayer::texture
if(impIsValid(rUV, nX, nY))
{
if (mpReadTransparence)
const BitmapColor aBMCol(mpReadBitmap->GetColor(nY, nX));
if (maBitmap.HasAlpha())
{
// this texture has an alpha part, use it
const sal_uInt8 aAlpha(impGetAlpha(*mpReadTransparence, nX, nY));
const sal_uInt8 aAlpha(aBMCol.GetAlpha());
const double fNewOpacity(static_cast<double>(aAlpha) * (1.0 / 255.0));
rfOpacity = 1.0 - ((1.0 - fNewOpacity) * (1.0 - rfOpacity));
@@ -178,7 +166,6 @@ namespace drawinglayer::texture
else
{
// this texture is a color bitmap used as transparence map
const BitmapColor aBMCol(mpReadBitmap->GetColor(nY, nX));
const Color aColor(aBMCol.GetRed(), aBMCol.GetGreen(), aBMCol.GetBlue());
rfOpacity = (static_cast<double>(0xff - aColor.GetLuminance()) * (1.0 / 255.0));
@@ -232,11 +219,11 @@ namespace drawinglayer::texture
}
GeoTexSvxBitmapExTiled::GeoTexSvxBitmapExTiled(
const BitmapEx& rBitmapEx,
const Bitmap& rBitmap,
const basegfx::B2DRange& rRange,
double fOffsetX,
double fOffsetY)
: GeoTexSvxBitmapEx(rBitmapEx, rRange),
: GeoTexSvxBitmapEx(rBitmap, rRange),
mfOffsetX(std::clamp(fOffsetX, 0.0, 1.0)),
mfOffsetY(std::clamp(fOffsetY, 0.0, 1.0)),
mbUseOffsetX(!basegfx::fTools::equalZero(mfOffsetX)),