diff options
-rw-r--r-- | engines/zvision/image.cpp | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/engines/zvision/image.cpp b/engines/zvision/image.cpp index 1463401e0f..35ec9b3e2f 100644 --- a/engines/zvision/image.cpp +++ b/engines/zvision/image.cpp @@ -35,49 +35,49 @@ namespace ZVision { void ZVision::renderImageToScreen(const Common::String &fileName, uint32 x, uint32 y) { Common::File file; - if (file.open(fileName)) { - // Read the magic number - // Some files are true TGA, while others are TGZ - char fileType[4]; - file.read(fileType, 4); - - // Check for true TGA files - if (fileType[0] == 'T' && fileType[1] == 'G' && fileType[2] == 'A' && fileType[3] == '\0') { - // Reset the cursor - file.seek(0); - - // Decode - Graphics::TGADecoder tga; - if (!tga.loadStream(file)) - error("Error while reading TGA image"); - file.close(); - - const Graphics::Surface *tgaSurface = tga.getSurface(); - - _system->copyRectToScreen(tgaSurface->pixels, tgaSurface->pitch, x, y, tgaSurface->w, tgaSurface->h); - - tga.destroy(); - } else { - // TGZ files have a header and then Bitmap data that is compressed with LZSS - uint32 decompressedSize = file.readSint32LE(); - uint32 width = file.readSint32LE(); - uint32 height = file.readSint32LE(); - - LzssReadStream stream(&file, false, decompressedSize); - byte *buffer = new byte[stream.currentSize()]; - stream.read(buffer, stream.currentSize()); - - //Graphics::PixelFormat format(16, 5, 6, 5, 0, 11, 5, 0, 0); - // Graphics::PixelFormat format(16, 5, 5, 5, 1, 11, 6, 1, 0); - - _system->copyRectToScreen(buffer, width * 2, x, y, width, height); - } - - - _needsScreenUpdate = true; - } else { + if (!file.open(fileName)) { error("Could not open file %s", fileName.c_str()); + return; } + + // Read the magic number + // Some files are true TGA, while others are TGZ + char fileType[4]; + file.read(fileType, 4); + + // Check for TGZ files + if (fileType[0] == 'T' && fileType[1] == 'G' && fileType[2] == 'Z' && fileType[3] == '\0') { + // TGZ files have a header and then Bitmap data that is compressed with LZSS + uint32 decompressedSize = file.readSint32LE(); + uint32 width = file.readSint32LE(); + uint32 height = file.readSint32LE(); + + LzssReadStream stream(&file, false, decompressedSize); + byte *buffer = new byte[stream.currentSize()]; + stream.read(buffer, stream.currentSize()); + + //Graphics::PixelFormat format(16, 5, 6, 5, 0, 11, 5, 0, 0); + // Graphics::PixelFormat format(16, 5, 5, 5, 1, 11, 6, 1, 0); + + _system->copyRectToScreen(buffer, width * 2, x, y, width, height); + } else { + // Reset the cursor + file.seek(0); + + // Decode + Graphics::TGADecoder tga; + if (!tga.loadStream(file)) + error("Error while reading TGA image"); + file.close(); + + const Graphics::Surface *tgaSurface = tga.getSurface(); + + _system->copyRectToScreen(tgaSurface->pixels, tgaSurface->pitch, x, y, tgaSurface->w, tgaSurface->h); + + tga.destroy(); + } + + _needsScreenUpdate = true; } } // End of namespace ZVision |