aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2015-01-02 03:59:35 +0200
committerFilippos Karapetis2015-01-07 11:42:23 +0200
commit535249389a16f780fba51dd2c7ca8e1eddf65de9 (patch)
tree6d61feef0229a5d5cc0ff83fef7f19228035e8b6
parent6dbdf037461eced4a86b7da0b2da13329d9cb3f7 (diff)
downloadscummvm-rg350-535249389a16f780fba51dd2c7ca8e1eddf65de9.tar.gz
scummvm-rg350-535249389a16f780fba51dd2c7ca8e1eddf65de9.tar.bz2
scummvm-rg350-535249389a16f780fba51dd2c7ca8e1eddf65de9.zip
ZVISION: Add a new command, "dumpimage", to dump any game image to BMP
-rw-r--r--engines/zvision/core/console.cpp59
-rw-r--r--engines/zvision/core/console.h1
2 files changed, 60 insertions, 0 deletions
diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp
index b5e542d777..65821b1702 100644
--- a/engines/zvision/core/console.cpp
+++ b/engines/zvision/core/console.cpp
@@ -53,6 +53,7 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) {
registerCmd("location", WRAP_METHOD(Console, cmdLocation));
registerCmd("dumpfile", WRAP_METHOD(Console, cmdDumpFile));
registerCmd("dumpfiles", WRAP_METHOD(Console, cmdDumpFiles));
+ registerCmd("dumpimage", WRAP_METHOD(Console, cmdDumpImage));
}
bool Console::cmdLoadVideo(int argc, const char **argv) {
@@ -269,4 +270,62 @@ bool Console::cmdDumpFiles(int argc, const char **argv) {
return true;
}
+bool Console::cmdDumpImage(int argc, const char **argv) {
+ if (argc != 2) {
+ debugPrintf("Use %s <TGA/TGZ name> to dump a ZVision TGA/TGZ image into a regular BMP image\n", argv[0]);
+ return true;
+ }
+
+ Common::String fileName = argv[1];
+ if (!fileName.hasSuffix(".tga")) {
+ debugPrintf("%s is not an image file", argv[1]);
+ }
+
+ Common::File f;
+ if (!_engine->getSearchManager()->openFile(f, argv[1])) {
+ warning("File not found: %s", argv[1]);
+ return true;
+ }
+
+ Graphics::Surface surface;
+ _engine->getRenderManager()->readImageToSurface(argv[1], surface, false);
+
+ // Open file
+ Common::DumpFile out;
+
+ fileName.setChar('b', fileName.size() - 3);
+ fileName.setChar('m', fileName.size() - 2);
+ fileName.setChar('p', fileName.size() - 1);
+
+ out.open(fileName);
+
+ // Write BMP header
+ out.writeByte('B');
+ out.writeByte('M');
+ out.writeUint32LE(surface.h * surface.pitch + 54);
+ out.writeUint32LE(0);
+ out.writeUint32LE(54);
+ out.writeUint32LE(40);
+ out.writeUint32LE(surface.w);
+ out.writeUint32LE(surface.h);
+ out.writeUint16LE(1);
+ out.writeUint16LE(16);
+ out.writeUint32LE(0);
+ out.writeUint32LE(0);
+ out.writeUint32LE(0);
+ out.writeUint32LE(0);
+ out.writeUint32LE(0);
+ out.writeUint32LE(0);
+
+ // Write pixel data to BMP
+ out.write(surface.getPixels(), surface.pitch * surface.h);
+
+ out.flush();
+ out.close();
+
+ surface.free();
+
+ return true;
+}
+
} // End of namespace ZVision
diff --git a/engines/zvision/core/console.h b/engines/zvision/core/console.h
index a7bd88ebc3..ffce87869f 100644
--- a/engines/zvision/core/console.h
+++ b/engines/zvision/core/console.h
@@ -47,6 +47,7 @@ private:
bool cmdLocation(int argc, const char **argv);
bool cmdDumpFile(int argc, const char **argv);
bool cmdDumpFiles(int argc, const char **argv);
+ bool cmdDumpImage(int argc, const char **argv);
};
} // End of namespace ZVision