From 47f10fe78426159f76abd585f4b40f3025e7473f Mon Sep 17 00:00:00 2001 From: richiesams Date: Sat, 3 Aug 2013 13:51:11 -0500 Subject: ZVISION: Overload renderImageToScreen to handle fileNames and ReadStreams --- engines/zvision/render_manager.cpp | 22 +++++++++++++--------- engines/zvision/render_manager.h | 12 ++++++++++++ 2 files changed, 25 insertions(+), 9 deletions(-) (limited to 'engines/zvision') diff --git a/engines/zvision/render_manager.cpp b/engines/zvision/render_manager.cpp index 7edbf52039..4fd1a83088 100644 --- a/engines/zvision/render_manager.cpp +++ b/engines/zvision/render_manager.cpp @@ -63,14 +63,14 @@ void RenderManager::updateScreen(bool isConsoleActive) { void RenderManager::renderSubRectToScreen(uint16 *buffer, uint32 imageWidth, uint32 imageHeight, uint32 horizontalPitch, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle) { // Panoramas are transposed - // The actual data is transposed in the RenderTable lookup + // The actual data is transposed in mutateImage if (_renderTable.getRenderState() == RenderTable::PANORAMA || _renderTable.getRenderState() == RenderTable::TILT) { uint32 temp = imageHeight; imageHeight = imageWidth; imageWidth = temp; } - // Check if we truly want a subRect of the image + // If subRect is empty, use the entire image if (subRectangle.isEmpty()) subRectangle = Common::Rect(imageWidth, imageHeight); @@ -107,19 +107,23 @@ void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 d return; } + renderImageToScreen(file, destinationX, destinationY, subRectangle); +} + +void RenderManager::renderImageToScreen(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle) { // Read the magic number // Some files are true TGA, while others are TGZ uint32 fileType; - fileType = file.readUint32BE(); + fileType = stream.readUint32BE(); // Check for TGZ files if (fileType == MKTAG('T', 'G', 'Z', '\0')) { // TGZ files have a header and then Bitmap data that is compressed with LZSS - uint32 decompressedSize = file.readSint32LE(); - uint32 imageWidth = file.readSint32LE(); - uint32 imageHeight = file.readSint32LE(); + uint32 decompressedSize = stream.readSint32LE(); + uint32 imageWidth = stream.readSint32LE(); + uint32 imageHeight = stream.readSint32LE(); - LzssReadStream stream(&file); + LzssReadStream stream(&stream); byte *buffer = new byte[decompressedSize]; stream.read(buffer, decompressedSize); @@ -129,11 +133,11 @@ void RenderManager::renderImageToScreen(const Common::String &fileName, uint32 d delete[] buffer; } else { // Reset the cursor - file.seek(0); + stream.seek(0); // Decode Graphics::TGADecoder tga; - if (!tga.loadStream(file)) { + if (!tga.loadStream(stream)) { warning("Error while reading TGA image"); return; } diff --git a/engines/zvision/render_manager.h b/engines/zvision/render_manager.h index 8b4d7e840b..f9d1375ecf 100644 --- a/engines/zvision/render_manager.h +++ b/engines/zvision/render_manager.h @@ -34,6 +34,7 @@ class OSystem; namespace Common { class String; +class SeekableReadStream; } namespace Video { @@ -89,6 +90,17 @@ public: */ void renderImageToScreen(const Common::String &fileName, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle = Common::Rect(0, 0, 0, 0)); + /** + * Blits the image or a portion of the image to the screen. Actual screen updates won't happen until the end of the frame. + * The image will be clipped to fit inside the window. + * + * @param stream Stream to read the image data from + * @param destinationX X position where the image should be put + * @param destinationY Y position where the image should be put + * @param subRectangle The subrectangle of the image that should be rendered. If this is an empty rectangle, it will blit the entire image. + */ + void renderImageToScreen(Common::SeekableReadStream &stream, uint32 destinationX, uint32 destinationY, Common::Rect subRectangle = Common::Rect(0, 0, 0, 0)); + RenderTable *getRenderTable(); bool needsScreenUpdate() { return _needsScreenUpdate; }; -- cgit v1.2.3