]> git.sesse.net Git - casparcg/blob - modules/psd/layer.h
* psd: support for extracting scaling-data of text-layer, and extracting sheet-color...
[casparcg] / modules / psd / layer.h
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 #ifndef _PSDLAYER_H__
23 #define _PSDLAYER_H__
24
25 #pragma once
26
27 #include <vector>
28 #include <string>
29 #include "common/memory.h"
30 #include "util\bigendian_file_input_stream.h"
31
32 #include "image.h"
33 #include "misc.h"
34 #include "channel.h"
35 #include <boost/property_tree/ptree_fwd.hpp>
36
37 namespace caspar { namespace psd {
38
39 class layer;
40 typedef std::shared_ptr<layer> layer_ptr;
41 class psd_document;
42
43 class layer
44 {
45         struct impl;
46         spl::shared_ptr<impl> impl_;
47
48 public:
49         class layer_mask_info
50         {
51                 friend struct layer::impl;
52
53                 void read_mask_data(BEFileInputStream&);
54
55                 image8bit_ptr   bitmap_;
56                 unsigned char   default_value_;
57                 unsigned char   flags_;
58                 char                    mask_id_;
59                 rect<long>              rect_;
60
61         public:
62                 bool enabled() const { return (flags_ & 2) == 0; }
63                 bool linked() const { return (flags_ & 1) == 0;  }
64                 bool inverted() const { return (flags_ & 4) == 4; }
65
66                 const point<long>& location() const { return rect_.location; }
67                 const image8bit_ptr& bitmap() const { return bitmap_; }
68         };
69
70         layer();
71
72         void populate(BEFileInputStream&, const psd_document&);
73         void read_channel_data(BEFileInputStream&);
74
75         const std::wstring& name() const;
76         unsigned char opacity() const;
77         unsigned short sheet_color() const;
78         bool is_visible();
79         bool is_position_protected();
80
81         float text_scale() const;
82         bool is_text() const;
83         const boost::property_tree::wptree& text_data() const;
84
85         bool is_solid() const;
86         color<unsigned char> solid_color() const;
87
88         bool has_timeline() const;
89         const boost::property_tree::wptree& timeline_data() const;
90
91         const point<long>& location() const;
92         const image8bit_ptr& bitmap() const;
93
94         int link_group_id() const;
95         void set_link_group_id(int id);
96 };
97
98 }       //namespace psd
99 }       //namespace caspar
100
101 #endif  //_PSDLAYER_H__