summaryrefslogtreecommitdiffstats
path: root/src/libs/dimg/loaders/jpegsettings.cpp
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2024-11-22 18:41:30 +0900
committerMichele Calgaro <[email protected]>2024-11-22 18:41:30 +0900
commitee0d99607c14cb63d3ebdb3a970b508949fa8219 (patch)
tree94ac1efedb94cb38bf6879ba0610fe75b554216b /src/libs/dimg/loaders/jpegsettings.cpp
parent4adff739380e4ae9f30e443ee95644f184456869 (diff)
downloaddigikam-ee0d99607c14cb63d3ebdb3a970b508949fa8219.tar.gz
digikam-ee0d99607c14cb63d3ebdb3a970b508949fa8219.zip
Rename 'digikam' folder to 'src'
Signed-off-by: Michele Calgaro <[email protected]>
Diffstat (limited to 'src/libs/dimg/loaders/jpegsettings.cpp')
-rw-r--r--src/libs/dimg/loaders/jpegsettings.cpp154
1 files changed, 154 insertions, 0 deletions
diff --git a/src/libs/dimg/loaders/jpegsettings.cpp b/src/libs/dimg/loaders/jpegsettings.cpp
new file mode 100644
index 00000000..62bd6365
--- /dev/null
+++ b/src/libs/dimg/loaders/jpegsettings.cpp
@@ -0,0 +1,154 @@
+/* ============================================================
+ *
+ * This file is a part of digiKam project
+ * http://www.digikam.org
+ *
+ * Date : 2007-08-02
+ * Description : save JPEG image options.
+ *
+ * Copyright (C) 2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General
+ * Public License as published by the Free Software Foundation;
+ * either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * ============================================================ */
+
+// TQt includes.
+
+#include <tqstring.h>
+#include <tqlabel.h>
+#include <tqlayout.h>
+#include <tqwhatsthis.h>
+#include <tqcombobox.h>
+
+// KDE includes.
+
+#include <tdelocale.h>
+#include <kdialog.h>
+#include <knuminput.h>
+#include <kactivelabel.h>
+
+// Local includes.
+
+#include "jpegsettings.h"
+#include "jpegsettings.moc"
+
+namespace Digikam
+{
+
+class JPEGSettingsPriv
+{
+
+public:
+
+ JPEGSettingsPriv()
+ {
+ JPEGGrid = 0;
+ labelJPEGcompression = 0;
+ JPEGcompression = 0;
+ labelWarning = 0;
+ labelSubSampling = 0;
+ subSamplingCB = 0;
+ }
+
+ TQGridLayout *JPEGGrid;
+
+ TQLabel *labelJPEGcompression;
+ TQLabel *labelSubSampling;
+
+ TQComboBox *subSamplingCB;
+
+ KActiveLabel *labelWarning;
+
+ KIntNumInput *JPEGcompression;
+};
+
+JPEGSettings::JPEGSettings(TQWidget *parent)
+ : TQWidget(parent, 0, TQt::WDestructiveClose)
+{
+ d = new JPEGSettingsPriv;
+
+ d->JPEGGrid = new TQGridLayout(this, 1, 2, KDialog::spacingHint());
+ d->JPEGcompression = new KIntNumInput(75, this);
+ d->JPEGcompression->setRange(1, 100, 1, true );
+ d->labelJPEGcompression = new TQLabel(i18n("JPEG quality:"), this);
+
+ TQWhatsThis::add(d->JPEGcompression, i18n("<p>The JPEG image quality:<p>"
+ "<b>1</b>: low quality (high compression and small "
+ "file size)<p>"
+ "<b>50</b>: medium quality<p>"
+ "<b>75</b>: good quality (default)<p>"
+ "<b>100</b>: high quality (no compression and "
+ "large file size)<p>"
+ "<b>Note: JPEG always uses lossy compression.</b>"));
+
+ d->labelWarning = new KActiveLabel(i18n("<qt><font size=-1 color=\"red\"><i>"
+ "Warning: <a href='http://en.wikipedia.org/wiki/JPEG'>JPEG</a> is a<br>"
+ "lossy compression<br>"
+ "image format!</p>"
+ "</i></qt>"), this);
+
+ d->labelWarning->setFrameStyle(TQFrame::Box | TQFrame::Plain);
+ d->labelWarning->setLineWidth(1);
+ d->labelWarning->setFrameShape(TQFrame::Box);
+
+ d->labelSubSampling = new TQLabel(i18n("Chroma subsampling:"), this);
+
+ d->subSamplingCB = new TQComboBox(false, this);
+ d->subSamplingCB->insertItem(i18n("None")); // 1x1, 1x1, 1x1 (4:4:4)
+ d->subSamplingCB->insertItem(i18n("Medium")); // 2x1, 1x1, 1x1 (4:2:2)
+ d->subSamplingCB->insertItem(i18n("High")); // 2x2, 1x1, 1x1 (4:1:1)
+ TQWhatsThis::add(d->subSamplingCB, i18n("<p>JPEG Chroma subsampling level \n(color is saved with less resolution " "than luminance):<p>"
+ "<b>None</b>=best: uses 4:4:4 ratio. Does not employ chroma "
+ "subsampling at all. This preserves edges and contrasting "
+ "colors, whilst adding no additional compression<p>"
+ "<b>Medium</b>: uses 4:2:2 ratio. Medium compression: reduces "
+ "the color resolution by one-third with little to "
+ "no visual difference<p>"
+ "<b>High</b>: use 4:1:1 ratio. High compression: suits "
+ "images with soft edges but tends to alter colors<p>"
+ "<b>Note: JPEG always uses lossy compression.</b>"));
+
+ d->JPEGGrid->addMultiCellWidget(d->labelJPEGcompression, 0, 0, 0, 0);
+ d->JPEGGrid->addMultiCellWidget(d->JPEGcompression, 0, 0, 1, 1);
+ d->JPEGGrid->addMultiCellWidget(d->labelSubSampling, 1, 1, 0, 0);
+ d->JPEGGrid->addMultiCellWidget(d->subSamplingCB, 1, 1, 1, 1);
+ d->JPEGGrid->addMultiCellWidget(d->labelWarning, 0, 1, 2, 2);
+ d->JPEGGrid->setColStretch(1, 10);
+ d->JPEGGrid->setRowStretch(2, 10);
+}
+
+JPEGSettings::~JPEGSettings()
+{
+ delete d;
+}
+
+void JPEGSettings::setCompressionValue(int val)
+{
+ d->JPEGcompression->setValue(val);
+}
+
+int JPEGSettings::getCompressionValue()
+{
+ return d->JPEGcompression->value();
+}
+
+void JPEGSettings::setSubSamplingValue(int val)
+{
+ d->subSamplingCB->setCurrentItem(val);
+}
+
+int JPEGSettings::getSubSamplingValue()
+{
+ return d->subSamplingCB->currentItem();
+}
+
+} // namespace Digikam