aboutsummaryrefslogtreecommitdiff
path: root/graphics/iff.h
diff options
context:
space:
mode:
authorNorbert Lange2009-07-01 14:45:24 +0000
committerNorbert Lange2009-07-01 14:45:24 +0000
commitabef70f4e14f495b20097cb46411d1fafbafdd53 (patch)
tree27462f82f352b303ac059dd275466930c88b2de6 /graphics/iff.h
parent3b94e2488df9a699a899727515ac69af6a0a1a6e (diff)
parentf9298ff40310149779b37ccdecc873afba7adf2f (diff)
downloadscummvm-rg350-abef70f4e14f495b20097cb46411d1fafbafdd53.tar.gz
scummvm-rg350-abef70f4e14f495b20097cb46411d1fafbafdd53.tar.bz2
scummvm-rg350-abef70f4e14f495b20097cb46411d1fafbafdd53.zip
Merging in changes from trunk
svn-id: r41989
Diffstat (limited to 'graphics/iff.h')
-rw-r--r--graphics/iff.h101
1 files changed, 63 insertions, 38 deletions
diff --git a/graphics/iff.h b/graphics/iff.h
index 13b82a673c..fc1b6ceefa 100644
--- a/graphics/iff.h
+++ b/graphics/iff.h
@@ -52,55 +52,80 @@ struct BMHD {
BMHD() {
memset(this, 0, sizeof(*this));
}
-};
-
-// handles ILBM subtype of IFF FORM files
-//
-class ILBMDecoder : public Common::IFFParser {
+ void load(Common::ReadStream *stream);
+};
-protected:
- void readBMHD(Common::IFFChunk &chunk);
- void readCMAP(Common::IFFChunk &chunk);
- void readBODY(Common::IFFChunk &chunk);
- BMHD _bitmapHeader;
- uint32 _colorCount;
+struct ILBMDecoder {
+ /**
+ * ILBM header data, necessary for loadBitmap()
+ */
+ Graphics::BMHD _header;
+
+ /**
+ * Available decoding modes for loadBitmap().
+ */
+ enum {
+ ILBM_UNPACK_PLANES = 0xFF, //!< Decode all bitplanes, and map 1 pixel to 1 byte.
+ ILBM_PACK_PLANES = 0x100, //!< Request unpacking, used as a mask with below options.
+
+ ILBM_1_PLANES = 1, //!< Decode only the first bitplane, don't pack.
+ ILBM_1_PACK_PLANES = ILBM_1_PLANES | ILBM_PACK_PLANES, //!< Decode only the first bitplane, pack 8 pixels in 1 byte.
+ ILBM_2_PLANES = 2, //!< Decode first 2 bitplanes, don't pack.
+ ILBM_2_PACK_PLANES = ILBM_2_PLANES | ILBM_PACK_PLANES, //!< Decode first 2 bitplanes, pack 4 pixels in 1 byte.
+ ILBM_3_PLANES = 3, //!< Decode first 3 bitplanes, don't pack.
+ ILBM_4_PLANES = 4, //!< Decode first 4 bitplanes, don't pack.
+ ILBM_4_PACK_PLANES = ILBM_4_PLANES | ILBM_PACK_PLANES, //!< Decode first 4 bitplanes, pack 2 pixels in 1 byte.
+ ILBM_5_PLANES = 5, //!< Decode first 5 bitplanes, don't pack.
+ ILBM_8_PLANES = 8 //!< Decode all 8 bitplanes.
+ };
+
+ /**
+ * Fills the _header member from the given stream.
+ */
+ void loadHeader(Common::ReadStream *stream);
+
+ /**
+ * Loads and unpacks the ILBM bitmap data from the stream into the buffer.
+ * The functions assumes the buffer is large enough to contain all data.
+ * The caller controls how data should be packed by choosing mode from
+ * the enum above.
+ */
+ void loadBitmap(uint32 mode, byte *buffer, Common::ReadStream *stream);
+
+ /**
+ * Converts from bitplanar to chunky representation. Intended for internal
+ * usage, but you can be (ab)use it from client code if you know what you
+ * are doing.
+ */
+ void planarToChunky(byte *out, uint32 width, byte *in, uint32 planeWidth, uint32 nPlanes, bool packPlanes);
+};
- 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();
+struct PBMDecoder {
+ /**
+ * PBM header data, necessary for loadBitmap()
+ */
+ Graphics::BMHD _header;
+
+ /**
+ * Fills the _header member from the given stream.
+ */
+ void loadHeader(Common::ReadStream *stream);
+
+ /**
+ * Loads and unpacks the PBM bitmap data from the stream into the buffer.
+ * The functions assumes the buffer is large enough to contain all data.
+ */
+ void loadBitmap(byte *buffer, Common::ReadStream *stream);
};
-void decodePBM(Common::ReadStream &input, Surface &surface, byte *&colors);
+void decodePBM(Common::ReadStream &input, Surface &surface, byte *colors);
/*