1 /** -*- mode: c++ ; c-basic-offset: 2 -*-
2  *
3  *  @file host.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 "gmic_qt.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 GmicQt
37 {
38 extern const QString HostApplicationName;
39 extern const char * HostApplicationShortname;
40 extern const bool DarkThemeIsDefault;
41 } // namespace GmicQt
42 
43 /**
44  * @brief gmic_qt_get_image_size
45  *
46  * Already deprecated ! gmic_qt_get_layers_extends is the one actually used.
47  *
48  * @param[out] width
49  * @param[out] height
50  */
51 void gmic_qt_get_image_size(int * width, int * height);
52 
53 /**
54  * @brief Get the largest width and largest height among all the layers
55  *        according to the input mode (\see gmic_qt.h).
56  *
57  * @param[out] width
58  * @param[out] height
59  */
60 void gmic_qt_get_layers_extent(int * width, int * height, GmicQt::InputMode);
61 
62 /**
63  * @brief Get a list of (cropped) image layers from host software.
64  *
65  *  Caution: returned images should contain "entire pixels" with respect to
66  *  to the normalized coordinates. Hence, integer coordinates should be computed
67  *  as (x,y,w,h) with :
68  *   x = static_cast<int>(std::floor(x * input_image_width));
69  *   w = std::min(input_image_width - x,static_cast<int>(1+std::ceil(width * input_image_width)));
70  *
71  * @param[out] images list
72  * @param[out] imageNames Per layer description strings (position, opacity, etc.)
73  * @param x Top-left corner normalized x coordinate w.r.t. image/extends width (i.e., in [0,1])
74  * @param y Top-left corner normalized y coordinate w.r.t. image/extends width (i.e., in [0,1])
75  * @param width Normalized width of the layers w.r.t. image/extends width
76  * @param height Normalized height of the layers w.r.t. image/extends height
77  * @param mode Input mode
78  */
79 void gmic_qt_get_cropped_images(cimg_library::CImgList<gmic_pixel_type> & images, cimg_library::CImgList<char> & imageNames, double x, double y, double width, double height, GmicQt::InputMode mode);
80 
81 /**
82  * @brief Send a list of new image layers to the host application according to
83  *        an output mode (\see gmic_qt.cpp)
84  *
85  * @param images List of layers to be sent to the host application. May be modified.
86  * @param imageNames Layers labels
87  * @param mode Output mode (\see gmic_qt.cpp)
88  * @param verboseLayersLabel Name used for all layers in VerboseLayerName mode, otherwise null.
89  */
90 void gmic_qt_output_images(cimg_library::CImgList<gmic_pixel_type> & images, const cimg_library::CImgList<char> & imageNames, GmicQt::OutputMode mode, const char * verboseLayersLabel = nullptr);
91 
92 /**
93  * @brief Apply a color profile to a given image
94  *
95  * @param [in,out] images An image
96  */
97 void gmic_qt_apply_color_profile(cimg_library::CImg<gmic_pixel_type> & images);
98 
99 /**
100  * @brief Display a message in the host application.
101  *        This function is only used if the plugin is launched using
102  *        launchPluginHeadless(). If a given plugin implementation never
103  *        calls the latter function, show_message() can do nothing!
104  *
105  * @param message A message to be displayed by the host application
106  */
107 void gmic_qt_show_message(const char * message);
108 
109 #endif // GMIC_QT_HOST_H
110