File indexing completed on 2025-01-19 03:50:55
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2009-11-21 0007 * Description : Anti-vignetting batch tool. 0008 * 0009 * SPDX-FileCopyrightText: 2009-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #include "antivignetting.h" 0016 0017 // Qt includes 0018 0019 #include <QLabel> 0020 #include <QWidget> 0021 0022 // KDE includes 0023 0024 #include <klocalizedstring.h> 0025 0026 // Local includes 0027 0028 #include "dimg.h" 0029 #include "antivignettingfilter.h" 0030 0031 namespace DigikamBqmAntiVignettingPlugin 0032 { 0033 0034 AntiVignetting::AntiVignetting(QObject* const parent) 0035 : BatchTool(QLatin1String("AntiVignetting"), EnhanceTool, parent), 0036 m_settingsView(nullptr) 0037 { 0038 } 0039 0040 AntiVignetting::~AntiVignetting() 0041 { 0042 } 0043 0044 BatchTool* AntiVignetting::clone(QObject* const parent) const 0045 { 0046 return new AntiVignetting(parent); 0047 } 0048 0049 void AntiVignetting::registerSettingsWidget() 0050 { 0051 m_settingsWidget = new QWidget; 0052 m_settingsView = new AntiVignettingSettings(m_settingsWidget); 0053 0054 connect(m_settingsView, SIGNAL(signalSettingsChanged()), 0055 this, SLOT(slotSettingsChanged())); 0056 0057 BatchTool::registerSettingsWidget(); 0058 } 0059 0060 BatchToolSettings AntiVignetting::defaultSettings() 0061 { 0062 BatchToolSettings prm; 0063 AntiVignettingContainer defaultPrm = m_settingsView->defaultSettings(); 0064 0065 prm.insert(QLatin1String("addvignetting"), (bool)defaultPrm.addvignetting); 0066 prm.insert(QLatin1String("density"), (double)defaultPrm.density); 0067 prm.insert(QLatin1String("power"), (double)defaultPrm.power); 0068 prm.insert(QLatin1String("innerradius"), (double)defaultPrm.innerradius); 0069 prm.insert(QLatin1String("outerradius"), (double)defaultPrm.outerradius); 0070 prm.insert(QLatin1String("xshift"), (double)defaultPrm.xshift); 0071 prm.insert(QLatin1String("yshift"), (double)defaultPrm.yshift); 0072 0073 return prm; 0074 } 0075 0076 void AntiVignetting::slotAssignSettings2Widget() 0077 { 0078 AntiVignettingContainer prm; 0079 prm.addvignetting = settings()[QLatin1String("addvignetting")].toBool(); 0080 prm.density = settings()[QLatin1String("density")].toDouble(); 0081 prm.power = settings()[QLatin1String("power")].toDouble(); 0082 prm.innerradius = settings()[QLatin1String("innerradius")].toDouble(); 0083 prm.outerradius = settings()[QLatin1String("outerradius")].toDouble(); 0084 prm.xshift = settings()[QLatin1String("xshift")].toDouble(); 0085 prm.yshift = settings()[QLatin1String("yshift")].toDouble(); 0086 m_settingsView->setSettings(prm); 0087 } 0088 0089 void AntiVignetting::slotSettingsChanged() 0090 { 0091 BatchToolSettings prm; 0092 AntiVignettingContainer currentPrm = m_settingsView->settings(); 0093 0094 prm.insert(QLatin1String("addvignetting"), (bool)currentPrm.addvignetting); 0095 prm.insert(QLatin1String("density"), (double)currentPrm.density); 0096 prm.insert(QLatin1String("power"), (double)currentPrm.power); 0097 prm.insert(QLatin1String("innerradius"), (double)currentPrm.innerradius); 0098 prm.insert(QLatin1String("outerradius"), (double)currentPrm.outerradius); 0099 prm.insert(QLatin1String("xshift"), (double)currentPrm.xshift); 0100 prm.insert(QLatin1String("yshift"), (double)currentPrm.yshift); 0101 0102 BatchTool::slotSettingsChanged(prm); 0103 } 0104 0105 bool AntiVignetting::toolOperations() 0106 { 0107 if (!loadToDImg()) 0108 { 0109 return false; 0110 } 0111 0112 AntiVignettingContainer prm; 0113 prm.addvignetting = settings()[QLatin1String("addvignetting")].toBool(); 0114 prm.density = settings()[QLatin1String("density")].toDouble(); 0115 prm.power = settings()[QLatin1String("power")].toDouble(); 0116 prm.innerradius = settings()[QLatin1String("innerradius")].toDouble(); 0117 prm.outerradius = settings()[QLatin1String("outerradius")].toDouble(); 0118 prm.xshift = settings()[QLatin1String("xshift")].toDouble(); 0119 prm.yshift = settings()[QLatin1String("yshift")].toDouble(); 0120 0121 AntiVignettingFilter vig(&image(), nullptr, prm); 0122 applyFilter(&vig); 0123 0124 return (savefromDImg()); 0125 } 0126 0127 } // namespace DigikamBqmAntiVignettingPlugin 0128 0129 #include "moc_antivignetting.cpp"