1 /** -*- mode: c++ ; c-basic-offset: 2 -*-
2  *
3  *  @file GmicQtHost.h
4  *
5  *  Copyright 2017 Sebastien Fourey
6  *
7  *  This file is part of G'MIC-Qt, a generic plug-in for raster graphics
8  *  editors, offering hundreds of filters thanks to the underlying G'MIC
9  *  image processing framework.
10  *
11  *  gmic_qt is free software: you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License as published by
13  *  the Free Software Foundation, either version 3 of the License, or
14  *  (at your option) any later version.
15  *
16  *  gmic_qt is distributed in the hope that it will be useful,
17  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *  GNU General Public License for more details.
20  *
21  *  You should have received a copy of the GNU General Public License
22  *  along with gmic_qt.  If not, see <http://www.gnu.org/licenses/>.
23  *
24  */
25 #ifndef GMIC_QT_HOST_H
26 #define GMIC_QT_HOST_H
27 #include <QString>
28 #include "GmicQt.h"
29 
30 namespace cimg_library
31 {
32 template <typename T> struct CImg;
33 template <typename T> struct CImgList;
34 } // namespace cimg_library
35 
36 namespace GmicQtHost
37 {
38 extern const QString ApplicationName;
39 extern const char * const ApplicationShortname;
40 extern const bool DarkThemeIsDefault;
41 
42 /**
43  * @brief Get the largest width and largest height among all the layers according to the input mode (\see GmicQt.h).
44  *
45  * @param[out] width
46  * @param[out] height
47  */
48 void getLayersExtent(int * width, int * height, GmicQt::InputMode);
49 
50 /**
51  * @brief Get a list of (cropped) image layers from host software.
52  *
53  *  Caution: returned images should contain "entire pixels" with respect to
54  *  to the normalized coordinates. Hence, integer coordinates should be computed
55  *  as (x,y,w,h) with :
56  *   x = static_cast<int>(std::floor(x * input_image_width));
57  *   w = std::min(input_image_width - x,static_cast<int>(1+std::ceil(width * input_image_width)));
58  *
59  * @param[out] images list
60  * @param[out] imageNames Per layer description strings (position, opacity, etc.)
61  * @param x Top-left corner normalized x coordinate w.r.t. image/extends width (i.e., in [0,1])
62  * @param y Top-left corner normalized y coordinate w.r.t. image/extends width (i.e., in [0,1])
63  * @param width Normalized width of the layers w.r.t. image/extends width
64  * @param height Normalized height of the layers w.r.t. image/extends height
65  * @param mode Input mode
66  */
67 void getCroppedImages(cimg_library::CImgList<gmic_pixel_type> & images, //
68                       cimg_library::CImgList<char> & imageNames,        //
69                       double x,                                         //
70                       double y,                                         //
71                       double width,                                     //
72                       double height,                                    //
73                       GmicQt::InputMode mode);
74 
75 /**
76  * @brief Send a list of new image layers to the host application according to an output mode (\see GmicQt.h)
77  *
78  * @param images List of layers to be sent to the host application. May be modified.
79  * @param imageNames Layers labels
80  * @param mode Output mode (\see GmicQt.h)
81  */
82 void outputImages(cimg_library::CImgList<gmic_pixel_type> & images, const cimg_library::CImgList<char> & imageNames, GmicQt::OutputMode mode);
83 
84 /**
85  * @brief Apply a color profile to a given image
86  *
87  * @param [in,out] images An image
88  */
89 void applyColorProfile(cimg_library::CImg<gmic_pixel_type> & images);
90 
91 /**
92  * @brief Display a message in the host application.
93  *        This function is only used if the plugin is launched using the UserInterfaceMode::Silent mode.
94  *        If a given plugin implementation never calls the latter function, show_message() can do nothing!
95  *
96  * @param message A message to be displayed by the host application
97  */
98 void showMessage(const char * message);
99 
100 } // namespace GmicQtHost
101 
102 #endif // GMIC_QT_HOST_H
103