1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
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
|