]> git.sesse.net Git - casparcg/blob - modules/psd/misc.cpp
54c3923368cb8615a78305c66a9f1c189c11abe5
[casparcg] / modules / psd / misc.cpp
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 #include <vector>
23 #include "misc.h"
24
25 namespace caspar { namespace psd {
26
27 blend_mode int_to_blend_mode(std::uint32_t x)
28 {
29         blend_mode mode = static_cast<blend_mode>(x);
30
31         switch (mode)
32         {
33                 case blend_mode::Normal:
34                 case blend_mode::Darken:
35                 case blend_mode::Lighten:
36                 case blend_mode::Hue:
37                 case blend_mode::Saturation:
38                 case blend_mode::Color:
39                 case blend_mode::Luminosity:
40                 case blend_mode::Multiply:
41                 case blend_mode::Screen:
42                 case blend_mode::Dissolve:
43                 case blend_mode::Overlay:
44                 case blend_mode::HardLight:
45                 case blend_mode::SoftLight:
46                 case blend_mode::Difference:
47                 case blend_mode::Exclusion:
48                 case blend_mode::ColorDodge:
49                 case blend_mode::ColorBurn:
50                         return mode;
51                 default:
52                         return blend_mode::InvalidBlendMode;
53         }
54 }
55
56 std::wstring blend_mode_to_string(blend_mode b)
57 {
58         switch(b)
59         {
60                 case blend_mode::Normal: return L"Normal";
61                 case blend_mode::Darken: return L"Darken";
62                 case blend_mode::Lighten: return L"Lighten";
63                 case blend_mode::Hue: return L"Hue";
64                 case blend_mode::Saturation: return L"Saturation";
65                 case blend_mode::Color: return L"Color";
66                 case blend_mode::Luminosity: return L"Luminosity";
67                 case blend_mode::Multiply: return L"Multiply";
68                 case blend_mode::Screen: return L"Screen";
69                 case blend_mode::Dissolve: return L"Dissolve";
70                 case blend_mode::Overlay: return L"Overlay";
71                 case blend_mode::HardLight: return L"HardLight";
72                 case blend_mode::SoftLight: return L"SoftLight";
73                 case blend_mode::Difference: return L"Difference";
74                 case blend_mode::Exclusion: return L"Exclusion";
75                 case blend_mode::ColorDodge: return L"ColorDodge";
76                 case blend_mode::ColorBurn: return L"ColorBurn";
77                 default: return L"Invalid";
78         }
79 }
80
81 color_mode int_to_color_mode(std::uint16_t x)
82 {
83         color_mode mode = static_cast<color_mode>(x);
84
85         switch(mode)
86         {
87                 case color_mode::Bitmap:
88                 case color_mode::Grayscale:
89                 case color_mode::Indexed:
90                 case color_mode::RGB:
91                 case color_mode::CMYK:
92                 case color_mode::Multichannel:
93                 case color_mode::Duotone:
94                 case color_mode::Lab:
95                         return mode;
96                 default:
97                         return color_mode::InvalidColorMode;
98         };
99 }
100
101 std::wstring color_mode_to_string(color_mode c)
102 {
103         switch(c)
104         {
105                 case color_mode::Bitmap: return L"Bitmap";
106                 case color_mode::Grayscale:     return L"Grayscale";
107                 case color_mode::Indexed: return L"Indexed";
108                 case color_mode::RGB: return L"RGB";
109                 case color_mode::CMYK: return L"CMYK";
110                 case color_mode::Multichannel: return L"Multichannel";
111                 case color_mode::Duotone: return L"Duotone";
112                 case color_mode::Lab: return L"Lab";
113                 default: return L"Invalid";
114         };
115 }
116
117 }       //namespace psd
118 }       //namespace caspar