1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef GOB_SURFACE_H
#define GOB_SURFACE_H
#include "common/scummsys.h"
#include "common/ptr.h"
#include "common/rational.h"
namespace Gob {
/** An iterator over a surface's image data, automatically handles different color depths. */
class Pixel {
public:
Pixel(byte *vidMem, uint8 bpp, byte *min, byte *max);
Pixel &operator++();
Pixel operator++(int x);
Pixel &operator--();
Pixel operator--(int x);
Pixel &operator+=(int x);
Pixel &operator-=(int x);
uint32 get() const;
void set(uint32 p);
bool isValid() const;
private:
byte *_vidMem;
byte *_min, *_max;
uint8 _bpp;
};
/** A const iterator over a surface's image data, automatically handles different color depths. */
class ConstPixel {
public:
ConstPixel(const byte *vidMem, uint8 bpp, const byte *min, const byte *max);
ConstPixel &operator++();
ConstPixel operator++(int x);
ConstPixel &operator--();
ConstPixel operator--(int x);
ConstPixel &operator+=(int x);
ConstPixel &operator-=(int x);
uint32 get() const;
bool isValid() const;
private:
const byte *_vidMem;
const byte *_min, *_max;
uint8 _bpp;
};
class Surface {
public:
Surface(uint16 width, uint16 height, uint8 bpp, byte *vidMem = 0);
~Surface();
uint16 getWidth () const;
uint16 getHeight() const;
uint8 getBPP () const;
byte *getData(uint16 x = 0, uint16 y = 0);
const byte *getData(uint16 x = 0, uint16 y = 0) const;
void resize(uint16 width, uint16 height);
void setBPP(uint8 bpp);
Pixel get(uint16 x = 0, uint16 y = 0);
ConstPixel get(uint16 x = 0, uint16 y = 0) const;
void blit(const Surface &from, int16 left, int16 top, int16 right, int16 bottom,
int16 x, int16 y, int32 transp = -1);
void blit(const Surface &from, int16 x, int16 y, int32 transp = -1);
void blit(const Surface &from, int32 transp = -1);
void blitScaled(const Surface &from, int16 left, int16 top, int16 right, int16 bottom,
int16 x, int16 y, Common::Rational scale, int32 transp = -1);
void blitScaled(const Surface &from, int16 x, int16 y, Common::Rational scale, int32 transp = -1);
void blitScaled(const Surface &from, Common::Rational scale, int32 transp = -1);
void fillRect(uint16 left, uint16 top, uint16 right, uint16 bottom, uint32 color);
void fill(uint32 color);
void clear();
void shadeRect(uint16 left, uint16 top, uint16 right, uint16 bottom,
uint32 color, uint8 strength);
void putPixel(uint16 x, uint16 y, uint32 color);
void drawLine(uint16 x0, uint16 y0, uint16 x1, uint16 y1, uint32 color);
void drawCircle(uint16 x0, uint16 y0, uint16 radius, uint32 color, int16 pattern = 0);
void blitToScreen(uint16 left, uint16 top, uint16 right, uint16 bottom, uint16 x, uint16 y) const;
private:
uint16 _width;
uint16 _height;
uint8 _bpp;
bool _ownVidMem;
byte *_vidMem;
static bool clipBlitRect(int16 &left, int16 &top, int16 &right, int16 &bottom, int16 &x, int16 &y,
uint16 dWidth, uint16 dHeight, uint16 sWidth, uint16 sHeight);
};
typedef Common::SharedPtr<Surface> SurfacePtr;
} // End of namespace Gob
#endif // GOB_SURFACE_H
|