ScummVM API documentation
pal.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef CINE_PAL_H
23#define CINE_PAL_H
24
25#include "graphics/pixelformat.h"
26
27namespace Cine {
28
37 CINE_NATIVE_ENDIAN,
38 CINE_LITTLE_ENDIAN,
39 CINE_BIG_ENDIAN
40};
41
42struct PalEntry {
43 char name[10];
44 byte pal1[16];
45 byte pal2[16];
46};
47
48void loadPal(const char *fileName);
49
50void loadRelatedPalette(const char *fileName);
51
56class Palette {
57public:
58 struct Color {
59 uint8 r, g, b;
60 };
61
68 Palette(const Graphics::PixelFormat &format = Graphics::PixelFormat(), const uint numColors = 0);
69 Palette(const Palette& other);
70 Palette& operator=(const Palette& other);
71
77
86 Palette &load(const byte *buf, const uint size, const Graphics::PixelFormat &format, const uint numColors, const EndianType endian);
87
94 byte *save(byte *buf, const uint size, const EndianType endian) const;
95
103 byte *save(byte *buf, const uint size, const Graphics::PixelFormat &format, const EndianType endian) const;
104
114 byte *save(byte *buf, const uint size, const Graphics::PixelFormat &format, const uint numColors, const EndianType endian, const byte firstIndex = 0) const;
115
119 Palette &rotateRight(byte firstIndex, byte lastIndex);
120 Palette &rotateLeft(byte firstIndex, byte lastIndex);
121 Palette &saturatedAddColor(Palette &output, byte firstIndex, byte lastIndex, signed r, signed g, signed b) const;
122
135 Palette &saturatedAddColor(Palette &output, byte firstIndex, byte lastIndex, signed rSource, signed gSource, signed bSource, const Graphics::PixelFormat &sourceFormat) const;
136
147 Palette &saturatedAddNormalizedGray(Palette &output, byte firstIndex, byte lastIndex, signed grayDividend, signed grayDenominator) const;
148
149 bool empty() const;
150 uint colorCount() const;
151 Palette &fillWithBlack();
152
154 bool isValid() const;
155
158
161
163 Color getColor(byte index) const;
164
166 uint8 getR(byte index) const;
167
169 uint8 getG(byte index) const;
170
172 uint8 getB(byte index) const;
173
174 bool ensureContrast(byte &minBrightnessColorIndex);
175 bool isEqual(byte index1, byte index2);
176
177private:
178 int findMinBrightnessColorIndex(uint minColorIndex = 1);
179 byte brightness(byte colorIndex);
180 void setColorFormat(const Graphics::PixelFormat &format);
181 void saturatedAddColor(Color &result, const Color &baseColor, signed r, signed g, signed b) const;
182
183private:
184 Graphics::PixelFormat _format;
185 Common::Array<Color> _colors;
186};
187
188} // End of namespace Cine
189
190#endif
Definition: pal.h:56
uint8 getB(byte index) const
void setGlobalOSystemPalette() const
Palette & clear()
uint8 getG(byte index) const
Palette & saturatedAddColor(Palette &output, byte firstIndex, byte lastIndex, signed rSource, signed gSource, signed bSource, const Graphics::PixelFormat &sourceFormat) const
const Graphics::PixelFormat & colorFormat() const
uint8 getR(byte index) const
Palette(const Graphics::PixelFormat &format=Graphics::PixelFormat(), const uint numColors=0)
Palette & rotateRight(byte firstIndex, byte lastIndex)
Palette & load(const byte *buf, const uint size, const Graphics::PixelFormat &format, const uint numColors, const EndianType endian)
byte * save(byte *buf, const uint size, const EndianType endian) const
byte * save(byte *buf, const uint size, const Graphics::PixelFormat &format, const uint numColors, const EndianType endian, const byte firstIndex=0) const
byte * save(byte *buf, const uint size, const Graphics::PixelFormat &format, const EndianType endian) const
Color getColor(byte index) const
Palette & saturatedAddNormalizedGray(Palette &output, byte firstIndex, byte lastIndex, signed grayDividend, signed grayDenominator) const
bool isValid() const
Definition: array.h:52
Definition: anim.h:29
EndianType
Definition: pal.h:36
Definition: pal.h:42
Definition: pal.h:58
Definition: pixelformat.h:138