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>
30
31class SAL_DLLPUBLIC_RTTI BitmapReadAccess : public BitmapInfoAccess
32{
33 friend class BitmapWriteAccess;
34
35public:
38 VCL_DLLPUBLIC virtual ~BitmapReadAccess() override;
39
41 {
42 assert(mpBuffer && "Access is not valid!");
43
44 return mpBuffer ? mpBuffer->mpBits : nullptr;
45 }
46
48 {
49 assert(mpBuffer && "Access is not valid!");
50 assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!");
51
53 {
54 return mpBuffer->mpBits + (nY * mpBuffer->mnScanlineSize);
55 }
56 return mpBuffer->mpBits + ((mpBuffer->mnHeight - 1 - nY) * mpBuffer->mnScanlineSize);
57 }
58
60 {
61 assert(pData && "Access is not valid!");
62
63 return mFncGetPixel(pData, nX, maColorMask);
64 }
65
67 {
68 return GetPixelFromData(pData, nX).GetIndex();
69 }
70
71 void SetPixelOnData(sal_uInt8* pData, tools::Long nX, const BitmapColor& rBitmapColor)
72 {
73 assert(pData && "Access is not valid!");
74
75 mFncSetPixel(pData, nX, rBitmapColor, maColorMask);
76 }
77
79 {
80 assert(mpBuffer && "Access is not valid!");
81 assert(nX < mpBuffer->mnWidth && "x-coordinate out of range!");
82 assert(nY < mpBuffer->mnHeight && "y-coordinate out of range!");
83
84 return mFncGetPixel(GetScanline(nY), nX, maColorMask);
85 }
86
87 BitmapColor GetPixel(const Point& point) const { return GetPixel(point.Y(), point.X()); }
88
90 {
91 if (HasPalette())
92 {
93 const BitmapBuffer* pBuffer = mpBuffer;
94 return pBuffer->maPalette[GetPixelIndex(nY, nX)];
95 }
96 else
97 return GetPixel(nY, nX);
98 }
99
100 BitmapColor GetColor(const Point& point) const { return GetColor(point.Y(), point.X()); }
101
103 {
104 return GetPixel(nY, nX).GetIndex();
105 }
106
107 sal_uInt8 GetPixelIndex(const Point& point) const
108 {
109 return GetPixelIndex(point.Y(), point.X());
110 }
111
114 const BitmapColor& rFallback) const;
115
118 BitmapColor GetColorWithFallback(double fY, double fX, const BitmapColor& rFallback) const;
119
120private:
123
124protected:
127
128public:
130
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);
156 const ColorMask& rMask);
157
158 static void SetPixelForN1BitMsbPal(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: */
BitmapAccessMode
void(* FncSetPixel)(Scanline pScanline, tools::Long nX, const BitmapColor &rBitmapColor, const ColorMask &rMask)
BitmapColor(* FncGetPixel)(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
const sal_uInt8 * ConstScanline
Definition: Scanline.hxx:27
sal_uInt8 * Scanline
Definition: Scanline.hxx:26
ScanlineFormat
Definition: Scanline.hxx:29
sal_uInt8 GetIndex() const
Definition: BitmapColor.hxx:70
bool HasPalette() const
friend class BitmapReadAccess
BitmapBuffer * mpBuffer
BitmapBuffer * ImplGetBitmapBuffer() const
static void SetPixelForN32BitTcRgbx(Scanline pScanline, tools::Long nX, const BitmapColor &rBitmapColor, const ColorMask &rMask)
BitmapColor GetColorWithFallback(double fY, double fX, const BitmapColor &rFallback) const
Get the color at coordinates fY, fX; if outside, return rFallback.
Scanline GetBuffer() const
static void SetPixelForN32BitTcAbgr(Scanline pScanline, tools::Long nX, const BitmapColor &rBitmapColor, const ColorMask &rMask)
static BitmapColor GetPixelForN8BitPal(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
static BitmapColor GetPixelForN32BitTcRgbx(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
FncGetPixel mFncGetPixel
static FncGetPixel GetPixelFunction(ScanlineFormat nFormat)
BitmapReadAccess & operator=(const BitmapReadAccess &)=delete
BitmapColor GetColor(const Point &point) const
static BitmapColor GetPixelForN24BitTcRgb(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
virtual VCL_DLLPUBLIC ~BitmapReadAccess() override
static BitmapColor GetPixelForN32BitTcXbgr(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
FncSetPixel mFncSetPixel
static FncSetPixel SetPixelFunction(ScanlineFormat nFormat)
BitmapColor GetPixel(const Point &point) const
sal_uInt8 GetPixelIndex(tools::Long nY, tools::Long nX) const
static BitmapColor GetPixelForN32BitTcBgra(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
static void SetPixelForN1BitMsbPal(Scanline pScanline, tools::Long nX, const BitmapColor &rBitmapColor, const ColorMask &rMask)
static BitmapColor GetPixelForN1BitMsbPal(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
static void SetPixelForN24BitTcBgr(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)
BitmapColor GetPixel(tools::Long nY, tools::Long nX) const
static BitmapColor GetPixelForN24BitTcBgr(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
BitmapColor GetColor(tools::Long nY, tools::Long nX) const
static void SetPixelForN32BitTcXrgb(Scanline pScanline, tools::Long nX, const BitmapColor &rBitmapColor, const ColorMask &rMask)
static BitmapColor GetPixelForN32BitTcAbgr(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
void SetPixelOnData(sal_uInt8 *pData, tools::Long nX, const BitmapColor &rBitmapColor)
static void SetPixelForN32BitTcRgba(Scanline pScanline, tools::Long nX, const BitmapColor &rBitmapColor, const ColorMask &rMask)
static void SetPixelForN32BitTcBgrx(Scanline pScanline, tools::Long nX, const BitmapColor &rBitmapColor, const ColorMask &rMask)
static BitmapColor GetPixelForN32BitTcBgrx(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
static BitmapColor GetPixelForN32BitTcArgb(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
BitmapReadAccess(const BitmapReadAccess &)=delete
BitmapColor GetInterpolatedColorWithFallback(double fY, double fX, const BitmapColor &rFallback) const
Get the interpolated color at coordinates fY, fX; if outside, return rFallback.
sal_uInt8 GetPixelIndex(const Point &point) const
static void SetPixelForN8BitPal(Scanline pScanline, tools::Long nX, const BitmapColor &rBitmapColor, const ColorMask &rMask)
static void SetPixelForN32BitTcBgra(Scanline pScanline, tools::Long nX, const BitmapColor &rBitmapColor, const ColorMask &rMask)
static void SetPixelForN32BitTcArgb(Scanline pScanline, tools::Long nX, const BitmapColor &rBitmapColor, const ColorMask &rMask)
BitmapColor GetPixelFromData(const sal_uInt8 *pData, tools::Long nX) const
static void SetPixelForN32BitTcMask(Scanline pScanline, tools::Long nX, const BitmapColor &rBitmapColor, const ColorMask &rMask)
static BitmapColor GetPixelForN32BitTcXrgb(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
static void SetPixelForN32BitTcXbgr(Scanline pScanline, tools::Long nX, const BitmapColor &rBitmapColor, const ColorMask &rMask)
sal_uInt8 GetIndexFromData(const sal_uInt8 *pData, tools::Long nX) const
Scanline GetScanline(tools::Long nY) const
static BitmapColor GetPixelForN32BitTcRgba(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
static BitmapColor GetPixelForN32BitTcMask(ConstScanline pScanline, tools::Long nX, const ColorMask &rMask)
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
std::unique_ptr< sal_Int32[]> pData
def point()
long Long
double mnWidth
double mnHeight
BitmapPalette maPalette
sal_uInt8 * mpBits
tools::Long mnScanlineSize
ScanlineFormat mnFormat
tools::Long mnHeight
unsigned char sal_uInt8