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_BITMAPWRITEACCESS_HXX
12 #define INCLUDED_VCL_INC_BITMAPWRITEACCESS_HXX
13 
14 #include <vcl/alpha.hxx>
15 #include <vcl/bitmap.hxx>
16 #include <vcl/bitmapaccess.hxx>
17 #include <boost/optional.hpp>
18 
21 
24 
26 {
27 public:
28  BitmapWriteAccess(Bitmap& rBitmap);
29  virtual ~BitmapWriteAccess() override;
30 
31  void CopyScanline(long nY, const BitmapReadAccess& rReadAcc);
32  void CopyScanline(long nY, ConstScanline aSrcScanline, ScanlineFormat nSrcScanlineFormat,
33  sal_uInt32 nSrcScanlineSize);
34 
35  void CopyBuffer(const BitmapReadAccess& rReadAcc);
36 
37  void SetPalette(const BitmapPalette& rPalette)
38  {
39  assert(mpBuffer && "Access is not valid!");
40 
41  mpBuffer->maPalette = rPalette;
42  }
43 
44  void SetPaletteEntryCount(sal_uInt16 nCount)
45  {
46  assert(mpBuffer && "Access is not valid!");
47 
48  mpBuffer->maPalette.SetEntryCount(nCount);
49  }
50 
51  void SetPaletteColor(sal_uInt16 nColor, const BitmapColor& rBitmapColor)
52  {
53  assert(mpBuffer && "Access is not valid!");
54  assert(HasPalette() && "Bitmap has no palette!");
55 
56  mpBuffer->maPalette[nColor] = rBitmapColor;
57  }
58 
59  void SetPixel(long nY, long nX, const BitmapColor& rBitmapColor)
60  {
61  assert(mpBuffer && "Access is not valid!");
62  assert(nX < mpBuffer->mnWidth && "x-coordinate out of range!");
63  assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!");
64 
65  mFncSetPixel(GetScanline(nY), nX, rBitmapColor, maColorMask);
66  }
67 
68  void SetPixelIndex(long nY, long nX, sal_uInt8 cIndex)
69  {
70  SetPixel(nY, nX, BitmapColor(cIndex));
71  }
72 
73  void SetLineColor(const Color& rColor);
74 
75  void SetFillColor();
76  void SetFillColor(const Color& rColor);
77 
78  void Erase(const Color& rColor);
79 
80  void DrawLine(const Point& rStart, const Point& rEnd);
81 
82  void FillRect(const tools::Rectangle& rRect);
83  void DrawRect(const tools::Rectangle& rRect);
84 
85 private:
88 
89  BitmapWriteAccess() = delete;
90  BitmapWriteAccess(const BitmapWriteAccess&) = delete;
92 };
93 
94 #endif
95 
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
double mnHeight
Scanline GetScanline(long nY) const
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
void SetPixel(long nY, long nX, const BitmapColor &rBitmapColor)
vcl::ScopedBitmapAccess< BitmapWriteAccess, Bitmap,&Bitmap::AcquireWriteAccess > BitmapScopedWriteAccess
boost::optional< BitmapColor > mpLineColor
void SetPalette(const BitmapPalette &rPalette)
ScanlineFormat
Definition: Scanline.hxx:28
bool HasPalette() const
boost::optional< BitmapColor > mpFillColor
FncSetPixel mFncSetPixel
const sal_uInt8 * ConstScanline
Definition: Scanline.hxx:26
unsigned char sal_uInt8
double mnWidth
vcl::ScopedBitmapAccess< BitmapWriteAccess, AlphaMask,&AlphaMask::AcquireAlphaWriteAccess > AlphaScopedWriteAccess
void SetLineColor(const css::uno::Reference< css::beans::XPropertySet > &xGridProperties, sal_Int32 nColor)
friend class BitmapWriteAccess
void SetPaletteEntryCount(sal_uInt16 nCount)
void SetPaletteColor(sal_uInt16 nColor, const BitmapColor &rBitmapColor)
void SetPixelIndex(long nY, long nX, sal_uInt8 cIndex)
BitmapReadAccess & operator=(const BitmapReadAccess &)=delete