summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2018-01-21 04:48:50 +1100
committerStephan Bergmann <sbergman@redhat.com>2018-02-05 09:00:54 +0100
commit01e470f0ab49e458c57b0f28636a517b2bfb1b4a (patch)
treee153e55125b3d5682e60425b80568c5e03a3695a /svtools
parent79517c0471aff4abf336bd81834bd28732dad67f (diff)
vcl: remove BitmapColor Color() operator
BitmapColor has a Color() operator. However, this is confusing and tends to hide that the two classes aren't the same. I have converted this to GetColor(). Change-Id: I0be2dcb3fc420e7be9c8d04330e7a3fe69a5412a Reviewed-on: https://gerrit.libreoffice.org/48245 Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/graphic/transformer.cxx74
1 files changed, 40 insertions, 34 deletions
diff --git a/svtools/source/graphic/transformer.cxx b/svtools/source/graphic/transformer.cxx
index 775dfb1b0239..d21f0755624a 100644
--- a/svtools/source/graphic/transformer.cxx
+++ b/svtools/source/graphic/transformer.cxx
@@ -70,63 +70,69 @@ void setAlpha( Bitmap& rBitmap, AlphaMask& rAlpha, sal_uInt8 cIndexFrom, sal_Int
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 )
{
- const uno::Reference< uno::XInterface > xIFace( rxGraphic, uno::UNO_QUERY );
- ::Graphic aGraphic( *::unographic::Graphic::getImplementation( xIFace ) );
+ const uno::Reference< uno::XInterface > xIFace(rxGraphic, uno::UNO_QUERY);
+ ::Graphic aGraphic(*::unographic::Graphic::getImplementation(xIFace));
+
+ BitmapColor aBmpColorFrom(static_cast< sal_uInt8 >(nColorFrom), static_cast< sal_uInt8 >(nColorFrom >> 8), static_cast< sal_uInt8 >(nColorFrom >> 16));
+ BitmapColor aBmpColorTo( static_cast< sal_uInt8 >(nColorTo), static_cast< sal_uInt8 >(nColorTo >> 8), static_cast< sal_uInt8 >(nColorTo >> 16));
+
+ Color aColorFrom(aBmpColorFrom.GetColor());
+ Color aColorTo(aBmpColorTo.GetColor());
- BitmapColor aColorFrom( static_cast< sal_uInt8 >( nColorFrom ), static_cast< sal_uInt8 >( nColorFrom >> 8 ), static_cast< sal_uInt8 >( nColorFrom >> 16 ) );
- BitmapColor aColorTo( static_cast< sal_uInt8 >( nColorTo ), static_cast< sal_uInt8 >( nColorTo >> 8 ), static_cast< sal_uInt8 >( nColorTo >> 16 ) );
- const sal_uInt8 cIndexFrom = aColorFrom.GetBlueOrIndex();
+ const sal_uInt8 cIndexFrom = aBmpColorFrom.GetBlueOrIndex();
- if ( aGraphic.GetType() == GraphicType::Bitmap || aGraphic.GetType() == GraphicType::GdiMetafile )
+ if (aGraphic.GetType() == GraphicType::Bitmap || aGraphic.GetType() == GraphicType::GdiMetafile)
{
- BitmapEx aBitmapEx( aGraphic.GetBitmapEx() );
- Bitmap aBitmap( aBitmapEx.GetBitmap() );
+ BitmapEx aBitmapEx(aGraphic.GetBitmapEx());
+ Bitmap aBitmap(aBitmapEx.GetBitmap());
- if ( aBitmapEx.IsAlpha() )
+ if (aBitmapEx.IsAlpha())
{
- AlphaMask aAlphaMask( aBitmapEx.GetAlpha() );
- setAlpha( aBitmap, aAlphaMask, cIndexFrom, nAlphaTo );
- aBitmap.Replace( aColorFrom, aColorTo, nTolerance );
- aGraphic = ::Graphic( BitmapEx( aBitmap, aAlphaMask ) );
+ AlphaMask aAlphaMask(aBitmapEx.GetAlpha());
+ setAlpha(aBitmap, aAlphaMask, cIndexFrom, nAlphaTo);
+ aBitmap.Replace(aColorFrom, aColorTo, nTolerance);
+ aGraphic = ::Graphic(BitmapEx(aBitmap, aAlphaMask));
}
- else if ( aBitmapEx.IsTransparent() )
+ else if (aBitmapEx.IsTransparent())
{
- if ( nAlphaTo == sal::static_int_cast<sal_Int8>(0xff) )
+ if (nAlphaTo == sal::static_int_cast< sal_Int8 >(0xff))
{
- Bitmap aMask( aBitmapEx.GetMask() );
- Bitmap aMask2( aBitmap.CreateMask( aColorFrom, nTolerance ) );
- aMask.CombineSimple( aMask2, BmpCombine::Or );
- aBitmap.Replace( aColorFrom, aColorTo, nTolerance );
- aGraphic = ::Graphic( BitmapEx( aBitmap, aMask ) );
+ Bitmap aMask(aBitmapEx.GetMask());
+ Bitmap aMask2(aBitmap.CreateMask(aColorFrom, nTolerance));
+ aMask.CombineSimple(aMask2, BmpCombine::Or);
+ aBitmap.Replace(aColorFrom, aColorTo, nTolerance);
+ aGraphic = ::Graphic(BitmapEx(aBitmap, aMask));
}
else
{
- AlphaMask aAlphaMask( aBitmapEx.GetMask() );
- setAlpha( aBitmap, aAlphaMask, cIndexFrom, 0xff - nAlphaTo );
- aBitmap.Replace( aColorFrom, aColorTo, nTolerance );
- aGraphic = ::Graphic( BitmapEx( aBitmap, aAlphaMask ) );
+ AlphaMask aAlphaMask(aBitmapEx.GetMask());
+ setAlpha(aBitmap, aAlphaMask, cIndexFrom, 0xff - nAlphaTo);
+ aBitmap.Replace(aColorFrom, aColorTo, nTolerance);
+ aGraphic = ::Graphic(BitmapEx(aBitmap, aAlphaMask));
}
}
else
{
- if ( ( nAlphaTo == 0 ) || ( nAlphaTo == sal::static_int_cast<sal_Int8>(0xff) ) )
+ if ((nAlphaTo == 0) || (nAlphaTo == sal::static_int_cast< sal_Int8 >(0xff)))
{
- Bitmap aMask( aBitmap.CreateMask( aColorFrom, nTolerance ) );
- aBitmap.Replace( aColorFrom, aColorTo, nTolerance );
- aGraphic = ::Graphic( BitmapEx( aBitmap, aMask ) );
+ Bitmap aMask(aBitmap.CreateMask(aColorFrom, nTolerance));
+ aBitmap.Replace(aColorFrom, aColorTo, nTolerance);
+ aGraphic = ::Graphic(BitmapEx(aBitmap, aMask));
}
else
{
- AlphaMask aAlphaMask( aBitmapEx.GetSizePixel() );
- setAlpha( aBitmap, aAlphaMask, cIndexFrom, nAlphaTo );
- aBitmap.Replace( aColorFrom, aColorTo, nTolerance );
- aGraphic = ::Graphic( BitmapEx( aBitmap, aAlphaMask ) );
+ AlphaMask aAlphaMask(aBitmapEx.GetSizePixel());
+ setAlpha(aBitmap, aAlphaMask, cIndexFrom, nAlphaTo);
+ aBitmap.Replace(aColorFrom, aColorTo, nTolerance);
+ aGraphic = ::Graphic(BitmapEx(aBitmap, aAlphaMask));
}
}
}
+
::unographic::Graphic* pUnoGraphic = new ::unographic::Graphic();
- pUnoGraphic->init( aGraphic );
- uno::Reference< graphic::XGraphic > xRet( pUnoGraphic );
+ pUnoGraphic->init(aGraphic);
+ uno::Reference< graphic::XGraphic > xRet(pUnoGraphic);
+
return xRet;
}