* 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 color
{
- color() : red(0), green(0), blue(0), alpha(0)
- {}
+ T red = 0;
+ T green = 0;
+ T blue = 0;
+ T alpha = 0;
- T red;
- T green;
- T blue;
- T alpha;
+ std::uint32_t to_uint32()
+ {
+ return (alpha << 24) + (red << 16) + (green << 8) + blue;
+ }
};
template<typename T>
template<typename T>
struct rect
{
- point<T> location;
- size<T> size;
+ point<T> location;
+ psd::size<T> size;
bool empty() const { return size.width == 0 || size.height == 0; }
};
+struct psd_file_format_exception : virtual caspar_exception {};
-
-class PSDFileFormatException : public std::exception
-{
-public:
- virtual ~PSDFileFormatException()
- {}
- virtual const char *what() const
- {
- return "Unknown fileformat error";
- }
-};
-
-enum channel_type
+enum class channel_type
{
total_user_mask = -3,
user_mask = -2,
color_blue = 2
};
-enum blend_mode
+enum class blend_mode
{
InvalidBlendMode = -1,
Normal = 'norm',
ColorBurn = 'idiv'
};
-blend_mode int_to_blend_mode(unsigned long x);
+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