1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date        : 2010-03-16
7  * Description : Invert colors batch tool.
8  *
9  * Copyright (C) 2010-2021 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 "invert.h"
25 
26 // Qt includes
27 
28 #include <QWidget>
29 
30 // KDE includes
31 
32 #include <klocalizedstring.h>
33 
34 // Local includes
35 
36 #include "dimg.h"
37 #include "invertfilter.h"
38 
39 namespace DigikamBqmInvertPlugin
40 {
41 
Invert(QObject * const parent)42 Invert::Invert(QObject* const parent)
43     : BatchTool(QLatin1String("Invert"), ColorTool, parent)
44 {
45 }
46 
~Invert()47 Invert::~Invert()
48 {
49 }
50 
defaultSettings()51 BatchToolSettings Invert::defaultSettings()
52 {
53     return BatchToolSettings();
54 }
55 
clone(QObject * const parent) const56 BatchTool* Invert::clone(QObject* const parent) const
57 {
58     return new Invert(parent);
59 }
60 
toolOperations()61 bool Invert::toolOperations()
62 {
63     if (!loadToDImg())
64     {
65         return false;
66     }
67 
68     InvertFilter inv(&image(), nullptr);
69     applyFilter(&inv);
70 
71     return (savefromDImg());
72 }
73 
74 } // namespace DigikamBqmInvertPlugin
75