1
/* ============================================================
3
* This file is a part of digiKam project
4
* http://www.digikam.org
7
* Description : Color Balance batch tool.
9
* Copyright (C) 2010 by Gilles Caulier <caulier dot gilles at gmail dot com>
11
* This program is free software; you can redistribute it
12
* and/or modify it under the terms of the GNU General
13
* Public License as published by the Free Software Foundation;
14
* either version 2, or (at your option)
17
* This program is distributed in the hope that it will be useful,
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
* GNU General Public License for more details.
22
* ============================================================ */
24
#include "colorbalance.moc"
32
#include <kiconloader.h>
34
#include <kstandarddirs.h>
40
#include "cbsettings.h"
45
ColorBalance::ColorBalance(QObject* parent)
46
: BatchTool("ColorBalance", ColorTool, parent)
48
setToolTitle(i18n("Color Balance"));
49
setToolDescription(i18n("A tool to adjust color balance."));
50
setToolIcon(KIcon(SmallIcon("adjustrgb")));
52
QWidget* box = new QWidget;
53
m_settingsView = new CBSettings(box);
54
setSettingsWidget(box);
56
connect(m_settingsView, SIGNAL(signalSettingsChanged()),
57
this, SLOT(slotSettingsChanged()));
60
ColorBalance::~ColorBalance()
64
BatchToolSettings ColorBalance::defaultSettings()
66
BatchToolSettings prm;
67
CBContainer defaultPrm = m_settingsView->defaultSettings();
69
prm.insert("Red", (double)defaultPrm.red);
70
prm.insert("Green", (double)defaultPrm.green);
71
prm.insert("Blue", (double)defaultPrm.blue);
76
void ColorBalance::slotAssignSettings2Widget()
79
prm.red = settings()["Red"].toDouble();
80
prm.green = settings()["Green"].toDouble();
81
prm.blue = settings()["Blue"].toDouble();
82
m_settingsView->setSettings(prm);
85
void ColorBalance::slotSettingsChanged()
87
BatchToolSettings prm;
88
CBContainer currentPrm = m_settingsView->settings();
90
prm.insert("Red", (double)currentPrm.red);
91
prm.insert("Green", (double)currentPrm.green);
92
prm.insert("Blue", (double)currentPrm.blue);
94
BatchTool::slotSettingsChanged(prm);
97
bool ColorBalance::toolOperations()
99
if (!loadToDImg()) return false;
102
prm.red = settings()["Red"].toDouble();
103
prm.green = settings()["Green"].toDouble();
104
prm.blue = settings()["Blue"].toDouble();
106
CBFilter cb(&image(), 0L, prm);
107
cb.startFilterDirectly();
108
image().putImageData(cb.getTargetImage().bits());
110
return (savefromDImg());
113
} // namespace Digikam