DIRECTOR: Dump bitmap as PNGs when --dump-scripts is invoked.

This dump all Bitmap cast members into PNGs when --dump-scripts is invoked.
This commit is contained in:
kartiksharmakk 2023-11-28 23:17:16 +05:30 committed by Eugene Sandulenko
parent 5e55196ed8
commit ced5e6b1f8

View File

@ -19,12 +19,14 @@
*
*/
#include "common/config-manager.h"
#include "common/macresman.h"
#include "graphics/surface.h"
#include "graphics/macgui/macwidget.h"
#include "image/bmp.h"
#include "image/jpeg.h"
#include "image/pict.h"
#include "image/png.h"
#include "director/director.h"
#include "director/cast.h"
@ -547,6 +549,19 @@ void BitmapCastMember::load() {
}
debugC(5, kDebugImages, "BitmapCastMember::load(): Bitmap: id: %d, w: %d, h: %d, flags1: %x, flags2: %x bytes: %x, bpp: %d clut: %s", imgId, surf->w, surf->h, _flags1, _flags2, _bytes, _bitsPerPixel, _clut.asString().c_str());
if (ConfMan.getBool("dump_scripts")) {
Common::String prepend = "stream";
Common::String filename = Common::String::format("./dumps/%s-%s-%d.png", encodePathForDump(prepend).c_str(), tag2str(tag), imgId);
Common::DumpFile bitmapFile;
bitmapFile.open(Common::Path(filename), true);
Image::writePNG(bitmapFile, *decoder->getSurface(), decoder->getPalette());
bitmapFile.close();
}
delete pic;
delete decoder;
_loaded = true;
@ -607,6 +622,18 @@ void BitmapCastMember::load() {
setPicture(*img, true);
if (ConfMan.getBool("dump_scripts")) {
Common::String prepend = "stream";
Common::String filename = Common::String::format("./dumps/%s-%s-%d.png", encodePathForDump(prepend).c_str(), tag2str(tag), imgId);
Common::DumpFile bitmapFile;
bitmapFile.open(Common::Path(filename), true);
Image::writePNG(bitmapFile, *img->getSurface(), img->getPalette());
bitmapFile.close();
}
delete img;
delete pic;