]> git.sesse.net Git - casparcg/blob - modules/psd/misc.h
Made calltracing configurable
[casparcg] / modules / psd / misc.h
1 /*\r
2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
3 *\r
4 * This file is part of CasparCG (www.casparcg.com).\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 * Author: Niklas P Andersson, niklas.p.andersson@svt.se\r
20 */\r
21 \r
22 #pragma once\r
23 \r
24 #include <common/except.h>\r
25 #include <common/enum_class.h>\r
26 #include <core/mixer/image/blend_modes.h>\r
27 \r
28 #include <string>\r
29 #include <cstdint>\r
30 #include <vector>\r
31 \r
32 namespace caspar { namespace psd {\r
33         \r
34 template<typename T>\r
35 struct point\r
36 {\r
37         point() : x(0), y(0) {}\r
38         point(T x1, T y1) : x(x1), y(y1) {}\r
39         T x;\r
40         T y;\r
41 \r
42         void clear() { x = 0; y = 0; }\r
43         \r
44         bool operator==(const point& rhs) {\r
45                 return x == rhs.x && y == rhs.y;\r
46         }\r
47 };\r
48 \r
49 template<typename T>\r
50 struct color\r
51 {\r
52         T red           = 0;\r
53         T green         = 0;\r
54         T blue          = 0;\r
55         T alpha         = 0;\r
56 \r
57         std::uint32_t to_uint32()\r
58         {\r
59                 return (alpha << 24) + (red << 16) + (green << 8) + blue;\r
60         }\r
61 };\r
62 \r
63 template<typename T>\r
64 struct size\r
65 {\r
66         size() : width(0), height(0) {}\r
67         size(T w, T h) : width(w), height(h) {}\r
68         T width;\r
69         T height;\r
70 \r
71         void clear() { width = 0; height = 0; }\r
72 };\r
73 \r
74 template<typename T>\r
75 struct rect\r
76 {\r
77         point<T>                location;\r
78         psd::size<T>    size;\r
79 \r
80         bool empty() const { return size.width == 0 || size.height == 0; }\r
81         void clear() { location.clear(); size.clear(); }\r
82 };\r
83 \r
84 struct psd_file_format_exception : virtual caspar_exception {};\r
85 \r
86 enum class channel_type\r
87 {\r
88         total_user_mask = -3,\r
89         user_mask = -2,\r
90         transparency = -1,\r
91         color_red = 0,\r
92         color_green = 1,\r
93         color_blue = 2\r
94 };\r
95 \r
96 enum class layer_type\r
97 {\r
98         content = 0,\r
99         group,\r
100         timeline_group,\r
101         group_delimiter\r
102 };\r
103 layer_type int_to_layer_type(std::uint32_t x, std::uint32_t y);\r
104 std::wstring layer_type_to_string(layer_type b);\r
105 \r
106 caspar::core::blend_mode int_to_blend_mode(std::uint32_t x);\r
107 \r
108 enum class color_mode\r
109 {\r
110         InvalidColorMode = -1,\r
111         Bitmap = 0,\r
112         Grayscale = 1,\r
113         Indexed = 2,\r
114         RGB = 3,\r
115         CMYK = 4,\r
116         Multichannel = 7,\r
117         Duotone = 8,\r
118         Lab = 9\r
119 };\r
120 \r
121 color_mode int_to_color_mode(std::uint16_t x);\r
122 std::wstring color_mode_to_string(color_mode c);\r
123 \r
124 \r
125 enum class layer_tag : int {\r
126         none = 0,\r
127         placeholder = 1,\r
128         explicit_dynamic = 2,\r
129         moveable = 4,\r
130         resizable = 8,\r
131         rasterized = 16,\r
132         cornerpin = 32//,\r
133         //all = 63\r
134 };\r
135 ENUM_ENABLE_BITWISE(layer_tag);\r
136 \r
137 /*inline layer_tag operator ~ (layer_tag rhs)\r
138 {\r
139         return (layer_tag)(static_cast<int>(layer_tag::all) ^ static_cast<int>(rhs));\r
140 }*/\r
141 \r
142 layer_tag string_to_layer_tags(const std::wstring& str);\r
143 \r
144 }       //namespace psd\r
145 }       //namespace caspar\r
146 \r