-/*
-* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
-*
-* This file is part of CasparCG (www.casparcg.com).
-*
-* CasparCG is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 3 of the License, or
-* (at your option) any later version.
-*
-* CasparCG is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
-*
-* Author: Niklas P Andersson, niklas.p.andersson@svt.se
-*/
-
-#ifndef _PSDMISC_H__
-#define _PSDMISC_H__
-
-#include <string>
-
-namespace caspar { namespace psd {
-
-template<typename T>
-struct point
-{
- point() : x(0), y(0) {}
- point(T x1, T y1) : x(x1), y(y1) {}
- T x;
- T y;
-};
-
-template<typename T>
-struct color
-{
- color() : red(0), green(0), blue(0), alpha(0)
- {}
-
- T red;
- T green;
- T blue;
- T alpha;
-
- unsigned long to_uint32()
- {
- return (alpha << 24) + (red << 16) + (green << 8) + blue;
- }
-};
-
-template<typename T>
-struct size
-{
- size() : width(0), height(0) {}
- size(T w, T h) : width(w), height(h) {}
- T width;
- T height;
-};
-
-template<typename T>
-struct rect
-{
- point<T> location;
- size<T> size;
-
- bool empty() const { return size.width == 0 || size.height == 0; }
-};
-
-
-
-class PSDFileFormatException : public std::exception
-{
-public:
- virtual ~PSDFileFormatException()
- {}
- virtual const char *what() const
- {
- return "Unknown fileformat error";
- }
-};
-
-enum channel_type
-{
- total_user_mask = -3,
- user_mask = -2,
- transparency = -1,
- color_red = 0,
- color_green = 1,
- color_blue = 2
-};
-
-enum blend_mode
-{
- InvalidBlendMode = -1,
- Normal = 'norm',
- Darken = 'dark',
- Lighten = 'lite',
- Hue = 'hue ',
- Saturation = 'sat ',
- Color = 'colr',
- Luminosity = 'lum ',
- Multiply = 'mul ',
- Screen = 'scrn',
- Dissolve = 'diss',
- Overlay = 'over',
- HardLight = 'hLit',
- SoftLight = 'sLit',
- Difference = 'diff',
- Exclusion = 'smud',
- ColorDodge = 'div ',
- ColorBurn = 'idiv'
-};
-
-blend_mode int_to_blend_mode(unsigned long x);
-std::wstring blend_mode_to_string(blend_mode b);
-
-enum color_mode
-{
- InvalidColorMode = -1,
- Bitmap = 0,
- Grayscale = 1,
- Indexed = 2,
- RGB = 3,
- CMYK = 4,
- Multichannel = 7,
- Duotone = 8,
- Lab = 9
-};
-
-color_mode int_to_color_mode(unsigned short x);
-std::wstring color_mode_to_string(color_mode c);
-
-} //namespace psd
-} //namespace caspar
-
-#endif
\ No newline at end of file
+/*\r
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
+*\r
+* This file is part of CasparCG (www.casparcg.com).\r
+*\r
+* CasparCG is free software: you can redistribute it and/or modify\r
+* it under the terms of the GNU General Public License as published by\r
+* the Free Software Foundation, either version 3 of the License, or\r
+* (at your option) any later version.\r
+*\r
+* CasparCG is distributed in the hope that it will be useful,\r
+* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+* GNU General Public License for more details.\r
+*\r
+* You should have received a copy of the GNU General Public License\r
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
+*\r
+* Author: Niklas P Andersson, niklas.p.andersson@svt.se\r
+*/\r
+\r
+#pragma once\r
+\r
+#include <common/except.h>\r
+#include <common/enum_class.h>\r
+#include <core/mixer/image/blend_modes.h>\r
+\r
+#include <string>\r
+#include <cstdint>\r
+#include <vector>\r
+\r
+namespace caspar { namespace psd {\r
+ \r
+template<typename T>\r
+struct point\r
+{\r
+ point() : x(0), y(0) {}\r
+ point(T x1, T y1) : x(x1), y(y1) {}\r
+ T x;\r
+ T y;\r
+\r
+ void clear() { x = 0; y = 0; }\r
+ \r
+ bool operator==(const point& rhs) {\r
+ return x == rhs.x && y == rhs.y;\r
+ }\r
+};\r
+\r
+template<typename T>\r
+struct color\r
+{\r
+ T red = 0;\r
+ T green = 0;\r
+ T blue = 0;\r
+ T alpha = 0;\r
+\r
+ std::uint32_t to_uint32()\r
+ {\r
+ return (alpha << 24) + (red << 16) + (green << 8) + blue;\r
+ }\r
+};\r
+\r
+template<typename T>\r
+struct size\r
+{\r
+ size() : width(0), height(0) {}\r
+ size(T w, T h) : width(w), height(h) {}\r
+ T width;\r
+ T height;\r
+\r
+ void clear() { width = 0; height = 0; }\r
+};\r
+\r
+template<typename T>\r
+struct rect\r
+{\r
+ point<T> location;\r
+ psd::size<T> size;\r
+\r
+ bool empty() const { return size.width == 0 || size.height == 0; }\r
+ void clear() { location.clear(); size.clear(); }\r
+};\r
+\r
+struct psd_file_format_exception : virtual caspar_exception {};\r
+\r
+enum class channel_type\r
+{\r
+ total_user_mask = -3,\r
+ user_mask = -2,\r
+ transparency = -1,\r
+ color_red = 0,\r
+ color_green = 1,\r
+ color_blue = 2\r
+};\r
+\r
+enum class layer_type\r
+{\r
+ content = 0,\r
+ group,\r
+ timeline_group,\r
+ group_delimiter\r
+};\r
+layer_type int_to_layer_type(std::uint32_t x, std::uint32_t y);\r
+std::wstring layer_type_to_string(layer_type b);\r
+\r
+caspar::core::blend_mode int_to_blend_mode(std::uint32_t x);\r
+\r
+enum class color_mode\r
+{\r
+ InvalidColorMode = -1,\r
+ Bitmap = 0,\r
+ Grayscale = 1,\r
+ Indexed = 2,\r
+ RGB = 3,\r
+ CMYK = 4,\r
+ Multichannel = 7,\r
+ Duotone = 8,\r
+ Lab = 9\r
+};\r
+\r
+color_mode int_to_color_mode(std::uint16_t x);\r
+std::wstring color_mode_to_string(color_mode c);\r
+\r
+\r
+enum class layer_tag : int {\r
+ none = 0,\r
+ placeholder = 1,\r
+ explicit_dynamic = 2,\r
+ moveable = 4,\r
+ resizable = 8,\r
+ rasterized = 16,\r
+ cornerpin = 32//,\r
+ //all = 63\r
+};\r
+ENUM_ENABLE_BITWISE(layer_tag);\r
+\r
+/*inline layer_tag operator ~ (layer_tag rhs)\r
+{\r
+ return (layer_tag)(static_cast<int>(layer_tag::all) ^ static_cast<int>(rhs));\r
+}*/\r
+\r
+layer_tag string_to_layer_tags(const std::wstring& str);\r
+\r
+} //namespace psd\r
+} //namespace caspar\r
+\r