ScummVM API documentation
vectorimage.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/*
23 * This code is based on Broken Sword 2.5 engine
24 *
25 * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
26 *
27 * Licensed under GNU GPL v2
28 *
29 */
30
31#ifndef SWORD25_VECTORIMAGE_H
32#define SWORD25_VECTORIMAGE_H
33
34// -----------------------------------------------------------------------------
35// Includes
36// -----------------------------------------------------------------------------
37
38#include "sword25/kernel/common.h"
39#include "sword25/gfx/image/image.h"
40#include "common/rect.h"
41
42#include "art.h"
43
44namespace Sword25 {
45
46class VectorImage;
47
56public:
57 VectorPathInfo(ArtBpath *vec, int len, uint lineStyle, uint fillStyle0, uint fillStyle1) :
58 _vec(vec), _lineStyle(lineStyle), _fillStyle0(fillStyle0), _fillStyle1(fillStyle1), _len(len) {}
59
61 _lineStyle = _fillStyle0 = _fillStyle1 = _len = 0;
62 _vec = 0;
63 }
64
65 ArtBpath *getVec() const {
66 return _vec;
67 }
68 int getVecLen() const {
69 return _len;
70 }
71 uint getLineStyle() const {
72 return _lineStyle;
73 }
74 uint getFillStyle0() const {
75 return _fillStyle0;
76 }
77 uint getFillStyle1() const {
78 return _fillStyle1;
79 }
80
81private:
82 ArtBpath *_vec;
83 uint _lineStyle;
84 uint _fillStyle0;
85 uint _fillStyle1;
86 uint _len;
87};
88
94 friend class VectorImage;
95public:
96 uint getPathCount() const {
97 return _pathInfos.size();
98 }
99 const VectorPathInfo &getPathInfo(uint pathNr) const {
100 assert(pathNr < getPathCount());
101 return _pathInfos[pathNr];
102 }
103
104 double getLineStyleWidth(uint lineStyle) const {
105 assert(lineStyle < _lineStyles.size());
106 return _lineStyles[lineStyle].width;
107 }
108
109 uint getLineStyleCount() const {
110 return _lineStyles.size();
111 }
112
113 uint32 getLineStyleColor(uint lineStyle) const {
114 assert(lineStyle < _lineStyles.size());
115 return _lineStyles[lineStyle].color;
116 }
117
118 uint getFillStyleCount() const {
119 return _fillStyles.size();
120 }
121
122 uint32 getFillStyleColor(uint fillStyle) const {
123 assert(fillStyle < _fillStyles.size());
124 return _fillStyles[fillStyle];
125 }
126
127 const Common::Rect &getBoundingBox() const {
128 return _boundingBox;
129 }
130
131private:
132 struct LineStyleType {
133 LineStyleType(double width_, uint32 color_) : width(width_), color(color_) {}
134 LineStyleType() {
135 width = 0;
136 color = 0;
137 }
138 double width;
139 uint32 color;
140 };
141
144 Common::Array<uint32> _fillStyles;
145 Common::Rect _boundingBox;
146};
147
148
155class VectorImage : public Image {
156public:
157 VectorImage(const byte *pFileData, uint fileSize, bool &success, const Common::String &fname);
158 ~VectorImage() override;
159
160 uint getElementCount() const {
161 return _elements.size();
162 }
163 const VectorImageElement &getElement(uint elementNr) const {
164 assert(elementNr < _elements.size());
165 return _elements[elementNr];
166 }
167 const Common::Rect &getBoundingBox() const {
168 return _boundingBox;
169 }
170
171 //
172 // Die abstrakten Methoden von BS_Image
173 //
174 int getWidth() const override {
175 return _boundingBox.width();
176 }
177 int getHeight() const override {
178 return _boundingBox.height();
179 }
180 bool fill(const Common::Rect *pFillRect = 0, uint color = BS_RGB(0, 0, 0)) override;
181
182 void render(int width, int height);
183
184 uint getPixel(int x, int y) override;
185 bool isBlitSource() const override {
186 return true;
187 }
188 bool isBlitTarget() const override {
189 return false;
190 }
191 bool isScalingAllowed() const override {
192 return true;
193 }
194 bool isFillingAllowed() const override {
195 return false;
196 }
197 bool isAlphaAllowed() const override {
198 return true;
199 }
200 bool isColorModulationAllowed() const override {
201 return true;
202 }
203 bool isSetContentAllowed() const override {
204 return false;
205 }
206 bool setContent(const byte *pixeldata, uint size, uint offset, uint stride) override;
207 bool blit(int posX = 0, int posY = 0,
208 int flipping = Graphics::FLIP_NONE,
209 Common::Rect *pPartRect = NULL,
210 uint color = BS_ARGB(255, 255, 255, 255),
211 int width = -1, int height = -1,
212 RectangleList *updateRects = 0) override;
213
214 class SWFBitStream;
215
216private:
217 bool parseDefineShape(uint shapeType, SWFBitStream &bs);
218 bool parseStyles(uint shapeType, SWFBitStream &bs, uint &numFillBits, uint &numLineBits);
219
220 ArtBpath *storeBez(ArtBpath *bez, int lineStyle, int fillStyle0, int fillStyle1, int *bezNodes, int *bezAllocated);
222 Common::Rect _boundingBox;
223
224 byte *_pixelData;
225
226 Common::String _fname;
227 uint _bgColor;
228};
229
230} // End of namespace Sword25
231
232#endif
Definition: array.h:52
size_type size() const
Definition: array.h:316
Definition: str.h:59
Definition: image.h:50
Definition: microtiles.h:38
Ein Element eines Vektorbild. Ein BS_VectorImage besteht aus diesen Elementen, die jeweils einen Teil...
Definition: vectorimage.h:93
Eine Vektorgraphik.
Definition: vectorimage.h:155
bool isBlitTarget() const override
Checks, if the BS_Image can be a target image for a Blit call.
Definition: vectorimage.h:188
bool isBlitSource() const override
Checks, if it is allowed to call BS_Image Blit().
Definition: vectorimage.h:185
bool blit(int posX=0, int posY=0, int flipping=Graphics::FLIP_NONE, Common::Rect *pPartRect=NULL, uint color=BS_ARGB(255, 255, 255, 255), int width=-1, int height=-1, RectangleList *updateRects=0) override
renders the image in the framebuffer
uint getPixel(int x, int y) override
Reads out a pixel of the image.
int getHeight() const override
Returns the height of the image in pixels.
Definition: vectorimage.h:177
bool isFillingAllowed() const override
Returns true, if the BS_Image is allowed to be filled by a Fill() call.
Definition: vectorimage.h:194
bool isColorModulationAllowed() const override
Return true, if the BS_Image is allowed to be displayed with color modulation by a Blit() call.
Definition: vectorimage.h:200
bool fill(const Common::Rect *pFillRect=0, uint color=BS_RGB(0, 0, 0)) override
fills a rectangular section of the image with a color.
bool isAlphaAllowed() const override
Returns true, if the BS_Image is allowed to be displayed with an alpha value.
Definition: vectorimage.h:197
bool isSetContentAllowed() const override
Returns true, if the content of the BS_Image is allowed to be replaced by call of SetContent().
Definition: vectorimage.h:203
bool setContent(const byte *pixeldata, uint size, uint offset, uint stride) override
Fills the content of the image with pixel data.
int getWidth() const override
Returns the width of the image in pixels.
Definition: vectorimage.h:174
bool isScalingAllowed() const override
Returns true, if the BS_Image is allowed to be scaled by a Blit() call.
Definition: vectorimage.h:191
Pfadinformationen zu BS_VectorImageElement Objekten.
Definition: vectorimage.h:55
@ FLIP_NONE
The image will not be flipped.
Definition: transform_struct.h:49
Definition: console.h:27
T height() const
Definition: rect.h:218
T width() const
Definition: rect.h:217
Definition: rect.h:536
Definition: art.h:99