]> git.sesse.net Git - casparcg/blob - modules/psd/misc.h
9651f6becc17e8cdfe31883fbbf188e03feea2c7
[casparcg] / modules / psd / misc.h
1 /*
2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
3 *
4 * This file is part of CasparCG (www.casparcg.com).
5 *
6 * CasparCG is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * CasparCG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * Author: Niklas P Andersson, niklas.p.andersson@svt.se
20 */
21
22 #ifndef _PSDMISC_H__
23 #define _PSDMISC_H__
24
25 #include <string>
26
27 namespace caspar { namespace psd {
28         
29 template<typename T>
30 struct point
31 {
32         point() : x(0), y(0) {}
33         point(T x1, T y1) : x(x1), y(y1) {}
34         T x;
35         T y;
36 };
37
38 template<typename T>
39 struct color
40 {
41         color() : red(0), green(0), blue(0), alpha(0)
42         {}
43
44         T red;
45         T green;
46         T blue;
47         T alpha;
48
49         unsigned long to_uint32()
50         {
51                 return (alpha << 24) + (red << 16) + (green << 8) + blue;
52         }
53 };
54
55 template<typename T>
56 struct size
57 {
58         size() : width(0), height(0) {}
59         size(T w, T h) : width(w), height(h) {}
60         T width;
61         T height;
62 };
63
64 template<typename T>
65 struct rect
66 {
67         point<T>        location;
68         size<T>         size;
69
70         bool empty() const { return size.width == 0 || size.height == 0; }
71 };
72
73
74
75 class PSDFileFormatException : public std::exception
76 {
77 public:
78         virtual ~PSDFileFormatException()
79         {}
80         virtual const char *what() const
81         {
82                 return "Unknown fileformat error";
83         }
84 };
85
86 enum channel_type
87 {
88         total_user_mask = -3,
89         user_mask = -2,
90         transparency = -1,
91         color_red = 0,
92         color_green = 1,
93         color_blue = 2
94 };
95
96 enum blend_mode
97 {
98         InvalidBlendMode = -1,
99         Normal = 'norm',
100         Darken = 'dark',
101         Lighten = 'lite',
102         Hue = 'hue ',
103         Saturation = 'sat ',
104         Color = 'colr',
105         Luminosity = 'lum ',
106         Multiply = 'mul ',
107         Screen = 'scrn',
108         Dissolve = 'diss',
109         Overlay = 'over',
110         HardLight = 'hLit',
111         SoftLight = 'sLit',
112         Difference = 'diff',
113         Exclusion = 'smud',
114         ColorDodge = 'div ',
115         ColorBurn = 'idiv'
116 };
117
118 blend_mode int_to_blend_mode(unsigned long x);
119 std::wstring blend_mode_to_string(blend_mode b);
120
121 enum color_mode
122 {
123         InvalidColorMode = -1,
124         Bitmap = 0,
125         Grayscale = 1,
126         Indexed = 2,
127         RGB = 3,
128         CMYK = 4,
129         Multichannel = 7,
130         Duotone = 8,
131         Lab = 9
132 };
133
134 color_mode int_to_color_mode(unsigned short x);
135 std::wstring color_mode_to_string(color_mode c);
136
137 }       //namespace psd
138 }       //namespace caspar
139
140 #endif