]> git.sesse.net Git - casparcg/blob - core/producer/frame/image_transform.h
2.0. image_mixer: Refactored blend-modes.
[casparcg] / core / producer / frame / image_transform.h
1 /*\r
2 * copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
3 *\r
4 *  This file is part of CasparCG.\r
5 *\r
6 *    CasparCG is free software: you can redistribute it and/or modify\r
7 *    it under the terms of the GNU General Public License as published by\r
8 *    the Free Software Foundation, either version 3 of the License, or\r
9 *    (at your option) any later version.\r
10 *\r
11 *    CasparCG is distributed in the hope that it will be useful,\r
12 *    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14 *    GNU General Public License for more details.\r
15 \r
16 *    You should have received a copy of the GNU General Public License\r
17 *    along with CasparCG.  If not, see <http://www.gnu.org/licenses/>.\r
18 *\r
19 */\r
20 #pragma once\r
21 \r
22 #include <common/utility/tweener.h>\r
23 #include <core/video_format.h>\r
24 \r
25 #include <array>\r
26 #include <type_traits>\r
27 \r
28 namespace caspar { namespace core {\r
29 \r
30 struct pixel_format_desc;\r
31         \r
32 class image_transform \r
33 {\r
34 public:\r
35         \r
36         struct levels\r
37         {\r
38                 levels() \r
39                         : min_input(0.0)\r
40                         , max_input(1.0)\r
41                         , gamma(1.0)\r
42                         , min_output(0.0)\r
43                         , max_output(1.0)\r
44                 {               \r
45                 }\r
46                 double min_input;\r
47                 double max_input;\r
48                 double gamma;\r
49                 double min_output;\r
50                 double max_output;\r
51         };\r
52 \r
53         image_transform();\r
54 \r
55         void set_opacity(double value);\r
56         double get_opacity() const;\r
57         \r
58         void set_brightness(double value);\r
59         double get_brightness() const;\r
60 \r
61         void set_contrast(double value);\r
62         double get_contrast() const;\r
63 \r
64         void set_saturation(double value);\r
65         double get_saturation() const;\r
66         \r
67         void set_levels(const levels& value);\r
68         levels get_levels() const;\r
69         \r
70         void set_fill_translation(double x, double y);\r
71         std::array<double, 2> get_fill_translation() const;\r
72 \r
73         void set_fill_scale(double x, double y);\r
74         std::array<double, 2> get_fill_scale() const;\r
75         \r
76         void set_clip_translation(double x, double y);\r
77         std::array<double, 2> get_clip_translation() const;\r
78 \r
79         void set_clip_scale(double x, double y);\r
80         std::array<double, 2> get_clip_scale() const;\r
81         \r
82         image_transform& operator*=(const image_transform &other);\r
83         const image_transform operator*(const image_transform &other) const;\r
84 \r
85         void set_is_key(bool value);\r
86         bool get_is_key() const;\r
87                 \r
88 private:\r
89         double opacity_;\r
90         double gain_;\r
91         double contrast_;\r
92         double brightness_;\r
93         double saturation_;\r
94         double desaturation_;\r
95         levels levels_;\r
96         std::array<double, 2> fill_translation_; \r
97         std::array<double, 2> fill_scale_; \r
98         std::array<double, 2> clip_translation_; \r
99         std::array<double, 2> clip_scale_; \r
100         video_mode::type mode_;\r
101         bool is_key_;\r
102 };\r
103 \r
104 image_transform tween(double time, const image_transform& source, const image_transform& dest, double duration, const tweener_t& tweener);\r
105 \r
106 bool operator<(const image_transform& lhs, const image_transform& rhs);\r
107 bool operator==(const image_transform& lhs, const image_transform& rhs);\r
108 bool operator!=(const image_transform& lhs, const image_transform& rhs);\r
109 \r
110 }}