ScummVM API documentation
image_file.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 SHERLOCK_IMAGE_FILE_H
23#define SHERLOCK_IMAGE_FILE_H
24
25#include "common/array.h"
26#include "common/file.h"
27#include "common/path.h"
28#include "common/rect.h"
29#include "common/stream.h"
30#include "graphics/surface.h"
31
32namespace Sherlock {
33
34class SherlockEngine;
35
36struct ImageFrame {
37 uint32 _pos;
38 byte _decoded;
39 uint32 _size;
40 uint16 _width, _height;
41 int _paletteBase;
42 bool _rleEncoded;
43 Common::Point _offset;
44 byte _rleMarker;
45 Graphics::Surface _frame;
46
50 operator const Graphics::Surface &() { return _frame; }
51
55 void decompressFrame(const byte *src, bool isRoseTattoo);
56
60 int sDrawXSize(int scaleVal) const;
61
65 int sDrawYSize(int scaleVal) const;
66
70 int sDrawXOffset(int scaleVal) const;
71
75 int sDrawYOffset(int scaleVal) const;
76};
77
78class ImageFile {
79private:
80 static SherlockEngine *_vm;
82 Common::Path _name;
84
88 void load(Common::SeekableReadStream &stream, bool skipPalette, bool animImages);
89
93 void loadPalette(Common::SeekableReadStream &stream);
94protected:
95 virtual void decodeFrame(ImageFrame &frame);
96public:
97 ImageFrame& operator[](uint index);
98 uint size();
99 void push_back(const ImageFrame &frame);
100
101 byte _palette[256 * 3];
102public:
103 ImageFile();
104 ImageFile(const Common::Path &name, bool skipPal = false, bool animImages = false);
105 ImageFile(Common::SeekableReadStream &stream, bool skipPal = false);
106 virtual ~ImageFile();
107 static void setVm(SherlockEngine *vm);
108};
109
110enum ImageFile3DOType {
111 kImageFile3DOType_Animation = 0,
112 kImageFile3DOType_Cel = 1,
113 kImageFile3DOType_CelAnimation = 2,
114 kImageFile3DOType_RoomFormat = 3,
115 kImageFile3DOType_Font = 4
116};
117
119 uint16 pixelColor[256];
120};
121
122class ImageFile3DO : public ImageFile { // Common::Array<ImageFrame> {
123private:
124 static SherlockEngine *_vm;
125
129 void load(Common::SeekableReadStream &stream, bool isRoomData);
130
134 inline uint16 convertPixel(uint16 pixel3DO);
135
139 void load3DOCelFile(Common::SeekableReadStream &stream);
140
144 void load3DOCelRoomData(Common::SeekableReadStream &stream);
145
146 inline uint16 celGetBits(const byte *&dataPtr, byte bitCount, byte &dataBitsLeft);
147
151 void decompress3DOCelFrame(ImageFrame &frame, const byte *dataPtr, uint32 dataSize, byte bitsPerPixel, ImageFile3DOPixelLookupTable *pixelLookupTable);
152
156 void loadAnimationFile(Common::SeekableReadStream &stream);
157
161 void loadFont(Common::SeekableReadStream &stream);
162
163protected:
164 void decodeFrame(ImageFrame &frame);
165
166public:
167 ImageFile3DO(const Common::Path &name, ImageFile3DOType imageFile3DOType);
168 ImageFile3DO(Common::SeekableReadStream &stream, bool isRoomData = false);
169 static void setVm(SherlockEngine *vm);
170};
171
172#define STREAMING_BUFFER_SIZE 65536
173
175private:
176 int _frameNumber;
178 byte _buffer[STREAMING_BUFFER_SIZE];
179 bool _compressed;
180 bool _active;
181public:
182 ImageFrame _imageFrame;
183
184 Common::Point _position; // Animation position
185 Common::Rect _oldBounds; // Bounds of previous frame
186 Common::Rect _removeBounds; // Remove area for just drawn frame
187
188 int _flags; // Flags
189 int _scaleVal; // Specifies the scale amount
190 int _zPlacement; // Used by doBgAnim for determining Z order
191public:
194
198 void load(Common::SeekableReadStream *stream, bool compressed);
199
203 void close();
204
209
213 bool active() const { return _active; }
214
218 int frameNumber() const { return _frameNumber; }
219};
220
221} // End of namespace Sherlock
222
223#endif
Definition: array.h:52
Definition: path.h:52
Definition: stream.h:745
Definition: image_file.h:122
Definition: image_file.h:78
Definition: sherlock.h:206
Definition: image_file.h:174
bool active() const
Definition: image_file.h:213
void load(Common::SeekableReadStream *stream, bool compressed)
int frameNumber() const
Definition: image_file.h:218
Definition: rect.h:144
Definition: rect.h:536
Definition: surface.h:67
Definition: image_file.h:118
Definition: image_file.h:36
int sDrawYSize(int scaleVal) const
int sDrawYOffset(int scaleVal) const
void decompressFrame(const byte *src, bool isRoseTattoo)
int sDrawXSize(int scaleVal) const
int sDrawXOffset(int scaleVal) const