Merge pull request #10143 from Pokechu22/png-compression-level

Add option for setting the PNG zlib compression level
This commit is contained in:
Léo Lam 2021-11-23 16:40:34 +01:00 committed by GitHub
commit aa5cb35c86
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 125 additions and 30 deletions

View file

@ -103,6 +103,7 @@ void AdvancedWidget::CreateWidgets()
Config::GFX_INTERNAL_RESOLUTION_FRAME_DUMPS);
m_dump_use_ffv1 = new GraphicsBool(tr("Use Lossless Codec (FFV1)"), Config::GFX_USE_FFV1);
m_dump_bitrate = new GraphicsInteger(0, 1000000, Config::GFX_BITRATE_KBPS, 1000);
m_png_compression_level = new GraphicsInteger(0, 9, Config::GFX_PNG_COMPRESSION_LEVEL);
dump_layout->addWidget(m_use_fullres_framedumps, 0, 0);
#if defined(HAVE_FFMPEG)
@ -110,6 +111,9 @@ void AdvancedWidget::CreateWidgets()
dump_layout->addWidget(new QLabel(tr("Bitrate (kbps):")), 1, 0);
dump_layout->addWidget(m_dump_bitrate, 1, 1);
#endif
dump_layout->addWidget(new QLabel(tr("PNG Compression Level:")), 2, 0);
m_png_compression_level->SetTitle(tr("PNG Compression Level"));
dump_layout->addWidget(m_png_compression_level, 2, 1);
// Misc.
auto* misc_box = new QGroupBox(tr("Misc"));
@ -251,6 +255,16 @@ void AdvancedWidget::AddDescriptions()
QT_TR_NOOP("Encodes frame dumps using the FFV1 codec.<br><br><dolphin_emphasis>If "
"unsure, leave this unchecked.</dolphin_emphasis>");
#endif
static const char TR_PNG_COMPRESSION_LEVEL_DESCRIPTION[] =
QT_TR_NOOP("Specifies the zlib compression level to use when saving PNG images (both for "
"screenshots and framedumping).<br><br>"
"Since PNG uses lossless compression, this does not affect the image quality; "
"instead, it is a trade-off between file size and compression time.<br><br>"
"A value of 0 uses no compression at all. A value of 1 uses very little "
"compression, while the maximum value of 9 applies a lot of compression. "
"However, for PNG files, levels between 3 and 6 are generally about as good as "
"level 9 but finish in significantly less time.<br><br>"
"<dolphin_emphasis>If unsure, leave this at 6.</dolphin_emphasis>");
static const char TR_CROPPING_DESCRIPTION[] = QT_TR_NOOP(
"Crops the picture from its native aspect ratio to 4:3 or "
"16:9.<br><br><dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>");
@ -306,6 +320,7 @@ void AdvancedWidget::AddDescriptions()
#ifdef HAVE_FFMPEG
m_dump_use_ffv1->SetDescription(tr(TR_USE_FFV1_DESCRIPTION));
#endif
m_png_compression_level->SetDescription(tr(TR_PNG_COMPRESSION_LEVEL_DESCRIPTION));
m_enable_cropping->SetDescription(tr(TR_CROPPING_DESCRIPTION));
m_enable_prog_scan->SetDescription(tr(TR_PROGRESSIVE_SCAN_DESCRIPTION));
m_backend_multithreading->SetDescription(tr(TR_BACKEND_MULTITHREADING_DESCRIPTION));

View file

@ -52,6 +52,7 @@ private:
GraphicsBool* m_dump_use_ffv1;
GraphicsBool* m_use_fullres_framedumps;
GraphicsInteger* m_dump_bitrate;
GraphicsInteger* m_png_compression_level;
// Misc
GraphicsBool* m_enable_cropping;