LibreOffice Module vcl (master) 1
BitmapWriteAccess.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 */
10
11#ifndef INCLUDED_VCL_INC_BITMAP_BITMAPWRITEACCESS_HXX
12#define INCLUDED_VCL_INC_BITMAP_BITMAPWRITEACCESS_HXX
13
14#include <vcl/alpha.hxx>
15#include <vcl/bitmap.hxx>
17#include <optional>
18
21
24
26{
27public:
28 BitmapWriteAccess(Bitmap& rBitmap);
29 virtual ~BitmapWriteAccess() override;
30
31 void CopyScanline(tools::Long nY, const BitmapReadAccess& rReadAcc);
32 void CopyScanline(tools::Long nY, ConstScanline aSrcScanline, ScanlineFormat nSrcScanlineFormat,
33 sal_uInt32 nSrcScanlineSize);
34
35 void SetPalette(const BitmapPalette& rPalette)
36 {
37 assert(mpBuffer && "Access is not valid!");
38
39 mpBuffer->maPalette = rPalette;
40 }
41
42 void SetPaletteColor(sal_uInt16 nColor, const BitmapColor& rBitmapColor)
43 {
44 assert(mpBuffer && "Access is not valid!");
45 assert(HasPalette() && "Bitmap has no palette!");
46
47 mpBuffer->maPalette[nColor] = rBitmapColor;
48 }
49
50 void SetPixel(tools::Long nY, tools::Long nX, const BitmapColor& rBitmapColor)
51 {
52 assert(mpBuffer && "Access is not valid!");
53 assert(nX < mpBuffer->mnWidth && "x-coordinate out of range!");
54 assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!");
55
56 mFncSetPixel(GetScanline(nY), nX, rBitmapColor, maColorMask);
57 }
58
60 {
61 SetPixel(nY, nX, BitmapColor(cIndex));
62 }
63
64 void SetLineColor(const Color& rColor);
65
66 void SetFillColor();
67 void SetFillColor(const Color& rColor);
68
69 void Erase(const Color& rColor);
70
71 void DrawLine(const Point& rStart, const Point& rEnd);
72
73 void FillRect(const tools::Rectangle& rRect);
74 void DrawRect(const tools::Rectangle& rRect);
75
76private:
77 std::optional<BitmapColor> mpLineColor;
78 std::optional<BitmapColor> mpFillColor;
79
83};
84
85#endif
86
87/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
vcl::ScopedBitmapAccess< BitmapWriteAccess, AlphaMask, &AlphaMask::AcquireAlphaWriteAccess > AlphaScopedWriteAccess
vcl::ScopedBitmapAccess< BitmapWriteAccess, Bitmap, &Bitmap::AcquireWriteAccess > BitmapScopedWriteAccess
const sal_uInt8 * ConstScanline
Definition: Scanline.hxx:27
ScanlineFormat
Definition: Scanline.hxx:29
bool HasPalette() const
FncSetPixel mFncSetPixel
Scanline GetScanline(tools::Long nY) const
friend class BitmapWriteAccess
std::optional< BitmapColor > mpLineColor
void SetPalette(const BitmapPalette &rPalette)
void SetPaletteColor(sal_uInt16 nColor, const BitmapColor &rBitmapColor)
void SetPixelIndex(tools::Long nY, tools::Long nX, sal_uInt8 cIndex)
BitmapWriteAccess()=delete
void SetPixel(tools::Long nY, tools::Long nX, const BitmapColor &rBitmapColor)
BitmapWriteAccess(const BitmapWriteAccess &)=delete
std::optional< BitmapColor > mpFillColor
BitmapWriteAccess & operator=(const BitmapWriteAccess &)=delete
This template handles BitmapAccess the RAII way.
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
void SetLineColor(const css::uno::Reference< css::beans::XPropertySet > &xGridProperties, sal_Int32 nColor)
void DrawLine(OutputDevice &rDev, const basegfx::B2DPoint &rP1, const basegfx::B2DPoint &rP2, sal_uInt32 nWidth, SvxBorderLineStyle nDashing)
long Long
double mnWidth
double mnHeight
unsigned char sal_uInt8