浏览代码

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.
marauder2k7 1 年之前
父节点
当前提交
6ed0374768
共有 2 个文件被更改,包括 21 次插入2 次删除
  1. 4 1
      Engine/source/gfx/bitmap/gBitmap.h
  2. 17 1
      Engine/source/gfx/bitmap/loaders/bitmapSTB.cpp

+ 4 - 1
Engine/source/gfx/bitmap/gBitmap.h

@@ -246,7 +246,10 @@ public:
    /// Write a bitmap to a stream
    /// Write a bitmap to a stream
    /// @param bmType This is a file extension to describe the type of the data [i.e. "png" for PNG file, etc]
    /// @param bmType This is a file extension to describe the type of the data [i.e. "png" for PNG file, etc]
    /// @param ioStream The stream to read from
    /// @param ioStream The stream to read from
-   /// @param compressionLevel Image format-specific compression level.  If set to U32_MAX, we use the default compression defined when the format was registered.
+   /// @param compressionLevel Image format specific compression level. For JPEG sets the quality level percentage, range 0 to 100.
+   /// For PNG compression level is 0 - 9
+   /// Not used for other image formats.
+   
    bool  writeBitmap( const String &bmType, const Torque::Path& path, U32 compressionLevel = U32_MAX );
    bool  writeBitmap( const String &bmType, const Torque::Path& path, U32 compressionLevel = U32_MAX );
 
 
    bool readMNG(Stream& io_rStream);               // located in bitmapMng.cc
    bool readMNG(Stream& io_rStream);               // located in bitmapMng.cc

+ 17 - 1
Engine/source/gfx/bitmap/loaders/bitmapSTB.cpp

@@ -165,6 +165,22 @@ bool sReadSTB(const Torque::Path& path, GBitmap* bitmap)
    return true;
    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)
 bool sWriteSTB(const Torque::Path& path, GBitmap* bitmap, U32 compressionLevel)
 {
 {
    PROFILE_SCOPE(sWriteSTB);
    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 (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;
          return true;
    }
    }