From 79995f6222530c49d6bc5b46a3b5939af6ae093a Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 21 Aug 2016 11:04:18 +0200 Subject: DIRECTOR: Stub for 1bpp bitmap decoder --- engines/director/dib.cpp | 111 ------------------------------- engines/director/dib.h | 67 ------------------- engines/director/director.cpp | 2 +- engines/director/images.cpp | 150 ++++++++++++++++++++++++++++++++++++++++++ engines/director/images.h | 87 ++++++++++++++++++++++++ engines/director/module.mk | 2 +- engines/director/score.cpp | 19 +++--- 7 files changed, 250 insertions(+), 188 deletions(-) delete mode 100644 engines/director/dib.cpp delete mode 100644 engines/director/dib.h create mode 100644 engines/director/images.cpp create mode 100644 engines/director/images.h (limited to 'engines/director') diff --git a/engines/director/dib.cpp b/engines/director/dib.cpp deleted file mode 100644 index 04665e7d34..0000000000 --- a/engines/director/dib.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* 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. - * - */ - -#include "director/dib.h" - -#include "common/stream.h" -#include "common/substream.h" -#include "common/textconsole.h" -#include "graphics/pixelformat.h" -#include "graphics/surface.h" -#include "graphics/palette.h" -#include "image/codecs/codec.h" -#include "common/util.h" -#include "common/debug.h" -#include "image/codecs/bmp_raw.h" -#include "common/system.h" - -namespace Director { - -DIBDecoder::DIBDecoder() { - _surface = 0; - _palette = 0; - _paletteColorCount = 0; - _codec = 0; -} - -DIBDecoder::~DIBDecoder() { - destroy(); -} - -void DIBDecoder::destroy() { - _surface = 0; - - delete[] _palette; - _palette = 0; - _paletteColorCount = 0; - - delete _codec; - _codec = 0; -} - -void DIBDecoder::loadPalette(Common::SeekableReadStream &stream) { - uint16 steps = stream.size() / 6; - uint16 index = (steps * 3) - 1; - _paletteColorCount = steps; - _palette = new byte[index + 1]; - - for (uint8 i = 0; i < steps; i++) { - _palette[index - 2] = stream.readByte(); - stream.readByte(); - - _palette[index - 1] = stream.readByte(); - stream.readByte(); - - _palette[index] = stream.readByte(); - stream.readByte(); - index -= 3; - } -} - -bool DIBDecoder::loadStream(Common::SeekableReadStream &stream) { - uint32 headerSize = stream.readUint32LE(); - if (headerSize != 40) - return false; - - uint32 width = stream.readUint32LE(); - uint32 height = stream.readUint32LE(); - stream.readUint16LE(); // planes - uint16 bitsPerPixel = stream.readUint16LE(); - uint32 compression = stream.readUint32BE(); - uint32 imageSize = stream.readUint32LE(); - /* uint32 pixelsPerMeterX = */ stream.readUint32LE(); - /* uint32 pixelsPerMeterY = */ stream.readUint32LE(); - _paletteColorCount = stream.readUint32LE(); - /* uint32 colorsImportant = */ stream.readUint32LE(); - - _paletteColorCount = (_paletteColorCount == 0) ? 255: _paletteColorCount; - - uint16 imageRawSize = stream.size() - 40; - Common::SeekableSubReadStream subStream(&stream, 40, stream.size()); - - _codec = Image::createBitmapCodec(compression, width, height, bitsPerPixel); - - if (!_codec) - return false; - - _surface = _codec->decodeFrame(subStream); - - return true; -} - -} // End of namespace Director diff --git a/engines/director/dib.h b/engines/director/dib.h deleted file mode 100644 index e3763be2bf..0000000000 --- a/engines/director/dib.h +++ /dev/null @@ -1,67 +0,0 @@ -/* 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. - * - */ - -#ifndef DIRECTOR_DIB_H -#define DIRECTOR_DIB_H - -#include "common/scummsys.h" -#include "common/str.h" -#include "image/image_decoder.h" -#include "image/codecs/bmp_raw.h" - -namespace Common { -class SeekableReadStream; -} - -namespace Graphics { -struct Surface; -} - -namespace Image { -class Codec; -} - -namespace Director { - -class DIBDecoder : public Image::ImageDecoder { -public: - DIBDecoder(); - virtual ~DIBDecoder(); - - // ImageDecoder API - void destroy(); - virtual bool loadStream(Common::SeekableReadStream &stream); - virtual const Graphics::Surface *getSurface() const { return _surface; } - const byte *getPalette() const { return _palette; } - void loadPalette(Common::SeekableReadStream &stream); - uint16 getPaletteColorCount() const { return _paletteColorCount; } - -private: - Image::Codec *_codec; - const Graphics::Surface *_surface; - byte *_palette; - uint8 _paletteColorCount; -}; - -} // End of namespace Director - -#endif diff --git a/engines/director/director.cpp b/engines/director/director.cpp index 4898994f9f..01b5085e60 100644 --- a/engines/director/director.cpp +++ b/engines/director/director.cpp @@ -40,7 +40,7 @@ #include "graphics/macgui/macwindowmanager.h" #include "director/director.h" -#include "director/dib.h" +#include "director/images.h" #include "director/resource.h" #include "director/score.h" #include "director/lingo/lingo.h" diff --git a/engines/director/images.cpp b/engines/director/images.cpp new file mode 100644 index 0000000000..9bfd1e5397 --- /dev/null +++ b/engines/director/images.cpp @@ -0,0 +1,150 @@ +/* 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. + * + */ + +#include "common/stream.h" +#include "common/substream.h" +#include "common/textconsole.h" +#include "graphics/pixelformat.h" +#include "graphics/surface.h" +#include "graphics/palette.h" +#include "image/codecs/codec.h" +#include "common/util.h" +#include "common/debug.h" +#include "image/codecs/bmp_raw.h" +#include "common/system.h" + +#include "director/images.h" + +namespace Director { + +DIBDecoder::DIBDecoder() { + _surface = 0; + _palette = 0; + _paletteColorCount = 0; + _codec = 0; +} + +DIBDecoder::~DIBDecoder() { + destroy(); +} + +void DIBDecoder::destroy() { + _surface = 0; + + delete[] _palette; + _palette = 0; + _paletteColorCount = 0; + + delete _codec; + _codec = 0; +} + +void DIBDecoder::loadPalette(Common::SeekableReadStream &stream) { + uint16 steps = stream.size() / 6; + uint16 index = (steps * 3) - 1; + _paletteColorCount = steps; + _palette = new byte[index + 1]; + + for (uint8 i = 0; i < steps; i++) { + _palette[index - 2] = stream.readByte(); + stream.readByte(); + + _palette[index - 1] = stream.readByte(); + stream.readByte(); + + _palette[index] = stream.readByte(); + stream.readByte(); + index -= 3; + } +} + +bool DIBDecoder::loadStream(Common::SeekableReadStream &stream) { + uint32 headerSize = stream.readUint32LE(); + if (headerSize != 40) + return false; + + uint32 width = stream.readUint32LE(); + uint32 height = stream.readUint32LE(); + stream.readUint16LE(); // planes + uint16 bitsPerPixel = stream.readUint16LE(); + uint32 compression = stream.readUint32BE(); + uint32 imageSize = stream.readUint32LE(); + /* uint32 pixelsPerMeterX = */ stream.readUint32LE(); + /* uint32 pixelsPerMeterY = */ stream.readUint32LE(); + _paletteColorCount = stream.readUint32LE(); + /* uint32 colorsImportant = */ stream.readUint32LE(); + + _paletteColorCount = (_paletteColorCount == 0) ? 255: _paletteColorCount; + + uint16 imageRawSize = stream.size() - 40; + Common::SeekableSubReadStream subStream(&stream, 40, stream.size()); + + _codec = Image::createBitmapCodec(compression, width, height, bitsPerPixel); + + if (!_codec) + return false; + + _surface = _codec->decodeFrame(subStream); + + return true; +} + +BITDDecoder::BITDDecoder() { + _surface = 0; + _palette = 0; + _paletteColorCount = 0; + _codec = 0; +} + +BITDDecoder::~BITDDecoder() { + destroy(); +} + +void BITDDecoder::destroy() { + _surface = 0; + + delete[] _palette; + _palette = 0; + _paletteColorCount = 0; + + delete _codec; + _codec = 0; +} + +void BITDDecoder::loadPalette(Common::SeekableReadStream &stream) { + _palette = new byte[2 * 3]; + + _palette[0] = _palette[1] = _palette[2] = 0; + _palette[3] = _palette[4] = _palette[5] = 0xff; +} + +bool BITDDecoder::loadStream(Common::SeekableReadStream &stream) { + uint32 width = 512; // Should come from the Cast + uint32 height = 342; + + _surface = new Graphics::Surface(); + _surface->create(width, height, Graphics::PixelFormat::createFormatCLUT8()); + + return true; +} + +} // End of namespace Director diff --git a/engines/director/images.h b/engines/director/images.h new file mode 100644 index 0000000000..821b85ad48 --- /dev/null +++ b/engines/director/images.h @@ -0,0 +1,87 @@ +/* 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. + * + */ + +#ifndef DIRECTOR_IMAGES_H +#define DIRECTOR_IMAGES_H + +#include "common/scummsys.h" +#include "common/str.h" +#include "image/image_decoder.h" +#include "image/codecs/bmp_raw.h" + +namespace Common { +class SeekableReadStream; +} + +namespace Graphics { +struct Surface; +} + +namespace Image { +class Codec; +} + +namespace Director { + +class DIBDecoder : public Image::ImageDecoder { +public: + DIBDecoder(); + virtual ~DIBDecoder(); + + // ImageDecoder API + void destroy(); + virtual bool loadStream(Common::SeekableReadStream &stream); + virtual const Graphics::Surface *getSurface() const { return _surface; } + const byte *getPalette() const { return _palette; } + void loadPalette(Common::SeekableReadStream &stream); + uint16 getPaletteColorCount() const { return _paletteColorCount; } + +private: + Image::Codec *_codec; + const Graphics::Surface *_surface; + byte *_palette; + uint8 _paletteColorCount; +}; + +class BITDDecoder : public Image::ImageDecoder { +public: + BITDDecoder(); + virtual ~BITDDecoder(); + + // ImageDecoder API + void destroy(); + virtual bool loadStream(Common::SeekableReadStream &stream); + virtual const Graphics::Surface *getSurface() const { return _surface; } + const byte *getPalette() const { return _palette; } + void loadPalette(Common::SeekableReadStream &stream); + uint16 getPaletteColorCount() const { return _paletteColorCount; } + +private: + Image::Codec *_codec; + Graphics::Surface *_surface; + byte *_palette; + uint8 _paletteColorCount; +}; + +} // End of namespace Director + +#endif diff --git a/engines/director/module.mk b/engines/director/module.mk index 2499528304..05e92b76e0 100644 --- a/engines/director/module.mk +++ b/engines/director/module.mk @@ -2,8 +2,8 @@ MODULE := engines/director MODULE_OBJS = \ detection.o \ - dib.o \ director.o \ + images.o \ movie.o \ resource.o \ score.o \ diff --git a/engines/director/score.cpp b/engines/director/score.cpp index 231cb41a88..662820840e 100644 --- a/engines/director/score.cpp +++ b/engines/director/score.cpp @@ -20,7 +20,6 @@ * */ -#include "director/score.h" #include "common/stream.h" #include "common/debug.h" #include "common/file.h" @@ -28,12 +27,6 @@ #include "common/config-manager.h" #include "common/unzip.h" -#include "common/system.h" -#include "director/dib.h" -#include "director/resource.h" -#include "director/lingo/lingo.h" -#include "director/sound.h" - #include "graphics/palette.h" #include "common/events.h" #include "engines/util.h" @@ -43,6 +36,12 @@ #include "graphics/fontman.h" #include "graphics/fonts/bdf.h" +#include "director/score.h" +#include "director/images.h" +#include "director/resource.h" +#include "director/lingo/lingo.h" +#include "director/sound.h" + namespace Director { static byte defaultPalette[768] = { @@ -1339,7 +1338,11 @@ Image::ImageDecoder *Frame::getImageFrom(uint16 spriteId) { } if (_vm->_currentScore->getArchive()->hasResource(MKTAG('B', 'I', 'T', 'D'), imgId)) { - img = new Image::BitmapDecoder(); + if (_vm->getVersion() < 4) { + img = new BITDDecoder(); + } else { + img = new Image::BitmapDecoder(); + } if (debugChannelSet(8, kDebugLoading)) { Common::SeekableReadStream *s = _vm->_currentScore->getArchive()->getResource(MKTAG('B', 'I', 'T', 'D'), imgId); -- cgit v1.2.3