]> git.sesse.net Git - casparcg/blob - modules/psd/misc.h
primal psd-file reading
[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 rect
31 {
32         T top;
33         T right;
34         T bottom;
35         T left;
36         T width() { return right-left; }
37         T height() { return bottom-top; }
38 };
39
40 class PSDFileFormatException : public std::exception
41 {
42 public:
43         virtual ~PSDFileFormatException()
44         {}
45         virtual const char *what() const
46         {
47                 return "Unknown fileformat error";
48         }
49 };
50
51 enum ChannelType
52 {
53         TotalUserMask = -3,
54         UserMask = -2,
55         Transparency = -1,
56         ColorRed = 0,
57         ColorGreen = 1,
58         ColorBlue = 2
59 };
60
61 enum BlendMode
62 {
63         InvalidBlendMode = -1,
64         Normal = 'norm',
65         Darken = 'dark',
66         Lighten = 'lite',
67         Hue = 'hue ',
68         Saturation = 'sat ',
69         Color = 'colr',
70         Luminosity = 'lum ',
71         Multiply = 'mul ',
72         Screen = 'scrn',
73         Dissolve = 'diss',
74         Overlay = 'over',
75         HardLight = 'hLit',
76         SoftLight = 'sLit',
77         Difference = 'diff',
78         Exclusion = 'smud',
79         ColorDodge = 'div ',
80         ColorBurn = 'idiv'
81 };
82
83 BlendMode IntToBlendMode(unsigned long x);
84 std::wstring BlendModeToString(BlendMode b);
85
86 enum color_mode
87 {
88         InvalidColorMode = -1,
89         Bitmap = 0,
90         Grayscale = 1,
91         Indexed = 2,
92         RGB = 3,
93         CMYK = 4,
94         Multichannel = 7,
95         Duotone = 8,
96         Lab = 9
97 };
98
99 color_mode int_to_color_mode(unsigned short x);
100 std::wstring color_mode_to_string(color_mode c);
101
102 }       //namespace psd
103 }       //namespace caspar
104
105 #endif