ScummVM API documentation
palette.h
1 
2 /* ScummVM - Graphic Adventure Engine
3  *
4  * ScummVM is the legal property of its developers, whose names
5  * are too numerous to list here. Please refer to the COPYRIGHT
6  * file distributed with this source distribution.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef BAGEL_BOFLIB_GFX_PALETTE_H
24 #define BAGEL_BOFLIB_GFX_PALETTE_H
25 
26 #include "graphics/palette.h"
27 #include "bagel/afxwin.h"
28 #include "bagel/boflib/error.h"
29 #include "bagel/boflib/object.h"
30 #include "bagel/boflib/stdinc.h"
31 
32 namespace Bagel {
33 namespace SpaceBar {
34 
35 struct PaletteData {
36  byte _data[Graphics::PALETTE_SIZE];
37  int16 _numColors;
38  PaletteData(int16 numColors = Graphics::PALETTE_COUNT);
39 };
40 
41 struct PALETTEENTRY {
42  byte peRed;
43  byte peGreen;
44  byte peBlue;
45  byte peFlags;
46 };
47 struct LOGPALETTE {
48  int16 palNumEntries;
49  int16 palVersion;
50  PALETTEENTRY palPalEntry[1];
51 };
52 
53 struct BOFRGBQUAD {
54  byte rgbBlue;
55  byte rgbGreen;
56  byte rgbRed;
57  byte rgbReserved;
58 };
59 
60 #define GetRed(rgb) ((byte)((rgb) & 0x000000FF))
61 #define GetGreen(rgb) ((byte)(((rgb) >> 8) & 0x000000FF))
62 #define GetBlue(rgb) ((byte)(((rgb) >> 16) & 0x000000FF))
63 
64 class CBofPalette : public CBofError, public CBofObject {
65 protected:
66  PaletteData _palette;
67 
68  static CBofPalette *_pSharedPalette;
69  static char _szSharedPalFile[MAX_FNAME];
70 
74  void ReleasePalette();
75 
76 public:
80  CBofPalette();
81 
86  CBofPalette(const char *pszFileName);
87 
91  CBofPalette(const PaletteData &paletteData);
92 
99  ErrorCode loadPalette(const char *pszFileName, uint16 nFlags = PAL_DEFAULT);
100 
101  ErrorCode createDefault(uint16 nFlags = PAL_DEFAULT);
102 
103  byte getNearestIndex(COLORREF cColor);
104 
105  COLORREF getColor(byte nIndex);
106 
111  void setPalette(const PaletteData &PaletteData);
112 
113  const PaletteData &getPalette() const {
114  return _palette;
115  }
116 
117  const byte *getData() const {
118  return _palette._data;
119  }
120 
121  void setData(const byte* colors) {
122  memcpy(_palette._data, colors, Graphics::PALETTE_SIZE);
123  }
124 
125  virtual ~CBofPalette();
126 
130  CBofPalette *copyPalette();
131 
135  static void initialize();
136 
141  static ErrorCode setSharedPalette(const char *pszFileName);
142 
147  static CBofPalette *getSharedPalette();
148 };
149 
150 } // namespace SpaceBar
151 } // namespace Bagel
152 
153 #endif
Definition: palette.h:41
Definition: object.h:28
Definition: palette.h:53
Definition: error.h:52
Definition: palette.h:35
Definition: palette.h:47
Definition: palette.h:64
Definition: afxwin.h:27