summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-05-30 15:06:39 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-05-31 08:30:42 +0200
commit8b0ded99e5f8d71c9b763db264ac445b5f665234 (patch)
tree7809fdb80842f964a63bf1921029970c7cf93ca1 /vcl
parent98630a6edf91183dbd8f1bdb02616889251927de (diff)
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/55078 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/Library_vcl.mk1
-rw-r--r--vcl/source/bitmap/BitmapAlphaClampFilter.cxx47
2 files changed, 48 insertions, 0 deletions
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 38a2460cf81f..fd99be295c98 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -311,6 +311,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/graphic/UnoGraphicTransformer \
vcl/source/bitmap/bitmap \
vcl/source/bitmap/bitmapfilter \
+ vcl/source/bitmap/BitmapAlphaClampFilter \
vcl/source/bitmap/BitmapMonochromeFilter \
vcl/source/bitmap/BitmapSmoothenFilter \
vcl/source/bitmap/BitmapLightenFilter \
diff --git a/vcl/source/bitmap/BitmapAlphaClampFilter.cxx b/vcl/source/bitmap/BitmapAlphaClampFilter.cxx
new file mode 100644
index 000000000000..5fd19235b6d1
--- /dev/null
+++ b/vcl/source/bitmap/BitmapAlphaClampFilter.cxx
@@ -0,0 +1,47 @@
+/* -*- 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: */