summaryrefslogtreecommitdiff
path: root/drawinglayer/source/texture/texture3d.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'drawinglayer/source/texture/texture3d.cxx')
-rw-r--r--drawinglayer/source/texture/texture3d.cxx102
1 files changed, 19 insertions, 83 deletions
diff --git a/drawinglayer/source/texture/texture3d.cxx b/drawinglayer/source/texture/texture3d.cxx
index 1ea09cb0fdd9..03af53afe09b 100644
--- a/drawinglayer/source/texture/texture3d.cxx
+++ b/drawinglayer/source/texture/texture3d.cxx
@@ -22,10 +22,11 @@
#include <algorithm>
#include <texture/texture3d.hxx>
-#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapReadAccess.hxx>
#include <vcl/BitmapTools.hxx>
#include <primitive3d/hatchtextureprimitive3d.hxx>
#include <sal/log.hxx>
+#include <osl/diagnose.h>
namespace drawinglayer::texture
{
@@ -58,39 +59,16 @@ namespace drawinglayer::texture
GeoTexSvxBitmapEx::GeoTexSvxBitmapEx(
- const BitmapEx& rBitmapEx,
+ const Bitmap& rBitmap,
const basegfx::B2DRange& rRange)
- : maBitmapEx(rBitmapEx),
- maTransparence(),
+ : maBitmap(rBitmap),
maTopLeft(rRange.getMinimum()),
maSize(rRange.getRange()),
mfMulX(0.0),
- mfMulY(0.0),
- mbIsAlpha(false),
- mbIsTransparent(maBitmapEx.IsTransparent())
+ mfMulY(0.0)
{
- if(vcl::bitmap::convertBitmap32To24Plus8(maBitmapEx,maBitmapEx))
- mbIsTransparent = maBitmapEx.IsTransparent();
- // #121194# Todo: use alpha channel, too (for 3d)
- maBitmap = maBitmapEx.GetBitmap();
-
- if(mbIsTransparent)
- {
- if(maBitmapEx.IsAlpha())
- {
- mbIsAlpha = true;
- maTransparence = rBitmapEx.GetAlpha().GetBitmap();
- }
- else
- {
- maTransparence = rBitmapEx.GetMask();
- }
-
- mpReadTransparence = Bitmap::ScopedReadAccess(maTransparence);
- }
-
- if (!!maBitmap)
- mpReadBitmap = Bitmap::ScopedReadAccess(maBitmap);
+ if (!maBitmap.IsEmpty())
+ mpReadBitmap = maBitmap;
SAL_WARN_IF(!mpReadBitmap, "drawinglayer", "GeoTexSvxBitmapEx: Got no read access to Bitmap");
if (mpReadBitmap)
{
@@ -113,48 +91,6 @@ namespace drawinglayer::texture
{
}
- sal_uInt8 GeoTexSvxBitmapEx::impGetTransparence(sal_Int32 rX, sal_Int32 rY) const
- {
- switch(maBitmapEx.GetTransparentType())
- {
- case TransparentType::NONE:
- {
- break;
- }
- case TransparentType::Color:
- {
- const BitmapColor aBitmapColor(mpReadBitmap->GetColor(rY, rX));
-
- if(maBitmapEx.GetTransparentColor() == aBitmapColor)
- {
- return 255;
- }
-
- break;
- }
- case TransparentType::Bitmap:
- {
- OSL_ENSURE(mpReadTransparence, "OOps, transparence type Bitmap, but no read access created in the constructor (?)");
- const BitmapColor aBitmapColor(mpReadTransparence->GetPixel(rY, rX));
-
- if(mbIsAlpha)
- {
- return aBitmapColor.GetIndex();
- }
- else
- {
- if(0x00 != aBitmapColor.GetIndex())
- {
- return 255;
- }
- }
- break;
- }
- }
-
- return 0;
- }
-
bool GeoTexSvxBitmapEx::impIsValid(const basegfx::B2DPoint& rUV, sal_Int32& rX, sal_Int32& rY) const
{
if(mpReadBitmap)
@@ -187,12 +123,12 @@ namespace drawinglayer::texture
rBColor = aBSource;
- if(mbIsTransparent)
+ if (maBitmap.HasAlpha())
{
- // when we have a transparence, make use of it
- const sal_uInt8 aLuminance(impGetTransparence(nX, nY));
+ // when we have alpha, make use of it
+ const sal_uInt8 aAlpha(aBMCol.GetAlpha());
- rfOpacity = (static_cast<double>(0xff - aLuminance) * (1.0 / 255.0));
+ rfOpacity = (static_cast<double>(aAlpha) * (1.0 / 255.0));
}
else
{
@@ -211,18 +147,18 @@ namespace drawinglayer::texture
if(impIsValid(rUV, nX, nY))
{
- if(mbIsTransparent)
+ const BitmapColor aBMCol(mpReadBitmap->GetColor(nY, nX));
+ if (maBitmap.HasAlpha())
{
// this texture has an alpha part, use it
- const sal_uInt8 aLuminance(impGetTransparence(nX, nY));
- const double fNewOpacity(static_cast<double>(0xff - aLuminance) * (1.0 / 255.0));
+ 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));
}
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));
@@ -276,11 +212,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)),
@@ -327,7 +263,7 @@ namespace drawinglayer::texture
aOutlineRange,
aOutlineRange,
rHatch.getDistance(),
- fAngleA + F_PI2) );
+ fAngleA + M_PI_2) );
}
if(attribute::HatchStyle::Triple == rHatch.getStyle())
@@ -336,7 +272,7 @@ namespace drawinglayer::texture
aOutlineRange,
aOutlineRange,
rHatch.getDistance(),
- fAngleA + F_PI4) );
+ fAngleA + M_PI_4) );
}
}