LibreOffice Module vcl (master)  1
BitmapReadAccess.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  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_VCL_BITMAPREADACCESS_HXX
21 #define INCLUDED_VCL_BITMAPREADACCESS_HXX
22 
23 #include <vcl/dllapi.h>
24 #include <vcl/bitmap.hxx>
25 #include <vcl/Scanline.hxx>
26 #include <vcl/BitmapBuffer.hxx>
27 #include <vcl/BitmapColor.hxx>
28 #include <vcl/BitmapAccessMode.hxx>
29 #include <vcl/BitmapInfoAccess.hxx>
30 
32 {
33  friend class BitmapWriteAccess;
34 
35 public:
37  virtual ~BitmapReadAccess() override;
38 
40  {
41  assert(mpBuffer && "Access is not valid!");
42 
43  return mpBuffer ? mpBuffer->mpBits : nullptr;
44  }
45 
47  {
48  assert(mpBuffer && "Access is not valid!");
49  assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!");
50 
52  {
53  return mpBuffer->mpBits + (nY * mpBuffer->mnScanlineSize);
54  }
55  return mpBuffer->mpBits + ((mpBuffer->mnHeight - 1 - nY) * mpBuffer->mnScanlineSize);
56  }
57 
59  {
60  assert(pData && "Access is not valid!");
61 
62  return mFncGetPixel(pData, nX, maColorMask);
63  }
64 
66  {
67  return GetPixelFromData(pData, nX).GetIndex();
68  }
69 
70  void SetPixelOnData(sal_uInt8* pData, tools::Long nX, const BitmapColor& rBitmapColor)
71  {
72  assert(pData && "Access is not valid!");
73 
74  mFncSetPixel(pData, nX, rBitmapColor, maColorMask);
75  }
76 
78  {
79  assert(mpBuffer && "Access is not valid!");
80  assert(nX < mpBuffer->mnWidth && "x-coordinate out of range!");
81  assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!");
82 
83  return mFncGetPixel(GetScanline(nY), nX, maColorMask);
84  }
85 
86  BitmapColor GetPixel(const Point& point) const { return GetPixel(point.Y(), point.X()); }
87 
89  {
90  if (HasPalette())
91  return mpBuffer->maPalette[GetPixelIndex(nY, nX)];
92  else
93  return GetPixel(nY, nX);
94  }
95 
96  BitmapColor GetColor(const Point& point) const { return GetColor(point.Y(), point.X()); }
97 
99  {
100  return GetPixel(nY, nX).GetIndex();
101  }
102 
103  sal_uInt8 GetPixelIndex(const Point& point) const
104  {
105  return GetPixelIndex(point.Y(), point.X());
106  }
107 
109  BitmapColor GetInterpolatedColorWithFallback(double fY, double fX,
110  const BitmapColor& rFallback) const;
111 
114  BitmapColor GetColorWithFallback(double fY, double fX, const BitmapColor& rFallback) const;
115 
116 private:
117  BitmapReadAccess(const BitmapReadAccess&) = delete;
118  BitmapReadAccess& operator=(const BitmapReadAccess&) = delete;
119 
120 protected:
123 
124 public:
125  SAL_DLLPRIVATE BitmapBuffer* ImplGetBitmapBuffer() const { return mpBuffer; }
126 
128  const ColorMask& rMask);
130  const ColorMask& rMask);
132  const ColorMask& rMask);
134  const ColorMask& rMask);
136  const ColorMask& rMask);
138  const ColorMask& rMask);
140  const ColorMask& rMask);
142  const ColorMask& rMask);
144  const ColorMask& rMask);
146  const ColorMask& rMask);
148  const ColorMask& rMask);
150  const ColorMask& rMask);
152  const ColorMask& rMask);
154  const ColorMask& rMask);
155 
156  static void SetPixelForN1BitMsbPal(Scanline pScanline, tools::Long nX,
157  const BitmapColor& rBitmapColor, const ColorMask& rMask);
158  static void SetPixelForN1BitLsbPal(Scanline pScanline, tools::Long nX,
159  const BitmapColor& rBitmapColor, const ColorMask& rMask);
160  static void SetPixelForN8BitPal(Scanline pScanline, tools::Long nX,
161  const BitmapColor& rBitmapColor, const ColorMask& rMask);
162  static void SetPixelForN24BitTcBgr(Scanline pScanline, tools::Long nX,
163  const BitmapColor& rBitmapColor, const ColorMask& rMask);
164  static void SetPixelForN24BitTcRgb(Scanline pScanline, tools::Long nX,
165  const BitmapColor& rBitmapColor, const ColorMask& rMask);
166  static void SetPixelForN32BitTcAbgr(Scanline pScanline, tools::Long nX,
167  const BitmapColor& rBitmapColor, const ColorMask& rMask);
168  static void SetPixelForN32BitTcXbgr(Scanline pScanline, tools::Long nX,
169  const BitmapColor& rBitmapColor, const ColorMask& rMask);
170  static void SetPixelForN32BitTcArgb(Scanline pScanline, tools::Long nX,
171  const BitmapColor& rBitmapColor, const ColorMask& rMask);
172  static void SetPixelForN32BitTcXrgb(Scanline pScanline, tools::Long nX,
173  const BitmapColor& rBitmapColor, const ColorMask& rMask);
174  static void SetPixelForN32BitTcBgra(Scanline pScanline, tools::Long nX,
175  const BitmapColor& rBitmapColor, const ColorMask& rMask);
176  static void SetPixelForN32BitTcBgrx(Scanline pScanline, tools::Long nX,
177  const BitmapColor& rBitmapColor, const ColorMask& rMask);
178  static void SetPixelForN32BitTcRgba(Scanline pScanline, tools::Long nX,
179  const BitmapColor& rBitmapColor, const ColorMask& rMask);
180  static void SetPixelForN32BitTcRgbx(Scanline pScanline, tools::Long nX,
181  const BitmapColor& rBitmapColor, const ColorMask& rMask);
182  static void SetPixelForN32BitTcMask(Scanline pScanline, tools::Long nX,
183  const BitmapColor& rBitmapColor, const ColorMask& rMask);
184 
187 };
188 
189 #endif // INCLUDED_VCL_BITMAPREADACCESS_HXX
190 
191 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
double mnHeight
static BitmapColor GetPixelForN1BitMsbPal(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
sal_uInt8 GetIndexFromData(const sal_uInt8 *pData, tools::Long nX) const
Scanline GetBuffer() const
static void SetPixelForN32BitTcBgra(Scanline pScanline, tools::Long nX, const BitmapColor &rBitmapColor, const ColorMask &rMask)
sal_uInt8 GetIndex() const
Definition: BitmapColor.hxx:70
sal_uInt8 GetPixelIndex(tools::Long nY, tools::Long nX) const
static BitmapColor GetPixelForN32BitTcRgbx(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
static BitmapColor GetPixelForN32BitTcXbgr(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
static void SetPixelForN32BitTcArgb(Scanline pScanline, tools::Long nX, const BitmapColor &rBitmapColor, const ColorMask &rMask)
static FncSetPixel SetPixelFunction(ScanlineFormat nFormat)
BitmapColor GetColorWithFallback(double fY, double fX, const BitmapColor &rFallback) const
Get the color at coordinates fY, fX; if outside, return rFallback.
virtual ~BitmapReadAccess() override
static void SetPixelForN32BitTcXbgr(Scanline pScanline, tools::Long nX, const BitmapColor &rBitmapColor, const ColorMask &rMask)
tools::Long mnHeight
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
sal_uInt8 GetPixelIndex(const Point &point) const
long Long
static BitmapColor GetPixelForN32BitTcXrgb(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
void SetPixelOnData(sal_uInt8 *pData, tools::Long nX, const BitmapColor &rBitmapColor)
ScanlineFormat
Definition: Scanline.hxx:29
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
Scanline GetScanline(tools::Long nY) const
static void SetPixelForN1BitMsbPal(Scanline pScanline, tools::Long nX, const BitmapColor &rBitmapColor, const ColorMask &rMask)
BitmapColor GetInterpolatedColorWithFallback(double fY, double fX, const BitmapColor &rFallback) const
Get the interpolated color at coordinates fY, fX; if outside, return rFallback.
void(* FncSetPixel)(Scanline pScanline, tools::Long nX, const BitmapColor &rBitmapColor, const ColorMask &rMask)
BitmapBuffer * mpBuffer
static void SetPixelForN32BitTcBgrx(Scanline pScanline, tools::Long nX, const BitmapColor &rBitmapColor, const ColorMask &rMask)
static void SetPixelForN32BitTcMask(Scanline pScanline, tools::Long nX, const BitmapColor &rBitmapColor, const ColorMask &rMask)
SAL_DLLPRIVATE BitmapBuffer * ImplGetBitmapBuffer() const
ScanlineFormat mnFormat
FncGetPixel mFncGetPixel
sal_uInt8 * Scanline
Definition: Scanline.hxx:26
BitmapColor GetPixel(const Point &point) const
bool HasPalette() const
static BitmapColor GetPixelForN24BitTcBgr(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
static void SetPixelForN1BitLsbPal(Scanline pScanline, tools::Long nX, const BitmapColor &rBitmapColor, const ColorMask &rMask)
static BitmapColor GetPixelForN32BitTcBgrx(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
BitmapColor GetColor(tools::Long nY, tools::Long nX) const
static BitmapColor GetPixelForN32BitTcMask(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
static BitmapColor GetPixelForN32BitTcRgba(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
BitmapAccessMode
static void SetPixelForN32BitTcRgbx(Scanline pScanline, tools::Long nX, const BitmapColor &rBitmapColor, const ColorMask &rMask)
sal_uInt8 * mpBits
static BitmapColor GetPixelForN1BitLsbPal(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
friend class BitmapReadAccess
static BitmapColor GetPixelForN32BitTcAbgr(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
FncSetPixel mFncSetPixel
const sal_uInt8 * ConstScanline
Definition: Scanline.hxx:27
static BitmapColor GetPixelForN8BitPal(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
static FncGetPixel GetPixelFunction(ScanlineFormat nFormat)
static BitmapColor GetPixelForN32BitTcBgra(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
tools::Long mnScanlineSize
unsigned char sal_uInt8
BitmapColor GetColor(const Point &point) const
static void SetPixelForN32BitTcXrgb(Scanline pScanline, tools::Long nX, const BitmapColor &rBitmapColor, const ColorMask &rMask)
static BitmapColor GetPixelForN24BitTcRgb(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
double mnWidth
BitmapColor GetPixelFromData(const sal_uInt8 *pData, tools::Long nX) const
BitmapPalette maPalette
BitmapColor(* FncGetPixel)(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
static void SetPixelForN8BitPal(Scanline pScanline, tools::Long nX, const BitmapColor &rBitmapColor, const ColorMask &rMask)
static void SetPixelForN24BitTcRgb(Scanline pScanline, tools::Long nX, const BitmapColor &rBitmapColor, const ColorMask &rMask)
static void SetPixelForN24BitTcBgr(Scanline pScanline, tools::Long nX, const BitmapColor &rBitmapColor, const ColorMask &rMask)
BitmapColor GetPixel(tools::Long nY, tools::Long nX) const
BitmapInfoAccess & operator=(const BitmapInfoAccess &)=delete
static BitmapColor GetPixelForN32BitTcArgb(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
static void SetPixelForN32BitTcAbgr(Scanline pScanline, tools::Long nX, const BitmapColor &rBitmapColor, const ColorMask &rMask)
static void SetPixelForN32BitTcRgba(Scanline pScanline, tools::Long nX, const BitmapColor &rBitmapColor, const ColorMask &rMask)