From 940b4d1848e8c70ab7642901a68594e8016caffc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 18:51:28 +0200 Subject: Adding upstream version 1:7.0.4. Signed-off-by: Daniel Baumann --- vcl/inc/bitmapwriteaccess.hxx | 94 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 vcl/inc/bitmapwriteaccess.hxx (limited to 'vcl/inc/bitmapwriteaccess.hxx') diff --git a/vcl/inc/bitmapwriteaccess.hxx b/vcl/inc/bitmapwriteaccess.hxx new file mode 100644 index 000000000..f747223ec --- /dev/null +++ b/vcl/inc/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_BITMAPWRITEACCESS_HXX +#define INCLUDED_VCL_INC_BITMAPWRITEACCESS_HXX + +#include +#include +#include +#include + +typedef vcl::ScopedBitmapAccess + BitmapScopedWriteAccess; + +typedef vcl::ScopedBitmapAccess + AlphaScopedWriteAccess; + +class VCL_DLLPUBLIC BitmapWriteAccess : public BitmapReadAccess +{ +public: + BitmapWriteAccess(Bitmap& rBitmap); + virtual ~BitmapWriteAccess() override; + + void CopyScanline(long nY, const BitmapReadAccess& rReadAcc); + void CopyScanline(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(long nY, 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(long nY, 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 mpLineColor; + std::optional mpFillColor; + + BitmapWriteAccess() = delete; + BitmapWriteAccess(const BitmapWriteAccess&) = delete; + BitmapWriteAccess& operator=(const BitmapWriteAccess&) = delete; +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3