LibreOffice Module vcl (master) 1
BitmapInfoAccess.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_BITMAPINFOACCESS_HXX
21#define INCLUDED_VCL_BITMAPINFOACCESS_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>
29
31
32typedef BitmapColor (*FncGetPixel)(ConstScanline pScanline, tools::Long nX, const ColorMask& rMask);
33typedef void (*FncSetPixel)(Scanline pScanline, tools::Long nX, const BitmapColor& rBitmapColor,
34 const ColorMask& rMask);
35
37{
38 friend class BitmapReadAccess;
39
40public:
42 virtual ~BitmapInfoAccess();
43
44 bool operator!() const { return mpBuffer == nullptr; }
45
46 tools::Long Width() const { return mpBuffer ? mpBuffer->mnWidth : 0L; }
47
48 tools::Long Height() const { return mpBuffer ? mpBuffer->mnHeight : 0L; }
49
50 bool IsTopDown() const
51 {
52 assert(mpBuffer && "Access is not valid!");
53
55 }
56
57 bool IsBottomUp() const { return !IsTopDown(); }
58
60 {
61 assert(mpBuffer && "Access is not valid!");
62
64 }
65
66 sal_uInt32 GetScanlineSize() const
67 {
68 assert(mpBuffer && "Access is not valid!");
69
70 return mpBuffer ? mpBuffer->mnScanlineSize : 0;
71 }
72
73 sal_uInt16 GetBitCount() const
74 {
75 assert(mpBuffer && "Access is not valid!");
76
77 return mpBuffer ? mpBuffer->mnBitCount : 0;
78 }
79
80 BitmapColor GetBestMatchingColor(const BitmapColor& rBitmapColor) const
81 {
82 if (HasPalette())
83 return BitmapColor(static_cast<sal_uInt8>(GetBestPaletteIndex(rBitmapColor)));
84 else
85 return rBitmapColor;
86 }
87
88 bool HasPalette() const
89 {
90 const BitmapBuffer* pBuffer = mpBuffer;
91
92 assert(pBuffer && "Access is not valid!");
93
94 return pBuffer && !!pBuffer->maPalette;
95 }
96
98 {
99 const BitmapBuffer* pBuffer = mpBuffer;
100
101 assert(pBuffer && "Access is not valid!");
102
103 return pBuffer->maPalette;
104 }
105
106 sal_uInt16 GetPaletteEntryCount() const
107 {
108 const BitmapBuffer* pBuffer = mpBuffer;
109
110 assert(HasPalette() && "Bitmap has no palette!");
111
112 return HasPalette() ? pBuffer->maPalette.GetEntryCount() : 0;
113 }
114
115 const BitmapColor& GetPaletteColor(sal_uInt16 nColor) const
116 {
117 const BitmapBuffer* pBuffer = mpBuffer;
118 assert(pBuffer && "Access is not valid!");
119 assert(HasPalette() && "Bitmap has no palette!");
120
121 return pBuffer->maPalette[nColor];
122 }
123
124 sal_uInt16 GetBestPaletteIndex(const BitmapColor& rBitmapColor) const;
125
126 const ColorMask& GetColorMask() const
127 {
128 const BitmapBuffer* pBuffer = mpBuffer;
129
130 assert(pBuffer && "Access is not valid!");
131
132 return pBuffer->maColorMask;
133 }
134
135private:
138
139protected:
144};
145
146#endif // INCLUDED_VCL_BITMAPINFOACCESS_HXX
147
148/* 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)
bool Bitmap32IsPreMultipled()
const sal_uInt8 * ConstScanline
Definition: Scanline.hxx:27
sal_uInt8 * Scanline
Definition: Scanline.hxx:26
ScanlineFormat
Definition: Scanline.hxx:29
ScanlineFormat RemoveScanline(ScanlineFormat nFormat)
Definition: Scanline.hxx:53
tools::Long Height() const
BitmapInfoAccess(const BitmapInfoAccess &)=delete
tools::Long Width() const
const BitmapPalette & GetPalette() const
bool operator!() const
bool IsBottomUp() const
bool IsTopDown() const
BitmapColor GetBestMatchingColor(const BitmapColor &rBitmapColor) const
sal_uInt16 GetBestPaletteIndex(const BitmapColor &rBitmapColor) const
BitmapInfoAccess & operator=(const BitmapInfoAccess &)=delete
bool HasPalette() const
BitmapInfoAccess(Bitmap &rBitmap, BitmapAccessMode nMode=BitmapAccessMode::Info)
ScanlineFormat GetScanlineFormat() const
sal_uInt16 GetPaletteEntryCount() const
sal_uInt16 GetBitCount() const
BitmapAccessMode mnAccessMode
const ColorMask & GetColorMask() const
const BitmapColor & GetPaletteColor(sal_uInt16 nColor) const
BitmapBuffer * mpBuffer
sal_uInt32 GetScanlineSize() const
virtual ~BitmapInfoAccess()
sal_uInt16 GetEntryCount() const
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
long Long
BitmapPalette maPalette
tools::Long mnWidth
tools::Long mnScanlineSize
sal_uInt16 mnBitCount
ColorMask maColorMask
ScanlineFormat mnFormat
tools::Long mnHeight
unsigned char sal_uInt8