OpenXcom  1.0
Open-source clone of the original X-Com
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Palette.h
1 /*
2  * Copyright 2010-2014 OpenXcom Developers.
3  *
4  * This file is part of OpenXcom.
5  *
6  * OpenXcom is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * OpenXcom is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>.
18  */
19 #ifndef OPENXCOM_PALETTE_H
20 #define OPENXCOM_PALETTE_H
21 
22 #include <string>
23 #include <SDL.h>
24 
25 namespace OpenXcom
26 {
27 
33 class Palette
34 {
35 private:
36  SDL_Color *_colors;
37  int _count;
38 public:
40  Palette();
42  ~Palette();
44  void loadDat(const std::string &filename, int ncolors, int offset = 0);
45  // Gets a certain color from the palette.
46  SDL_Color *getColors(int offset = 0) const;
47 
48  void savePal(const std::string &file) const;
49 
51  static Uint32 getRGBA(SDL_Color* pal, Uint8 color);
53 
59  static inline int palOffset(int palette) { return palette*(768+6); }
61 
67  static inline Uint8 blockOffset(Uint8 block) { return block*16; }
69  static const int backPos = 224;
70 };
71 
72 }
73 
74 #endif
static const int backPos
Position of the background colors block in an X-Com palette (used for background images in screens)...
Definition: Palette.h:69
void loadDat(const std::string &filename, int ncolors, int offset=0)
Loads the colors from an X-Com palette.
Definition: Palette.cpp:50
SDL_Color * getColors(int offset=0) const
Provides access to colors contained in the palette.
Definition: Palette.cpp:88
static Uint8 blockOffset(Uint8 block)
Gets the position of a certain color block in a palette.
Definition: Palette.h:67
~Palette()
Cleans up the palette.
Definition: Palette.cpp:36
Palette()
Creates a blank palette.
Definition: Palette.cpp:29
Container for palettes (sets of 8bpp colors).
Definition: Palette.h:33
static int palOffset(int palette)
Gets the position of a given palette.
Definition: Palette.h:59
static Uint32 getRGBA(SDL_Color *pal, Uint8 color)
Converts a given color into a RGBA color value.
Definition: Palette.cpp:100