summaryrefslogtreecommitdiffstats
path: root/vcl/inc/bitmap/BitmapWriteAccess.hxx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
commited5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch)
tree7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /vcl/inc/bitmap/BitmapWriteAccess.hxx
parentInitial commit. (diff)
downloadlibreoffice-cb75148ebd0135178ff46f89a30139c44f8d2040.tar.xz
libreoffice-cb75148ebd0135178ff46f89a30139c44f8d2040.zip
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vcl/inc/bitmap/BitmapWriteAccess.hxx')
-rw-r--r--vcl/inc/bitmap/BitmapWriteAccess.hxx94
1 files changed, 94 insertions, 0 deletions
diff --git a/vcl/inc/bitmap/BitmapWriteAccess.hxx b/vcl/inc/bitmap/BitmapWriteAccess.hxx
new file mode 100644
index 000000000..bc903769d
--- /dev/null
+++ b/vcl/inc/bitmap/BitmapWriteAccess.hxx
@@ -0,0 +1,94 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#ifndef INCLUDED_VCL_INC_BITMAP_BITMAPWRITEACCESS_HXX
+#define INCLUDED_VCL_INC_BITMAP_BITMAPWRITEACCESS_HXX
+
+#include <vcl/alpha.hxx>
+#include <vcl/bitmap.hxx>
+#include <vcl/BitmapReadAccess.hxx>
+#include <optional>
+
+typedef vcl::ScopedBitmapAccess<BitmapWriteAccess, Bitmap, &Bitmap::AcquireWriteAccess>
+ BitmapScopedWriteAccess;
+
+typedef vcl::ScopedBitmapAccess<BitmapWriteAccess, AlphaMask, &AlphaMask::AcquireAlphaWriteAccess>
+ AlphaScopedWriteAccess;
+
+class VCL_DLLPUBLIC BitmapWriteAccess final : public BitmapReadAccess
+{
+public:
+ BitmapWriteAccess(Bitmap& rBitmap);
+ virtual ~BitmapWriteAccess() override;
+
+ void CopyScanline(tools::Long nY, const BitmapReadAccess& rReadAcc);
+ void CopyScanline(tools::Long nY, ConstScanline aSrcScanline, ScanlineFormat nSrcScanlineFormat,
+ sal_uInt32 nSrcScanlineSize);
+
+ void SetPalette(const BitmapPalette& rPalette)
+ {
+ assert(mpBuffer && "Access is not valid!");
+
+ mpBuffer->maPalette = rPalette;
+ }
+
+ void SetPaletteEntryCount(sal_uInt16 nCount)
+ {
+ assert(mpBuffer && "Access is not valid!");
+
+ mpBuffer->maPalette.SetEntryCount(nCount);
+ }
+
+ void SetPaletteColor(sal_uInt16 nColor, const BitmapColor& rBitmapColor)
+ {
+ assert(mpBuffer && "Access is not valid!");
+ assert(HasPalette() && "Bitmap has no palette!");
+
+ mpBuffer->maPalette[nColor] = rBitmapColor;
+ }
+
+ void SetPixel(tools::Long nY, tools::Long nX, const BitmapColor& rBitmapColor)
+ {
+ assert(mpBuffer && "Access is not valid!");
+ assert(nX < mpBuffer->mnWidth && "x-coordinate out of range!");
+ assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!");
+
+ mFncSetPixel(GetScanline(nY), nX, rBitmapColor, maColorMask);
+ }
+
+ void SetPixelIndex(tools::Long nY, tools::Long nX, sal_uInt8 cIndex)
+ {
+ SetPixel(nY, nX, BitmapColor(cIndex));
+ }
+
+ void SetLineColor(const Color& rColor);
+
+ void SetFillColor();
+ void SetFillColor(const Color& rColor);
+
+ void Erase(const Color& rColor);
+
+ void DrawLine(const Point& rStart, const Point& rEnd);
+
+ void FillRect(const tools::Rectangle& rRect);
+ void DrawRect(const tools::Rectangle& rRect);
+
+private:
+ std::optional<BitmapColor> mpLineColor;
+ std::optional<BitmapColor> mpFillColor;
+
+ BitmapWriteAccess() = delete;
+ BitmapWriteAccess(const BitmapWriteAccess&) = delete;
+ BitmapWriteAccess& operator=(const BitmapWriteAccess&) = delete;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */