[Libreoffice-commits] core.git: canvas/inc canvas/source drawinglayer/source emfio/qa emfio/source filter/source forms/source include/vcl sc/source sd/qa sd/source solenv/clang-format svx/source sw/qa vcl/backendtest vcl/inc vcl/Library_vcl.mk vcl/qa vcl/skia vcl/source vcl/unx vcl/win vcl/workben
Chris Sherlock (via logerrit)
logerrit at kemper.freedesktop.org
Thu Dec 24 08:40:57 UTC 2020
canvas/inc/pch/precompiled_vclcanvas.hxx | 5
canvas/source/directx/dx_vcltools.cxx | 2
canvas/source/vcl/canvashelper.cxx | 2
drawinglayer/source/texture/texture3d.cxx | 2
emfio/qa/cppunit/emf/EmfImportTest.cxx | 2
emfio/source/reader/wmfreader.cxx | 2
filter/source/graphicfilter/egif/egif.cxx | 2
filter/source/graphicfilter/eps/eps.cxx | 2
filter/source/graphicfilter/etiff/etiff.cxx | 2
filter/source/msfilter/msdffimp.cxx | 2
filter/source/msfilter/svdfppt.cxx | 2
forms/source/component/imgprod.cxx | 2
include/vcl/BitmapInfoAccess.hxx | 144 +++
include/vcl/BitmapReadAccess.hxx | 190 ++++
include/vcl/bitmapaccess.hxx | 283 ------
sc/source/filter/excel/xeescher.cxx | 2
sd/qa/unit/import-tests.cxx | 2
sd/source/ui/dlg/vectdlg.cxx | 2
solenv/clang-format/excludelist | 2
svx/source/svdraw/svdetc.cxx | 2
sw/qa/extras/tiledrendering/tiledrendering.cxx | 2
vcl/Library_vcl.mk | 6
vcl/backendtest/outputdevice/line.cxx | 2
vcl/inc/BitmapSymmetryCheck.hxx | 3
vcl/inc/bitmapwriteaccess.hxx | 2
vcl/inc/pch/precompiled_vcl.hxx | 6
vcl/qa/cppunit/BitmapFilterTest.cxx | 1
vcl/qa/cppunit/BitmapProcessorTest.cxx | 1
vcl/qa/cppunit/BitmapScaleTest.cxx | 1
vcl/qa/cppunit/BitmapTest.cxx | 1
vcl/qa/cppunit/GraphicTest.cxx | 2
vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx | 2
vcl/qa/cppunit/canvasbitmaptest.cxx | 1
vcl/qa/cppunit/jpeg/JpegWriterTest.cxx | 2
vcl/qa/cppunit/outdev.cxx | 1
vcl/qa/cppunit/png/PngFilterTest.cxx | 2
vcl/skia/salbmp.cxx | 2
vcl/source/bitmap/BitmapBasicMorphologyFilter.cxx | 1
vcl/source/bitmap/BitmapColorQuantizationFilter.cxx | 1
vcl/source/bitmap/BitmapConvolutionMatrixFilter.cxx | 1
vcl/source/bitmap/BitmapDisabledImageFilter.cxx | 2
vcl/source/bitmap/BitmapDuoToneFilter.cxx | 1
vcl/source/bitmap/BitmapEmbossGreyFilter.cxx | 1
vcl/source/bitmap/BitmapEx.cxx | 1
vcl/source/bitmap/BitmapFastScaleFilter.cxx | 1
vcl/source/bitmap/BitmapFilterStackBlur.cxx | 1
vcl/source/bitmap/BitmapGaussianSeparableBlurFilter.cxx | 1
vcl/source/bitmap/BitmapInfoAccess.cxx | 78 +
vcl/source/bitmap/BitmapInterpolateScaleFilter.cxx | 1
vcl/source/bitmap/BitmapLightenFilter.cxx | 2
vcl/source/bitmap/BitmapMedianFilter.cxx | 1
vcl/source/bitmap/BitmapMonochromeFilter.cxx | 1
vcl/source/bitmap/BitmapMosaicFilter.cxx | 1
vcl/source/bitmap/BitmapReadAccess.cxx | 609 ++++++++++++++
vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx | 2
vcl/source/bitmap/BitmapScaleSuperFilter.cxx | 1
vcl/source/bitmap/BitmapSeparableUnsharpenFilter.cxx | 1
vcl/source/bitmap/BitmapSepiaFilter.cxx | 1
vcl/source/bitmap/BitmapSimpleColorQuantizationFilter.cxx | 1
vcl/source/bitmap/BitmapSobelGreyFilter.cxx | 1
vcl/source/bitmap/BitmapSymmetryCheck.cxx | 2
vcl/source/bitmap/BitmapTools.cxx | 1
vcl/source/bitmap/BitmapWriteAccess.cxx | 132 ++-
vcl/source/bitmap/Octree.cxx | 2
vcl/source/bitmap/alpha.cxx | 1
vcl/source/bitmap/bitmap.cxx | 1
vcl/source/bitmap/bitmappaint.cxx | 1
vcl/source/bitmap/bmpacc.cxx | 433 ---------
vcl/source/bitmap/bmpacc2.cxx | 349 --------
vcl/source/bitmap/bmpfast.cxx | 1
vcl/source/bitmap/dibtools.cxx | 1
vcl/source/bitmap/impvect.cxx | 2
vcl/source/filter/jpeg/JpegWriter.cxx | 2
vcl/source/filter/jpeg/JpegWriter.hxx | 3
vcl/source/filter/png/pngwrite.cxx | 2
vcl/source/gdi/pdfwriter_impl.cxx | 3
vcl/source/gdi/pdfwriter_impl2.cxx | 2
vcl/source/gdi/print2.cxx | 2
vcl/source/gdi/salmisc.cxx | 2
vcl/source/helper/canvasbitmap.cxx | 2
vcl/source/outdev/bitmap.cxx | 1
vcl/source/outdev/transparent.cxx | 1
vcl/unx/generic/print/genpspgraphics.cxx | 2
vcl/unx/generic/window/salframe.cxx | 2
vcl/win/gdi/salgdi2.cxx | 2
vcl/workben/svptest.cxx | 1
vcl/workben/vcldemo.cxx | 1
87 files changed, 1200 insertions(+), 1156 deletions(-)
New commits:
commit 17aea7c41c95186c03c173a8c6f26cd2ebce4c54
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
AuthorDate: Sat Dec 19 01:09:27 2020 +1100
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Thu Dec 24 09:40:16 2020 +0100
vcl: move access functions into appropriate bitmap access files
Split class functions into BitmapInfoAccess.cxx, BitmapReadAccess.cxx
and BitmapWriteAccess.cxx
Split header files into BitmapInfoAccess.hxx and BitmapReadAccess.hxx
Change-Id: I7dcbe1d26c5b64d297658a6b809c93d7ad7f053d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108039
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/canvas/inc/pch/precompiled_vclcanvas.hxx b/canvas/inc/pch/precompiled_vclcanvas.hxx
index b31a1cd02792..797c16e3b354 100644
--- a/canvas/inc/pch/precompiled_vclcanvas.hxx
+++ b/canvas/inc/pch/precompiled_vclcanvas.hxx
@@ -13,7 +13,7 @@
manual changes will be rewritten by the next run of update_pch.sh (which presumably
also fixes all possible problems, so it's usually better to use it).
- Generated on 2020-12-01 16:34:48 using:
+ Generated on 2020-12-23 06:21:15 using:
./bin/update_pch canvas vclcanvas --cutoff=1 --exclude:system --include:module --include:local
If after updating build fails, use the following command to locate conflicting headers:
@@ -21,6 +21,7 @@
*/
#if PCH_LEVEL >= 1
+#include <cstdlib>
#include <memory>
#include <tuple>
#include <boost/cast.hpp>
@@ -33,9 +34,9 @@
#include <sal/log.hxx>
#include <vcl/BitmapAlphaClampFilter.hxx>
#include <vcl/BitmapMonochromeFilter.hxx>
+#include <vcl/BitmapReadAccess.hxx>
#include <vcl/BitmapTools.hxx>
#include <vcl/alpha.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <vcl/bitmapex.hxx>
#include <vcl/canvastools.hxx>
#include <vcl/dibtools.hxx>
diff --git a/canvas/source/directx/dx_vcltools.cxx b/canvas/source/directx/dx_vcltools.cxx
index 6309ebaaacb3..968b15b1dca3 100644
--- a/canvas/source/directx/dx_vcltools.cxx
+++ b/canvas/source/directx/dx_vcltools.cxx
@@ -25,7 +25,7 @@
#include <tools/diagnose_ex.h>
#include <vcl/bitmap.hxx>
#include <vcl/bitmapex.hxx>
-#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapReadAccess.hxx>
#include <vcl/canvastools.hxx>
#include "dx_impltools.hxx"
diff --git a/canvas/source/vcl/canvashelper.cxx b/canvas/source/vcl/canvashelper.cxx
index 8930f8fccb80..1f95b900592f 100644
--- a/canvas/source/vcl/canvashelper.cxx
+++ b/canvas/source/vcl/canvashelper.cxx
@@ -38,7 +38,7 @@
#include <tools/diagnose_ex.h>
#include <tools/poly.hxx>
#include <vcl/bitmapex.hxx>
-#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapReadAccess.hxx>
#include <vcl/canvastools.hxx>
#include <vcl/BitmapAlphaClampFilter.hxx>
diff --git a/drawinglayer/source/texture/texture3d.cxx b/drawinglayer/source/texture/texture3d.cxx
index 1ea09cb0fdd9..b4154f1e1bd6 100644
--- a/drawinglayer/source/texture/texture3d.cxx
+++ b/drawinglayer/source/texture/texture3d.cxx
@@ -22,7 +22,7 @@
#include <algorithm>
#include <texture/texture3d.hxx>
-#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapReadAccess.hxx>
#include <vcl/BitmapTools.hxx>
#include <primitive3d/hatchtextureprimitive3d.hxx>
#include <sal/log.hxx>
diff --git a/emfio/qa/cppunit/emf/EmfImportTest.cxx b/emfio/qa/cppunit/emf/EmfImportTest.cxx
index e8d4833e6424..a4e8cc920382 100644
--- a/emfio/qa/cppunit/emf/EmfImportTest.cxx
+++ b/emfio/qa/cppunit/emf/EmfImportTest.cxx
@@ -26,7 +26,7 @@
#include <drawinglayer/primitive2d/Primitive2DContainer.hxx>
#include <drawinglayer/tools/primitive2dxmldump.hxx>
-#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapReadAccess.hxx>
#include <memory>
diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx
index 123f1c06a731..78fee922ff35 100644
--- a/emfio/source/reader/wmfreader.cxx
+++ b/emfio/source/reader/wmfreader.cxx
@@ -34,7 +34,7 @@
#include <vcl/outdev.hxx>
#include <vcl/wmfexternal.hxx>
#include <tools/fract.hxx>
-#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapReadAccess.hxx>
#include <vcl/BitmapTools.hxx>
#include <osl/thread.h>
diff --git a/filter/source/graphicfilter/egif/egif.cxx b/filter/source/graphicfilter/egif/egif.cxx
index 314a899bef00..7a70d337e6c5 100644
--- a/filter/source/graphicfilter/egif/egif.cxx
+++ b/filter/source/graphicfilter/egif/egif.cxx
@@ -20,7 +20,7 @@
#include <tools/stream.hxx>
#include <tools/debug.hxx>
-#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapReadAccess.hxx>
#include <vcl/graph.hxx>
#include <vcl/outdev.hxx>
#include <vcl/FilterConfigItem.hxx>
diff --git a/filter/source/graphicfilter/eps/eps.cxx b/filter/source/graphicfilter/eps/eps.cxx
index 79ec4830c19d..561cfc87599d 100644
--- a/filter/source/graphicfilter/eps/eps.cxx
+++ b/filter/source/graphicfilter/eps/eps.cxx
@@ -25,7 +25,7 @@
#include <vcl/svapp.hxx>
#include <vcl/metaact.hxx>
#include <vcl/graph.hxx>
-#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapReadAccess.hxx>
#include <vcl/region.hxx>
#include <vcl/font.hxx>
#include <vcl/virdev.hxx>
diff --git a/filter/source/graphicfilter/etiff/etiff.cxx b/filter/source/graphicfilter/etiff/etiff.cxx
index 76c4a8f8ee05..80c185e1ea5b 100644
--- a/filter/source/graphicfilter/etiff/etiff.cxx
+++ b/filter/source/graphicfilter/etiff/etiff.cxx
@@ -21,7 +21,7 @@
#include <tools/stream.hxx>
#include <vcl/graph.hxx>
#include <vcl/outdev.hxx>
-#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapReadAccess.hxx>
#include <vcl/FilterConfigItem.hxx>
#include <com/sun/star/task/XStatusIndicator.hpp>
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index d3d548c39265..72c44289c9e4 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -67,7 +67,7 @@
#include <vcl/graphicfilter.hxx>
#include <tools/urlobj.hxx>
#include <vcl/virdev.hxx>
-#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapReadAccess.hxx>
#include <sot/storage.hxx>
#include <sfx2/docfilt.hxx>
#include <sfx2/fcontnr.hxx>
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index d287e0ab012a..4975ecfb2d2f 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -91,7 +91,7 @@
#include <editeng/lrspitem.hxx>
#include <editeng/numitem.hxx>
#include <vcl/gdimtf.hxx>
-#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapReadAccess.hxx>
#include <svx/svditer.hxx>
#include <editeng/flditem.hxx>
#include <tools/zcodec.hxx>
diff --git a/forms/source/component/imgprod.cxx b/forms/source/component/imgprod.cxx
index 3e79596bb07f..b38632ea4148 100644
--- a/forms/source/component/imgprod.cxx
+++ b/forms/source/component/imgprod.cxx
@@ -21,7 +21,7 @@
#include <osl/diagnose.h>
#include <tools/debug.hxx>
-#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapReadAccess.hxx>
#include <vcl/cvtgrf.hxx>
#include <vcl/svapp.hxx>
#include <unotools/ucbstreamhelper.hxx>
diff --git a/include/vcl/BitmapInfoAccess.hxx b/include/vcl/BitmapInfoAccess.hxx
new file mode 100644
index 000000000000..7fc8d1bce28a
--- /dev/null
+++ b/include/vcl/BitmapInfoAccess.hxx
@@ -0,0 +1,144 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_VCL_BITMAPINFOACCESS_HXX
+#define INCLUDED_VCL_BITMAPINFOACCESS_HXX
+
+#include <vcl/dllapi.h>
+#include <vcl/bitmap.hxx>
+#include <vcl/Scanline.hxx>
+#include <vcl/BitmapBuffer.hxx>
+#include <vcl/BitmapColor.hxx>
+#include <vcl/BitmapAccessMode.hxx>
+
+bool Bitmap32IsPreMultipled();
+
+typedef BitmapColor (*FncGetPixel)(ConstScanline pScanline, tools::Long nX, const ColorMask& rMask);
+typedef void (*FncSetPixel)(Scanline pScanline, tools::Long nX, const BitmapColor& rBitmapColor,
+ const ColorMask& rMask);
+
+class VCL_DLLPUBLIC BitmapInfoAccess
+{
+ friend class BitmapReadAccess;
+
+public:
+ BitmapInfoAccess(Bitmap& rBitmap, BitmapAccessMode nMode = BitmapAccessMode::Info);
+ virtual ~BitmapInfoAccess();
+
+ bool operator!() const { return mpBuffer == nullptr; }
+
+ tools::Long Width() const { return mpBuffer ? mpBuffer->mnWidth : 0L; }
+
+ tools::Long Height() const { return mpBuffer ? mpBuffer->mnHeight : 0L; }
+
+ bool IsTopDown() const
+ {
+ assert(mpBuffer && "Access is not valid!");
+
+ return mpBuffer && (mpBuffer->mnFormat & ScanlineFormat::TopDown);
+ }
+
+ bool IsBottomUp() const { return !IsTopDown(); }
+
+ ScanlineFormat GetScanlineFormat() const
+ {
+ assert(mpBuffer && "Access is not valid!");
+
+ return mpBuffer ? RemoveScanline(mpBuffer->mnFormat) : ScanlineFormat::NONE;
+ }
+
+ sal_uInt32 GetScanlineSize() const
+ {
+ assert(mpBuffer && "Access is not valid!");
+
+ return mpBuffer ? mpBuffer->mnScanlineSize : 0;
+ }
+
+ sal_uInt16 GetBitCount() const
+ {
+ assert(mpBuffer && "Access is not valid!");
+
+ return mpBuffer ? mpBuffer->mnBitCount : 0;
+ }
+
+ BitmapColor GetBestMatchingColor(const BitmapColor& rBitmapColor)
+ {
+ if (HasPalette())
+ return BitmapColor(static_cast<sal_uInt8>(GetBestPaletteIndex(rBitmapColor)));
+ else
+ return rBitmapColor;
+ }
+
+ bool HasPalette() const
+ {
+ assert(mpBuffer && "Access is not valid!");
+
+ return mpBuffer && !!mpBuffer->maPalette;
+ }
+
+ const BitmapPalette& GetPalette() const
+ {
+ assert(mpBuffer && "Access is not valid!");
+
+ return mpBuffer->maPalette;
+ }
+
+ sal_uInt16 GetPaletteEntryCount() const
+ {
+ assert(HasPalette() && "Bitmap has no palette!");
+
+ return HasPalette() ? mpBuffer->maPalette.GetEntryCount() : 0;
+ }
+
+ const BitmapColor& GetPaletteColor(sal_uInt16 nColor) const
+ {
+ assert(mpBuffer && "Access is not valid!");
+ assert(HasPalette() && "Bitmap has no palette!");
+
+ return mpBuffer->maPalette[nColor];
+ }
+
+ const BitmapColor& GetBestPaletteColor(const BitmapColor& rBitmapColor) const
+ {
+ return GetPaletteColor(GetBestPaletteIndex(rBitmapColor));
+ }
+
+ sal_uInt16 GetBestPaletteIndex(const BitmapColor& rBitmapColor) const;
+
+ ColorMask& GetColorMask() const
+ {
+ assert(mpBuffer && "Access is not valid!");
+
+ return mpBuffer->maColorMask;
+ }
+
+private:
+ BitmapInfoAccess(const BitmapInfoAccess&) = delete;
+ BitmapInfoAccess& operator=(const BitmapInfoAccess&) = delete;
+
+protected:
+ Bitmap maBitmap;
+ BitmapBuffer* mpBuffer;
+ ColorMask maColorMask;
+ BitmapAccessMode mnAccessMode;
+};
+
+#endif // INCLUDED_VCL_BITMAPINFOACCESS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/vcl/BitmapReadAccess.hxx b/include/vcl/BitmapReadAccess.hxx
new file mode 100644
index 000000000000..845e9994aa6b
--- /dev/null
+++ b/include/vcl/BitmapReadAccess.hxx
@@ -0,0 +1,190 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#ifndef INCLUDED_VCL_BITMAPREADACCESS_HXX
+#define INCLUDED_VCL_BITMAPREADACCESS_HXX
+
+#include <vcl/dllapi.h>
+#include <vcl/bitmap.hxx>
+#include <vcl/Scanline.hxx>
+#include <vcl/BitmapBuffer.hxx>
+#include <vcl/BitmapColor.hxx>
+#include <vcl/BitmapAccessMode.hxx>
+#include <vcl/BitmapInfoAccess.hxx>
+
+class VCL_DLLPUBLIC BitmapReadAccess : public BitmapInfoAccess
+{
+ friend class BitmapWriteAccess;
+
+public:
+ BitmapReadAccess(Bitmap& rBitmap, BitmapAccessMode nMode = BitmapAccessMode::Read);
+ virtual ~BitmapReadAccess() override;
+
+ Scanline GetBuffer() const
+ {
+ assert(mpBuffer && "Access is not valid!");
+
+ return mpBuffer ? mpBuffer->mpBits : nullptr;
+ }
+
+ Scanline GetScanline(tools::Long nY) const
+ {
+ assert(mpBuffer && "Access is not valid!");
+ assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!");
+
+ if (mpBuffer->mnFormat & ScanlineFormat::TopDown)
+ {
+ return mpBuffer->mpBits + (nY * mpBuffer->mnScanlineSize);
+ }
+ return mpBuffer->mpBits + ((mpBuffer->mnHeight - 1 - nY) * mpBuffer->mnScanlineSize);
+ }
+
+ BitmapColor GetPixelFromData(const sal_uInt8* pData, tools::Long nX) const
+ {
+ assert(pData && "Access is not valid!");
+
+ return mFncGetPixel(pData, nX, maColorMask);
+ }
+
+ sal_uInt8 GetIndexFromData(const sal_uInt8* pData, tools::Long nX) const
+ {
+ return GetPixelFromData(pData, nX).GetIndex();
+ }
+
+ void SetPixelOnData(sal_uInt8* pData, tools::Long nX, const BitmapColor& rBitmapColor)
+ {
+ assert(pData && "Access is not valid!");
+
+ mFncSetPixel(pData, nX, rBitmapColor, maColorMask);
+ }
+
+ BitmapColor GetPixel(tools::Long nY, tools::Long nX) const
+ {
+ assert(mpBuffer && "Access is not valid!");
+ assert(nX < mpBuffer->mnWidth && "x-coordinate out of range!");
+ assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!");
+
+ return mFncGetPixel(GetScanline(nY), nX, maColorMask);
+ }
+
+ BitmapColor GetColor(tools::Long nY, tools::Long nX) const
+ {
+ if (HasPalette())
+ return mpBuffer->maPalette[GetPixelIndex(nY, nX)];
+ else
+ return GetPixel(nY, nX);
+ }
+
+ sal_uInt8 GetPixelIndex(tools::Long nY, tools::Long nX) const
+ {
+ return GetPixel(nY, nX).GetIndex();
+ }
+
+ /** Get the interpolated color at coordinates fY, fX; if outside, return rFallback */
+ BitmapColor GetInterpolatedColorWithFallback(double fY, double fX,
+ const BitmapColor& rFallback) const;
+
+ /** Get the color at coordinates fY, fX; if outside, return rFallback. Automatically does the correct
+ inside/outside checks, e.g. static_cast< sal_uInt32 >(-0.25) *is* 0, not -1 and has to be outside */
+ BitmapColor GetColorWithFallback(double fY, double fX, const BitmapColor& rFallback) const;
+
+private:
+ BitmapReadAccess(const BitmapReadAccess&) = delete;
+ BitmapReadAccess& operator=(const BitmapReadAccess&) = delete;
+
+protected:
+ FncGetPixel mFncGetPixel;
+ FncSetPixel mFncSetPixel;
+
+public:
+ SAL_DLLPRIVATE BitmapBuffer* ImplGetBitmapBuffer() const { return mpBuffer; }
+
+ static BitmapColor GetPixelForN1BitMsbPal(ConstScanline pScanline, tools::Long nX,
+ const ColorMask& rMask);
+ static BitmapColor GetPixelForN1BitLsbPal(ConstScanline pScanline, tools::Long nX,
+ const ColorMask& rMask);
+ static BitmapColor GetPixelForN4BitMsnPal(ConstScanline pScanline, tools::Long nX,
+ const ColorMask& rMask);
+ static BitmapColor GetPixelForN4BitLsnPal(ConstScanline pScanline, tools::Long nX,
+ const ColorMask& rMask);
+ static BitmapColor GetPixelForN8BitPal(ConstScanline pScanline, tools::Long nX,
+ const ColorMask& rMask);
+ static BitmapColor GetPixelForN24BitTcBgr(ConstScanline pScanline, tools::Long nX,
+ const ColorMask& rMask);
+ static BitmapColor GetPixelForN24BitTcRgb(ConstScanline pScanline, tools::Long nX,
+ const ColorMask& rMask);
+ static BitmapColor GetPixelForN32BitTcAbgr(ConstScanline pScanline, tools::Long nX,
+ const ColorMask& rMask);
+ static BitmapColor GetPixelForN32BitTcXbgr(ConstScanline pScanline, tools::Long nX,
+ const ColorMask& rMask);
+ static BitmapColor GetPixelForN32BitTcArgb(ConstScanline pScanline, tools::Long nX,
+ const ColorMask& rMask);
+ static BitmapColor GetPixelForN32BitTcXrgb(ConstScanline pScanline, tools::Long nX,
+ const ColorMask& rMask);
+ static BitmapColor GetPixelForN32BitTcBgra(ConstScanline pScanline, tools::Long nX,
+ const ColorMask& rMask);
+ static BitmapColor GetPixelForN32BitTcBgrx(ConstScanline pScanline, tools::Long nX,
+ const ColorMask& rMask);
+ static BitmapColor GetPixelForN32BitTcRgba(ConstScanline pScanline, tools::Long nX,
+ const ColorMask& rMask);
+ static BitmapColor GetPixelForN32BitTcRgbx(ConstScanline pScanline, tools::Long nX,
+ const ColorMask& rMask);
+ static BitmapColor GetPixelForN32BitTcMask(ConstScanline pScanline, tools::Long nX,
+ const ColorMask& rMask);
+
+ static void SetPixelForN1BitMsbPal(Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask& rMask);
+ static void SetPixelForN1BitLsbPal(Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask& rMask);
+ static void SetPixelForN4BitMsnPal(Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask& rMask);
+ static void SetPixelForN4BitLsnPal(Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask& rMask);
+ static void SetPixelForN8BitPal(Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask& rMask);
+ static void SetPixelForN24BitTcBgr(Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask& rMask);
+ static void SetPixelForN24BitTcRgb(Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask& rMask);
+ static void SetPixelForN32BitTcAbgr(Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask& rMask);
+ static void SetPixelForN32BitTcXbgr(Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask& rMask);
+ static void SetPixelForN32BitTcArgb(Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask& rMask);
+ static void SetPixelForN32BitTcXrgb(Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask& rMask);
+ static void SetPixelForN32BitTcBgra(Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask& rMask);
+ static void SetPixelForN32BitTcBgrx(Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask& rMask);
+ static void SetPixelForN32BitTcRgba(Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask& rMask);
+ static void SetPixelForN32BitTcRgbx(Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask& rMask);
+ static void SetPixelForN32BitTcMask(Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask& rMask);
+
+ static FncGetPixel GetPixelFunction(ScanlineFormat nFormat);
+ static FncSetPixel SetPixelFunction(ScanlineFormat nFormat);
+};
+
+#endif // INCLUDED_VCL_BITMAPREADACCESS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/vcl/bitmapaccess.hxx b/include/vcl/bitmapaccess.hxx
deleted file mode 100644
index 12304d96ff86..000000000000
--- a/include/vcl/bitmapaccess.hxx
+++ /dev/null
@@ -1,283 +0,0 @@
-/* -*- 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/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_VCL_BMPACC_HXX
-#define INCLUDED_VCL_BMPACC_HXX
-
-#include <vcl/dllapi.h>
-#include <vcl/bitmap.hxx>
-#include <vcl/Scanline.hxx>
-#include <vcl/BitmapBuffer.hxx>
-#include <vcl/BitmapColor.hxx>
-#include <vcl/BitmapAccessMode.hxx>
-
-typedef BitmapColor (*FncGetPixel)(ConstScanline pScanline, tools::Long nX, const ColorMask& rMask);
-typedef void (*FncSetPixel)(Scanline pScanline, tools::Long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
-
-class VCL_DLLPUBLIC BitmapInfoAccess
-{
- friend class BitmapReadAccess;
-
-public:
- BitmapInfoAccess(Bitmap& rBitmap, BitmapAccessMode nMode = BitmapAccessMode::Info);
- virtual ~BitmapInfoAccess();
-
- bool operator!() const
- {
- return mpBuffer == nullptr;
- }
-
- tools::Long Width() const
- {
- return mpBuffer ? mpBuffer->mnWidth : 0L;
- }
-
- tools::Long Height() const
- {
- return mpBuffer ? mpBuffer->mnHeight : 0L;
- }
-
- bool IsTopDown() const
- {
- assert(mpBuffer && "Access is not valid!");
-
- return mpBuffer && (mpBuffer->mnFormat & ScanlineFormat::TopDown);
- }
-
- bool IsBottomUp() const
- {
- return !IsTopDown();
- }
-
- ScanlineFormat GetScanlineFormat() const
- {
- assert(mpBuffer && "Access is not valid!");
-
- return mpBuffer ? RemoveScanline(mpBuffer->mnFormat) : ScanlineFormat::NONE;
- }
-
- sal_uInt32 GetScanlineSize() const
- {
- assert(mpBuffer && "Access is not valid!");
-
- return mpBuffer ? mpBuffer->mnScanlineSize : 0;
- }
-
- sal_uInt16 GetBitCount() const
- {
- assert(mpBuffer && "Access is not valid!");
-
- return mpBuffer ? mpBuffer->mnBitCount : 0;
- }
-
- BitmapColor GetBestMatchingColor(const BitmapColor& rBitmapColor)
- {
- if (HasPalette())
- return BitmapColor(static_cast<sal_uInt8>(GetBestPaletteIndex(rBitmapColor)));
- else
- return rBitmapColor;
- }
-
- bool HasPalette() const
- {
- assert(mpBuffer && "Access is not valid!");
-
- return mpBuffer && !!mpBuffer->maPalette;
- }
-
- const BitmapPalette& GetPalette() const
- {
- assert(mpBuffer && "Access is not valid!");
-
- return mpBuffer->maPalette;
- }
-
- sal_uInt16 GetPaletteEntryCount() const
- {
- assert(HasPalette() && "Bitmap has no palette!");
-
- return HasPalette() ? mpBuffer->maPalette.GetEntryCount() : 0;
- }
-
- const BitmapColor& GetPaletteColor( sal_uInt16 nColor ) const
- {
- assert(mpBuffer && "Access is not valid!");
- assert(HasPalette() && "Bitmap has no palette!");
-
- return mpBuffer->maPalette[nColor];
- }
-
- const BitmapColor& GetBestPaletteColor(const BitmapColor& rBitmapColor) const
- {
- return GetPaletteColor(GetBestPaletteIndex(rBitmapColor));
- }
-
- sal_uInt16 GetBestPaletteIndex(const BitmapColor& rBitmapColor) const;
-
- ColorMask& GetColorMask() const
- {
- assert(mpBuffer && "Access is not valid!");
-
- return mpBuffer->maColorMask;
- }
-
-private:
- BitmapInfoAccess(const BitmapInfoAccess&) = delete;
- BitmapInfoAccess& operator=(const BitmapInfoAccess&) = delete;
-
-protected:
- Bitmap maBitmap;
- BitmapBuffer* mpBuffer;
- ColorMask maColorMask;
- BitmapAccessMode mnAccessMode;
-};
-
-
-class VCL_DLLPUBLIC BitmapReadAccess : public BitmapInfoAccess
-{
- friend class BitmapWriteAccess;
-
-public:
- BitmapReadAccess(Bitmap& rBitmap, BitmapAccessMode nMode = BitmapAccessMode::Read);
- virtual ~BitmapReadAccess() override;
-
- Scanline GetBuffer() const
- {
- assert(mpBuffer && "Access is not valid!");
-
- return mpBuffer ? mpBuffer->mpBits : nullptr;
- }
-
- Scanline GetScanline(tools::Long nY) const
- {
- assert(mpBuffer && "Access is not valid!");
- assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!");
-
- if (mpBuffer->mnFormat & ScanlineFormat::TopDown)
- {
- return mpBuffer->mpBits + (nY * mpBuffer->mnScanlineSize);
- }
- return mpBuffer->mpBits + ((mpBuffer->mnHeight - 1 - nY) * mpBuffer->mnScanlineSize);
- }
-
- BitmapColor GetPixelFromData(const sal_uInt8* pData, tools::Long nX) const
- {
- assert(pData && "Access is not valid!");
-
- return mFncGetPixel( pData, nX, maColorMask );
- }
-
- sal_uInt8 GetIndexFromData(const sal_uInt8* pData, tools::Long nX) const
- {
- return GetPixelFromData( pData, nX ).GetIndex();
- }
-
- void SetPixelOnData(sal_uInt8* pData, tools::Long nX, const BitmapColor& rBitmapColor)
- {
- assert(pData && "Access is not valid!");
-
- mFncSetPixel(pData, nX, rBitmapColor, maColorMask);
- }
-
- BitmapColor GetPixel(tools::Long nY, tools::Long nX) const
- {
- assert(mpBuffer && "Access is not valid!");
- assert(nX < mpBuffer->mnWidth && "x-coordinate out of range!");
- assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!");
-
- return mFncGetPixel(GetScanline(nY), nX, maColorMask );
- }
-
- BitmapColor GetColor(tools::Long nY, tools::Long nX) const
- {
- if (HasPalette())
- return mpBuffer->maPalette[GetPixelIndex(nY, nX)];
- else
- return GetPixel(nY, nX);
- }
-
- sal_uInt8 GetPixelIndex(tools::Long nY, tools::Long nX) const
- {
- return GetPixel(nY, nX).GetIndex();
- }
-
- /** Get the interpolated color at coordinates fY, fX; if outside, return rFallback */
- BitmapColor GetInterpolatedColorWithFallback( double fY, double fX, const BitmapColor& rFallback ) const;
-
- /** Get the color at coordinates fY, fX; if outside, return rFallback. Automatically does the correct
- inside/outside checks, e.g. static_cast< sal_uInt32 >(-0.25) *is* 0, not -1 and has to be outside */
- BitmapColor GetColorWithFallback( double fY, double fX, const BitmapColor& rFallback ) const;
-
-private:
- BitmapReadAccess(const BitmapReadAccess&) = delete;
- BitmapReadAccess& operator=(const BitmapReadAccess&) = delete;
-
-protected:
- FncGetPixel mFncGetPixel;
- FncSetPixel mFncSetPixel;
-
-public:
-
- SAL_DLLPRIVATE BitmapBuffer* ImplGetBitmapBuffer() const
- {
- return mpBuffer;
- }
-
- static BitmapColor GetPixelForN1BitMsbPal(ConstScanline pScanline, tools::Long nX, const ColorMask& rMask);
- static BitmapColor GetPixelForN1BitLsbPal(ConstScanline pScanline, tools::Long nX, const ColorMask& rMask);
- static BitmapColor GetPixelForN4BitMsnPal(ConstScanline pScanline, tools::Long nX, const ColorMask& rMask);
- static BitmapColor GetPixelForN4BitLsnPal(ConstScanline pScanline, tools::Long nX, const ColorMask& rMask);
- static BitmapColor GetPixelForN8BitPal(ConstScanline pScanline, tools::Long nX, const ColorMask& rMask);
- static BitmapColor GetPixelForN24BitTcBgr(ConstScanline pScanline, tools::Long nX, const ColorMask& rMask);
- static BitmapColor GetPixelForN24BitTcRgb(ConstScanline pScanline, tools::Long nX, const ColorMask& rMask);
- static BitmapColor GetPixelForN32BitTcAbgr(ConstScanline pScanline, tools::Long nX, const ColorMask& rMask);
- static BitmapColor GetPixelForN32BitTcXbgr(ConstScanline pScanline, tools::Long nX, const ColorMask& rMask);
- static BitmapColor GetPixelForN32BitTcArgb(ConstScanline pScanline, tools::Long nX, const ColorMask& rMask);
- static BitmapColor GetPixelForN32BitTcXrgb(ConstScanline pScanline, tools::Long nX, const ColorMask& rMask);
- static BitmapColor GetPixelForN32BitTcBgra(ConstScanline pScanline, tools::Long nX, const ColorMask& rMask);
- static BitmapColor GetPixelForN32BitTcBgrx(ConstScanline pScanline, tools::Long nX, const ColorMask& rMask);
- static BitmapColor GetPixelForN32BitTcRgba(ConstScanline pScanline, tools::Long nX, const ColorMask& rMask);
- static BitmapColor GetPixelForN32BitTcRgbx(ConstScanline pScanline, tools::Long nX, const ColorMask& rMask);
- static BitmapColor GetPixelForN32BitTcMask(ConstScanline pScanline, tools::Long nX, const ColorMask& rMask);
-
- static void SetPixelForN1BitMsbPal(Scanline pScanline, tools::Long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
- static void SetPixelForN1BitLsbPal(Scanline pScanline, tools::Long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
- static void SetPixelForN4BitMsnPal(Scanline pScanline, tools::Long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
- static void SetPixelForN4BitLsnPal(Scanline pScanline, tools::Long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
- static void SetPixelForN8BitPal(Scanline pScanline, tools::Long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
- static void SetPixelForN24BitTcBgr(Scanline pScanline, tools::Long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
- static void SetPixelForN24BitTcRgb(Scanline pScanline, tools::Long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
- static void SetPixelForN32BitTcAbgr(Scanline pScanline, tools::Long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
- static void SetPixelForN32BitTcXbgr(Scanline pScanline, tools::Long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
- static void SetPixelForN32BitTcArgb(Scanline pScanline, tools::Long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
- static void SetPixelForN32BitTcXrgb(Scanline pScanline, tools::Long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
- static void SetPixelForN32BitTcBgra(Scanline pScanline, tools::Long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
- static void SetPixelForN32BitTcBgrx(Scanline pScanline, tools::Long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
- static void SetPixelForN32BitTcRgba(Scanline pScanline, tools::Long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
- static void SetPixelForN32BitTcRgbx(Scanline pScanline, tools::Long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
- static void SetPixelForN32BitTcMask(Scanline pScanline, tools::Long nX, const BitmapColor& rBitmapColor, const ColorMask& rMask);
-
- static FncGetPixel GetPixelFunction( ScanlineFormat nFormat );
- static FncSetPixel SetPixelFunction( ScanlineFormat nFormat );
-};
-
-
-#endif // INCLUDED_VCL_BMPACC_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/excel/xeescher.cxx b/sc/source/filter/excel/xeescher.cxx
index 37bb6593b62a..f4f29e83e02d 100644
--- a/sc/source/filter/excel/xeescher.cxx
+++ b/sc/source/filter/excel/xeescher.cxx
@@ -32,7 +32,7 @@
#include <com/sun/star/chart/XChartDocument.hpp>
#include <set>
-#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapReadAccess.hxx>
#include <svx/svdoole2.hxx>
#include <svx/svdocapt.hxx>
#include <editeng/outlobj.hxx>
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 12b340ccf3fa..bf8681502682 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -93,7 +93,7 @@
#include <comphelper/graphicmimetype.hxx>
#include <comphelper/lok.hxx>
#include <vcl/pngread.hxx>
-#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapReadAccess.hxx>
#include <vcl/dibtools.hxx>
#include <svx/svdograf.hxx>
diff --git a/sd/source/ui/dlg/vectdlg.cxx b/sd/source/ui/dlg/vectdlg.cxx
index a7bcee55aaea..066fe9d8a659 100644
--- a/sd/source/ui/dlg/vectdlg.cxx
+++ b/sd/source/ui/dlg/vectdlg.cxx
@@ -18,7 +18,7 @@
*/
#include <vcl/vclenum.hxx>
-#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapReadAccess.hxx>
#include <vcl/metaact.hxx>
#include <vcl/BitmapSimpleColorQuantizationFilter.hxx>
#include <vcl/svapp.hxx>
diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist
index 8083ab7d7b6e..fd0cb3212681 100644
--- a/solenv/clang-format/excludelist
+++ b/solenv/clang-format/excludelist
@@ -14898,8 +14898,6 @@ vcl/source/bitmap/BitmapTools.cxx
vcl/source/bitmap/alpha.cxx
vcl/source/bitmap/bitmap.cxx
vcl/source/bitmap/BitmapEx.cxx
-vcl/source/bitmap/bmpacc.cxx
-vcl/source/bitmap/bmpacc2.cxx
vcl/source/bitmap/bmpfast.cxx
vcl/source/bitmap/checksum.cxx
vcl/source/bitmap/dibtools.cxx
diff --git a/svx/source/svdraw/svdetc.cxx b/svx/source/svdraw/svdetc.cxx
index 0d82f6632b35..4964c2fc7ed7 100644
--- a/svx/source/svdraw/svdetc.cxx
+++ b/svx/source/svdraw/svdetc.cxx
@@ -25,7 +25,7 @@
#include <svx/svdedxv.hxx>
#include <svx/svdmodel.hxx>
#include <svx/svdoutl.hxx>
-#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapReadAccess.hxx>
#include <editeng/eeitem.hxx>
#include <svl/itemset.hxx>
#include <svl/whiter.hxx>
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 752f2431630a..bd356dfcdc4a 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -39,7 +39,7 @@
#include <sfx2/lokhelper.hxx>
#include <vcl/scheduler.hxx>
#include <vcl/vclevent.hxx>
-#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapReadAccess.hxx>
#include <vcl/ITiledRenderable.hxx>
#include <tools/json_writer.hxx>
#include <unotools/mediadescriptor.hxx>
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 4667f5794cc5..ecbf79d2cf4d 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -337,11 +337,11 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/bitmap/impvect \
vcl/source/bitmap/bitmap \
vcl/source/bitmap/BitmapEx \
+ vcl/source/bitmap/BitmapInfoAccess \
+ vcl/source/bitmap/BitmapReadAccess \
+ vcl/source/bitmap/BitmapWriteAccess \
vcl/source/bitmap/alpha \
vcl/source/bitmap/dibtools \
- vcl/source/bitmap/bmpacc2 \
- vcl/source/bitmap/bmpacc3 \
- vcl/source/bitmap/bmpacc \
vcl/source/bitmap/bmpfast \
vcl/source/bitmap/bitmapfilter \
vcl/source/bitmap/BitmapAlphaClampFilter \
diff --git a/vcl/backendtest/outputdevice/line.cxx b/vcl/backendtest/outputdevice/line.cxx
index df96c4593b98..73505c0ef43d 100644
--- a/vcl/backendtest/outputdevice/line.cxx
+++ b/vcl/backendtest/outputdevice/line.cxx
@@ -11,7 +11,7 @@
#include <test/outputdevice.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx>
-#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapReadAccess.hxx>
#include <list>
diff --git a/vcl/inc/BitmapSymmetryCheck.hxx b/vcl/inc/BitmapSymmetryCheck.hxx
index 0c7d4444c774..3e79a426b94c 100644
--- a/vcl/inc/BitmapSymmetryCheck.hxx
+++ b/vcl/inc/BitmapSymmetryCheck.hxx
@@ -12,7 +12,8 @@
#define INCLUDED_VCL_INC_BITMAPSYMMETRYCHECK_HXX
#include <vcl/bitmap.hxx>
-#include <vcl/bitmapaccess.hxx>
+
+class BitmapReadAccess;
class VCL_DLLPUBLIC BitmapSymmetryCheck final
{
diff --git a/vcl/inc/bitmapwriteaccess.hxx b/vcl/inc/bitmapwriteaccess.hxx
index f8916d800cc2..617773b82874 100644
--- a/vcl/inc/bitmapwriteaccess.hxx
+++ b/vcl/inc/bitmapwriteaccess.hxx
@@ -13,7 +13,7 @@
#include <vcl/alpha.hxx>
#include <vcl/bitmap.hxx>
-#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapReadAccess.hxx>
#include <optional>
typedef vcl::ScopedBitmapAccess<BitmapWriteAccess, Bitmap, &Bitmap::AcquireWriteAccess>
diff --git a/vcl/inc/pch/precompiled_vcl.hxx b/vcl/inc/pch/precompiled_vcl.hxx
index a816716d3ab6..20a6814939a2 100644
--- a/vcl/inc/pch/precompiled_vcl.hxx
+++ b/vcl/inc/pch/precompiled_vcl.hxx
@@ -13,7 +13,7 @@
manual changes will be rewritten by the next run of update_pch.sh (which presumably
also fixes all possible problems, so it's usually better to use it).
- Generated on 2020-12-04 10:00:12 using:
+ Generated on 2020-12-22 23:59:32 using:
./bin/update_pch vcl vcl --cutoff=6 --exclude:system --include:module --include:local
If after updating build fails, use the following command to locate conflicting headers:
@@ -272,17 +272,19 @@
#include <sft.hxx>
#include <svdata.hxx>
#include <vcl/AccessibleBrowseBoxObjType.hxx>
+#include <vcl/BitmapColor.hxx>
#include <vcl/BitmapFilter.hxx>
+#include <vcl/BitmapReadAccess.hxx>
#include <vcl/BitmapTools.hxx>
#include <vcl/QueueInfo.hxx>
#include <vcl/accel.hxx>
#include <vcl/alpha.hxx>
#include <vcl/bitmap.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <vcl/bitmapex.hxx>
#include <vcl/builder.hxx>
#include <vcl/button.hxx>
#include <vcl/canvastools.hxx>
+#include <vcl/checksum.hxx>
#include <vcl/commandevent.hxx>
#include <vcl/commandinfoprovider.hxx>
#include <vcl/ctrl.hxx>
diff --git a/vcl/qa/cppunit/BitmapFilterTest.cxx b/vcl/qa/cppunit/BitmapFilterTest.cxx
index 1f9e14d2ef94..13c94fbf8a8a 100644
--- a/vcl/qa/cppunit/BitmapFilterTest.cxx
+++ b/vcl/qa/cppunit/BitmapFilterTest.cxx
@@ -10,7 +10,6 @@
#include <test/bootstrapfixture.hxx>
#include <vcl/bitmap.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <bitmapwriteaccess.hxx>
#include <tools/stream.hxx>
diff --git a/vcl/qa/cppunit/BitmapProcessorTest.cxx b/vcl/qa/cppunit/BitmapProcessorTest.cxx
index e7793cf0a67f..b1a4f6bceb2c 100644
--- a/vcl/qa/cppunit/BitmapProcessorTest.cxx
+++ b/vcl/qa/cppunit/BitmapProcessorTest.cxx
@@ -13,7 +13,6 @@
#include <cppunit/plugin/TestPlugIn.h>
#include <vcl/bitmap.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <vcl/alpha.hxx>
#include <BitmapDisabledImageFilter.hxx>
diff --git a/vcl/qa/cppunit/BitmapScaleTest.cxx b/vcl/qa/cppunit/BitmapScaleTest.cxx
index 7de2f7d8678d..f23a2ae50ec9 100644
--- a/vcl/qa/cppunit/BitmapScaleTest.cxx
+++ b/vcl/qa/cppunit/BitmapScaleTest.cxx
@@ -12,7 +12,6 @@
#include <cppunit/extensions/HelperMacros.h>
#include <vcl/bitmap.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <tools/stream.hxx>
#include <vcl/graphicfilter.hxx>
diff --git a/vcl/qa/cppunit/BitmapTest.cxx b/vcl/qa/cppunit/BitmapTest.cxx
index 8a931df524eb..7caf3dae88dd 100644
--- a/vcl/qa/cppunit/BitmapTest.cxx
+++ b/vcl/qa/cppunit/BitmapTest.cxx
@@ -14,7 +14,6 @@
#include <unordered_map>
#include <vcl/bitmap.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <vcl/virdev.hxx>
#include <rtl/strbuf.hxx>
diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx
index 4c6a1a6972dc..2059dde020f1 100644
--- a/vcl/qa/cppunit/GraphicTest.cxx
+++ b/vcl/qa/cppunit/GraphicTest.cxx
@@ -17,7 +17,7 @@
#include <com/sun/star/beans/PropertyValue.hpp>
-#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapReadAccess.hxx>
#include <vcl/graph.hxx>
#include <vcl/graphicfilter.hxx>
#include <tools/stream.hxx>
diff --git a/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx b/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx
index fb892395ecc1..10e6f82fc219 100644
--- a/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx
+++ b/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx
@@ -10,7 +10,7 @@
#include <test/bootstrapfixture.hxx>
#include <vcl/virdev.hxx>
-#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapReadAccess.hxx>
#include <vcl/svapp.hxx>
#include <tools/stream.hxx>
diff --git a/vcl/qa/cppunit/canvasbitmaptest.cxx b/vcl/qa/cppunit/canvasbitmaptest.cxx
index 511874a0c2df..11c7deaee697 100644
--- a/vcl/qa/cppunit/canvasbitmaptest.cxx
+++ b/vcl/qa/cppunit/canvasbitmaptest.cxx
@@ -33,7 +33,6 @@
#include <sal/log.hxx>
#include <vcl/canvastools.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <vcl/bitmapex.hxx>
#include <canvasbitmap.hxx>
diff --git a/vcl/qa/cppunit/jpeg/JpegWriterTest.cxx b/vcl/qa/cppunit/jpeg/JpegWriterTest.cxx
index fcd343ec4edc..234b2ea14514 100644
--- a/vcl/qa/cppunit/jpeg/JpegWriterTest.cxx
+++ b/vcl/qa/cppunit/jpeg/JpegWriterTest.cxx
@@ -10,7 +10,7 @@
#include <unotest/bootstrapfixturebase.hxx>
#include <vcl/graphicfilter.hxx>
-#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapReadAccess.hxx>
#include <tools/stream.hxx>
constexpr OUStringLiteral gaDataUrl(u"/vcl/qa/cppunit/jpeg/data/");
diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx
index 97ec62096ce9..9f7605c86ce0 100644
--- a/vcl/qa/cppunit/outdev.cxx
+++ b/vcl/qa/cppunit/outdev.cxx
@@ -12,7 +12,6 @@
#include <vcl/print.hxx>
#include <vcl/virdev.hxx>
#include <vcl/window.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <vcl/gdimtf.hxx>
#include <vcl/metaact.hxx>
#include <bitmapwriteaccess.hxx>
diff --git a/vcl/qa/cppunit/png/PngFilterTest.cxx b/vcl/qa/cppunit/png/PngFilterTest.cxx
index eda7d830fca4..d0d356f23702 100644
--- a/vcl/qa/cppunit/png/PngFilterTest.cxx
+++ b/vcl/qa/cppunit/png/PngFilterTest.cxx
@@ -20,7 +20,7 @@
#include <test/bootstrapfixture.hxx>
#include <tools/stream.hxx>
#include <vcl/filter/PngImageReader.hxx>
-#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapReadAccess.hxx>
#include <vcl/alpha.hxx>
using namespace css;
diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index 119f4acda526..63062aa22a08 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -28,7 +28,7 @@
#include <scanlinewriter.hxx>
#include <svdata.hxx>
#include <bmpfast.hxx>
-#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapReadAccess.hxx>
#include <SkCanvas.h>
#include <SkImage.h>
diff --git a/vcl/source/bitmap/BitmapBasicMorphologyFilter.cxx b/vcl/source/bitmap/BitmapBasicMorphologyFilter.cxx
index 62be25514e90..c3a440fa18bd 100644
--- a/vcl/source/bitmap/BitmapBasicMorphologyFilter.cxx
+++ b/vcl/source/bitmap/BitmapBasicMorphologyFilter.cxx
@@ -12,7 +12,6 @@
#include <comphelper/threadpool.hxx>
#include <sal/log.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <vcl/BitmapBasicMorphologyFilter.hxx>
#include <bitmapwriteaccess.hxx>
diff --git a/vcl/source/bitmap/BitmapColorQuantizationFilter.cxx b/vcl/source/bitmap/BitmapColorQuantizationFilter.cxx
index 40b4b803dcb0..34ed5929dfac 100644
--- a/vcl/source/bitmap/BitmapColorQuantizationFilter.cxx
+++ b/vcl/source/bitmap/BitmapColorQuantizationFilter.cxx
@@ -15,7 +15,6 @@
#include <vcl/bitmap.hxx>
#include <vcl/bitmapex.hxx>
#include <vcl/BitmapColorQuantizationFilter.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <bitmapwriteaccess.hxx>
diff --git a/vcl/source/bitmap/BitmapConvolutionMatrixFilter.cxx b/vcl/source/bitmap/BitmapConvolutionMatrixFilter.cxx
index 2d050b5cc117..94eb81675bd2 100644
--- a/vcl/source/bitmap/BitmapConvolutionMatrixFilter.cxx
+++ b/vcl/source/bitmap/BitmapConvolutionMatrixFilter.cxx
@@ -11,7 +11,6 @@
#include <tools/helpers.hxx>
#include <vcl/bitmap.hxx>
#include <vcl/bitmapex.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <vcl/BitmapConvolutionMatrixFilter.hxx>
#include <vcl/BitmapSharpenFilter.hxx>
diff --git a/vcl/source/bitmap/BitmapDisabledImageFilter.cxx b/vcl/source/bitmap/BitmapDisabledImageFilter.cxx
index 1110b9c5d5a6..4a70bed1ccb9 100644
--- a/vcl/source/bitmap/BitmapDisabledImageFilter.cxx
+++ b/vcl/source/bitmap/BitmapDisabledImageFilter.cxx
@@ -8,8 +8,6 @@
*
*/
-#include <vcl/bitmapaccess.hxx>
-
#include <bitmapwriteaccess.hxx>
#include <BitmapDisabledImageFilter.hxx>
diff --git a/vcl/source/bitmap/BitmapDuoToneFilter.cxx b/vcl/source/bitmap/BitmapDuoToneFilter.cxx
index 3bcf1035a4c7..f72edb79a438 100644
--- a/vcl/source/bitmap/BitmapDuoToneFilter.cxx
+++ b/vcl/source/bitmap/BitmapDuoToneFilter.cxx
@@ -11,7 +11,6 @@
#include <vcl/bitmap.hxx>
#include <vcl/bitmapex.hxx>
#include <vcl/BitmapDuoToneFilter.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <bitmapwriteaccess.hxx>
diff --git a/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx b/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx
index 9470dfd3acad..173de3f3fefa 100644
--- a/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx
+++ b/vcl/source/bitmap/BitmapEmbossGreyFilter.cxx
@@ -15,7 +15,6 @@
#include <tools/helpers.hxx>
#include <vcl/bitmap.hxx>
#include <vcl/bitmapex.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <vcl/BitmapEmbossGreyFilter.hxx>
#include <bitmapwriteaccess.hxx>
diff --git a/vcl/source/bitmap/BitmapEx.cxx b/vcl/source/bitmap/BitmapEx.cxx
index 7c50435c6fc7..35936c2ff8ab 100644
--- a/vcl/source/bitmap/BitmapEx.cxx
+++ b/vcl/source/bitmap/BitmapEx.cxx
@@ -29,7 +29,6 @@
#include <vcl/alpha.hxx>
#include <vcl/bitmapex.hxx>
#include <vcl/svapp.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <vcl/virdev.hxx>
#include <vcl/settings.hxx>
#include <vcl/BitmapMonochromeFilter.hxx>
diff --git a/vcl/source/bitmap/BitmapFastScaleFilter.cxx b/vcl/source/bitmap/BitmapFastScaleFilter.cxx
index 7c8b63a0f729..9969abcd8892 100644
--- a/vcl/source/bitmap/BitmapFastScaleFilter.cxx
+++ b/vcl/source/bitmap/BitmapFastScaleFilter.cxx
@@ -20,7 +20,6 @@
#include <tools/helpers.hxx>
#include <vcl/bitmapex.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <bitmapwriteaccess.hxx>
#include <BitmapFastScaleFilter.hxx>
diff --git a/vcl/source/bitmap/BitmapFilterStackBlur.cxx b/vcl/source/bitmap/BitmapFilterStackBlur.cxx
index d3e1ddea9310..0d4f67d2dbfe 100644
--- a/vcl/source/bitmap/BitmapFilterStackBlur.cxx
+++ b/vcl/source/bitmap/BitmapFilterStackBlur.cxx
@@ -9,7 +9,6 @@
*/
#include <vcl/BitmapFilterStackBlur.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <bitmapwriteaccess.hxx>
#include <sal/log.hxx>
diff --git a/vcl/source/bitmap/BitmapGaussianSeparableBlurFilter.cxx b/vcl/source/bitmap/BitmapGaussianSeparableBlurFilter.cxx
index b1837f4a5867..5426195ba36e 100644
--- a/vcl/source/bitmap/BitmapGaussianSeparableBlurFilter.cxx
+++ b/vcl/source/bitmap/BitmapGaussianSeparableBlurFilter.cxx
@@ -11,7 +11,6 @@
#include <tools/helpers.hxx>
#include <vcl/bitmap.hxx>
#include <vcl/bitmapex.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <vcl/BitmapGaussianSeparableBlurFilter.hxx>
#include <bitmapwriteaccess.hxx>
diff --git a/vcl/source/bitmap/BitmapInfoAccess.cxx b/vcl/source/bitmap/BitmapInfoAccess.cxx
new file mode 100644
index 000000000000..8c90e8fb8d25
--- /dev/null
+++ b/vcl/source/bitmap/BitmapInfoAccess.cxx
@@ -0,0 +1,78 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <vcl/BitmapInfoAccess.hxx>
+
+#include <salbmp.hxx>
+#include <svdata.hxx>
+#include <salinst.hxx>
+
+BitmapInfoAccess::BitmapInfoAccess(Bitmap& rBitmap, BitmapAccessMode nMode)
+ : mpBuffer(nullptr)
+ , mnAccessMode(nMode)
+{
+ std::shared_ptr<SalBitmap> xImpBmp = rBitmap.ImplGetSalBitmap();
+
+ if (!xImpBmp)
+ return;
+
+ if (mnAccessMode == BitmapAccessMode::Write)
+ {
+ xImpBmp->DropScaledCache();
+
+ if (xImpBmp.use_count() > 2)
+ {
+ xImpBmp.reset();
+ rBitmap.ImplMakeUnique();
+ xImpBmp = rBitmap.ImplGetSalBitmap();
+ }
+ }
+
+ mpBuffer = xImpBmp->AcquireBuffer(mnAccessMode);
+
+ if (!mpBuffer)
+ {
+ std::shared_ptr<SalBitmap> xNewImpBmp(ImplGetSVData()->mpDefInst->CreateSalBitmap());
+ if (xNewImpBmp->Create(*xImpBmp, rBitmap.GetBitCount()))
+ {
+ xImpBmp = xNewImpBmp;
+ rBitmap.ImplSetSalBitmap(xImpBmp);
+ mpBuffer = xImpBmp->AcquireBuffer(mnAccessMode);
+ }
+ }
+
+ maBitmap = rBitmap;
+}
+
+BitmapInfoAccess::~BitmapInfoAccess()
+{
+ std::shared_ptr<SalBitmap> xImpBmp = maBitmap.ImplGetSalBitmap();
+
+ if (mpBuffer && xImpBmp)
+ {
+ xImpBmp->ReleaseBuffer(mpBuffer, mnAccessMode);
+ }
+}
+
+sal_uInt16 BitmapInfoAccess::GetBestPaletteIndex(const BitmapColor& rBitmapColor) const
+{
+ return (HasPalette() ? mpBuffer->maPalette.GetBestIndex(rBitmapColor) : 0);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/bitmap/BitmapInterpolateScaleFilter.cxx b/vcl/source/bitmap/BitmapInterpolateScaleFilter.cxx
index eb1d027bb295..9f6fee90cc7e 100644
--- a/vcl/source/bitmap/BitmapInterpolateScaleFilter.cxx
+++ b/vcl/source/bitmap/BitmapInterpolateScaleFilter.cxx
@@ -21,7 +21,6 @@
#include <osl/diagnose.h>
#include <vcl/bitmapex.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <bitmapwriteaccess.hxx>
#include <BitmapFastScaleFilter.hxx>
diff --git a/vcl/source/bitmap/BitmapLightenFilter.cxx b/vcl/source/bitmap/BitmapLightenFilter.cxx
index b85ac4387406..489fba611394 100644
--- a/vcl/source/bitmap/BitmapLightenFilter.cxx
+++ b/vcl/source/bitmap/BitmapLightenFilter.cxx
@@ -10,8 +10,6 @@
#include <basegfx/color/bcolortools.hxx>
-#include <vcl/bitmapaccess.hxx>
-
#include <bitmapwriteaccess.hxx>
#include <BitmapLightenFilter.hxx>
diff --git a/vcl/source/bitmap/BitmapMedianFilter.cxx b/vcl/source/bitmap/BitmapMedianFilter.cxx
index 91bc75a7d4bd..1dd7b3b552b0 100644
--- a/vcl/source/bitmap/BitmapMedianFilter.cxx
+++ b/vcl/source/bitmap/BitmapMedianFilter.cxx
@@ -10,7 +10,6 @@
#include <vcl/bitmap.hxx>
#include <vcl/bitmapex.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <vcl/BitmapMedianFilter.hxx>
#include <bitmapwriteaccess.hxx>
diff --git a/vcl/source/bitmap/BitmapMonochromeFilter.cxx b/vcl/source/bitmap/BitmapMonochromeFilter.cxx
index 224a66ab9558..9347eca5f5e4 100644
--- a/vcl/source/bitmap/BitmapMonochromeFilter.cxx
+++ b/vcl/source/bitmap/BitmapMonochromeFilter.cxx
@@ -11,7 +11,6 @@
#include <vcl/bitmap.hxx>
#include <vcl/bitmapex.hxx>
#include <vcl/BitmapMonochromeFilter.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <bitmapwriteaccess.hxx>
diff --git a/vcl/source/bitmap/BitmapMosaicFilter.cxx b/vcl/source/bitmap/BitmapMosaicFilter.cxx
index 5afbb90d6bcb..68afdfab0a39 100644
--- a/vcl/source/bitmap/BitmapMosaicFilter.cxx
+++ b/vcl/source/bitmap/BitmapMosaicFilter.cxx
@@ -10,7 +10,6 @@
#include <vcl/bitmap.hxx>
#include <vcl/bitmapex.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <vcl/BitmapMosaicFilter.hxx>
#include <bitmapwriteaccess.hxx>
diff --git a/vcl/source/bitmap/BitmapReadAccess.cxx b/vcl/source/bitmap/BitmapReadAccess.cxx
new file mode 100644
index 000000000000..9b5218065a3c
--- /dev/null
+++ b/vcl/source/bitmap/BitmapReadAccess.cxx
@@ -0,0 +1,609 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <vcl/BitmapReadAccess.hxx>
+#include <vcl/BitmapTools.hxx>
+
+#include <salbmp.hxx>
+#include <svdata.hxx>
+#include <salinst.hxx>
+
+BitmapReadAccess::BitmapReadAccess(Bitmap& rBitmap, BitmapAccessMode nMode)
+ : BitmapInfoAccess(rBitmap, nMode)
+ , mFncGetPixel(nullptr)
+ , mFncSetPixel(nullptr)
+{
+ if (!mpBuffer)
+ return;
+
+ const std::shared_ptr<SalBitmap>& xImpBmp = rBitmap.ImplGetSalBitmap();
+ if (!xImpBmp)
+ return;
+
+ maColorMask = mpBuffer->maColorMask;
+
+ mFncGetPixel = GetPixelFunction(mpBuffer->mnFormat);
+ mFncSetPixel = SetPixelFunction(mpBuffer->mnFormat);
+
+ if (!mFncGetPixel || !mFncSetPixel)
+ {
+ xImpBmp->ReleaseBuffer(mpBuffer, mnAccessMode);
+ mpBuffer = nullptr;
+ }
+}
+
+BitmapReadAccess::~BitmapReadAccess() {}
+
+bool Bitmap32IsPreMultipled()
+{
+ auto pBackendCapabilities = ImplGetSVData()->mpDefInst->GetBackendCapabilities();
+ return pBackendCapabilities->mbSupportsBitmap32;
+}
+
+FncGetPixel BitmapReadAccess::GetPixelFunction(ScanlineFormat nFormat)
+{
+ switch (RemoveScanline(nFormat))
+ {
+ case ScanlineFormat::N1BitMsbPal:
+ return GetPixelForN1BitMsbPal;
+ case ScanlineFormat::N1BitLsbPal:
+ return GetPixelForN1BitLsbPal;
+ case ScanlineFormat::N4BitMsnPal:
+ return GetPixelForN4BitMsnPal;
+ case ScanlineFormat::N4BitLsnPal:
+ return GetPixelForN4BitLsnPal;
+ case ScanlineFormat::N8BitPal:
+ return GetPixelForN8BitPal;
+ case ScanlineFormat::N24BitTcBgr:
+ return GetPixelForN24BitTcBgr;
+ case ScanlineFormat::N24BitTcRgb:
+ return GetPixelForN24BitTcRgb;
+ case ScanlineFormat::N32BitTcAbgr:
+ if (Bitmap32IsPreMultipled())
+ return GetPixelForN32BitTcAbgr;
+ else
+ return GetPixelForN32BitTcXbgr;
+ case ScanlineFormat::N32BitTcArgb:
+ if (Bitmap32IsPreMultipled())
+ return GetPixelForN32BitTcArgb;
+ else
+ return GetPixelForN32BitTcXrgb;
+ case ScanlineFormat::N32BitTcBgra:
+ if (Bitmap32IsPreMultipled())
+ return GetPixelForN32BitTcBgra;
+ else
+ return GetPixelForN32BitTcBgrx;
+ case ScanlineFormat::N32BitTcRgba:
+ if (Bitmap32IsPreMultipled())
+ return GetPixelForN32BitTcRgba;
+ else
+ return GetPixelForN32BitTcRgbx;
+ case ScanlineFormat::N32BitTcMask:
+ return GetPixelForN32BitTcMask;
+
+ default:
+ return nullptr;
+ }
+}
+
+FncSetPixel BitmapReadAccess::SetPixelFunction(ScanlineFormat nFormat)
+{
+ switch (RemoveScanline(nFormat))
+ {
+ case ScanlineFormat::N1BitMsbPal:
+ return SetPixelForN1BitMsbPal;
+ case ScanlineFormat::N1BitLsbPal:
+ return SetPixelForN1BitLsbPal;
+ case ScanlineFormat::N4BitMsnPal:
+ return SetPixelForN4BitMsnPal;
+ case ScanlineFormat::N4BitLsnPal:
+ return SetPixelForN4BitLsnPal;
+ case ScanlineFormat::N8BitPal:
+ return SetPixelForN8BitPal;
+ case ScanlineFormat::N24BitTcBgr:
+ return SetPixelForN24BitTcBgr;
+ case ScanlineFormat::N24BitTcRgb:
+ return SetPixelForN24BitTcRgb;
+ case ScanlineFormat::N32BitTcAbgr:
+ if (Bitmap32IsPreMultipled())
+ return SetPixelForN32BitTcAbgr;
+ else
+ return SetPixelForN32BitTcXbgr;
+ case ScanlineFormat::N32BitTcArgb:
+ if (Bitmap32IsPreMultipled())
+ return SetPixelForN32BitTcArgb;
+ else
+ return SetPixelForN32BitTcXrgb;
+ case ScanlineFormat::N32BitTcBgra:
+ if (Bitmap32IsPreMultipled())
+ return SetPixelForN32BitTcBgra;
+ else
+ return SetPixelForN32BitTcBgrx;
+ case ScanlineFormat::N32BitTcRgba:
+ if (Bitmap32IsPreMultipled())
+ return SetPixelForN32BitTcRgba;
+ else
+ return SetPixelForN32BitTcRgbx;
+ case ScanlineFormat::N32BitTcMask:
+ return SetPixelForN32BitTcMask;
+ break;
+
+ default:
+ return nullptr;
+ }
+}
+
+BitmapColor BitmapReadAccess::GetInterpolatedColorWithFallback(double fY, double fX,
+ const BitmapColor& rFallback) const
+{
+ // ask directly doubles >= 0.0 here to avoid rounded values of 0 at small negative
+ // double values, e.g. static_cast< sal_Int32 >(-0.25) is 0, not -1, but *has* to be outside (!)
+ if (mpBuffer && fX >= 0.0 && fY >= 0.0)
+ {
+ const sal_Int64 nX(static_cast<sal_Int64>(fX));
+ const sal_Int64 nY(static_cast<sal_Int64>(fY));
+
+ if (nX < mpBuffer->mnWidth && nY < mpBuffer->mnHeight)
+ {
+ // get base-return value from inside pixel
+ BitmapColor aRetval(GetColor(nY, nX));
+
+ // calculate deltas and indices for neighbour accesses
+ sal_Int16 nDeltaX((fX - (nX + 0.5)) * 255.0); // [-255 .. 255]
+ sal_Int16 nDeltaY((fY - (nY + 0.5)) * 255.0); // [-255 .. 255]
+ sal_Int16 nIndX(0);
+ sal_Int16 nIndY(0);
+
+ if (nDeltaX > 0)
+ {
+ nIndX = nX + 1;
+ }
+ else
+ {
+ nIndX = nX - 1;
+ nDeltaX = -nDeltaX;
+ }
+
+ if (nDeltaY > 0)
+ {
+ nIndY = nY + 1;
+ }
+ else
+ {
+ nIndY = nY - 1;
+ nDeltaY = -nDeltaY;
+ }
+
+ // get right/left neighbour
+ BitmapColor aXCol(rFallback);
+
+ if (nDeltaX && nIndX >= 0 && nIndX < mpBuffer->mnWidth)
+ {
+ aXCol = GetColor(nY, nIndX);
+ }
+
+ // get top/bottom neighbour
+ BitmapColor aYCol(rFallback);
+
+ if (nDeltaY && nIndY >= 0 && nIndY < mpBuffer->mnHeight)
+ {
+ aYCol = GetColor(nIndY, nX);
+ }
+
+ // get one of four edge neighbours
+ BitmapColor aXYCol(rFallback);
+
+ if (nDeltaX && nDeltaY && nIndX >= 0 && nIndY >= 0 && nIndX < mpBuffer->mnWidth
+ && nIndY < mpBuffer->mnHeight)
+ {
+ aXYCol = GetColor(nIndY, nIndX);
+ }
+
+ // merge return value with right/left neighbour
+ if (aXCol != aRetval)
+ {
+ aRetval.Merge(aXCol, 255 - nDeltaX);
+ }
+
+ // merge top/bottom neighbour with edge
+ if (aYCol != aXYCol)
+ {
+ aYCol.Merge(aXYCol, 255 - nDeltaX);
+ }
+
+ // merge return value with already merged top/bottom neighbour
+ if (aRetval != aYCol)
+ {
+ aRetval.Merge(aYCol, 255 - nDeltaY);
+ }
+
+ return aRetval;
+ }
+ }
+
+ return rFallback;
+}
+
+BitmapColor BitmapReadAccess::GetColorWithFallback(double fY, double fX,
+ const BitmapColor& rFallback) const
+{
+ // ask directly doubles >= 0.0 here to avoid rounded values of 0 at small negative
+ // double values, e.g. static_cast< sal_Int32 >(-0.25) is 0, not -1, but *has* to be outside (!)
+ if (mpBuffer && fX >= 0.0 && fY >= 0.0)
+ {
+ const sal_Int32 nX(static_cast<sal_Int32>(fX));
+ const sal_Int32 nY(static_cast<sal_Int32>(fY));
+
+ if (nX < mpBuffer->mnWidth && nY < mpBuffer->mnHeight)
+ {
+ return GetColor(nY, nX);
+ }
+ }
+
+ return rFallback;
+}
+
+BitmapColor BitmapReadAccess::GetPixelForN1BitMsbPal(ConstScanline pScanline, tools::Long nX,
+ const ColorMask&)
+{
+ return BitmapColor(pScanline[nX >> 3] & (1 << (7 - (nX & 7))) ? 1 : 0);
+}
+
+void BitmapReadAccess::SetPixelForN1BitMsbPal(const Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask&)
+{
+ sal_uInt8& rByte = pScanline[nX >> 3];
+
+ if (rBitmapColor.GetIndex() & 1)
+ rByte |= 1 << (7 - (nX & 7));
+ else
+ rByte &= ~(1 << (7 - (nX & 7)));
+}
+
+BitmapColor BitmapReadAccess::GetPixelForN1BitLsbPal(ConstScanline pScanline, tools::Long nX,
+ const ColorMask&)
+{
+ return BitmapColor(pScanline[nX >> 3] & (1 << (nX & 7)) ? 1 : 0);
+}
+
+void BitmapReadAccess::SetPixelForN1BitLsbPal(const Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask&)
+{
+ sal_uInt8& rByte = pScanline[nX >> 3];
+
+ if (rBitmapColor.GetIndex() & 1)
+ rByte |= 1 << (nX & 7);
+ else
+ rByte &= ~(1 << (nX & 7));
+}
+
+BitmapColor BitmapReadAccess::GetPixelForN4BitMsnPal(ConstScanline pScanline, tools::Long nX,
+ const ColorMask&)
+{
+ return BitmapColor((pScanline[nX >> 1] >> (nX & 1 ? 0 : 4)) & 0x0f);
+}
+
+void BitmapReadAccess::SetPixelForN4BitMsnPal(const Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask&)
+{
+ sal_uInt8& rByte = pScanline[nX >> 1];
+
+ if (nX & 1)
+ {
+ rByte &= 0xf0;
+ rByte |= (rBitmapColor.GetIndex() & 0x0f);
+ }
+ else
+ {
+ rByte &= 0x0f;
+ rByte |= (rBitmapColor.GetIndex() << 4);
+ }
+}
+
+BitmapColor BitmapReadAccess::GetPixelForN4BitLsnPal(ConstScanline pScanline, tools::Long nX,
+ const ColorMask&)
+{
+ return BitmapColor((pScanline[nX >> 1] >> (nX & 1 ? 4 : 0)) & 0x0f);
+}
+
+void BitmapReadAccess::SetPixelForN4BitLsnPal(const Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask&)
+{
+ sal_uInt8& rByte = pScanline[nX >> 1];
+
+ if (nX & 1)
+ {
+ rByte &= 0x0f;
+ rByte |= (rBitmapColor.GetIndex() << 4);
+ }
+ else
+ {
+ rByte &= 0xf0;
+ rByte |= (rBitmapColor.GetIndex() & 0x0f);
+ }
+}
+
+BitmapColor BitmapReadAccess::GetPixelForN8BitPal(ConstScanline pScanline, tools::Long nX,
+ const ColorMask&)
+{
+ return BitmapColor(pScanline[nX]);
+}
+
+void BitmapReadAccess::SetPixelForN8BitPal(Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask&)
+{
+ pScanline[nX] = rBitmapColor.GetIndex();
+}
+
+BitmapColor BitmapReadAccess::GetPixelForN24BitTcBgr(ConstScanline pScanline, tools::Long nX,
+ const ColorMask&)
+{
+ BitmapColor aBitmapColor;
+
+ pScanline = pScanline + nX * 3;
+ aBitmapColor.SetBlue(*pScanline++);
+ aBitmapColor.SetGreen(*pScanline++);
+ aBitmapColor.SetRed(*pScanline);
+
+ return aBitmapColor;
+}
+
+void BitmapReadAccess::SetPixelForN24BitTcBgr(Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask&)
+{
+ pScanline = pScanline + nX * 3;
+ *pScanline++ = rBitmapColor.GetBlue();
+ *pScanline++ = rBitmapColor.GetGreen();
+ *pScanline = rBitmapColor.GetRed();
+}
+
+BitmapColor BitmapReadAccess::GetPixelForN24BitTcRgb(ConstScanline pScanline, tools::Long nX,
+ const ColorMask&)
+{
+ BitmapColor aBitmapColor;
+
+ pScanline = pScanline + nX * 3;
+ aBitmapColor.SetRed(*pScanline++);
+ aBitmapColor.SetGreen(*pScanline++);
+ aBitmapColor.SetBlue(*pScanline);
+
+ return aBitmapColor;
+}
+
+void BitmapReadAccess::SetPixelForN24BitTcRgb(Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask&)
+{
+ pScanline = pScanline + nX * 3;
+ *pScanline++ = rBitmapColor.GetRed();
+ *pScanline++ = rBitmapColor.GetGreen();
+ *pScanline = rBitmapColor.GetBlue();
+}
+
+BitmapColor BitmapReadAccess::GetPixelForN32BitTcAbgr(ConstScanline pScanline, tools::Long nX,
+ const ColorMask&)
+{
+ pScanline = pScanline + nX * 4;
+
+ sal_uInt8 a = *pScanline++;
+ sal_uInt8 b = *pScanline++;
+ sal_uInt8 g = *pScanline++;
+ sal_uInt8 r = *pScanline;
+
+ return BitmapColor(vcl::bitmap::unpremultiply(r, a), vcl::bitmap::unpremultiply(g, a),
+ vcl::bitmap::unpremultiply(b, a), 0xFF - a);
+}
+
+BitmapColor BitmapReadAccess::GetPixelForN32BitTcXbgr(ConstScanline pScanline, tools::Long nX,
+ const ColorMask&)
+{
+ BitmapColor aBitmapColor;
+
+ pScanline = pScanline + (nX << 2) + 1;
+ aBitmapColor.SetBlue(*pScanline++);
+ aBitmapColor.SetGreen(*pScanline++);
+ aBitmapColor.SetRed(*pScanline);
+
+ return aBitmapColor;
+}
+
+void BitmapReadAccess::SetPixelForN32BitTcAbgr(Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask&)
+{
+ pScanline = pScanline + nX * 4;
+
+ sal_uInt8 alpha = 0xFF - rBitmapColor.GetAlpha();
+ *pScanline++ = alpha;
+ *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetBlue(), alpha);
+ *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetGreen(), alpha);
+ *pScanline = vcl::bitmap::premultiply(rBitmapColor.GetRed(), alpha);
+}
+
+void BitmapReadAccess::SetPixelForN32BitTcXbgr(Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask&)
+{
+ pScanline = pScanline + (nX << 2);
+ *pScanline++ = 0xFF;
+ *pScanline++ = rBitmapColor.GetBlue();
+ *pScanline++ = rBitmapColor.GetGreen();
+ *pScanline = rBitmapColor.GetRed();
+}
+
+BitmapColor BitmapReadAccess::GetPixelForN32BitTcArgb(ConstScanline pScanline, tools::Long nX,
+ const ColorMask&)
+{
+ pScanline = pScanline + nX * 4;
+
+ sal_uInt8 a = *pScanline++;
+ sal_uInt8 r = *pScanline++;
+ sal_uInt8 g = *pScanline++;
+ sal_uInt8 b = *pScanline;
+
+ return BitmapColor(vcl::bitmap::unpremultiply(r, a), vcl::bitmap::unpremultiply(g, a),
+ vcl::bitmap::unpremultiply(b, a), 0xFF - a);
+}
+
+BitmapColor BitmapReadAccess::GetPixelForN32BitTcXrgb(ConstScanline pScanline, tools::Long nX,
+ const ColorMask&)
+{
+ BitmapColor aBitmapColor;
+
+ pScanline = pScanline + (nX << 2) + 1;
+ aBitmapColor.SetRed(*pScanline++);
+ aBitmapColor.SetGreen(*pScanline++);
+ aBitmapColor.SetBlue(*pScanline);
+
+ return aBitmapColor;
+}
+
+void BitmapReadAccess::SetPixelForN32BitTcArgb(Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask&)
+{
+ pScanline = pScanline + nX * 4;
+
+ sal_uInt8 alpha = 0xFF - rBitmapColor.GetAlpha();
+ *pScanline++ = alpha;
+ *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetRed(), alpha);
+ *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetGreen(), alpha);
+ *pScanline = vcl::bitmap::premultiply(rBitmapColor.GetBlue(), alpha);
+}
+
+void BitmapReadAccess::SetPixelForN32BitTcXrgb(Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask&)
+{
+ pScanline = pScanline + (nX << 2);
+ *pScanline++ = 0xFF;
+ *pScanline++ = rBitmapColor.GetRed();
+ *pScanline++ = rBitmapColor.GetGreen();
+ *pScanline = rBitmapColor.GetBlue();
+}
+
+BitmapColor BitmapReadAccess::GetPixelForN32BitTcBgra(ConstScanline pScanline, tools::Long nX,
+ const ColorMask&)
+{
+ pScanline = pScanline + nX * 4;
+
+ sal_uInt8 b = *pScanline++;
+ sal_uInt8 g = *pScanline++;
+ sal_uInt8 r = *pScanline++;
+ sal_uInt8 a = *pScanline;
+
+ return BitmapColor(vcl::bitmap::unpremultiply(r, a), vcl::bitmap::unpremultiply(g, a),
+ vcl::bitmap::unpremultiply(b, a), 0xFF - a);
+}
+
+BitmapColor BitmapReadAccess::GetPixelForN32BitTcBgrx(ConstScanline pScanline, tools::Long nX,
+ const ColorMask&)
+{
+ BitmapColor aBitmapColor;
+
+ pScanline = pScanline + (nX << 2);
+ aBitmapColor.SetBlue(*pScanline++);
+ aBitmapColor.SetGreen(*pScanline++);
+ aBitmapColor.SetRed(*pScanline);
+
+ return aBitmapColor;
+}
+
+void BitmapReadAccess::SetPixelForN32BitTcBgra(Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask&)
+{
+ pScanline = pScanline + nX * 4;
+
+ sal_uInt8 alpha = 0xFF - rBitmapColor.GetAlpha();
+ *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetBlue(), alpha);
+ *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetGreen(), alpha);
+ *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetRed(), alpha);
+ *pScanline = alpha;
+}
+
+void BitmapReadAccess::SetPixelForN32BitTcBgrx(Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask&)
+{
+ pScanline = pScanline + (nX << 2);
+ *pScanline++ = rBitmapColor.GetBlue();
+ *pScanline++ = rBitmapColor.GetGreen();
+ *pScanline++ = rBitmapColor.GetRed();
+ *pScanline = 0xFF;
+}
+
+BitmapColor BitmapReadAccess::GetPixelForN32BitTcRgba(ConstScanline pScanline, tools::Long nX,
+ const ColorMask&)
+{
+ pScanline = pScanline + nX * 4;
+
+ sal_uInt8 r = *pScanline++;
+ sal_uInt8 g = *pScanline++;
+ sal_uInt8 b = *pScanline++;
+ sal_uInt8 a = *pScanline;
+
+ return BitmapColor(vcl::bitmap::unpremultiply(r, a), vcl::bitmap::unpremultiply(g, a),
+ vcl::bitmap::unpremultiply(b, a), 0xFF - a);
+}
+
+BitmapColor BitmapReadAccess::GetPixelForN32BitTcRgbx(ConstScanline pScanline, tools::Long nX,
+ const ColorMask&)
+{
+ BitmapColor aBitmapColor;
+
+ pScanline = pScanline + (nX << 2);
+ aBitmapColor.SetRed(*pScanline++);
+ aBitmapColor.SetGreen(*pScanline++);
+ aBitmapColor.SetBlue(*pScanline);
+
+ return aBitmapColor;
+}
+
+void BitmapReadAccess::SetPixelForN32BitTcRgba(Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask&)
+{
+ pScanline = pScanline + nX * 4;
+
+ sal_uInt8 alpha = 0xFF - rBitmapColor.GetAlpha();
+ *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetRed(), alpha);
+ *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetGreen(), alpha);
+ *pScanline++ = vcl::bitmap::premultiply(rBitmapColor.GetBlue(), alpha);
+ *pScanline = alpha;
+}
+
+void BitmapReadAccess::SetPixelForN32BitTcRgbx(Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor, const ColorMask&)
+{
+ pScanline = pScanline + (nX << 2);
+ *pScanline++ = rBitmapColor.GetRed();
+ *pScanline++ = rBitmapColor.GetGreen();
+ *pScanline++ = rBitmapColor.GetBlue();
+ *pScanline = 0xFF;
+}
+
+BitmapColor BitmapReadAccess::GetPixelForN32BitTcMask(ConstScanline pScanline, tools::Long nX,
+ const ColorMask& rMask)
+{
+ BitmapColor aColor;
+ rMask.GetColorFor32Bit(aColor, pScanline + (nX << 2));
+ return aColor;
+}
+
+void BitmapReadAccess::SetPixelForN32BitTcMask(Scanline pScanline, tools::Long nX,
+ const BitmapColor& rBitmapColor,
+ const ColorMask& rMask)
+{
+ rMask.SetColorFor32Bit(rBitmapColor, pScanline + (nX << 2));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx b/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx
index bf210fa21236..cc01bae62adf 100644
--- a/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx
+++ b/vcl/source/bitmap/BitmapScaleConvolutionFilter.cxx
@@ -18,9 +18,7 @@
*/
#include <osl/diagnose.h>
-
#include <tools/helpers.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <bitmapwriteaccess.hxx>
#include <BitmapScaleConvolutionFilter.hxx>
diff --git a/vcl/source/bitmap/BitmapScaleSuperFilter.cxx b/vcl/source/bitmap/BitmapScaleSuperFilter.cxx
index 95c86f038dd9..c655d8fac975 100644
--- a/vcl/source/bitmap/BitmapScaleSuperFilter.cxx
+++ b/vcl/source/bitmap/BitmapScaleSuperFilter.cxx
@@ -20,7 +20,6 @@
#include <comphelper/threadpool.hxx>
#include <tools/helpers.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <bitmapwriteaccess.hxx>
#include <BitmapScaleSuperFilter.hxx>
diff --git a/vcl/source/bitmap/BitmapSeparableUnsharpenFilter.cxx b/vcl/source/bitmap/BitmapSeparableUnsharpenFilter.cxx
index 9a8b462e47a2..ab545951ed5e 100644
--- a/vcl/source/bitmap/BitmapSeparableUnsharpenFilter.cxx
+++ b/vcl/source/bitmap/BitmapSeparableUnsharpenFilter.cxx
@@ -11,7 +11,6 @@
#include <tools/helpers.hxx>
#include <vcl/bitmap.hxx>
#include <vcl/bitmapex.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <vcl/BitmapGaussianSeparableBlurFilter.hxx>
#include <vcl/BitmapSeparableUnsharpenFilter.hxx>
diff --git a/vcl/source/bitmap/BitmapSepiaFilter.cxx b/vcl/source/bitmap/BitmapSepiaFilter.cxx
index cfac984b8fa3..43d1a9e78109 100644
--- a/vcl/source/bitmap/BitmapSepiaFilter.cxx
+++ b/vcl/source/bitmap/BitmapSepiaFilter.cxx
@@ -14,7 +14,6 @@
#include <vcl/bitmap.hxx>
#include <vcl/bitmapex.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <vcl/BitmapSepiaFilter.hxx>
#include <bitmapwriteaccess.hxx>
diff --git a/vcl/source/bitmap/BitmapSimpleColorQuantizationFilter.cxx b/vcl/source/bitmap/BitmapSimpleColorQuantizationFilter.cxx
index 4284db563ac3..81e129af32bb 100644
--- a/vcl/source/bitmap/BitmapSimpleColorQuantizationFilter.cxx
+++ b/vcl/source/bitmap/BitmapSimpleColorQuantizationFilter.cxx
@@ -10,7 +10,6 @@
#include <vcl/bitmap.hxx>
#include <vcl/bitmapex.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <vcl/BitmapSimpleColorQuantizationFilter.hxx>
#include <bitmapwriteaccess.hxx>
diff --git a/vcl/source/bitmap/BitmapSobelGreyFilter.cxx b/vcl/source/bitmap/BitmapSobelGreyFilter.cxx
index e34af85df300..e03781975836 100644
--- a/vcl/source/bitmap/BitmapSobelGreyFilter.cxx
+++ b/vcl/source/bitmap/BitmapSobelGreyFilter.cxx
@@ -14,7 +14,6 @@
#include <vcl/bitmap.hxx>
#include <vcl/bitmapex.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <vcl/BitmapSobelGreyFilter.hxx>
#include <bitmapwriteaccess.hxx>
diff --git a/vcl/source/bitmap/BitmapSymmetryCheck.cxx b/vcl/source/bitmap/BitmapSymmetryCheck.cxx
index ce5235132e80..d2e450c0337d 100644
--- a/vcl/source/bitmap/BitmapSymmetryCheck.cxx
+++ b/vcl/source/bitmap/BitmapSymmetryCheck.cxx
@@ -8,6 +8,8 @@
*
*/
+#include <vcl/BitmapReadAccess.hxx>
+
#include <BitmapSymmetryCheck.hxx>
BitmapSymmetryCheck::BitmapSymmetryCheck()
diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx
index 2fc8b1c96386..7dcc8245fdd0 100644
--- a/vcl/source/bitmap/BitmapTools.cxx
+++ b/vcl/source/bitmap/BitmapTools.cxx
@@ -26,7 +26,6 @@
#include <vcl/dibtools.hxx>
#include <vcl/settings.hxx>
#include <vcl/svapp.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <vcl/virdev.hxx>
#if ENABLE_CAIRO_CANVAS
#include <cairo.h>
diff --git a/vcl/source/bitmap/bmpacc3.cxx b/vcl/source/bitmap/BitmapWriteAccess.cxx
similarity index 59%
rename from vcl/source/bitmap/bmpacc3.cxx
rename to vcl/source/bitmap/BitmapWriteAccess.cxx
index 0bf75b12d743..e94bf5952016 100644
--- a/vcl/source/bitmap/bmpacc3.cxx
+++ b/vcl/source/bitmap/BitmapWriteAccess.cxx
@@ -18,13 +18,137 @@
*/
#include <sal/config.h>
+#include <sal/log.hxx>
+#include <tools/debug.hxx>
-#include <cstdlib>
+#include <bitmapwriteaccess.hxx>
+#include <bmpfast.hxx>
-#include <vcl/bitmap.hxx>
+BitmapWriteAccess::BitmapWriteAccess(Bitmap& rBitmap)
+ : BitmapReadAccess(rBitmap, BitmapAccessMode::Write)
+{
+}
-#include <bmpfast.hxx>
-#include <bitmapwriteaccess.hxx>
+BitmapWriteAccess::~BitmapWriteAccess() {}
+
+void BitmapWriteAccess::CopyScanline(tools::Long nY, const BitmapReadAccess& rReadAcc)
+{
+ assert(nY >= 0 && nY < mpBuffer->mnHeight && "y-coordinate in destination out of range!");
+ SAL_WARN_IF(nY >= rReadAcc.Height(), "vcl", "y-coordinate in source out of range!");
+ SAL_WARN_IF((!HasPalette() || !rReadAcc.HasPalette())
+ && (HasPalette() || rReadAcc.HasPalette()),
+ "vcl", "No copying possible between palette bitmap and TC bitmap!");
+
+ if ((GetScanlineFormat() == rReadAcc.GetScanlineFormat())
+ && (GetScanlineSize() >= rReadAcc.GetScanlineSize()))
+ {
+ memcpy(GetScanline(nY), rReadAcc.GetScanline(nY), rReadAcc.GetScanlineSize());
+ }
+ else
+ {
+ tools::Long nWidth = std::min(mpBuffer->mnWidth, rReadAcc.Width());
+ if (!ImplFastCopyScanline(nY, *ImplGetBitmapBuffer(), *rReadAcc.ImplGetBitmapBuffer()))
+ {
+ Scanline pScanline = GetScanline(nY);
+ Scanline pScanlineRead = rReadAcc.GetScanline(nY);
+ for (tools::Long nX = 0; nX < nWidth; nX++)
+ SetPixelOnData(pScanline, nX, rReadAcc.GetPixelFromData(pScanlineRead, nX));
+ }
+ }
+}
+
+void BitmapWriteAccess::CopyScanline(tools::Long nY, ConstScanline aSrcScanline,
+ ScanlineFormat nSrcScanlineFormat, sal_uInt32 nSrcScanlineSize)
+{
+ const ScanlineFormat nFormat = RemoveScanline(nSrcScanlineFormat);
+
+ assert(nY >= 0 && nY < mpBuffer->mnHeight && "y-coordinate in destination out of range!");
+ DBG_ASSERT((HasPalette() && nFormat <= ScanlineFormat::N8BitPal)
+ || (!HasPalette() && nFormat > ScanlineFormat::N8BitPal),
+ "No copying possible between palette and non palette scanlines!");
+
+ const sal_uLong nCount = std::min(GetScanlineSize(), nSrcScanlineSize);
+
+ if (!nCount)
+ return;
+
+ if (GetScanlineFormat() == RemoveScanline(nSrcScanlineFormat))
+ memcpy(GetScanline(nY), aSrcScanline, nCount);
+ else
+ {
+ if (ImplFastCopyScanline(nY, *ImplGetBitmapBuffer(), aSrcScanline, nSrcScanlineFormat,
+ nSrcScanlineSize))
+ return;
+
+ DBG_ASSERT(nFormat != ScanlineFormat::N32BitTcMask,
+ "No support for pixel formats with color masks yet!");
+ FncGetPixel pFncGetPixel;
+ switch (nFormat)
+ {
+ case ScanlineFormat::N1BitMsbPal:
+ pFncGetPixel = GetPixelForN1BitMsbPal;
+ break;
+ case ScanlineFormat::N1BitLsbPal:
+ pFncGetPixel = GetPixelForN1BitLsbPal;
+ break;
+ case ScanlineFormat::N4BitMsnPal:
+ pFncGetPixel = GetPixelForN4BitMsnPal;
+ break;
+ case ScanlineFormat::N4BitLsnPal:
+ pFncGetPixel = GetPixelForN4BitLsnPal;
+ break;
+ case ScanlineFormat::N8BitPal:
+ pFncGetPixel = GetPixelForN8BitPal;
+ break;
+ case ScanlineFormat::N24BitTcBgr:
+ pFncGetPixel = GetPixelForN24BitTcBgr;
+ break;
+ case ScanlineFormat::N24BitTcRgb:
+ pFncGetPixel = GetPixelForN24BitTcRgb;
+ break;
+ case ScanlineFormat::N32BitTcAbgr:
+ if (Bitmap32IsPreMultipled())
+ pFncGetPixel = GetPixelForN32BitTcAbgr;
+ else
+ pFncGetPixel = GetPixelForN32BitTcXbgr;
+ break;
+ case ScanlineFormat::N32BitTcArgb:
+ if (Bitmap32IsPreMultipled())
+ pFncGetPixel = GetPixelForN32BitTcArgb;
+ else
+ pFncGetPixel = GetPixelForN32BitTcXrgb;
+ break;
+ case ScanlineFormat::N32BitTcBgra:
+ if (Bitmap32IsPreMultipled())
+ pFncGetPixel = GetPixelForN32BitTcBgra;
+ else
+ pFncGetPixel = GetPixelForN32BitTcBgrx;
+ break;
+ case ScanlineFormat::N32BitTcRgba:
+ if (Bitmap32IsPreMultipled())
+ pFncGetPixel = GetPixelForN32BitTcRgba;
+ else
+ pFncGetPixel = GetPixelForN32BitTcRgbx;
+ break;
+ case ScanlineFormat::N32BitTcMask:
+ pFncGetPixel = GetPixelForN32BitTcMask;
+ break;
+
+ default:
+ assert(false);
+ pFncGetPixel = nullptr;
+ break;
+ }
+
+ if (pFncGetPixel)
+ {
+ const ColorMask aDummyMask;
+ Scanline pScanline = GetScanline(nY);
+ for (tools::Long nX = 0, nWidth = mpBuffer->mnWidth; nX < nWidth; ++nX)
+ SetPixelOnData(pScanline, nX, pFncGetPixel(aSrcScanline, nX, aDummyMask));
+ }
+ }
+}
void BitmapWriteAccess::SetLineColor(const Color& rColor)
{
diff --git a/vcl/source/bitmap/Octree.cxx b/vcl/source/bitmap/Octree.cxx
index 8f813315600e..fab0c8374ca8 100644
--- a/vcl/source/bitmap/Octree.cxx
+++ b/vcl/source/bitmap/Octree.cxx
@@ -17,7 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <vcl/bitmapaccess.hxx>
+#include <vcl/BitmapReadAccess.hxx>
#include <bitmap/Octree.hxx>
diff --git a/vcl/source/bitmap/alpha.cxx b/vcl/source/bitmap/alpha.cxx
index a8042aeaed6f..11b2fefba4ce 100644
--- a/vcl/source/bitmap/alpha.cxx
+++ b/vcl/source/bitmap/alpha.cxx
@@ -17,7 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-#include <vcl/bitmapaccess.hxx>
#include <tools/color.hxx>
#include <vcl/alpha.hxx>
#include <bitmapwriteaccess.hxx>
diff --git a/vcl/source/bitmap/bitmap.cxx b/vcl/source/bitmap/bitmap.cxx
index 5c37b3b8269c..c71e5cbe34ec 100644
--- a/vcl/source/bitmap/bitmap.cxx
+++ b/vcl/source/bitmap/bitmap.cxx
@@ -25,7 +25,6 @@
#include <vcl/bitmap.hxx>
#include <vcl/bitmapex.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <vcl/outdev.hxx>
#include <svdata.hxx>
diff --git a/vcl/source/bitmap/bitmappaint.cxx b/vcl/source/bitmap/bitmappaint.cxx
index a1ddb1333785..98c4a37a435a 100644
--- a/vcl/source/bitmap/bitmappaint.cxx
+++ b/vcl/source/bitmap/bitmappaint.cxx
@@ -20,7 +20,6 @@
#include <tools/poly.hxx>
#include <tools/helpers.hxx>
#include <vcl/bitmap.hxx>
-#include <vcl/bitmapaccess.hxx>
#include <vcl/alpha.hxx>
#include <bitmapwriteaccess.hxx>
diff --git a/vcl/source/bitmap/bmpacc.cxx b/vcl/source/bitmap/bmpacc.cxx
deleted file mode 100644
index 18c5769678c5..000000000000
--- a/vcl/source/bitmap/bmpacc.cxx
+++ /dev/null
@@ -1,433 +0,0 @@
-/* -*- 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/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <vcl/bitmap.hxx>
-#include <vcl/bitmapaccess.hxx>
-
-#include <bitmapwriteaccess.hxx>
-#include <salbmp.hxx>
-#include <svdata.hxx>
-#include <salinst.hxx>
-#include <bmpfast.hxx>
-
-#include <string.h>
-#include <sal/log.hxx>
-#include <tools/debug.hxx>
-
-BitmapInfoAccess::BitmapInfoAccess( Bitmap& rBitmap, BitmapAccessMode nMode ) :
- mpBuffer ( nullptr ),
- mnAccessMode ( nMode )
-{
- std::shared_ptr<SalBitmap> xImpBmp = rBitmap.ImplGetSalBitmap();
-
- if( !xImpBmp )
- return;
-
- if (mnAccessMode == BitmapAccessMode::Write)
- {
- xImpBmp->DropScaledCache();
-
- if (xImpBmp.use_count() > 2)
- {
- xImpBmp.reset();
- rBitmap.ImplMakeUnique();
- xImpBmp = rBitmap.ImplGetSalBitmap();
- }
- }
-
- mpBuffer = xImpBmp->AcquireBuffer( mnAccessMode );
-
- if( !mpBuffer )
- {
- std::shared_ptr<SalBitmap> xNewImpBmp(ImplGetSVData()->mpDefInst->CreateSalBitmap());
- if (xNewImpBmp->Create(*xImpBmp, rBitmap.GetBitCount()))
- {
- xImpBmp = xNewImpBmp;
- rBitmap.ImplSetSalBitmap( xImpBmp );
- mpBuffer = xImpBmp->AcquireBuffer( mnAccessMode );
- }
- }
-
- maBitmap = rBitmap;
-}
-
-BitmapInfoAccess::~BitmapInfoAccess()
-{
- std::shared_ptr<SalBitmap> xImpBmp = maBitmap.ImplGetSalBitmap();
-
- if (mpBuffer && xImpBmp)
- {
- xImpBmp->ReleaseBuffer( mpBuffer, mnAccessMode );
- }
-}
-
-sal_uInt16 BitmapInfoAccess::GetBestPaletteIndex( const BitmapColor& rBitmapColor ) const
-{
- return( HasPalette() ? mpBuffer->maPalette.GetBestIndex( rBitmapColor ) : 0 );
-}
-
-BitmapReadAccess::BitmapReadAccess( Bitmap& rBitmap, BitmapAccessMode nMode ) :
- BitmapInfoAccess( rBitmap, nMode ),
- mFncGetPixel ( nullptr ),
- mFncSetPixel ( nullptr )
-{
- if (!mpBuffer)
- return;
-
- const std::shared_ptr<SalBitmap>& xImpBmp = rBitmap.ImplGetSalBitmap();
- if (!xImpBmp)
- return;
-
- maColorMask = mpBuffer->maColorMask;
-
- mFncGetPixel = GetPixelFunction(mpBuffer->mnFormat);
- mFncSetPixel = SetPixelFunction(mpBuffer->mnFormat);
-
- if (!mFncGetPixel || !mFncSetPixel)
- {
- xImpBmp->ReleaseBuffer( mpBuffer, mnAccessMode );
- mpBuffer = nullptr;
- }
-}
-
-BitmapReadAccess::~BitmapReadAccess()
-{
-}
-
-namespace
-{
- bool Bitmap32IsPreMultipled()
- {
- auto pBackendCapabilities = ImplGetSVData()->mpDefInst->GetBackendCapabilities();
- return pBackendCapabilities->mbSupportsBitmap32;
- }
-}
-
-FncGetPixel BitmapReadAccess::GetPixelFunction( ScanlineFormat nFormat )
-{
- switch( RemoveScanline( nFormat ))
- {
- case ScanlineFormat::N1BitMsbPal:
- return GetPixelForN1BitMsbPal;
- case ScanlineFormat::N1BitLsbPal:
- return GetPixelForN1BitLsbPal;
- case ScanlineFormat::N4BitMsnPal:
- return GetPixelForN4BitMsnPal;
- case ScanlineFormat::N4BitLsnPal:
- return GetPixelForN4BitLsnPal;
- case ScanlineFormat::N8BitPal:
- return GetPixelForN8BitPal;
- case ScanlineFormat::N24BitTcBgr:
- return GetPixelForN24BitTcBgr;
- case ScanlineFormat::N24BitTcRgb:
- return GetPixelForN24BitTcRgb;
- case ScanlineFormat::N32BitTcAbgr:
- if (Bitmap32IsPreMultipled())
- return GetPixelForN32BitTcAbgr;
- else
- return GetPixelForN32BitTcXbgr;
- case ScanlineFormat::N32BitTcArgb:
- if (Bitmap32IsPreMultipled())
- return GetPixelForN32BitTcArgb;
- else
- return GetPixelForN32BitTcXrgb;
- case ScanlineFormat::N32BitTcBgra:
- if (Bitmap32IsPreMultipled())
- return GetPixelForN32BitTcBgra;
- else
- return GetPixelForN32BitTcBgrx;
- case ScanlineFormat::N32BitTcRgba:
- if (Bitmap32IsPreMultipled())
- return GetPixelForN32BitTcRgba;
- else
- return GetPixelForN32BitTcRgbx;
- case ScanlineFormat::N32BitTcMask:
- return GetPixelForN32BitTcMask;
-
- default:
- return nullptr;
- }
-}
-
-FncSetPixel BitmapReadAccess::SetPixelFunction( ScanlineFormat nFormat )
-{
- switch( RemoveScanline( nFormat ))
- {
- case ScanlineFormat::N1BitMsbPal:
- return SetPixelForN1BitMsbPal;
- case ScanlineFormat::N1BitLsbPal:
- return SetPixelForN1BitLsbPal;
- case ScanlineFormat::N4BitMsnPal:
- return SetPixelForN4BitMsnPal;
- case ScanlineFormat::N4BitLsnPal:
- return SetPixelForN4BitLsnPal;
- case ScanlineFormat::N8BitPal:
- return SetPixelForN8BitPal;
- case ScanlineFormat::N24BitTcBgr:
- return SetPixelForN24BitTcBgr;
- case ScanlineFormat::N24BitTcRgb:
- return SetPixelForN24BitTcRgb;
- case ScanlineFormat::N32BitTcAbgr:
- if (Bitmap32IsPreMultipled())
- return SetPixelForN32BitTcAbgr;
- else
- return SetPixelForN32BitTcXbgr;
- case ScanlineFormat::N32BitTcArgb:
- if (Bitmap32IsPreMultipled())
- return SetPixelForN32BitTcArgb;
- else
- return SetPixelForN32BitTcXrgb;
- case ScanlineFormat::N32BitTcBgra:
- if (Bitmap32IsPreMultipled())
- return SetPixelForN32BitTcBgra;
- else
- return SetPixelForN32BitTcBgrx;
- case ScanlineFormat::N32BitTcRgba:
- if (Bitmap32IsPreMultipled())
- return SetPixelForN32BitTcRgba;
- else
- return SetPixelForN32BitTcRgbx;
- case ScanlineFormat::N32BitTcMask:
- return SetPixelForN32BitTcMask;
- break;
-
- default:
- return nullptr;
- }
-}
-
-BitmapColor BitmapReadAccess::GetInterpolatedColorWithFallback( double fY, double fX, const BitmapColor& rFallback ) const
-{
- // ask directly doubles >= 0.0 here to avoid rounded values of 0 at small negative
- // double values, e.g. static_cast< sal_Int32 >(-0.25) is 0, not -1, but *has* to be outside (!)
- if(mpBuffer && fX >= 0.0 && fY >= 0.0)
- {
- const sal_Int64 nX(static_cast<sal_Int64>(fX));
- const sal_Int64 nY(static_cast<sal_Int64>(fY));
-
- if(nX < mpBuffer->mnWidth && nY < mpBuffer->mnHeight)
- {
- // get base-return value from inside pixel
- BitmapColor aRetval(GetColor(nY, nX));
-
- // calculate deltas and indices for neighbour accesses
- sal_Int16 nDeltaX((fX - (nX + 0.5)) * 255.0); // [-255 .. 255]
- sal_Int16 nDeltaY((fY - (nY + 0.5)) * 255.0); // [-255 .. 255]
- sal_Int16 nIndX(0);
- sal_Int16 nIndY(0);
-
- if(nDeltaX > 0)
- {
- nIndX = nX + 1;
- }
- else
- {
- nIndX = nX - 1;
- nDeltaX = -nDeltaX;
- }
-
- if(nDeltaY > 0)
- {
- nIndY = nY + 1;
- }
- else
- {
- nIndY = nY - 1;
- nDeltaY = -nDeltaY;
- }
-
- // get right/left neighbour
- BitmapColor aXCol(rFallback);
-
- if(nDeltaX && nIndX >= 0 && nIndX < mpBuffer->mnWidth)
- {
- aXCol = GetColor(nY, nIndX);
- }
-
- // get top/bottom neighbour
- BitmapColor aYCol(rFallback);
-
- if(nDeltaY && nIndY >= 0 && nIndY < mpBuffer->mnHeight)
- {
- aYCol = GetColor(nIndY, nX);
- }
-
- // get one of four edge neighbours
- BitmapColor aXYCol(rFallback);
-
- if(nDeltaX && nDeltaY && nIndX >=0 && nIndY >= 0 && nIndX < mpBuffer->mnWidth && nIndY < mpBuffer->mnHeight)
- {
- aXYCol = GetColor(nIndY, nIndX);
- }
-
- // merge return value with right/left neighbour
- if(aXCol != aRetval)
- {
- aRetval.Merge(aXCol, 255 - nDeltaX);
- }
-
- // merge top/bottom neighbour with edge
- if(aYCol != aXYCol)
- {
- aYCol.Merge(aXYCol, 255 - nDeltaX);
- }
-
- // merge return value with already merged top/bottom neighbour
- if(aRetval != aYCol)
- {
- aRetval.Merge(aYCol, 255 - nDeltaY);
- }
-
- return aRetval;
- }
- }
-
- return rFallback;
-}
-
-BitmapColor BitmapReadAccess::GetColorWithFallback( double fY, double fX, const BitmapColor& rFallback ) const
-{
- // ask directly doubles >= 0.0 here to avoid rounded values of 0 at small negative
- // double values, e.g. static_cast< sal_Int32 >(-0.25) is 0, not -1, but *has* to be outside (!)
- if(mpBuffer && fX >= 0.0 && fY >= 0.0)
- {
- const sal_Int32 nX(static_cast< sal_Int32 >(fX));
- const sal_Int32 nY(static_cast< sal_Int32 >(fY));
-
- if(nX < mpBuffer->mnWidth && nY < mpBuffer->mnHeight)
- {
- return GetColor(nY, nX);
- }
- }
-
- return rFallback;
-}
-
-BitmapWriteAccess::BitmapWriteAccess(Bitmap& rBitmap)
- : BitmapReadAccess(rBitmap, BitmapAccessMode::Write)
-{
-}
-
-BitmapWriteAccess::~BitmapWriteAccess()
-{
-}
-
-void BitmapWriteAccess::CopyScanline( tools::Long nY, const BitmapReadAccess& rReadAcc )
-{
- assert(nY >= 0 && nY < mpBuffer->mnHeight && "y-coordinate in destination out of range!");
- SAL_WARN_IF( nY >= rReadAcc.Height(), "vcl", "y-coordinate in source out of range!" );
- SAL_WARN_IF( ( !HasPalette() || !rReadAcc.HasPalette() ) && ( HasPalette() || rReadAcc.HasPalette() ), "vcl", "No copying possible between palette bitmap and TC bitmap!" );
-
- if( ( GetScanlineFormat() == rReadAcc.GetScanlineFormat() ) &&
- ( GetScanlineSize() >= rReadAcc.GetScanlineSize() ) )
- {
- memcpy(GetScanline(nY), rReadAcc.GetScanline(nY), rReadAcc.GetScanlineSize());
- }
- else
- {
- tools::Long nWidth = std::min( mpBuffer->mnWidth, rReadAcc.Width() );
- if(!ImplFastCopyScanline( nY, *ImplGetBitmapBuffer(), *rReadAcc.ImplGetBitmapBuffer()))
- {
- Scanline pScanline = GetScanline( nY );
- Scanline pScanlineRead = rReadAcc.GetScanline(nY);
- for( tools::Long nX = 0; nX < nWidth; nX++ )
- SetPixelOnData( pScanline, nX, rReadAcc.GetPixelFromData( pScanlineRead, nX ) );
- }
- }
-}
-
-void BitmapWriteAccess::CopyScanline( tools::Long nY, ConstScanline aSrcScanline,
- ScanlineFormat nSrcScanlineFormat, sal_uInt32 nSrcScanlineSize )
-{
- const ScanlineFormat nFormat = RemoveScanline( nSrcScanlineFormat );
-
- assert(nY >= 0 && nY < mpBuffer->mnHeight && "y-coordinate in destination out of range!");
- DBG_ASSERT( ( HasPalette() && nFormat <= ScanlineFormat::N8BitPal ) ||
- ( !HasPalette() && nFormat > ScanlineFormat::N8BitPal ),
- "No copying possible between palette and non palette scanlines!" );
-
- const sal_uLong nCount = std::min( GetScanlineSize(), nSrcScanlineSize );
-
- if( !nCount )
- return;
-
- if( GetScanlineFormat() == RemoveScanline( nSrcScanlineFormat ) )
- memcpy(GetScanline(nY), aSrcScanline, nCount);
- else
- {
- if(ImplFastCopyScanline( nY, *ImplGetBitmapBuffer(), aSrcScanline, nSrcScanlineFormat, nSrcScanlineSize ))
- return;
-
- DBG_ASSERT( nFormat != ScanlineFormat::N32BitTcMask,
- "No support for pixel formats with color masks yet!" );
- FncGetPixel pFncGetPixel;
- switch( nFormat )
- {
- case ScanlineFormat::N1BitMsbPal: pFncGetPixel = GetPixelForN1BitMsbPal; break;
- case ScanlineFormat::N1BitLsbPal: pFncGetPixel = GetPixelForN1BitLsbPal; break;
- case ScanlineFormat::N4BitMsnPal: pFncGetPixel = GetPixelForN4BitMsnPal; break;
- case ScanlineFormat::N4BitLsnPal: pFncGetPixel = GetPixelForN4BitLsnPal; break;
- case ScanlineFormat::N8BitPal: pFncGetPixel = GetPixelForN8BitPal; break;
- case ScanlineFormat::N24BitTcBgr: pFncGetPixel = GetPixelForN24BitTcBgr; break;
- case ScanlineFormat::N24BitTcRgb: pFncGetPixel = GetPixelForN24BitTcRgb; break;
- case ScanlineFormat::N32BitTcAbgr:
- if (Bitmap32IsPreMultipled())
- pFncGetPixel = GetPixelForN32BitTcAbgr;
- else
- pFncGetPixel = GetPixelForN32BitTcXbgr;
- break;
- case ScanlineFormat::N32BitTcArgb:
- if (Bitmap32IsPreMultipled())
- pFncGetPixel = GetPixelForN32BitTcArgb;
- else
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list