ZVISION: Overload renderImageToScreen to handle fileNames and ReadStreams

This commit is contained in:
richiesams 2013-08-03 13:51:11 -05:00
parent ebe83ed390
commit 47f10fe784
2 changed files with 25 additions and 9 deletions

View File

@ -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;
}

View File

@ -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; };