move framework/toolkit use of BitmapEx::GetMask inside vcl

Change-Id: I2a942377d6e9b8b09673e5ad2804e0e7fb2bb943
Reviewed-on: https://gerrit.libreoffice.org/51387
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
diff --git a/framework/source/fwe/classes/imagewrapper.cxx b/framework/source/fwe/classes/imagewrapper.cxx
index f916d7a..bb7b65a 100644
--- a/framework/source/fwe/classes/imagewrapper.cxx
+++ b/framework/source/fwe/classes/imagewrapper.cxx
@@ -21,6 +21,7 @@
#include <vcl/svapp.hxx>
#include <vcl/bitmap.hxx>
#include <vcl/bitmapex.hxx>
#include <vcl/BitmapTools.hxx>
#include <tools/stream.hxx>
#include <cppuhelper/typeprovider.hxx>
#include <vcl/dibtools.hxx>
@@ -74,22 +75,8 @@ Sequence< sal_Int8 > SAL_CALL ImageWrapper::getDIB()
Sequence< sal_Int8 > SAL_CALL ImageWrapper::getMaskDIB()
{
    SolarMutexGuard aGuard;
    BitmapEx    aBmpEx( m_aImage.GetBitmapEx() );

    if ( aBmpEx.IsAlpha() )
    {
        SvMemoryStream aMem;
        WriteDIB(aBmpEx.GetAlpha().GetBitmap(), aMem, false, true);
        return Sequence< sal_Int8 >( static_cast<sal_Int8 const *>(aMem.GetData()), aMem.Tell() );
    }
    else if ( aBmpEx.IsTransparent() )
    {
        SvMemoryStream aMem;
        WriteDIB(aBmpEx.GetMask(), aMem, false, true);
        return Sequence< sal_Int8 >( static_cast<sal_Int8 const *>(aMem.GetData()), aMem.Tell() );
    }

    return Sequence< sal_Int8 >();
    return vcl::bitmap::GetMaskDIB(m_aImage.GetBitmapEx());
}

// XUnoTunnel
diff --git a/include/vcl/BitmapTools.hxx b/include/vcl/BitmapTools.hxx
index 6ff484a..3a16927 100644
--- a/include/vcl/BitmapTools.hxx
+++ b/include/vcl/BitmapTools.hxx
@@ -96,6 +96,8 @@ VCL_DLLPUBLIC void DrawAlphaBitmapAndAlphaGradient(BitmapEx & rBitmapEx, bool bF

VCL_DLLPUBLIC void DrawAndClipBitmap(const Point& rPos, const Size& rSize, const BitmapEx& rBitmap, BitmapEx & aBmpEx, basegfx::B2DPolyPolygon const & rClipPath);

VCL_DLLPUBLIC css::uno::Sequence< sal_Int8 > GetMaskDIB(BitmapEx const & aBmpEx);

}} // end vcl::bitmap

#endif // INCLUDED_VCL_BITMAP_TOOLS_HXX
diff --git a/toolkit/source/awt/vclxbitmap.cxx b/toolkit/source/awt/vclxbitmap.cxx
index da0f083..c8f531d 100644
--- a/toolkit/source/awt/vclxbitmap.cxx
+++ b/toolkit/source/awt/vclxbitmap.cxx
@@ -24,6 +24,7 @@
#include <tools/stream.hxx>
#include <rtl/uuid.h>
#include <vcl/dibtools.hxx>
#include <vcl/BitmapTools.hxx>


//  class VCLXBitmap
@@ -72,9 +73,7 @@ css::uno::Sequence< sal_Int8 > VCLXBitmap::getMaskDIB()
{
    ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );

    SvMemoryStream aMem;
    WriteDIB(maBitmap.GetMask(), aMem, false, true);
    return css::uno::Sequence<sal_Int8>( static_cast<sal_Int8 const *>(aMem.GetData()), aMem.Tell() );
    return vcl::bitmap::GetMaskDIB(maBitmap);
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx
index 366c6be3..3abd1ca 100644
--- a/vcl/source/bitmap/BitmapTools.cxx
+++ b/vcl/source/bitmap/BitmapTools.cxx
@@ -22,6 +22,7 @@
#include <com/sun/star/rendering/XIntegerReadOnlyBitmap.hpp>

#include <unotools/resmgr.hxx>
#include <vcl/dibtools.hxx>
#include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
#include <vcl/salbtype.hxx>
@@ -628,6 +629,25 @@ void DrawAndClipBitmap(const Point& rPos, const Size& rSize, const BitmapEx& rBi
    }
}


css::uno::Sequence< sal_Int8 > GetMaskDIB(BitmapEx const & aBmpEx)
{
    if ( aBmpEx.IsAlpha() )
    {
        SvMemoryStream aMem;
        WriteDIB(aBmpEx.GetAlpha().GetBitmap(), aMem, false, true);
        return css::uno::Sequence< sal_Int8 >( static_cast<sal_Int8 const *>(aMem.GetData()), aMem.Tell() );
    }
    else if ( aBmpEx.IsTransparent() )
    {
        SvMemoryStream aMem;
        WriteDIB(aBmpEx.GetMask(), aMem, false, true);
        return css::uno::Sequence< sal_Int8 >( static_cast<sal_Int8 const *>(aMem.GetData()), aMem.Tell() );
    }

    return css::uno::Sequence< sal_Int8 >();
}

}} // end vcl::bitmap

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */