OpenXcom  1.0
Open-source clone of the original X-Com
Palette.h
1 #pragma once
2 /*
3  * Copyright 2010-2016 OpenXcom Developers.
4  *
5  * This file is part of OpenXcom.
6  *
7  * OpenXcom 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  * OpenXcom 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 OpenXcom. If not, see <http://www.gnu.org/licenses/>.
19  */
20 #include <string>
21 #include <SDL.h>
22 
23 namespace OpenXcom
24 {
25 
31 class Palette
32 {
33 private:
34  SDL_Color *_colors;
35  int _count;
36 public:
38  Palette();
40  ~Palette();
42  void loadDat(const std::string &filename, int ncolors, int offset = 0);
43  // Gets a certain color from the palette.
44  SDL_Color *getColors(int offset = 0) const;
45 
46  void savePal(const std::string &file) const;
47  void setColors(SDL_Color* pal, int ncolors);
49  static Uint32 getRGBA(SDL_Color* pal, Uint8 color);
51 
57  static inline int palOffset(int palette) { return palette*(768+6); }
59 
65  static inline Uint8 blockOffset(Uint8 block) { return block*16; }
67  static const int backPos = 224;
68 };
69 
70 }
static const int backPos
Position of the background colors block in an X-Com palette (used for background images in screens)...
Definition: Palette.h:67
void loadDat(const std::string &filename, int ncolors, int offset=0)
Loads the colors from an X-Com palette.
Definition: Palette.cpp:50
static Uint8 blockOffset(Uint8 block)
Gets the position of a certain color block in a palette.
Definition: Palette.h:65
~Palette()
Cleans up the palette.
Definition: Palette.cpp:36
SDL_Color * getColors(int offset=0) const
Provides access to colors contained in the palette.
Definition: Palette.cpp:88
Palette()
Creates a blank palette.
Definition: Palette.cpp:29
Container for palettes (sets of 8bpp colors).
Definition: Palette.h:31
static int palOffset(int palette)
Gets the position of a given palette.
Definition: Palette.h:57
static Uint32 getRGBA(SDL_Color *pal, Uint8 color)
Converts a given color into a RGBA color value.
Definition: Palette.cpp:100
Definition: BaseInfoState.cpp:40