Added documentation

CompressionLevel argument now used to set jpeg quality as well. Values need to be 0-100 range for jpeg and 0-10 for png.
This commit is contained in:
marauder2k7 2023-11-30 15:57:59 +00:00
parent 870fae3e47
commit 6ed0374768
2 changed files with 21 additions and 2 deletions

View file

@ -165,6 +165,22 @@ bool sReadSTB(const Torque::Path& path, GBitmap* bitmap)
return true;
}
/**
* Write bitmap to an image file.
*
* @param[in] path Destination image file path. File name extension determines image format.
* ".bmp" for Microsoft Bitmap.
* ".hdr" for High Dynamic Range (HDR).
* ".jpg" or ".jpeg" for Joint Photographic Experts Group (JPEG).
* ".png" for Portable Network Graphics (PNG).
* ".tga" for Truevision TGA (TARGA).
*
*
* @param[in] bitmap Source bitmap to encode image from.
* @param compressionLevel Image format specific compression level.
* For JPEG sets the quality level percentage, range 0 to 100.
* Not used for other image formats.
*/
bool sWriteSTB(const Torque::Path& path, GBitmap* bitmap, U32 compressionLevel)
{
PROFILE_SCOPE(sWriteSTB);
@ -212,7 +228,7 @@ bool sWriteSTB(const Torque::Path& path, GBitmap* bitmap, U32 compressionLevel)
if (ext.equal("jpg") || ext.equal("jpeg"))
{
if (stbi_write_jpg(path.getFullPath().c_str(), width, height, comp, bitmap->getWritableBits(), 90))
if (stbi_write_jpg(path.getFullPath().c_str(), width, height, comp, bitmap->getWritableBits(), compressionLevel))
return true;
}