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