STB Memory functions for fonts

Add the ability to read and write to a stream.
This commit is contained in:
marauder2k7 2024-01-20 22:15:17 +00:00
parent 7216ba8530
commit 106346630d
4 changed files with 129 additions and 15 deletions

View file

@ -1206,6 +1206,20 @@ bool GBitmap::readBitmap(const String& bmType, const Torque::Path& path)
return regInfo->readFunc(path, this);
}
bool GBitmap::readBitmapStream(const String& bmType, Stream& ioStream, U32 len)
{
PROFILE_SCOPE(ResourceGBitmap_readBitmapStream);
const GBitmap::Registration* regInfo = GBitmap::sFindRegInfo(bmType);
if (regInfo == NULL)
{
Con::errorf("[GBitmap::readBitmap] unable to find registration for extension [%s]", bmType.c_str());
return false;
}
return regInfo->readStreamFunc(ioStream, this, len);
}
bool GBitmap::writeBitmap( const String &bmType, const Torque::Path& path, U32 compressionLevel )
{
FileStream stream;
@ -1230,6 +1244,19 @@ bool GBitmap::writeBitmap( const String &bmType, const Torque::Path& path, U32
return regInfo->writeFunc(path, this, (compressionLevel == U32_MAX) ? regInfo->defaultCompression : compressionLevel );
}
bool GBitmap::writeBitmapStream(const String& bmType, Stream& ioStream, U32 compressionLevel)
{
const GBitmap::Registration* regInfo = GBitmap::sFindRegInfo(bmType);
if (regInfo == NULL)
{
Con::errorf("[GBitmap::writeBitmap] unable to find registration for extension [%s]", bmType.c_str());
return false;
}
return regInfo->writeStreamFunc(ioStream, this, (compressionLevel == U32_MAX) ? regInfo->defaultCompression : compressionLevel);
}
template<> void *Resource<GBitmap>::create(const Torque::Path &path)
{
PROFILE_SCOPE( ResourceGBitmap_create );