/* ============================================================ * * 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 * * 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 #include #include #include #include // KDE includes. #include #include #include #include // 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("

The JPEG image quality:

" "1: low quality (high compression and small " "file size)

" "50: medium quality

" "75: good quality (default)

" "100: high quality (no compression and " "large file size)

" "Note: JPEG always uses lossy compression.")); d->labelWarning = new KActiveLabel(i18n("" "Warning: JPEG is a
" "lossy compression
" "image format!

" ""), 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("

JPEG Chroma subsampling level \n(color is saved with less resolution " "than luminance):

" "None=best: uses 4:4:4 ratio. Does not employ chroma " "subsampling at all. This preserves edges and contrasting " "colors, whilst adding no additional compression

" "Medium: uses 4:2:2 ratio. Medium compression: reduces " "the color resolution by one-third with little to " "no visual difference

" "High: use 4:1:1 ratio. High compression: suits " "images with soft edges but tends to alter colors

" "Note: JPEG always uses lossy compression.")); 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