Initial commit
This commit is contained in:
70
engines/cryomni3d/image/hlz.cpp
Normal file
70
engines/cryomni3d/image/hlz.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "cryomni3d/image/hlz.h"
|
||||
|
||||
#include "common/stream.h"
|
||||
#include "common/substream.h"
|
||||
#include "common/textconsole.h"
|
||||
#include "graphics/pixelformat.h"
|
||||
#include "graphics/surface.h"
|
||||
#include "image/codecs/codec.h"
|
||||
|
||||
#include "image/codecs/hlz.h"
|
||||
|
||||
namespace Image {
|
||||
|
||||
HLZFileDecoder::HLZFileDecoder() : _codec(nullptr), _surface(nullptr), _palette(256) {
|
||||
}
|
||||
|
||||
HLZFileDecoder::~HLZFileDecoder() {
|
||||
destroy();
|
||||
}
|
||||
|
||||
void HLZFileDecoder::destroy() {
|
||||
delete _codec;
|
||||
_codec = nullptr;
|
||||
_surface = nullptr;
|
||||
}
|
||||
|
||||
bool HLZFileDecoder::loadStream(Common::SeekableReadStream &stream) {
|
||||
destroy();
|
||||
|
||||
for (uint16 i = 0; i < 256; i++) {
|
||||
byte r = stream.readByte();
|
||||
byte g = stream.readByte();
|
||||
byte b = stream.readByte();
|
||||
_palette.set(i, r, g, b);
|
||||
}
|
||||
|
||||
uint16 width = stream.readUint16LE();
|
||||
uint16 height = stream.readUint16LE();
|
||||
|
||||
if (width == 0 || height == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
_codec = new HLZDecoder(width, height);
|
||||
_surface = _codec->decodeFrame(stream);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // End of namespace Image
|
||||
60
engines/cryomni3d/image/hlz.h
Normal file
60
engines/cryomni3d/image/hlz.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRYOMNI3D_IMAGE_HLZ_H
|
||||
#define CRYOMNI3D_IMAGE_HLZ_H
|
||||
|
||||
#include "common/scummsys.h"
|
||||
#include "common/str.h"
|
||||
#include "graphics/palette.h"
|
||||
#include "image/image_decoder.h"
|
||||
|
||||
namespace Common {
|
||||
class SeekableReadStream;
|
||||
}
|
||||
|
||||
namespace Graphics {
|
||||
struct Surface;
|
||||
}
|
||||
|
||||
namespace Image {
|
||||
class HLZDecoder;
|
||||
|
||||
class HLZFileDecoder : public ImageDecoder {
|
||||
public:
|
||||
HLZFileDecoder();
|
||||
~HLZFileDecoder() override;
|
||||
|
||||
// ImageDecoder API
|
||||
void destroy() override;
|
||||
bool loadStream(Common::SeekableReadStream &stream) override;
|
||||
const Graphics::Surface *getSurface() const override { return _surface; }
|
||||
const Graphics::Palette &getPalette() const override { return _palette; }
|
||||
|
||||
private:
|
||||
HLZDecoder *_codec;
|
||||
const Graphics::Surface *_surface;
|
||||
Graphics::Palette _palette;
|
||||
};
|
||||
|
||||
} // End of namespace Image
|
||||
|
||||
#endif
|
||||
116
engines/cryomni3d/image/hnm.cpp
Normal file
116
engines/cryomni3d/image/hnm.cpp
Normal file
@@ -0,0 +1,116 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "cryomni3d/image/hnm.h"
|
||||
|
||||
#include "common/stream.h"
|
||||
#include "common/substream.h"
|
||||
#include "common/textconsole.h"
|
||||
#include "graphics/pixelformat.h"
|
||||
#include "graphics/surface.h"
|
||||
#include "image/codecs/codec.h"
|
||||
|
||||
#include "image/codecs/hnm.h"
|
||||
|
||||
namespace Image {
|
||||
|
||||
HNMFileDecoder::HNMFileDecoder(const Graphics::PixelFormat &format) :
|
||||
_format(format), _surface(nullptr), _codec(nullptr) {
|
||||
}
|
||||
|
||||
HNMFileDecoder::~HNMFileDecoder() {
|
||||
destroy();
|
||||
}
|
||||
|
||||
void HNMFileDecoder::destroy() {
|
||||
delete _codec;
|
||||
_codec = nullptr;
|
||||
_surface = nullptr;
|
||||
}
|
||||
|
||||
bool HNMFileDecoder::loadStream(Common::SeekableReadStream &stream) {
|
||||
destroy();
|
||||
|
||||
uint32 tag = stream.readUint32BE();
|
||||
|
||||
/* Only HNM6 for HNM images */
|
||||
if (tag != MKTAG('H', 'N', 'M', '6')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//uint16 ukn = stream.readUint16BE();
|
||||
//byte audioflags = stream.readByte();
|
||||
//byte bpp = stream.readByte();
|
||||
stream.skip(4);
|
||||
uint16 width = stream.readUint16LE();
|
||||
uint16 height = stream.readUint16LE();
|
||||
//uint32 filesize = stream.readUint32LE();
|
||||
//uint32 numframes = stream.readUint32LE();
|
||||
//uint32 ukn2 = stream.readUint32LE();
|
||||
//uint16 speed = stream.readUint16LE();
|
||||
//uint16 maxbuffer = stream.readUint16LE();
|
||||
//uint32 buffer_size = stream.readUint32LE();
|
||||
//byte unknownStr[16];
|
||||
//byte copyright[16];
|
||||
//stream.read(unknownStr, sizeof(unknownStr));
|
||||
//stream.read(copyright, sizeof(copyright));
|
||||
|
||||
stream.skip(52);
|
||||
|
||||
if (width == 0 || height == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read frame header
|
||||
uint32 frameSize = stream.readUint32LE();
|
||||
if (frameSize < 12) {
|
||||
return false;
|
||||
}
|
||||
frameSize -= 4;
|
||||
|
||||
// Read chunk header
|
||||
uint32 chunkSize = stream.readUint32LE();
|
||||
uint16 chunkTag = stream.readUint16BE();
|
||||
//uint16 chunkUkn = stream.readUint16LE();
|
||||
stream.skip(2);
|
||||
|
||||
if (frameSize < chunkSize ||
|
||||
chunkSize < 8 + 24) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool warp;
|
||||
if (chunkTag == MKTAG16('I', 'W')) {
|
||||
warp = true;
|
||||
} else if (chunkTag == MKTAG16('I', 'X')) {
|
||||
warp = false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
// buffer_size is not reliable on IW and we already have the real size of the image source
|
||||
_codec = createHNM6Decoder(width, height, _format, chunkSize, false);
|
||||
_codec->setWarpMode(warp);
|
||||
_surface = _codec->decodeFrame(stream);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // End of namespace Image
|
||||
59
engines/cryomni3d/image/hnm.h
Normal file
59
engines/cryomni3d/image/hnm.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CRYOMNI3D_IMAGE_HNM_H
|
||||
#define CRYOMNI3D_IMAGE_HNM_H
|
||||
|
||||
#include "common/scummsys.h"
|
||||
#include "common/str.h"
|
||||
#include "graphics/pixelformat.h"
|
||||
#include "image/image_decoder.h"
|
||||
|
||||
namespace Common {
|
||||
class SeekableReadStream;
|
||||
}
|
||||
|
||||
namespace Graphics {
|
||||
struct Surface;
|
||||
}
|
||||
|
||||
namespace Image {
|
||||
class HNM6Decoder;
|
||||
|
||||
class HNMFileDecoder : public ImageDecoder {
|
||||
public:
|
||||
HNMFileDecoder(const Graphics::PixelFormat &format);
|
||||
~HNMFileDecoder() override;
|
||||
|
||||
// ImageDecoder API
|
||||
void destroy() override;
|
||||
bool loadStream(Common::SeekableReadStream &stream) override;
|
||||
const Graphics::Surface *getSurface() const override { return _surface; }
|
||||
|
||||
private:
|
||||
Graphics::PixelFormat _format;
|
||||
HNM6Decoder *_codec;
|
||||
const Graphics::Surface *_surface;
|
||||
};
|
||||
|
||||
} // End of namespace Image
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user