From 008042ac2538bebfce013cb0ec4efa4a5600e4bb Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Tue, 1 May 2007 15:39:40 +0000 Subject: Implemented a IFF (Interchange File Format) parser and added subclasses to parse graphics (ILBM, PBM) and audio (8SVX), thus replacing old decoding routines. SAGA and Parallaction have been adjusted to work with the new code. svn-id: r26719 --- graphics/iff.h | 139 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 graphics/iff.h (limited to 'graphics/iff.h') diff --git a/graphics/iff.h b/graphics/iff.h new file mode 100644 index 0000000000..d716418f8f --- /dev/null +++ b/graphics/iff.h @@ -0,0 +1,139 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2006 The ScummVM project + * + * 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 GRAPHICS_IFF_H +#define GRAPHICS_IFF_H + +#include "common/iff_container.h" + +namespace Graphics { + +class Surface; + + +struct BMHD { + uint16 width, height; + uint16 x, y; + byte depth; + byte masking; + byte pack; + byte flags; + uint16 transparentColor; + byte xAspect, yAspect; + uint16 pageWidth, pageHeight; + + BMHD() { + memset(this, 0, sizeof(*this)); + } +}; + + +// handles ILBM subtype of IFF FORM files +// +class ILBMDecoder : public Common::IFFParser { + +protected: + void readBMHD(Common::IFFChunk &chunk); + void readCMAP(Common::IFFChunk &chunk); + void readBODY(Common::IFFChunk &chunk); + + BMHD _bitmapHeader; + uint32 _colorCount; + + Surface *_surface; + byte **_colors; + + void fillPlane(byte *out, byte* buf, uint32 width, uint32 plane); + +public: + ILBMDecoder(Common::ReadStream &input, Surface &surface, byte *&colors); + virtual ~ILBMDecoder() { } + void decode(); +}; + + +// handles PBM subtype of IFF FORM files +// +class PBMDecoder : public Common::IFFParser { + +protected: + void readBMHD(Common::IFFChunk &chunk); + void readCMAP(Common::IFFChunk &chunk); + void readBODY(Common::IFFChunk &chunk); + + BMHD _bitmapHeader; + uint32 _colorCount; + + Surface *_surface; + byte **_colors; + +public: + PBMDecoder(Common::ReadStream &input, Surface &surface, byte *&colors); + virtual ~PBMDecoder() { } + void decode(); +}; + +/* + TODO: rename this routine to decodePBM, and update the SAGA code that's + using it. The routine has already been implemented using the above PBMDecoder. +*/ +void decodeILBM(Common::ReadStream &input, Surface &surface, byte *&colors); + + +/* + PackBits is a RLE compression algorithm introduced + by Apple. It is also used to encode ILBM and PBM + subtypes of IFF files, and some flavours of TIFF. + + The following implementation uses a static storage + and is buffered, that means you can't destroy the + input stream before you are done with it. +*/ +class PackBitsReadStream : public Common::ReadStream { + +protected: + Common::ReadStream *_input; + + byte _storage[257]; + byte *_wStoragePos; + byte *_rStoragePos; + + int32 _outSize; + byte* _out; + int32 _fed; + int32 _unpacked; + + void store(byte b); + void feed(); + void unpack(); + +public: + PackBitsReadStream(Common::ReadStream &input); + ~PackBitsReadStream(); + + virtual bool eos() const; + uint32 read(void *dataPtr, uint32 dataSize); +}; + +} + +#endif -- cgit v1.2.3 From 727867c66f5d856a848bbb6bb67543342dd0c63b Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Tue, 1 May 2007 17:28:59 +0000 Subject: - Fixed 32/64 bits pointer mismatch. - Changed Surface's forward from class to struct. svn-id: r26727 --- graphics/iff.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'graphics/iff.h') diff --git a/graphics/iff.h b/graphics/iff.h index d716418f8f..740f4b6d8c 100644 --- a/graphics/iff.h +++ b/graphics/iff.h @@ -27,7 +27,7 @@ namespace Graphics { -class Surface; +struct Surface; struct BMHD { @@ -117,8 +117,8 @@ protected: byte *_wStoragePos; byte *_rStoragePos; - int32 _outSize; byte* _out; + byte* _outEnd; int32 _fed; int32 _unpacked; -- cgit v1.2.3 From d08eeff7002d7296b2367242b66ca2e03c1ce4a1 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 1 May 2007 21:40:56 +0000 Subject: Renamed decodeILBM to decodePBM, removed a TODO svn-id: r26731 --- graphics/iff.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'graphics/iff.h') diff --git a/graphics/iff.h b/graphics/iff.h index 740f4b6d8c..322c372592 100644 --- a/graphics/iff.h +++ b/graphics/iff.h @@ -92,11 +92,7 @@ public: void decode(); }; -/* - TODO: rename this routine to decodePBM, and update the SAGA code that's - using it. The routine has already been implemented using the above PBMDecoder. -*/ -void decodeILBM(Common::ReadStream &input, Surface &surface, byte *&colors); +void decodePBM(Common::ReadStream &input, Surface &surface, byte *&colors); /* -- cgit v1.2.3