Kaydet (Commit) 8b0ded99 authored tarafından Noel Grandin's avatar Noel Grandin

move some CanvasHelper::implDrawBitmap inside vcl

part of making mask and alpha internal details of Bitmap/BitmapEx

Change-Id: I87ca24af18a29f5eb8a5761c5d95ae2806d97e77
Reviewed-on: https://gerrit.libreoffice.org/55078Reviewed-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst 98630a6e
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
#include <vcl/bitmapaccess.hxx> #include <vcl/bitmapaccess.hxx>
#include <vcl/canvastools.hxx> #include <vcl/canvastools.hxx>
#include <vcl/window.hxx> #include <vcl/window.hxx>
#include <vcl/BitmapMonochromeFilter.hxx> #include <vcl/BitmapAlphaClampFilter.hxx>
#include <canvas/canvastools.hxx> #include <canvas/canvastools.hxx>
...@@ -720,15 +720,7 @@ namespace vclcanvas ...@@ -720,15 +720,7 @@ namespace vclcanvas
// transparency is fully transparent // transparency is fully transparent
if( aBmpEx.IsAlpha() ) if( aBmpEx.IsAlpha() )
{ {
Bitmap aMask( aBmpEx.GetAlpha().GetBitmap() ); BitmapFilter::Filter(aBmpEx, BitmapAlphaClampFilter(253));
BitmapEx aMaskEx(aMask);
BitmapFilter::Filter(aMaskEx, BitmapMonochromeFilter(253));
aMask = aMaskEx.GetBitmap();
aBmpEx = BitmapEx( aBmpEx.GetBitmap(), aMask );
}
else if( aBmpEx.IsTransparent() )
{
aBmpEx = BitmapEx( aBmpEx.GetBitmap(), aBmpEx.GetMask() );
} }
mp2ndOutDevProvider->getOutDev().DrawBitmapEx( vcl::unotools::pointFromB2DPoint( aOutputPos ), mp2ndOutDevProvider->getOutDev().DrawBitmapEx( vcl::unotools::pointFromB2DPoint( aOutputPos ),
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
*/
#ifndef INCLUDED_INCLUDE_VCL_BITMAPMONOCHROMEFILTER_HXX
#define INCLUDED_INCLUDE_VCL_BITMAPMONOCHROMEFILTER_HXX
#include <tools/color.hxx>
#include <vcl/BitmapFilter.hxx>
/** If the alpha is beyond a certain threshold, make it fully transparent
*/
class VCL_DLLPUBLIC BitmapAlphaClampFilter : public BitmapFilter
{
public:
BitmapAlphaClampFilter(sal_uInt8 cThreshold)
: mcThreshold(cThreshold)
{
}
virtual BitmapEx execute(BitmapEx const& rBitmapEx) override;
private:
sal_uInt8 mcThreshold;
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -311,6 +311,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ ...@@ -311,6 +311,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/graphic/UnoGraphicTransformer \ vcl/source/graphic/UnoGraphicTransformer \
vcl/source/bitmap/bitmap \ vcl/source/bitmap/bitmap \
vcl/source/bitmap/bitmapfilter \ vcl/source/bitmap/bitmapfilter \
vcl/source/bitmap/BitmapAlphaClampFilter \
vcl/source/bitmap/BitmapMonochromeFilter \ vcl/source/bitmap/BitmapMonochromeFilter \
vcl/source/bitmap/BitmapSmoothenFilter \ vcl/source/bitmap/BitmapSmoothenFilter \
vcl/source/bitmap/BitmapLightenFilter \ vcl/source/bitmap/BitmapLightenFilter \
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
*/
#include <vcl/bitmap.hxx>
#include <vcl/bitmapex.hxx>
#include <vcl/BitmapAlphaClampFilter.hxx>
#include <vcl/bitmapaccess.hxx>
#include <bitmapwriteaccess.hxx>
BitmapEx BitmapAlphaClampFilter::execute(BitmapEx const& rBitmapEx)
{
if (!rBitmapEx.IsTransparent())
return rBitmapEx;
AlphaMask aBitmapAlpha(rBitmapEx.GetAlpha());
{
AlphaScopedWriteAccess pWriteAlpha(aBitmapAlpha);
const Size aSize(rBitmapEx.GetSizePixel());
for (long nY = 0; nY < aSize.Height(); ++nY)
{
Scanline pScanAlpha = pWriteAlpha->GetScanline(nY);
for (long nX = 0; nX < aSize.Width(); ++nX)
{
BitmapColor aBitmapAlphaValue(pWriteAlpha->GetPixelFromData(pScanAlpha, nX));
if (aBitmapAlphaValue.GetIndex() > mcThreshold)
{
aBitmapAlphaValue.SetIndex(255);
pWriteAlpha->SetPixelOnData(pScanAlpha, nX, aBitmapAlphaValue);
}
}
}
}
return BitmapEx(rBitmapEx.GetBitmap(), aBitmapAlpha);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment