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 "dgds/resource.h"
28
29namespace Common {
30class SeekableReadStream;
31}
32
33namespace Graphics {
34struct Surface;
35class ManagedSurface;
36}
37
38namespace Dgds {
39
40class Decompressor;
41class DgdsChunkReader;
42class ResourceManager;
43
44enum ImageFlipMode {
45 kImageFlipNone = 0,
46 kImageFlipV = 1,
47 kImageFlipH = 2,
48 kImageFlipHV = 3,
49};
50
51class Image {
52public:
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 getFrameFromMatrix(int16 x, int16 y);
68
69 int16 width(uint frameno) const;
70 int16 height(uint frameno) const;
71
72 int loadedFrameCount() const { return _frames.size(); }
73 bool isLoaded() const { return !_frames.empty(); }
74
75 const Common::String &getFilename() const { return _filename; }
76
77private:
78 void loadAmigaBitmap(Common::SeekableReadStream *stream, DGDS_EX ex);
79 void loadPCBitmap(Common::SeekableReadStream *stream, DGDS_EX ex);
80
81 void loadAmigaScreen(Graphics::ManagedSurface &surf, Common::SeekableReadStream *stream, DGDS_EX ex);
82 void loadPCScreen(Graphics::ManagedSurface &surf, Common::SeekableReadStream *stream, DGDS_EX ex);
83
84 void loadBitmap4(Graphics::ManagedSurface *surf, uint32 toffset, Common::SeekableReadStream *stream, bool highByte, uint16 width, uint16 height);
85 void loadBitmap8(Graphics::ManagedSurface *surf, uint32 toffset, Common::SeekableReadStream *stream, uint16 width, uint16 height);
86 uint32 loadVQT(Graphics::ManagedSurface *surf, uint32 toffset, Common::SeekableReadStream *stream);
87 bool loadSCN(Graphics::ManagedSurface *surf, Common::SeekableReadStream *stream);
88
90 ResourceManager *_resourceMan;
91 Decompressor *_decompressor;
92
93 Common::String _filename; // the file this was loaded from - only used for debugging
94
95 // Used if the image is a scrolling image.
96 int16 _matrixX;
97 int16 _matrixY;
98 Common::Array<uint16> _tileMatrix;
99};
100
101} // End of namespace Dgds
102
103#endif // DGDS_IMAGE_H
Definition: array.h:52
size_type size() const
Definition: array.h:316
bool empty() const
Definition: array.h:352
Definition: stream.h:745
Definition: str.h:59
Definition: decompress.h:67
Definition: image.h:51
Definition: resource.h:48
Definition: managed_surface.h:51
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: rect.h:536