~ubuntu-branches/ubuntu/saucy/digikam/saucy

« back to all changes in this revision

Viewing changes to utilities/queuemanager/basetools/color/colorbalance.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Christian Mangold
  • Date: 2010-04-09 21:30:01 UTC
  • mfrom: (1.2.28 upstream)
  • Revision ID: james.westby@ubuntu.com-20100409213001-4bfyibrd359rn7o3
Tags: 2:1.2.0-0ubuntu1
* New upstream release (LP: #560576)
* Remove all patches, fixed upstream
  - Remove quilt build-depend

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ============================================================
 
2
 *
 
3
 * This file is a part of digiKam project
 
4
 * http://www.digikam.org
 
5
 *
 
6
 * Date        : 2010-02-11
 
7
 * Description : Color Balance batch tool.
 
8
 *
 
9
 * Copyright (C) 2010 by Gilles Caulier <caulier dot gilles at gmail dot com>
 
10
 *
 
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)
 
15
 * any later version.
 
16
 *
 
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.
 
21
 *
 
22
 * ============================================================ */
 
23
 
 
24
#include "colorbalance.moc"
 
25
 
 
26
// Qt includes
 
27
 
 
28
#include <QWidget>
 
29
 
 
30
// KDE includes
 
31
 
 
32
#include <kiconloader.h>
 
33
#include <klocale.h>
 
34
#include <kstandarddirs.h>
 
35
 
 
36
// Local includes
 
37
 
 
38
#include "dimg.h"
 
39
#include "cbfilter.h"
 
40
#include "cbsettings.h"
 
41
 
 
42
namespace Digikam
 
43
{
 
44
 
 
45
ColorBalance::ColorBalance(QObject* parent)
 
46
             : BatchTool("ColorBalance", ColorTool, parent)
 
47
{
 
48
    setToolTitle(i18n("Color Balance"));
 
49
    setToolDescription(i18n("A tool to adjust color balance."));
 
50
    setToolIcon(KIcon(SmallIcon("adjustrgb")));
 
51
 
 
52
    QWidget* box   = new QWidget;
 
53
    m_settingsView = new CBSettings(box);
 
54
    setSettingsWidget(box);
 
55
 
 
56
    connect(m_settingsView, SIGNAL(signalSettingsChanged()),
 
57
            this, SLOT(slotSettingsChanged()));
 
58
}
 
59
 
 
60
ColorBalance::~ColorBalance()
 
61
{
 
62
}
 
63
 
 
64
BatchToolSettings ColorBalance::defaultSettings()
 
65
{
 
66
    BatchToolSettings prm;
 
67
    CBContainer defaultPrm = m_settingsView->defaultSettings();
 
68
 
 
69
    prm.insert("Red",   (double)defaultPrm.red);
 
70
    prm.insert("Green", (double)defaultPrm.green);
 
71
    prm.insert("Blue",  (double)defaultPrm.blue);
 
72
 
 
73
    return prm;
 
74
}
 
75
 
 
76
void ColorBalance::slotAssignSettings2Widget()
 
77
{
 
78
    CBContainer prm;
 
79
    prm.red   = settings()["Red"].toDouble();
 
80
    prm.green = settings()["Green"].toDouble();
 
81
    prm.blue  = settings()["Blue"].toDouble();
 
82
    m_settingsView->setSettings(prm);
 
83
}
 
84
 
 
85
void ColorBalance::slotSettingsChanged()
 
86
{
 
87
    BatchToolSettings prm;
 
88
    CBContainer currentPrm = m_settingsView->settings();
 
89
 
 
90
    prm.insert("Red",   (double)currentPrm.red);
 
91
    prm.insert("Green", (double)currentPrm.green);
 
92
    prm.insert("Blue",  (double)currentPrm.blue);
 
93
 
 
94
    BatchTool::slotSettingsChanged(prm);
 
95
}
 
96
 
 
97
bool ColorBalance::toolOperations()
 
98
{
 
99
    if (!loadToDImg()) return false;
 
100
 
 
101
    CBContainer prm;
 
102
    prm.red   = settings()["Red"].toDouble();
 
103
    prm.green = settings()["Green"].toDouble();
 
104
    prm.blue  = settings()["Blue"].toDouble();
 
105
 
 
106
    CBFilter cb(&image(), 0L, prm);
 
107
    cb.startFilterDirectly();
 
108
    image().putImageData(cb.getTargetImage().bits());
 
109
 
 
110
    return (savefromDImg());
 
111
}
 
112
 
 
113
}  // namespace Digikam