1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL$
* $Id$
*
*/
#ifndef PARALLACTION_IFF_H
#define PARALLACTION_IFF_H
#include "common/stream.h"
#include "common/iff_container.h" // for IFF chunk names
#include "graphics/iff.h" // for BMHD
// this IFF parser code is courtesy of the Kyra engine team ;)
namespace Parallaction {
class IFFParser {
public:
IFFParser() : _stream(0), _startOffset(0), _endOffset(0) {}
IFFParser(Common::SeekableReadStream *stream) : _stream(0), _startOffset(0), _endOffset(0) {
setInputStream(stream);
}
~IFFParser() { destroy(); }
void setInputStream(Common::SeekableReadStream *stream);
operator bool() const { return (_startOffset != _endOffset) && _stream; }
uint32 getFORMSize() const;
Common::IFF_ID getFORMType() const;
uint32 getIFFBlockSize(Common::IFF_ID chunk);
bool loadIFFBlock(Common::IFF_ID chunk, void *loadTo, uint32 ptrSize);
Common::SeekableReadStream *getIFFBlockStream(Common::IFF_ID chunkName);
private:
void destroy();
uint32 moveToIFFBlock(Common::IFF_ID chunkName);
Common::SeekableReadStream *_stream;
uint32 _startOffset;
uint32 _endOffset;
uint32 _formSize;
Common::IFF_ID _formType;
};
class ILBMDecoder {
Common::SeekableReadStream *_in;
bool _disposeStream;
void planarToChunky(byte *out, uint32 width, byte *in, uint32 planeWidth, uint32 nPlanes, bool packPlanes);
protected:
IFFParser _parser;
Graphics::BMHD _header;
bool _hasHeader;
uint32 _bodySize;
uint32 _paletteSize;
public:
ILBMDecoder(Common::SeekableReadStream *input, bool disposeStream = false);
virtual ~ILBMDecoder();
uint32 getWidth();
uint32 getHeight();
uint32 getNumColors();
byte *getPalette();
byte *getBitmap(uint32 numPlanes, bool packPlanes);
byte *getBitmap() {
assert(_hasHeader);
return getBitmap(_header.depth, false);
}
};
}
#endif
|