ScummVM API documentation
image.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 DGDS_IMAGE_H
23 #define DGDS_IMAGE_H
24 
25 #include <common/ptr.h>
26 #include <common/rect.h>
27 #include <graphics/palette.h>
28 
29 namespace Common {
30 class SeekableReadStream;
31 }
32 
33 namespace Graphics {
34 struct Surface;
35 class ManagedSurface;
36 }
37 
38 namespace Dgds {
39 
40 class Decompressor;
41 class DgdsChunkReader;
42 class ResourceManager;
43 
44 enum ImageFlipMode {
45  kImageFlipNone = 0,
46  kImageFlipV = 1,
47  kImageFlipH = 2,
48  kImageFlipHV = 3,
49 };
50 
51 class Image {
52 public:
53  Image(ResourceManager *resourceMan, Decompressor *decompressor);
54  virtual ~Image();
55 
56  void drawScreen(const Common::String &filename, Graphics::ManagedSurface &dst);
57 
58  void loadBitmap(const Common::String &filename);
59  int frameCount(const Common::String &filename);
60  void drawBitmap(uint frameno, int x, int y, const Common::Rect &drawWin, Graphics::ManagedSurface &dst, ImageFlipMode flip = kImageFlipNone, int dstWidth = 0, int dstHeight = 0) const;
61  void drawScrollBitmap(int16 x, int16 y, int16 width, int16 height, int16 scrollX, int16 scrollY, const Common::Rect &drawWin, Graphics::ManagedSurface &dst) const;
62 
63  Common::SharedPtr<Graphics::ManagedSurface> getSurface(uint frameno) const;
64 
65  const Common::Array<Common::SharedPtr<Graphics::ManagedSurface>> &getFrames() const { return _frames; }
66 
67  int16 width(uint frameno) const;
68  int16 height(uint frameno) const;
69 
70  int loadedFrameCount() const { return _frames.size(); }
71  bool isLoaded() const { return !_frames.empty(); }
72 
73  const Common::String &getFilename() const { return _filename; }
74 
75 private:
76  void loadBitmap4(Graphics::ManagedSurface *surf, uint32 toffset, Common::SeekableReadStream *stream, bool highByte, uint16 width, uint16 height);
77  void loadBitmap8(Graphics::ManagedSurface *surf, uint32 toffset, Common::SeekableReadStream *stream, uint16 width, uint16 height);
78  uint32 loadVQT(Graphics::ManagedSurface *surf, uint32 toffset, Common::SeekableReadStream *stream);
79  bool loadSCN(Graphics::ManagedSurface *surf, Common::SeekableReadStream *stream);
80 
82  ResourceManager *_resourceMan;
83  Decompressor *_decompressor;
84 
85  Common::String _filename; // the file this was loaded from - only used for debugging
86 
87  // Used if the image is a scrolling image.
88  int16 _matrixX;
89  int16 _matrixY;
90  Common::Array<uint16> _tileMatrix;
91 };
92 
93 } // End of namespace Dgds
94 
95 #endif // DGDS_IMAGE_H
Definition: managed_surface.h:51
Definition: str.h:59
Definition: array.h:52
Definition: ads.h:28
Definition: rect.h:144
Definition: stream.h:745
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: movie_decoder.h:32
Definition: decompress.h:67
Definition: resource.h:49