ScummVM API documentation
palette.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 ULTIMA8_GFX_PALETTE_H
23 #define ULTIMA8_GFX_PALETTE_H
24 
25 #include "graphics/palette.h"
26 #include "graphics/pixelformat.h"
27 #include "ultima/ultima8/gfx/pal_transforms.h"
28 
29 namespace Common {
30 class ReadStream;
31 }
32 
33 namespace Ultima {
34 namespace Ultima8 {
35 
36 class Palette: public Graphics::Palette {
37 public:
38  Palette() : Graphics::Palette(256) {}
39 
40  void load(Common::ReadStream &rs, Common::ReadStream &xformrs);
41  void load(Common::ReadStream &rs);
42 
43  // Transform a single set of rgb values based on the current matrix.
44  // Not designed for speed - just useful for one-offs.
45  void transformRGB(int &r, int &g, int &b) const;
46 
47  // Update the palette maps based on the pixel format and the current transformation matrix
48  void updateNativeMap(const Graphics::PixelFormat &format, int maxindex = 0);
49 
50  // Untransformed pixel format palette map
51  uint32 _native_untransformed[256];
52 
53  // Transformed pixel format palette map
54  uint32 _native[256];
55 
56  // Untransformed XFORM ARGB palette map
57  uint32 _xform_untransformed[256];
58 
59  // Transformed XFORM ARGB palette map
60  uint32 _xform[256];
61 
62  // Colour transformation matrix (for fades, hue shifts)
63  // Applied by the RenderSurface (fixed -4.11)
64  // R = R*matrix[0] + G*matrix[1] + B*matrix[2] + matrix[3];
65  // G = R*matrix[4] + G*matrix[5] + B*matrix[6] + matrix[7];
66  // B = R*matrix[8] + G*matrix[9] + B*matrix[10] + matrix[11];
67  // A = A;
68  int16 _matrix[12];
69 
70  // The current palette transform
71  PalTransforms _transform;
72 };
73 
74 } // End of namespace Ultima8
75 } // End of namespace Ultima
76 
77 #endif
Definition: pixelformat.h:138
Definition: detection.h:27
Definition: algorithm.h:29
Definition: stream.h:385
Simple class for handling a palette data.
Definition: palette.h:55
Definition: palette.h:36