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);
67  ~ImageAsset();
68 
69  void blitInto(Graphics::ManagedSurface *target, int x, int y, BlitMode mode);
70 
71  bool isPointInside(Common::Point point);
72  bool isRectInside(Common::Rect rect);
73 
74  int getWidth();
75  int getHeight();
76 
77 private:
78  void decodePPIC(Common::SeekableReadStream *baseStream, Common::Array<byte> &data, uint &bitHeight, uint &bitWidth, uint &rowBytes);
79  void decodePPIC(ObjID id, Common::Array<byte> &data, uint &bitHeight, uint &bitWidth, uint &rowBytes);
80 
81  void decodePPIC0(Common::BitStream32BEMSB &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes);
82  void decodePPIC1(Common::BitStream32BEMSB &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes);
83  void decodePPIC2(Common::BitStream32BEMSB &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes);
84  void decodePPIC3(Common::BitStream32BEMSB &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes);
85 
86  void decodeHuffGraphic(const PPICHuff &huff, Common::BitStream32BEMSB &stream, Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes);
87  byte walkHuff(const PPICHuff &huff, Common::BitStream32BEMSB &stream);
88 
89  void blitDirect(Graphics::ManagedSurface *target, int ox, int oy, const Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes);
90  void blitBIC(Graphics::ManagedSurface *target, int ox, int oy, const Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes);
91  void blitOR(Graphics::ManagedSurface *target, int ox, int oy, const Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes);
92  void blitXOR(Graphics::ManagedSurface *target, int ox, int oy, const Common::Array<byte> &data, uint bitHeight, uint bitWidth, uint rowBytes);
93 
94  void calculateSectionToDraw(Graphics::ManagedSurface *target, int &ox, int &oy, uint bitWidth, uint bitHeight, uint &sx, uint &sy, uint &w, uint &h);
95  void calculateSectionInDirection(uint targetWhole, uint originWhole, int &originPosition, uint &startPosition, uint &blittedWhole);
96 
97 private:
98  ObjID _id;
99  ObjID _mask;
100  Container *_container;
101 
102  uint16 _walkRepeat;
103  uint16 _walkLast;
104 
105  Common::Array<byte> _imgData;
106  uint16 _imgRowBytes;
107  uint16 _imgBitWidth;
108  uint16 _imgBitHeight;
109 
110  Common::Array<byte> _maskData;
111  uint16 _maskRowBytes;
112  uint16 _maskBitWidth;
113  uint16 _maskBitHeight;
114 };
115 
116 } // End of namespace MacVenture
117 
118 #endif
Definition: managed_surface.h:51
Definition: image.h:63
Definition: rect.h:524
Definition: stream.h:745
Definition: container.h:48
Definition: bitstream.h:55
Definition: rect.h:144
Definition: container.h:38
Definition: image.h:57