Speech bubbles can point down right.
[scummvm-innocent.git] / graphics / iff.h
blobfc1b6ceefa28d765e26c57916864931b295a9b78
1 /* ScummVM - Graphic Adventure Engine
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.
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.
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.
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.
21 * $URL$
22 * $Id$
25 /**
26 * Bitmap decoder used in engines:
27 * - parallaction
28 * - saga
31 #ifndef GRAPHICS_IFF_H
32 #define GRAPHICS_IFF_H
34 #include "common/iff_container.h"
36 namespace Graphics {
38 struct Surface;
41 struct BMHD {
42 uint16 width, height;
43 uint16 x, y;
44 byte depth;
45 byte masking;
46 byte pack;
47 byte flags;
48 uint16 transparentColor;
49 byte xAspect, yAspect;
50 uint16 pageWidth, pageHeight;
52 BMHD() {
53 memset(this, 0, sizeof(*this));
56 void load(Common::ReadStream *stream);
60 struct ILBMDecoder {
61 /**
62 * ILBM header data, necessary for loadBitmap()
64 Graphics::BMHD _header;
66 /**
67 * Available decoding modes for loadBitmap().
69 enum {
70 ILBM_UNPACK_PLANES = 0xFF, //!< Decode all bitplanes, and map 1 pixel to 1 byte.
71 ILBM_PACK_PLANES = 0x100, //!< Request unpacking, used as a mask with below options.
73 ILBM_1_PLANES = 1, //!< Decode only the first bitplane, don't pack.
74 ILBM_1_PACK_PLANES = ILBM_1_PLANES | ILBM_PACK_PLANES, //!< Decode only the first bitplane, pack 8 pixels in 1 byte.
75 ILBM_2_PLANES = 2, //!< Decode first 2 bitplanes, don't pack.
76 ILBM_2_PACK_PLANES = ILBM_2_PLANES | ILBM_PACK_PLANES, //!< Decode first 2 bitplanes, pack 4 pixels in 1 byte.
77 ILBM_3_PLANES = 3, //!< Decode first 3 bitplanes, don't pack.
78 ILBM_4_PLANES = 4, //!< Decode first 4 bitplanes, don't pack.
79 ILBM_4_PACK_PLANES = ILBM_4_PLANES | ILBM_PACK_PLANES, //!< Decode first 4 bitplanes, pack 2 pixels in 1 byte.
80 ILBM_5_PLANES = 5, //!< Decode first 5 bitplanes, don't pack.
81 ILBM_8_PLANES = 8 //!< Decode all 8 bitplanes.
84 /**
85 * Fills the _header member from the given stream.
87 void loadHeader(Common::ReadStream *stream);
89 /**
90 * Loads and unpacks the ILBM bitmap data from the stream into the buffer.
91 * The functions assumes the buffer is large enough to contain all data.
92 * The caller controls how data should be packed by choosing mode from
93 * the enum above.
95 void loadBitmap(uint32 mode, byte *buffer, Common::ReadStream *stream);
97 /**
98 * Converts from bitplanar to chunky representation. Intended for internal
99 * usage, but you can be (ab)use it from client code if you know what you
100 * are doing.
102 void planarToChunky(byte *out, uint32 width, byte *in, uint32 planeWidth, uint32 nPlanes, bool packPlanes);
108 // handles PBM subtype of IFF FORM files
110 struct PBMDecoder {
112 * PBM header data, necessary for loadBitmap()
114 Graphics::BMHD _header;
117 * Fills the _header member from the given stream.
119 void loadHeader(Common::ReadStream *stream);
122 * Loads and unpacks the PBM bitmap data from the stream into the buffer.
123 * The functions assumes the buffer is large enough to contain all data.
125 void loadBitmap(byte *buffer, Common::ReadStream *stream);
128 void decodePBM(Common::ReadStream &input, Surface &surface, byte *colors);
132 PackBits is a RLE compression algorithm introduced
133 by Apple. It is also used to encode ILBM and PBM
134 subtypes of IFF files, and some flavours of TIFF.
136 As there is no compression across row boundaries
137 in the above formats, read() will extract a *new*
138 line on each call, discarding any alignment or
139 padding.
141 class PackBitsReadStream : public Common::ReadStream {
143 protected:
144 Common::ReadStream *_input;
146 public:
147 PackBitsReadStream(Common::ReadStream &input);
148 ~PackBitsReadStream();
150 virtual bool eos() const;
152 uint32 read(void *dataPtr, uint32 dataSize);
157 #endif