]> git.sesse.net Git - casparcg/blobdiff - modules/psd/misc.h
Log cadence in decklink_producer to be able to debug cadence mismatches
[casparcg] / modules / psd / misc.h
index 7474f487fd51d9a4be362992c9a256716504389c..f451fef300fcc0081eea80655c235eba5e2471f7 100644 (file)
 * 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 {
        
@@ -38,13 +40,15 @@ struct point
 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>
@@ -59,26 +63,15 @@ struct size
 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,
@@ -88,7 +81,7 @@ enum channel_type
        color_blue = 2
 };
 
-enum blend_mode
+enum class blend_mode
 {
        InvalidBlendMode = -1,
        Normal = 'norm',
@@ -110,10 +103,10 @@ enum blend_mode
        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,
@@ -126,10 +119,9 @@ enum color_mode
        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