EXR: support for lossy HTJ2K quality introduced in OpenEXR 3.5

This commit is contained in:
Mirco Miranda
2026-10-30 14:54:54 +01:00
committed by Mirco Miranda
parent 59157971e8
commit 487b51ae9c
2 changed files with 18 additions and 8 deletions
+7
View File
@@ -774,9 +774,16 @@ bool EXRHandler::write(const QImage &image)
// set the DCT quality (used by DCT compressions only)
if (m_quality > -1 && m_quality <= 100) {
header.dwaCompressionLevel() = float(m_quality);
#if QT_VERSION_CHECK(OPENEXR_VERSION_MAJOR, OPENEXR_VERSION_MINOR, OPENEXR_VERSION_PATCH) >= QT_VERSION_CHECK(3, 5, 0)
header.lossyHTJ2KQuality() = float(m_quality) * 1.5f; // Lossy J2K max quality is 150
#endif
}
// make ZIP compression fast (used by ZIP compressions)
header.zipCompressionLevel() = 1;
#if QT_VERSION_CHECK(OPENEXR_VERSION_MAJOR, OPENEXR_VERSION_MINOR, OPENEXR_VERSION_PATCH) >= QT_VERSION_CHECK(3, 5, 0)
// make ZSTD compression fast (used by ZSTD compressions)
header.zstdCompressionLevel() = 1; // default is 5 -> 1 is faster
#endif
// set preview (don't set it for small images)
if (width > 1024 || height > 1024) {
+11 -8
View File
@@ -76,18 +76,21 @@ private:
* Value set by QImageWriter::setCompression().
*
* The compression scheme is the same as defined by OpenEXR library:
* - 0: no compression
* - 1: run length encoding
* - 2: zlib compression, one scan line at a time
* - 3: zlib compression, in blocks of 16 scan lines
* - 4: piz-based wavelet compression (default)
* - 5: lossy 24-bit float compression
* - 6: lossy 4-by-4 pixel block compression, fixed compression rate
* - 7: lossy 4-by-4 pixel block compression, fields are compressed more
* - 0: no compression.
* - 1: run length encoding.
* - 2: zlib compression, one scan line at a time.
* - 3: zlib compression, in blocks of 16 scan lines.
* - 4: piz-based wavelet compression (default).
* - 5: lossy 24-bit float compression.
* - 6: lossy 4-by-4 pixel block compression, fixed compression rate.
* - 7: lossy 4-by-4 pixel block compression, fields are compressed more.
* - 8: lossy DCT based compression, in blocks of 32 scanlines. More efficient for partial buffer access.
* - 9: lossy DCT based compression, in blocks of 256 scanlines. More efficient space wise and faster to decode full frames than DWAA_COMPRESSION.
* - 10: High-Throughput JPEG2000 (HTJ2K), 256 scanlines (requires OpenEXR 3.4+).
* - 11: High-Throughput JPEG2000 (HTJ2K), 32 scanlines (requires OpenEXR 3.4+).
* - 12: High-Throughput JPEG2000 (HTJ2K), lossy, 256 scanlines (requires OpenEXR 3.5+).
* - 13: zstd lossless compression, one scan line at a time (requires OpenEXR 3.5+).
* \note If compiled with a more recent EXR library, any new compression methods can be used.
*/
qint32 m_compressionRatio;