From 5ea89b63d90644c59797101b1c10ce7fca7e5343 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 23 Sep 2016 13:31:41 +0200 Subject: [PATCH] Changed: Factorize saving to right bitmap format --- code/nel/tools/3d/build_interface/main.cpp | 34 +++++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/code/nel/tools/3d/build_interface/main.cpp b/code/nel/tools/3d/build_interface/main.cpp index 94cdb56cf..04213d34b 100644 --- a/code/nel/tools/3d/build_interface/main.cpp +++ b/code/nel/tools/3d/build_interface/main.cpp @@ -174,6 +174,30 @@ void enlargeCanvas(NLMISC::CBitmap &b) b = b2; } +bool writeFileDependingOnFilename(const std::string &filename, CBitmap &bitmap) +{ + NLMISC::COFile out; + + if (out.open(filename)) + { + if (toLower(filename).find(".png") != string::npos) + { + bitmap.writePNG(out, 32); + } + else + { + bitmap.writeTGA(out, 32); + } + + out.close(); + + return true; + } + + return false; +} + + // *************************************************************************** // main // *************************************************************************** @@ -325,13 +349,7 @@ int main(int argc, char **argv) } // Write global texture file - //SetCurrentDirectory (sExeDir); - CPath::setCurrentPath(sExeDir.c_str()); - - NLMISC::COFile outTga; - if (fmtName.rfind('.') == string::npos) - fmtName += ".tga"; - if (outTga.open(fmtName)) + if (writeFileDependingOnFilename(fmtName, GlobalTexture)) { outString(toString("Writing %s", fmtName.c_str())); } @@ -345,7 +363,7 @@ int main(int argc, char **argv) { fmtName = fmtName.substr(0, fmtName.rfind('.')); fmtName += ".txt"; - FILE *f = fopen (fmtName.c_str(), "wt"); + FILE *f = nlfopen(fmtName, "wt"); if (f != NULL) { for (sint i = 0; i < mapSize; ++i)