mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 01:09:50 +00:00
Changed: Factorize saving to right bitmap format
--HG-- branch : develop
This commit is contained in:
parent
35b4a3d98a
commit
536483f8a7
1 changed files with 26 additions and 8 deletions
|
@ -174,6 +174,30 @@ void enlargeCanvas(NLMISC::CBitmap &b)
|
||||||
b = b2;
|
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
|
// main
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
@ -325,13 +349,7 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write global texture file
|
// Write global texture file
|
||||||
//SetCurrentDirectory (sExeDir);
|
if (writeFileDependingOnFilename(fmtName, GlobalTexture))
|
||||||
CPath::setCurrentPath(sExeDir.c_str());
|
|
||||||
|
|
||||||
NLMISC::COFile outTga;
|
|
||||||
if (fmtName.rfind('.') == string::npos)
|
|
||||||
fmtName += ".tga";
|
|
||||||
if (outTga.open(fmtName))
|
|
||||||
{
|
{
|
||||||
outString(toString("Writing %s", fmtName.c_str()));
|
outString(toString("Writing %s", fmtName.c_str()));
|
||||||
}
|
}
|
||||||
|
@ -345,7 +363,7 @@ int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
fmtName = fmtName.substr(0, fmtName.rfind('.'));
|
fmtName = fmtName.substr(0, fmtName.rfind('.'));
|
||||||
fmtName += ".txt";
|
fmtName += ".txt";
|
||||||
FILE *f = fopen (fmtName.c_str(), "wt");
|
FILE *f = nlfopen(fmtName, "wt");
|
||||||
if (f != NULL)
|
if (f != NULL)
|
||||||
{
|
{
|
||||||
for (sint i = 0; i < mapSize; ++i)
|
for (sint i = 0; i < mapSize; ++i)
|
||||||
|
|
Loading…
Reference in a new issue