7
7
* Description : a digiKam image plugin for fixing dots produced by
8
8
* hot/stuck/dead pixels from a CCD.
10
* Copyright (C) 2005-2007 by Gilles Caulier <caulier dot gilles at gmail dot com>
10
* Copyright (C) 2005-2008 by Gilles Caulier <caulier dot gilles at gmail dot com>
11
11
* Copyright (C) 2005-2006 by Unai Garro <ugarro at users dot sourceforge dot net>
13
13
* This program is free software; you can redistribute it
72
74
I18N_NOOP("A digiKam image plugin for fixing dots produced by "
73
75
"hot/stuck/dead pixels from a CCD."),
74
76
KAboutData::License_GPL,
75
"(c) 2005-2007, Unai Garro and Gilles Caulier",
77
"(c) 2005-2006, Unai Garro\n(c) 2005-2008, Gilles Caulier",
77
79
"http://www.digikam.org");
79
81
about->addAuthor("Unai Garro", I18N_NOOP("Author and maintainer"),
80
82
"ugarro at sourceforge dot net");
82
84
about->addAuthor("Gilles Caulier", I18N_NOOP("Developer"),
83
85
"caulier dot gilles at gmail dot com");
85
87
setAboutData(about);
87
89
// -------------------------------------------------------------
89
91
QWidget *gboxSettings = new QWidget(m_imagePreviewWidget);
90
QGridLayout* gridSettings = new QGridLayout( gboxSettings, 2, 2, 0, spacingHint());
92
QGridLayout* gridSettings = new QGridLayout(gboxSettings, 3, 2, 0, spacingHint());
92
94
QLabel *filterMethodLabel = new QLabel(i18n("Filter:"), gboxSettings);
93
95
m_filterMethodCombo = new QComboBox(gboxSettings);
94
96
m_filterMethodCombo->insertItem(i18n("Average"));
100
102
setButtonWhatsThis( Apply, i18n("<p>Use this button to add a new black frame file which will "
101
103
"be used by the hot pixels removal filter.") );
103
gridSettings->addMultiCellWidget(filterMethodLabel, 0, 0, 0, 0);
104
gridSettings->addMultiCellWidget(m_filterMethodCombo, 0, 0, 1, 1);
105
gridSettings->addMultiCellWidget(m_blackFrameButton, 0, 0, 2, 2);
107
105
m_blackFrameListView = new BlackFrameListView(gboxSettings);
106
m_progressBar = new KProgress(100, gboxSettings);
107
m_progressBar->setValue(0);
108
m_progressBar->hide();
110
gridSettings->addMultiCellWidget(filterMethodLabel, 0, 0, 0, 0);
111
gridSettings->addMultiCellWidget(m_filterMethodCombo, 0, 0, 1, 1);
112
gridSettings->addMultiCellWidget(m_blackFrameButton, 0, 0, 2, 2);
108
113
gridSettings->addMultiCellWidget(m_blackFrameListView, 1, 2, 0, 2);
114
gridSettings->addMultiCellWidget(m_progressBar, 3, 3, 0, 2);
110
116
m_imagePreviewWidget->setUserAreaWidget(gboxSettings);
112
118
// -------------------------------------------------------------
114
120
connect(m_filterMethodCombo, SIGNAL(activated(int)),
115
121
this, SLOT(slotEffect()));
117
123
connect(m_blackFrameButton, SIGNAL(clicked()),
118
124
this, SLOT(slotAddBlackFrame()));
120
126
connect(m_blackFrameListView, SIGNAL(blackFrameSelected(QValueList<HotPixel>, const KURL&)),
121
127
this, SLOT(slotBlackFrame(QValueList<HotPixel>, const KURL&)));
128
void ImageEffect_HotPixels::readUserSettings(void)
134
void ImageEffect_HotPixels::readUserSettings()
130
136
KConfig *config = kapp->config();
131
137
config->setGroup("hotpixels Tool Dialog");
132
138
m_blackFrameURL = KURL(config->readEntry("Last Black Frame File", QString()));
133
139
m_filterMethodCombo->setCurrentItem(config->readNumEntry("Filter Method",
134
140
HotPixelFixer::QUADRATIC_INTERPOLATION));
136
142
if (m_blackFrameURL.isValid())
137
new BlackFrameListViewItem(m_blackFrameListView, m_blackFrameURL);
144
BlackFrameListViewItem *item = new BlackFrameListViewItem(m_blackFrameListView, m_blackFrameURL);
146
connect(item, SIGNAL(signalLoadingProgress(float)),
147
this, SLOT(slotLoadingProgress(float)));
149
connect(item, SIGNAL(signalLoadingComplete()),
150
this, SLOT(slotLoadingComplete()));
140
void ImageEffect_HotPixels::writeUserSettings(void)
154
void ImageEffect_HotPixels::writeUserSettings()
142
156
KConfig *config = kapp->config();
143
157
config->setGroup("hotpixels Tool Dialog");
156
170
void ImageEffect_HotPixels::slotAddBlackFrame()
158
KFileDialog fileSelectDialog(QString(), KImageIO::pattern(), this, "", true);
159
fileSelectDialog.setCaption(i18n("Select Black Frame Image"));
160
fileSelectDialog.setURL(m_blackFrameURL.path());
162
if (fileSelectDialog.exec() != QDialog::Rejected)
172
KURL url = Digikam::ImageDialog::getImageURL(this, m_blackFrameURL,
173
i18n("Select Black Frame Image"));
164
//Load the selected file and insert into the list
166
m_blackFrameURL = fileSelectDialog.selectedURL();
167
m_blackFrameListView->clear();
168
new BlackFrameListViewItem(m_blackFrameListView, m_blackFrameURL);
177
// Load the selected file and insert into the list.
179
m_blackFrameURL = url;
180
m_blackFrameListView->clear();
181
BlackFrameListViewItem *item = new BlackFrameListViewItem(m_blackFrameListView, m_blackFrameURL);
183
connect(item, SIGNAL(signalLoadingProgress(float)),
184
this, SLOT(slotLoadingProgress(float)));
186
connect(item, SIGNAL(signalLoadingComplete()),
187
this, SLOT(slotLoadingComplete()));
172
void ImageEffect_HotPixels::renderingFinished(void)
191
void ImageEffect_HotPixels::slotLoadingProgress(float v)
193
m_progressBar->show();
194
m_progressBar->setValue((int)(v*100));
197
void ImageEffect_HotPixels::slotLoadingComplete()
199
m_progressBar->hide();
202
void ImageEffect_HotPixels::renderingFinished()
174
204
m_filterMethodCombo->setEnabled(true);
175
205
m_blackFrameListView->setEnabled(true);
176
enableButton(Apply, true);
206
enableButton(Apply, true);
179
209
void ImageEffect_HotPixels::prepareEffect()
217
247
new HotPixelFixer(iface.getOriginalImg(), this,m_hotPixelsList,interpolationMethod));
220
void ImageEffect_HotPixels::putPreviewData(void)
250
void ImageEffect_HotPixels::putPreviewData()
222
252
m_imagePreviewWidget->setPreviewImage(m_threadedFilter->getTargetImage());
225
void ImageEffect_HotPixels::putFinalData(void)
255
void ImageEffect_HotPixels::putFinalData()
227
257
Digikam::ImageIface iface(0, 0);
228
258
iface.putOriginalImage(i18n("Hot Pixels Correction"), m_threadedFilter->getTargetImage().bits());