* Author: Niklas P Andersson, niklas.p.andersson@svt.se
*/
-#ifndef _PSDMISC_H__
-#define _PSDMISC_H__
+#pragma once
+
+#include <common/except.h>
#include <string>
+#include <cstdint>
namespace caspar { namespace psd {
-
+
template<typename T>
-struct rect
+struct point
{
- T top;
- T right;
- T bottom;
- T left;
- T width() { return right-left; }
- T height() { return bottom-top; }
+ point() : x(0), y(0) {}
+ point(T x1, T y1) : x(x1), y(y1) {}
+ T x;
+ T y;
+
+ void clear() { x = 0; y = 0; }
};
-class PSDFileFormatException : public std::exception
+template<typename T>
+struct color
{
-public:
- virtual ~PSDFileFormatException()
- {}
- virtual const char *what() const
+ T red = 0;
+ T green = 0;
+ T blue = 0;
+ T alpha = 0;
+
+ std::uint32_t to_uint32()
{
- return "Unknown fileformat error";
+ return (alpha << 24) + (red << 16) + (green << 8) + blue;
}
};
-enum ChannelType
+template<typename T>
+struct size
+{
+ size() : width(0), height(0) {}
+ size(T w, T h) : width(w), height(h) {}
+ T width;
+ T height;
+
+ void clear() { width = 0; height = 0; }
+};
+
+template<typename T>
+struct rect
+{
+ point<T> location;
+ psd::size<T> size;
+
+ bool empty() const { return size.width == 0 || size.height == 0; }
+ void clear() { location.clear(); size.clear(); }
+};
+
+struct psd_file_format_exception : virtual caspar_exception {};
+
+enum class channel_type
+{
+ total_user_mask = -3,
+ user_mask = -2,
+ transparency = -1,
+ color_red = 0,
+ color_green = 1,
+ color_blue = 2
+};
+
+enum class layer_type
{
- TotalUserMask = -3,
- UserMask = -2,
- Transparency = -1,
- ColorRed = 0,
- ColorGreen = 1,
- ColorBlue = 2
+ content = 0,
+ group,
+ timeline_group,
+ group_delimiter
};
+layer_type int_to_layer_type(std::uint32_t x, std::uint32_t y);
+std::wstring layer_type_to_string(layer_type b);
-enum BlendMode
+enum class blend_mode
{
InvalidBlendMode = -1,
Normal = 'norm',
ColorBurn = 'idiv'
};
-BlendMode IntToBlendMode(unsigned long x);
-std::wstring BlendModeToString(BlendMode b);
+blend_mode int_to_blend_mode(std::uint32_t x);
+std::wstring blend_mode_to_string(blend_mode b);
-enum color_mode
+enum class color_mode
{
InvalidColorMode = -1,
Bitmap = 0,
Lab = 9
};
-color_mode int_to_color_mode(unsigned short x);
+color_mode int_to_color_mode(std::uint16_t x);
std::wstring color_mode_to_string(color_mode c);
} //namespace psd
} //namespace caspar
-#endif
\ No newline at end of file