ScummVM API documentation
transparency_surface.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 TITANIC_TRANSPARENCY_SURFACE_H
23 #define TITANIC_TRANSPARENCY_SURFACE_H
24 
25 #include "common/rect.h"
26 #include "graphics/surface.h"
27 
28 namespace Titanic {
29 
30 enum TransparencyMode {
31  TRANS_MASK0 = 0, TRANS_MASK255 = 1, TRANS_ALPHA0 = 2,
32  TRANS_ALPHA255 = 3, TRANS_DEFAULT = 4
33 };
34 
36 private:
37  const Graphics::Surface *_surface;
38  Common::Point _pos;
39  int _pitch;
40  int _runLength;
41  bool _flag;
42  byte _transparentColor;
43  byte _opaqueColor;
44 private:
48  inline uint getPixel() const {
49  byte pixel = *(const byte *)_surface->getBasePtr(_pos.x, _pos.y);
50  return pixel;
51  }
52 public:
56  CTransparencySurface(const Graphics::Surface *surface, TransparencyMode transMode);
57 
61  inline void setRow(int yp) { _pos.y = yp; }
62 
66  inline void setCol(int xp) { _pos.x = xp; }
67 
71  inline int moveX() {
72  if (++_pos.x >= _surface->w) {
73  _pos.x = 0;
74  ++_pos.y;
75  }
76 
77  return 1;
78  }
79 
83  inline uint getAlpha() const {
84  byte pixel = getPixel();
85  return _opaqueColor ? 0xFF - pixel : pixel;
86  }
87 
91  inline bool isPixelOpaque() const {
92  byte pixel = getPixel();
93  return _opaqueColor ? pixel >= 0xf0 : pixel < 0x10;
94  }
95 
99  inline bool isPixelTransparent() const {
100  byte pixel = getPixel();
101  return _transparentColor ? pixel >= 0xf0 : pixel < 0x10;
102  }
103 };
104 
105 } // End of namespace Titanic
106 
107 #endif /* TITANIC_TRANSPARENCY_SURFACE_H */
Definition: surface.h:67
CTransparencySurface(const Graphics::Surface *surface, TransparencyMode transMode)
uint getAlpha() const
Definition: transparency_surface.h:83
const void * getBasePtr(int x, int y) const
Definition: surface.h:138
Definition: rect.h:45
Definition: arm.h:30
int moveX()
Definition: transparency_surface.h:71
void setRow(int yp)
Definition: transparency_surface.h:61
int16 x
Definition: rect.h:46
Definition: transparency_surface.h:35
int16 y
Definition: rect.h:47
bool isPixelOpaque() const
Definition: transparency_surface.h:91
int16 w
Definition: surface.h:71
void setCol(int xp)
Definition: transparency_surface.h:66
bool isPixelTransparent() const
Definition: transparency_surface.h:99