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 /*
23  * Based on
24  * WebVenture (c) 2010, Sean Kasun
25  * https://github.com/mrkite/webventure, http://seancode.com/webventure/
26  *
27  * Used with explicit permission from the author
28  */
29 
30 #ifndef MACVENTURE_IMAGE_H
31 #define MACVENTURE_IMAGE_H
32 
33 #include "macventure/macventure.h"
34 #include "macventure/container.h"
35 #include "common/bitstream.h"
36 
37 namespace MacVenture {
38 
39 typedef uint32 ObjID;
40 class Container;
41 
42 
43 enum BlitMode {
44  kBlitDirect = 0,
45  kBlitBIC = 1,
46  kBlitOR = 2,
47  kBlitXOR = 3
48 };
49 
50 enum GraphicsEncoding {
51  kPPIC0 = 0,
52  kPPIC1 = 1,
53  kPPIC2 = 2,
54  kPPIC3 = 3
55 };
56 
57 struct PPICHuff {
58  uint16 masks[17];
59  uint16 lens[17];
60  uint8 symbols[17];
61 };
62 
63 class ImageAsset {
64 public:
65  ImageAsset(ObjID original, Container *container);
66  ~ImageAsset();
67 
68  void blitInto(Graphics::ManagedSurface *target, int x, int y, BlitMode mode);
69 
70  bool isPointInside(Common::Point point);
71  bool isRectInside(Common::Rect rect);
72 
73  int getWidth();
74  int getHeight();
75 
76 private:
77  void decodePPIC(ObjID id, Common::Array<byte> &data, uint &bitHeight, uint &bitWidth, uint &rowBytes);
78 
79  void decodePPIC0(Common::BitStream32BEMSB &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes);
80  void decodePPIC1(Common::BitStream32BEMSB &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes);
81  void decodePPIC2(Common::BitStream32BEMSB &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes);
82  void decodePPIC3(Common::BitStream32BEMSB &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes);
83 
84  void decodeHuffGraphic(const PPICHuff &huff, Common::BitStream32BEMSB &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes);
85  byte walkHuff(const PPICHuff &huff, Common::BitStream32BEMSB &stream);
86 
87  void blitDirect(Graphics::ManagedSurface *target, int ox, int oy, const Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes);
88  void blitBIC(Graphics::ManagedSurface *target, int ox, int oy, const Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes);
89  void blitOR(Graphics::ManagedSurface *target, int ox, int oy, const Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes);
90  void blitXOR(Graphics::ManagedSurface *target, int ox, int oy, const Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes);
91 
92  void calculateSectionToDraw(Graphics::ManagedSurface *target, int &ox, int &oy, uint bitWidth, uint bitHeight, uint &sx, uint &sy, uint &w, uint &h);
93  void calculateSectionInDirection(uint targetWhole, uint originWhole, int &originPosition, uint &startPosition, uint &blittedWhole);
94 
95 private:
96  ObjID _id;
97  ObjID _mask;
98  Container *_container;
99 
100  uint16 _walkRepeat;
101  uint16 _walkLast;
102 
103  Common::Array<byte> _imgData;
104  uint16 _imgRowBytes;
105  uint16 _imgBitWidth;
106  uint16 _imgBitHeight;
107 
108  Common::Array<byte> _maskData;
109  uint16 _maskRowBytes;
110  uint16 _maskBitWidth;
111  uint16 _maskBitHeight;
112 };
113 
114 } // End of namespace MacVenture
115 
116 #endif
Definition: managed_surface.h:51
Definition: image.h:63
Definition: rect.h:144
Definition: container.h:48
Definition: bitstream.h:55
Definition: rect.h:45
Definition: container.h:38
Definition: image.h:57