1
/* ============================================================
3
* This file is a part of digiKam project
4
* http://www.digikam.org
7
* Description : image channels mixer.
9
* Copyright (C) 2005-2010 by Gilles Caulier <caulier dot gilles at gmail dot com>
11
* Load and save mixer gains methods inspired from
12
* Gimp 2.2.3 and copyrighted 2002 by Martin Guldahl <mguldahl at xmission dot com>
14
* This program is free software; you can redistribute it
15
* and/or modify it under the terms of the GNU General
16
* Public License as published by the Free Software Foundation;
17
* either version 2, or (at your option)
20
* This program is distributed in the hope that it will be useful,
21
* but WITHOUT ANY WARRANTY; without even the implied warranty of
22
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
* GNU General Public License for more details.
25
* ============================================================ */
27
#include "channelmixertool.moc"
43
#include <QGridLayout>
45
#include <QHBoxLayout>
49
#include <QPushButton>
52
#include <QToolButton>
56
#include <kaboutdata.h>
57
#include <kapplication.h>
60
#include <kfiledialog.h>
62
#include <kglobalsettings.h>
63
#include <khelpmenu.h>
65
#include <kiconloader.h>
68
#include <kmessagebox.h>
69
#include <kselector.h>
70
#include <kstandarddirs.h>
75
#include <libkdcraw/rnuminput.h>
79
#include "colorgradientwidget.h"
80
#include "daboutdata.h"
82
#include "dimgimagefilters.h"
83
#include "editortoolsettings.h"
84
#include "histogrambox.h"
85
#include "histogramwidget.h"
86
#include "imagehistogram.h"
87
#include "imageiface.h"
88
#include "imageguidewidget.h"
91
using namespace KDcrawIface;
92
using namespace Digikam;
94
namespace DigikamChannelMixerImagesPlugin
97
class ChannelMixerToolPriv
101
ChannelMixerToolPriv() :
102
configGroupName("channelmixer Tool"),
103
configMonochromeEntry("Monochrome"),
104
configPreserveLuminosityEntry("PreserveLuminosity"),
105
configRedRedGainEntry("RedRedGain"),
106
configRedGreenGainEntry("RedGreenGain"),
107
configRedBlueGainEntry("RedBlueGain"),
108
configGreenRedGainEntry("GreenRedGain"),
109
configGreenGreenGainEntry("GreenGreenGain"),
110
configGreenBlueGainEntry("GreenBlueGain"),
111
configBlueRedGainEntry("BlueRedGain"),
112
configBlueGreenGainEntry("BlueGreenGain"),
113
configBlueBlueGainEntry("BlueBlueGain"),
114
configBlackRedGainEntry("BlackRedGain"),
115
configBlackGreenGainEntry("BlackGreenGain"),
116
configBlackBlueGainEntry("BlackBlueGain"),
117
configHistogramChannelEntry("Histogram Channel"),
118
configHistogramScaleEntry("Histogram Scale"),
120
destinationPreviewData(0),
134
preserveLuminosity(0),
143
const QString configGroupName;
144
const QString configMonochromeEntry;
145
const QString configPreserveLuminosityEntry;
146
const QString configRedRedGainEntry;
147
const QString configRedGreenGainEntry;
148
const QString configRedBlueGainEntry;
149
const QString configGreenRedGainEntry;
150
const QString configGreenGreenGainEntry;
151
const QString configGreenBlueGainEntry;
152
const QString configBlueRedGainEntry;
153
const QString configBlueGreenGainEntry;
154
const QString configBlueBlueGainEntry;
155
const QString configBlackRedGainEntry;
156
const QString configBlackGreenGainEntry;
157
const QString configBlackBlueGainEntry;
158
const QString configHistogramChannelEntry;
159
const QString configHistogramScaleEntry;
161
uchar* destinationPreviewData;
167
double greenGreenGain;
168
double greenBlueGain;
170
double blueGreenGain;
173
double blackGreenGain;
174
double blackBlueGain;
176
QPushButton* resetButton;
178
QCheckBox* preserveLuminosity;
179
QCheckBox* monochrome;
181
RDoubleNumInput* redGain;
182
RDoubleNumInput* greenGain;
183
RDoubleNumInput* blueGain;
185
ImageGuideWidget* previewWidget;
186
EditorToolSettings* gboxSettings;
189
ChannelMixerTool::ChannelMixerTool(QObject* parent)
190
: EditorTool(parent),
191
d(new ChannelMixerToolPriv)
193
setObjectName("channelmixer");
194
setToolName(i18n("Channel Mixer"));
195
setToolIcon(SmallIcon("channelmixer"));
197
// -------------------------------------------------------------
199
d->destinationPreviewData = 0;
201
d->previewWidget = new ImageGuideWidget;
202
d->previewWidget->setWhatsThis(i18n("You can see here the image's color channels' "
203
"gain adjustments preview. You can pick a color on the image "
204
"to see the corresponding color level on the histogram."));
205
setToolView(d->previewWidget);
206
setPreviewModeMask(PreviewToolBar::AllPreviewModes);
208
// -------------------------------------------------------------
210
d->gboxSettings = new EditorToolSettings;
211
d->gboxSettings->setButtons(EditorToolSettings::Default|
212
EditorToolSettings::Load|
213
EditorToolSettings::SaveAs|
214
EditorToolSettings::Ok|
215
EditorToolSettings::Cancel);
217
d->gboxSettings->setTools(EditorToolSettings::Histogram);
218
d->gboxSettings->setHistogramType(Digikam::RGB);
220
QGridLayout* grid = new QGridLayout(d->gboxSettings->plainPage());
222
// -------------------------------------------------------------
224
QLabel *redLabel = new QLabel(i18n("Red:"), d->gboxSettings->plainPage());
225
d->redGain = new RDoubleNumInput(d->gboxSettings->plainPage());
226
d->redGain->setDecimals(0);
227
d->redGain->setRange(-200.0, 200.0, 1);
228
d->redGain->setDefaultValue(0);
229
d->redGain->setWhatsThis(i18n("Select the red color gain, as a percentage, "
230
"for the current channel."));
232
QLabel *greenLabel = new QLabel(i18n("Green:"), d->gboxSettings->plainPage());
233
d->greenGain = new RDoubleNumInput(d->gboxSettings->plainPage());
234
d->greenGain->setDecimals(0);
235
d->greenGain->setRange(-200.0, 200.0, 1);
236
d->greenGain->setDefaultValue(0);
237
d->greenGain->setWhatsThis(i18n("Select the green color gain, as a percentage, "
238
"for the current channel."));
240
QLabel *blueLabel = new QLabel(i18n("Blue:"), d->gboxSettings->plainPage());
241
d->blueGain = new RDoubleNumInput(d->gboxSettings->plainPage());
242
d->blueGain->setDecimals(0);
243
d->blueGain->setRange(-200.0, 200.0, 1);
244
d->blueGain->setDefaultValue(0);
245
d->blueGain->setWhatsThis(i18n("Select the blue color gain, as a percentage, "
246
"for the current channel."));
248
d->resetButton = new QPushButton(i18n("&Reset"), d->gboxSettings->plainPage());
249
d->resetButton->setIcon(KIconLoader::global()->loadIcon("document-revert", KIconLoader::Toolbar));
250
d->resetButton->setWhatsThis(i18n("Reset color channels' gains settings from "
251
"the currently selected channel."));
253
// -------------------------------------------------------------
255
d->monochrome = new QCheckBox(i18n("Monochrome"), d->gboxSettings->plainPage());
256
d->monochrome->setWhatsThis(i18n("Enable this option if you want the image rendered "
257
"in monochrome mode. "
258
"In this mode, the histogram will display only luminosity values."));
260
d->preserveLuminosity = new QCheckBox(i18n("Preserve luminosity"), d->gboxSettings->plainPage());
261
d->preserveLuminosity->setWhatsThis(i18n("Enable this option is you want preserve "
262
"the image luminosity."));
264
// -------------------------------------------------------------
266
grid->addWidget(redLabel, 0, 0, 1, 1);
267
grid->addWidget(d->redGain, 0, 1, 1, 4);
268
grid->addWidget(greenLabel, 1, 0, 1, 1);
269
grid->addWidget(d->greenGain, 1, 1, 1, 4);
270
grid->addWidget(blueLabel, 2, 0, 1, 1);
271
grid->addWidget(d->blueGain, 2, 1, 1, 4);
272
grid->addWidget(d->resetButton, 3, 0, 1, 2);
273
grid->addWidget(d->monochrome, 4, 0, 1, 5);
274
grid->addWidget(d->preserveLuminosity, 5, 0, 1, 5);
275
grid->setRowStretch(6, 10);
276
grid->setMargin(d->gboxSettings->spacingHint());
277
grid->setSpacing(d->gboxSettings->spacingHint());
279
setToolSettings(d->gboxSettings);
282
// -------------------------------------------------------------
283
// Channels and scale selection slots.
285
connect(d->previewWidget, SIGNAL(spotPositionChangedFromTarget( const Digikam::DColor &, const QPoint & )),
286
this, SLOT(slotColorSelectedFromTarget( const Digikam::DColor & )));
288
connect(d->previewWidget, SIGNAL(signalResized()),
289
this, SLOT(slotEffect()));
291
// -------------------------------------------------------------
292
// Gains settings slots.
294
connect(d->redGain, SIGNAL(valueChanged(double)),
295
this, SLOT(slotGainsChanged()));
297
connect(d->greenGain, SIGNAL(valueChanged(double)),
298
this, SLOT(slotGainsChanged()));
300
connect(d->blueGain, SIGNAL(valueChanged(double)),
301
this, SLOT(slotGainsChanged()));
303
connect(d->preserveLuminosity, SIGNAL(toggled (bool)),
304
this, SLOT(slotEffect()));
306
connect(d->monochrome, SIGNAL(toggled (bool)),
307
this, SLOT(slotMonochromeActived(bool)));
309
// -------------------------------------------------------------
312
connect(d->resetButton, SIGNAL(clicked()),
313
this, SLOT(slotResetCurrentChannel()));
316
ChannelMixerTool::~ChannelMixerTool()
318
if (d->destinationPreviewData)
319
delete [] d->destinationPreviewData;
324
void ChannelMixerTool::slotResetCurrentChannel()
326
switch (d->gboxSettings->histogramBox()->channel())
329
d->greenRedGain = 0.0;
330
d->greenGreenGain = 1.0;
331
d->greenBlueGain = 0.0;
335
d->blueRedGain = 0.0;
336
d->blueGreenGain = 0.0;
337
d->blueBlueGain = 1.0;
340
default: // Red or monochrome.
341
if (d->monochrome->isChecked())
343
d->blackRedGain = 1.0;
344
d->blackGreenGain = 0.0;
345
d->blackBlueGain = 0.0;
350
d->redGreenGain = 0.0;
351
d->redBlueGain = 0.0;
358
d->gboxSettings->histogramBox()->histogram()->reset();
361
void ChannelMixerTool::slotColorSelectedFromTarget( const DColor& color )
363
d->gboxSettings->histogramBox()->histogram()->setHistogramGuideByColor(color);
366
void ChannelMixerTool::slotGainsChanged()
368
switch(d->gboxSettings->histogramBox()->channel())
370
case GreenChannel: // Green.
371
d->greenRedGain = d->redGain->value() / 100.0;
372
d->greenGreenGain = d->greenGain->value() / 100.0;
373
d->greenBlueGain = d->blueGain->value() / 100.0;
376
case BlueChannel: // Blue.
377
d->blueRedGain = d->redGain->value() / 100.0;
378
d->blueGreenGain = d->greenGain->value() / 100.0;
379
d->blueBlueGain = d->blueGain->value() / 100.0;
382
default: // Red or monochrome.
383
if ( d->monochrome->isChecked() )
385
d->blackRedGain = d->redGain->value() / 100.0;
386
d->blackGreenGain = d->greenGain->value() / 100.0;
387
d->blackBlueGain = d->blueGain->value() / 100.0;
391
d->redRedGain = d->redGain->value() / 100.0;
392
d->redGreenGain = d->greenGain->value() / 100.0;
393
d->redBlueGain = d->blueGain->value() / 100.0;
401
void ChannelMixerTool::adjustSliders()
403
d->redGain->blockSignals(true);
404
d->greenGain->blockSignals(true);
405
d->blueGain->blockSignals(true);
407
switch(d->gboxSettings->histogramBox()->channel())
409
case GreenChannel: // Green.
410
d->redGain->setDefaultValue(0);
411
d->greenGain->setDefaultValue(100);
412
d->blueGain->setDefaultValue(0);
413
d->redGain->setValue(d->greenRedGain * 100.0);
414
d->greenGain->setValue(d->greenGreenGain * 100.0);
415
d->blueGain->setValue(d->greenBlueGain * 100.0);
418
case BlueChannel: // Blue.
419
d->redGain->setDefaultValue(0);
420
d->greenGain->setDefaultValue(0);
421
d->blueGain->setDefaultValue(100);
422
d->redGain->setValue(d->blueRedGain * 100.0);
423
d->greenGain->setValue(d->blueGreenGain * 100.0);
424
d->blueGain->setValue(d->blueBlueGain * 100.0);
427
default: // Red or monochrome.
428
if ( d->monochrome->isChecked() )
430
d->redGain->setDefaultValue(100);
431
d->greenGain->setDefaultValue(0);
432
d->blueGain->setDefaultValue(0);
433
d->redGain->setValue(d->blackRedGain * 100.0);
434
d->greenGain->setValue(d->blackGreenGain * 100.0);
435
d->blueGain->setValue(d->blackBlueGain * 100.0);
439
d->redGain->setDefaultValue(100);
440
d->greenGain->setDefaultValue(0);
441
d->blueGain->setDefaultValue(0);
442
d->redGain->setValue(d->redRedGain * 100.0);
443
d->greenGain->setValue(d->redGreenGain * 100.0);
444
d->blueGain->setValue(d->redBlueGain * 100.0);
449
d->redGain->blockSignals(false);
450
d->greenGain->blockSignals(false);
451
d->blueGain->blockSignals(false);
454
void ChannelMixerTool::slotMonochromeActived(bool mono)
456
d->gboxSettings->histogramBox()->setChannelEnabled(!mono);
457
d->gboxSettings->histogramBox()->setChannel(RedChannel);
460
void ChannelMixerTool::slotEffect()
462
ImageIface* iface = d->previewWidget->imageIface();
463
uchar *data = iface->getPreviewImage();
464
int w = iface->previewWidth();
465
int h = iface->previewHeight();
466
bool sb = iface->previewSixteenBit();
468
// Create the new empty destination image data space.
469
d->gboxSettings->histogramBox()->histogram()->stopHistogramComputation();
471
if (d->destinationPreviewData)
472
delete [] d->destinationPreviewData;
474
d->destinationPreviewData = new uchar[w*h*(sb ? 8 : 4)];
475
DImgImageFilters filter;
477
if (d->monochrome->isChecked())
479
filter.channelMixerImage(data, w, h, sb, // Image data.
480
d->preserveLuminosity->isChecked(), // Preserve luminosity.
481
d->monochrome->isChecked(), // Monochrome.
482
d->blackRedGain, d->blackGreenGain, d->blackBlueGain, // Red channel gains.
483
0.0, 1.0, 0.0, // Green channel gains (not used).
484
0.0, 0.0, 1.0); // Blue channel gains (not used).
488
filter.channelMixerImage(data, w, h, sb, // Image data.
489
d->preserveLuminosity->isChecked(), // Preserve luminosity.
490
d->monochrome->isChecked(), // Monochrome.
491
d->redRedGain, d->redGreenGain, d->redBlueGain, // Red channel gains.
492
d->greenRedGain, d->greenGreenGain, d->greenBlueGain, // Green channel gains.
493
d->blueRedGain, d->blueGreenGain, d->blueBlueGain); // Blue channel gains.
496
iface->putPreviewImage(data);
497
d->previewWidget->updatePreview();
500
memcpy (d->destinationPreviewData, data, w*h*(sb ? 8 : 4));
501
d->gboxSettings->histogramBox()->histogram()->updateData(d->destinationPreviewData, w, h, sb, 0, 0, 0, false);
505
void ChannelMixerTool::finalRendering()
507
kapp->setOverrideCursor( Qt::WaitCursor );
508
ImageIface* iface = d->previewWidget->imageIface();
509
uchar *data = iface->getOriginalImage();
510
int w = iface->originalWidth();
511
int h = iface->originalHeight();
512
bool sb = iface->originalSixteenBit();
514
DImgImageFilters filter;
516
if (d->monochrome->isChecked())
518
filter.channelMixerImage(data, w, h, sb, // Image data.
519
d->preserveLuminosity->isChecked(), // Preserve luminosity.
520
d->monochrome->isChecked(), // Monochrome.
521
d->blackRedGain, d->blackGreenGain, d->blackBlueGain, // Red channel gains.
522
0.0, 1.0, 0.0, // Green channel gains (not used).
523
0.0, 0.0, 1.0); // Blue channel gains (not used).
527
filter.channelMixerImage(data, w, h, sb, // Image data.
528
d->preserveLuminosity->isChecked(), // Preserve luminosity.
529
d->monochrome->isChecked(), // Monochrome.
530
d->redRedGain, d->redGreenGain, d->redBlueGain, // Red channel gains.
531
d->greenRedGain, d->greenGreenGain, d->greenBlueGain, // Green channel gains.
532
d->blueRedGain, d->blueGreenGain, d->blueBlueGain); // Blue channel gains.
535
iface->putOriginalImage(i18n("Channel Mixer"), data);
537
kapp->restoreOverrideCursor();
540
void ChannelMixerTool::slotChannelChanged()
542
if (d->monochrome->isChecked())
543
d->gboxSettings->histogramBox()->setGradientColors(QColor("black"), QColor("white"));
549
void ChannelMixerTool::readSettings()
551
KSharedConfig::Ptr config = KGlobal::config();
552
KConfigGroup group = config->group(d->configGroupName);
554
d->monochrome->setChecked(group.readEntry(d->configMonochromeEntry, false));
555
d->preserveLuminosity->setChecked(group.readEntry(d->configPreserveLuminosityEntry, false));
557
d->redRedGain = group.readEntry(d->configRedRedGainEntry, 1.0);
558
d->redGreenGain = group.readEntry(d->configRedGreenGainEntry, 0.0);
559
d->redBlueGain = group.readEntry(d->configRedBlueGainEntry, 0.0);
561
d->greenRedGain = group.readEntry(d->configGreenRedGainEntry, 0.0);
562
d->greenGreenGain = group.readEntry(d->configGreenGreenGainEntry, 1.0);
563
d->greenBlueGain = group.readEntry(d->configGreenBlueGainEntry, 0.0);
565
d->blueRedGain = group.readEntry(d->configBlueRedGainEntry, 0.0);
566
d->blueGreenGain = group.readEntry(d->configBlueGreenGainEntry, 0.0);
567
d->blueBlueGain = group.readEntry(d->configBlueBlueGainEntry, 1.0);
569
d->blackRedGain = group.readEntry(d->configBlackRedGainEntry, 1.0);
570
d->blackGreenGain = group.readEntry(d->configBlackGreenGainEntry, 0.0);
571
d->blackBlueGain = group.readEntry(d->configBlackBlueGainEntry, 0.0);
575
// we need to call the set methods here, otherwise the histogram will not be updated correctly
576
d->gboxSettings->histogramBox()->setChannel(group.readEntry(d->configHistogramChannelEntry,
577
(int)LuminosityChannel));
578
d->gboxSettings->histogramBox()->setScale((HistogramScale)group.readEntry(d->configHistogramScaleEntry,
579
(int)LogScaleHistogram));
581
d->gboxSettings->histogramBox()->histogram()->reset();
586
void ChannelMixerTool::writeSettings()
588
KSharedConfig::Ptr config = KGlobal::config();
589
KConfigGroup group = config->group(d->configGroupName);
591
group.writeEntry(d->configHistogramChannelEntry, d->gboxSettings->histogramBox()->channel());
592
group.writeEntry(d->configHistogramScaleEntry, (int)d->gboxSettings->histogramBox()->scale());
594
group.writeEntry(d->configMonochromeEntry, d->monochrome->isChecked());
595
group.writeEntry(d->configPreserveLuminosityEntry, d->preserveLuminosity->isChecked());
597
group.writeEntry(d->configRedRedGainEntry, d->redRedGain);
598
group.writeEntry(d->configRedGreenGainEntry, d->redGreenGain);
599
group.writeEntry(d->configRedBlueGainEntry, d->redBlueGain);
601
group.writeEntry(d->configGreenRedGainEntry, d->greenRedGain);
602
group.writeEntry(d->configGreenGreenGainEntry, d->greenGreenGain);
603
group.writeEntry(d->configGreenBlueGainEntry, d->greenBlueGain);
605
group.writeEntry(d->configBlueRedGainEntry, d->blueRedGain);
606
group.writeEntry(d->configBlueGreenGainEntry, d->blueGreenGain);
607
group.writeEntry(d->configBlueBlueGainEntry, d->blueBlueGain);
609
group.writeEntry(d->configBlackRedGainEntry, d->blackRedGain);
610
group.writeEntry(d->configBlackGreenGainEntry, d->blackGreenGain);
611
group.writeEntry(d->configBlackBlueGainEntry, d->blackBlueGain);
616
void ChannelMixerTool::slotResetSettings()
618
d->monochrome->blockSignals(true);
619
d->preserveLuminosity->blockSignals(true);
622
d->redGreenGain = 0.0;
623
d->redBlueGain = 0.0;
625
d->greenRedGain = 0.0;
626
d->greenGreenGain = 1.0;
627
d->greenBlueGain = 0.0;
629
d->blueRedGain = 0.0;
630
d->blueGreenGain = 0.0;
631
d->blueBlueGain = 1.0;
633
d->blackRedGain = 1.0;
634
d->blackGreenGain = 0.0;
635
d->blackBlueGain = 0.0;
639
d->monochrome->blockSignals(false);
640
d->preserveLuminosity->blockSignals(false);
641
d->gboxSettings->histogramBox()->histogram()->reset();
642
d->gboxSettings->histogramBox()->setChannel(RedChannel);
646
void ChannelMixerTool::slotLoadSettings()
648
KUrl loadGainsFileUrl;
651
loadGainsFileUrl = KFileDialog::getOpenUrl(KGlobalSettings::documentPath(),
652
QString( "*" ), kapp->activeWindow(),
653
QString( i18n("Select Gimp Gains Mixer File to Load")) );
654
if ( loadGainsFileUrl.isEmpty() )
657
fp = fopen(QFile::encodeName(loadGainsFileUrl.toLocalFile()), "r");
662
int currentOutputChannel = RedChannel;
669
fgets(buf1, 1023, fp);
671
fscanf (fp, "%*s %s", buf1);
673
// Get the current output channel in dialog.
675
if (strcmp (buf1, "RED") == 0)
676
currentOutputChannel = RedChannel;
677
else if (strcmp (buf1, "GREEN") == 0)
678
currentOutputChannel = GreenChannel;
679
else if (strcmp (buf1, "BLUE") == 0)
680
currentOutputChannel = BlueChannel;
682
fscanf (fp, "%*s %s", buf1); // preview flag, preserved for compatibility
684
fscanf (fp, "%*s %s", buf1);
686
if (strcmp (buf1, "true") == 0)
691
fscanf (fp, "%*s %s", buf1);
693
if (strcmp (buf1, "true") == 0)
694
d->preserveLuminosity->setChecked(true);
696
d->preserveLuminosity->setChecked(false);
698
fscanf (fp, "%*s %s %s %s", buf1, buf2, buf3);
699
d->redRedGain = atof(buf1);
700
d->redGreenGain = atof(buf2);
701
d->redBlueGain = atof(buf3);
703
fscanf (fp, "%*s %s %s %s", buf1, buf2, buf3);
704
d->greenRedGain = atof(buf1);
705
d->greenGreenGain = atof(buf2);
706
d->greenBlueGain = atof(buf3);
708
fscanf (fp, "%*s %s %s %s", buf1, buf2, buf3);
709
d->blueRedGain = atof(buf1);
710
d->blueGreenGain = atof(buf2);
711
d->blueBlueGain = atof(buf3);
713
fscanf (fp, "%*s %s %s %s", buf1, buf2, buf3);
714
d->blackRedGain = atof(buf1);
715
d->blackGreenGain = atof(buf2);
716
d->blackBlueGain = atof(buf3);
721
d->monochrome->setChecked(monochrome);
722
d->gboxSettings->histogramBox()->setChannel(currentOutputChannel);
726
KMessageBox::error(kapp->activeWindow(),
727
i18n("Cannot load settings from the Gains Mixer text file."));
733
void ChannelMixerTool::slotSaveAsSettings()
735
KUrl saveGainsFileUrl;
738
saveGainsFileUrl = KFileDialog::getSaveUrl(KGlobalSettings::documentPath(),
739
QString( "*" ), kapp->activeWindow(),
740
QString( i18n("Gimp Gains Mixer File to Save")) );
741
if ( saveGainsFileUrl.isEmpty() )
744
fp = fopen(QFile::encodeName(saveGainsFileUrl.toLocalFile()), "w");
748
const char *str = 0L;
753
switch (d->gboxSettings->histogramBox()->channel())
765
kWarning() << "Unknown Color channel gains";
769
fprintf (fp, "# Channel Mixer Configuration File\n");
771
fprintf (fp, "CHANNEL: %s\n", str);
772
fprintf (fp, "PREVIEW: %s\n", "true"); // preserved for compatibility
773
fprintf (fp, "MONOCHROME: %s\n",
774
d->monochrome->isChecked() ? "true" : "false");
775
fprintf (fp, "PRESERVE_LUMINOSITY: %s\n",
776
d->preserveLuminosity->isChecked() ? "true" : "false");
778
sprintf (buf1, "%5.3f", d->redRedGain);
779
sprintf (buf2, "%5.3f", d->redGreenGain);
780
sprintf (buf3, "%5.3f", d->redBlueGain);
781
fprintf (fp, "RED: %s %s %s\n", buf1, buf2,buf3);
783
sprintf (buf1, "%5.3f", d->greenRedGain);
784
sprintf (buf2, "%5.3f", d->greenGreenGain);
785
sprintf (buf3, "%5.3f", d->greenBlueGain);
786
fprintf (fp, "GREEN: %s %s %s\n", buf1, buf2,buf3);
788
sprintf (buf1, "%5.3f", d->blueRedGain);
789
sprintf (buf2, "%5.3f", d->blueGreenGain);
790
sprintf (buf3, "%5.3f", d->blueBlueGain);
791
fprintf (fp, "BLUE: %s %s %s\n", buf1, buf2,buf3);
793
sprintf (buf1, "%5.3f", d->blackRedGain);
794
sprintf (buf2, "%5.3f", d->blackGreenGain);
795
sprintf (buf3, "%5.3f", d->blackBlueGain);
796
fprintf (fp, "BLACK: %s %s %s\n", buf1, buf2,buf3);
802
KMessageBox::error(kapp->activeWindow(),
803
i18n("Cannot save settings to the Gains Mixer text file."));
808
} // namespace DigikamChannelMixerImagesPlugin