summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-02-07 15:09:12 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-02-08 09:01:56 +0100
commit5531e6338bc9d7d5676a5c52059d5ccb2fcccb0c (patch)
treea9aa8b54de82c75f4084386cb66036889f78e379 /svtools
parent7f9f58f3a304733f7089719a5a65eef8c68c2b8d (diff)
move setAlphaFrom from GraphicTransformer to BitmapEx
Change-Id: I69329c61e81791db3806fabe3256571fa937deb6 Reviewed-on: https://gerrit.libreoffice.org/49360 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/graphic/transformer.cxx43
1 files changed, 9 insertions, 34 deletions
diff --git a/svtools/source/graphic/transformer.cxx b/svtools/source/graphic/transformer.cxx
index 17fb3a3f87c6..12bc40f3babc 100644
--- a/svtools/source/graphic/transformer.cxx
+++ b/svtools/source/graphic/transformer.cxx
@@ -46,28 +46,6 @@ GraphicTransformer::~GraphicTransformer()
}
-void setAlpha( Bitmap& rBitmap, AlphaMask& rAlpha, sal_uInt8 cIndexFrom, sal_Int8 nAlphaTo )
-{
- BitmapWriteAccess* pWriteAccess = rAlpha.AcquireWriteAccess();
- BitmapReadAccess* pReadAccess = rBitmap.AcquireReadAccess();
- if ( pReadAccess && pWriteAccess )
- {
- for ( long nY = 0; nY < pReadAccess->Height(); nY++ )
- {
- Scanline pScanline = pWriteAccess->GetScanline( nY );
- Scanline pScanlineRead = pReadAccess->GetScanline( nY );
- for ( long nX = 0; nX < pReadAccess->Width(); nX++ )
- {
- const sal_uInt8 cIndex = pReadAccess->GetIndexFromData( pScanlineRead, nX );
- if ( cIndex == cIndexFrom )
- pWriteAccess->SetPixelOnData( pScanline, nX, BitmapColor(nAlphaTo) );
- }
- }
- }
- Bitmap::ReleaseAccess( pReadAccess );
- rAlpha.ReleaseAccess( pWriteAccess );
-}
-
// XGraphicTransformer
uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::colorChange(
const uno::Reference< graphic::XGraphic >& rxGraphic, sal_Int32 nColorFrom, sal_Int8 nTolerance, sal_Int32 nColorTo, sal_Int8 nAlphaTo )
@@ -90,10 +68,9 @@ uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::colorChange(
if (aBitmapEx.IsAlpha())
{
- AlphaMask aAlphaMask(aBitmapEx.GetAlpha());
- setAlpha(aBitmap, aAlphaMask, cIndexFrom, nAlphaTo);
- aBitmap.Replace(aColorFrom, aColorTo, nTolerance);
- aGraphic = ::Graphic(BitmapEx(aBitmap, aAlphaMask));
+ aBitmapEx.setAlphaFrom( cIndexFrom, nAlphaTo );
+ aBitmapEx.Replace(aColorFrom, aColorTo, nTolerance);
+ aGraphic = ::Graphic(aBitmapEx);
}
else if (aBitmapEx.IsTransparent())
{
@@ -107,10 +84,9 @@ uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::colorChange(
}
else
{
- AlphaMask aAlphaMask(aBitmapEx.GetMask());
- setAlpha(aBitmap, aAlphaMask, cIndexFrom, 0xff - nAlphaTo);
- aBitmap.Replace(aColorFrom, aColorTo, nTolerance);
- aGraphic = ::Graphic(BitmapEx(aBitmap, aAlphaMask));
+ aBitmapEx.setAlphaFrom(cIndexFrom, 0xff - nAlphaTo);
+ aBitmapEx.Replace(aColorFrom, aColorTo, nTolerance);
+ aGraphic = ::Graphic(aBitmapEx);
}
}
else
@@ -123,10 +99,9 @@ uno::Reference< graphic::XGraphic > SAL_CALL GraphicTransformer::colorChange(
}
else
{
- AlphaMask aAlphaMask(aBitmapEx.GetSizePixel());
- setAlpha(aBitmap, aAlphaMask, cIndexFrom, nAlphaTo);
- aBitmap.Replace(aColorFrom, aColorTo, nTolerance);
- aGraphic = ::Graphic(BitmapEx(aBitmap, aAlphaMask));
+ aBitmapEx.setAlphaFrom(cIndexFrom, nAlphaTo);
+ aBitmapEx.Replace(aColorFrom, aColorTo, nTolerance);
+ aGraphic = ::Graphic(aBitmapEx);
}
}
}