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 
32 namespace Sherlock {
33 
34 class SherlockEngine;
35 
36 struct 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 
78 class ImageFile {
79 private:
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);
94 protected:
95  virtual void decodeFrame(ImageFrame &frame);
96 public:
97  ImageFrame& operator[](uint index);
98  uint size();
99  void push_back(const ImageFrame &frame);
100 
101  byte _palette[256 * 3];
102 public:
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 
110 enum 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 
122 class ImageFile3DO : public ImageFile { // Common::Array<ImageFrame> {
123 private:
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 
163 protected:
164  void decodeFrame(ImageFrame &frame);
165 
166 public:
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 
175 private:
176  int _frameNumber;
178  byte _buffer[STREAMING_BUFFER_SIZE];
179  bool _compressed;
180  bool _active;
181 public:
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
191 public:
194 
198  void load(Common::SeekableReadStream *stream, bool compressed);
199 
203  void close();
204 
208  bool getNextFrame();
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: image_file.h:118
Definition: surface.h:67
Definition: array.h:52
Definition: image_file.h:122
Definition: animation.h:29
Definition: rect.h:144
Definition: path.h:52
Definition: stream.h:745
Definition: image_file.h:36
int sDrawXSize(int scaleVal) const
Definition: sherlock.h:76
Definition: rect.h:45
int sDrawXOffset(int scaleVal) const
int sDrawYOffset(int scaleVal) const
void decompressFrame(const byte *src, bool isRoseTattoo)
Definition: image_file.h:78
bool active() const
Definition: image_file.h:213
int sDrawYSize(int scaleVal) const
int frameNumber() const
Definition: image_file.h:218
Definition: image_file.h:174