1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
11 #ifndef INCLUDED_VCL_INC_BITMAP_BITMAPWRITEACCESS_HXX
12 #define INCLUDED_VCL_INC_BITMAP_BITMAPWRITEACCESS_HXX
14 #include <vcl/alpha.hxx>
15 #include <vcl/bitmap.hxx>
16 #include <vcl/BitmapReadAccess.hxx>
19 typedef vcl::ScopedBitmapAccess
<BitmapWriteAccess
, Bitmap
, &Bitmap::AcquireWriteAccess
>
20 BitmapScopedWriteAccess
;
22 typedef vcl::ScopedBitmapAccess
<BitmapWriteAccess
, AlphaMask
, &AlphaMask::AcquireAlphaWriteAccess
>
23 AlphaScopedWriteAccess
;
25 class VCL_DLLPUBLIC BitmapWriteAccess
: public BitmapReadAccess
28 BitmapWriteAccess(Bitmap
& rBitmap
);
29 virtual ~BitmapWriteAccess() override
;
31 void CopyScanline(tools::Long nY
, const BitmapReadAccess
& rReadAcc
);
32 void CopyScanline(tools::Long nY
, ConstScanline aSrcScanline
, ScanlineFormat nSrcScanlineFormat
,
33 sal_uInt32 nSrcScanlineSize
);
35 void SetPalette(const BitmapPalette
& rPalette
)
37 assert(mpBuffer
&& "Access is not valid!");
39 mpBuffer
->maPalette
= rPalette
;
42 void SetPaletteEntryCount(sal_uInt16 nCount
)
44 assert(mpBuffer
&& "Access is not valid!");
46 mpBuffer
->maPalette
.SetEntryCount(nCount
);
49 void SetPaletteColor(sal_uInt16 nColor
, const BitmapColor
& rBitmapColor
)
51 assert(mpBuffer
&& "Access is not valid!");
52 assert(HasPalette() && "Bitmap has no palette!");
54 mpBuffer
->maPalette
[nColor
] = rBitmapColor
;
57 void SetPixel(tools::Long nY
, tools::Long nX
, const BitmapColor
& rBitmapColor
)
59 assert(mpBuffer
&& "Access is not valid!");
60 assert(nX
< mpBuffer
->mnWidth
&& "x-coordinate out of range!");
61 assert(nY
< mpBuffer
->mnHeight
&& "y-coordinate out of range!");
63 mFncSetPixel(GetScanline(nY
), nX
, rBitmapColor
, maColorMask
);
66 void SetPixelIndex(tools::Long nY
, tools::Long nX
, sal_uInt8 cIndex
)
68 SetPixel(nY
, nX
, BitmapColor(cIndex
));
71 void SetLineColor(const Color
& rColor
);
74 void SetFillColor(const Color
& rColor
);
76 void Erase(const Color
& rColor
);
78 void DrawLine(const Point
& rStart
, const Point
& rEnd
);
80 void FillRect(const tools::Rectangle
& rRect
);
81 void DrawRect(const tools::Rectangle
& rRect
);
84 std::optional
<BitmapColor
> mpLineColor
;
85 std::optional
<BitmapColor
> mpFillColor
;
87 BitmapWriteAccess() = delete;
88 BitmapWriteAccess(const BitmapWriteAccess
&) = delete;
89 BitmapWriteAccess
& operator=(const BitmapWriteAccess
&) = delete;
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */