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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  * Copyright 2020 Google
22  *
23  */
24 #ifndef HADESCH_POD_IMAGE_H
25 #define HADESCH_POD_IMAGE_H
26 
27 #include "hadesch/pod_file.h"
28 #include "common/ptr.h"
29 #include "common/rect.h"
30 #include "common/hashmap.h"
31 #include "hadesch/gfx_context.h"
32 #include "graphics/cursor.h"
33 
34 namespace Hadesch {
35 
36 class PodImage : public Graphics::Cursor {
37 public:
38 	PodImage();
39 	bool loadImage(const PodFile &col, int index);
40 	void render(Common::SharedPtr<GfxContext>, Common::Point offset,
41 		    int colourScale = 0x100, int scale = 100) const;
42 	bool isValid() const;
43 	void setHotspot(Common::Point pnt);
44 	Common::Point getOffset() const;
45 
46 	uint16 getWidth() const override;
47 	uint16 getHeight() const override;
48 	uint16 getHotspotX() const override;
49 	uint16 getHotspotY() const override;
50 	byte getKeyColor() const override;
51 	const byte *getSurface() const override;
52 	const byte *getPalette() const override;
53 	byte getPaletteStartIndex() const override;
54 	uint16 getPaletteCount() const override;
55 
56 	~PodImage();
57 private:
58 	struct ScaledVersion {
59 		Common::SharedPtr<byte> _pixels;
60 		int _w, _h;
61 	};
62 	void makeScale(int scale) const;
63 
64 	mutable Common::HashMap<int, ScaledVersion> _scales;
65 	int _w, _h;
66 	Common::Point _pos, _hotspot;
67 	int _ncolors;
68 	Common::SharedPtr<byte> _pixels;
69 	Common::SharedPtr<byte> _palette;
70 	Common::SharedPtr<byte> _paletteCursor;
71 };
72 }
73 
74 #endif
75