mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 03:33:48 +00:00
revert #1148 as prematurely incorporated
it's getting there, but there have been a few spots noted where it eroneously corrupts text, so we'll have to pull this back out for a bit barring a proper resolution
This commit is contained in:
parent
78b56688d3
commit
f946088214
22 changed files with 1813 additions and 20385 deletions
|
|
@ -1192,7 +1192,7 @@ bool GBitmap::write(Stream& io_rStream) const
|
|||
//-------------------------------------- Persistent I/O
|
||||
//
|
||||
|
||||
bool GBitmap::readBitmap(const String& bmType, const Torque::Path& path)
|
||||
bool GBitmap::readBitmap( const String &bmType, Stream &ioStream )
|
||||
{
|
||||
PROFILE_SCOPE(ResourceGBitmap_readBitmap);
|
||||
const GBitmap::Registration *regInfo = GBitmap::sFindRegInfo( bmType );
|
||||
|
|
@ -1203,22 +1203,11 @@ bool GBitmap::readBitmap(const String& bmType, const Torque::Path& path)
|
|||
return false;
|
||||
}
|
||||
|
||||
return regInfo->readFunc(path, this);
|
||||
return regInfo->readFunc( ioStream, this );
|
||||
}
|
||||
|
||||
bool GBitmap::writeBitmap( const String &bmType, const Torque::Path& path, U32 compressionLevel )
|
||||
bool GBitmap::writeBitmap( const String &bmType, Stream &ioStream, U32 compressionLevel )
|
||||
{
|
||||
FileStream stream;
|
||||
if (!stream.open(path, Torque::FS::File::Write))
|
||||
{
|
||||
Con::errorf("GBitmap::writeBitmap failed to open path %s", path.getFullFileName().c_str());
|
||||
stream.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
// free file for stb
|
||||
stream.close();
|
||||
|
||||
const GBitmap::Registration *regInfo = GBitmap::sFindRegInfo( bmType );
|
||||
|
||||
if ( regInfo == NULL )
|
||||
|
|
@ -1227,7 +1216,7 @@ bool GBitmap::writeBitmap( const String &bmType, const Torque::Path& path, U32
|
|||
return false;
|
||||
}
|
||||
|
||||
return regInfo->writeFunc(path, this, (compressionLevel == U32_MAX) ? regInfo->defaultCompression : compressionLevel );
|
||||
return regInfo->writeFunc( this, ioStream, (compressionLevel == U32_MAX) ? regInfo->defaultCompression : compressionLevel );
|
||||
}
|
||||
|
||||
template<> void *Resource<GBitmap>::create(const Torque::Path &path)
|
||||
|
|
@ -1250,7 +1239,7 @@ template<> void *Resource<GBitmap>::create(const Torque::Path &path)
|
|||
|
||||
GBitmap *bmp = new GBitmap;
|
||||
const String extension = path.getExtension();
|
||||
if( !bmp->readBitmap( extension, path ) )
|
||||
if( !bmp->readBitmap( extension, stream ) )
|
||||
{
|
||||
Con::errorf( "Resource<GBitmap>::create - error reading '%s'", path.getFullPath().c_str() );
|
||||
delete bmp;
|
||||
|
|
@ -1442,14 +1431,21 @@ DefineEngineFunction(saveScaledImage, bool, (const char* bitmapSource, const cha
|
|||
Torque::Path destinationPath = Torque::Path(bitmapDest);
|
||||
destinationPath.setExtension("png");
|
||||
|
||||
if(!image->writeBitmap("png", destinationPath.getFullPath()))
|
||||
// Open up the file on disk.
|
||||
FileStream fs;
|
||||
if (!fs.open(destinationPath.getFullPath(), Torque::FS::File::Write))
|
||||
{
|
||||
Con::errorf("saveScaledImage() - Error writing %s !", bitmapDest);
|
||||
Con::errorf("saveScaledImage() - Failed to open output file '%s'!", bitmapDest);
|
||||
delete image;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
image->writeBitmap("png", fs);
|
||||
|
||||
fs.close();
|
||||
delete image;
|
||||
}
|
||||
|
||||
|
||||
delete image;
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue