]> git.sesse.net Git - casparcg/blob - modules/psd/image.h
[flash] Fixed bug where template-host copying didn't work.
[casparcg] / modules / psd / image.h
1 /*
2 * CasparCG is free software: you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation, either version 3 of the License, or
5 * (at your option) any later version.
6 *
7 * CasparCG is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
14 *
15 * Author: Niklas P Andersson, niklas.p.andersson@svt.se
16 */
17
18 #pragma once
19
20 #include <memory>
21 #include <vector>
22 #include <cstdint>
23
24 namespace caspar { namespace psd {
25
26 template<typename T>
27 class image
28 {
29 public:
30         image(int width, int height, int channels) : width_(width), height_(height), channels_(channels)
31         {
32                 data_.resize(width*height*channels);
33         }
34
35         int width() const { return width_; }
36         int height() const { return height_; }
37         int channel_count() const { return channels_; }
38
39         T* data() { return data_.data(); }
40
41 private:
42         std::vector<T>  data_;
43         int                             width_;
44         int                             height_;
45         int                             channels_;
46 };
47
48 typedef image<std::uint8_t>             image8bit;
49 typedef image<std::uint16_t>    image16bit;
50 typedef image<std::uint32_t>    image32bit;
51
52 typedef std::shared_ptr<image8bit>      image8bit_ptr;
53 typedef std::shared_ptr<image16bit>     image16bit_ptr;
54 typedef std::shared_ptr<image32bit>     image32bit_ptr;
55
56 }       //namespace psd
57 }       //namespace caspar