]> git.sesse.net Git - casparcg/blob - modules/psd/image.h
82b992b271c000cdcb53d0c5a8824e4d1dc1f0d7
[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
23 namespace caspar { namespace psd {
24
25 template<typename T>
26 class image
27 {
28 public:
29         image(std::uint32_t width, std::uint32_t height, std::uint8_t channels) : width_(width), height_(height), channels_(channels)
30         {
31                 data_.resize(width*height*channels);
32         }
33
34         std::uint32_t width() const { return width_; }
35         std::uint32_t height() const { return height_; }
36         std::uint8_t channel_count() const { return channels_; }
37
38         T* data() { return data_.data(); }
39
40 private:
41         std::vector<T> data_;
42         std::uint32_t width_;
43         std::uint32_t height_;
44         std::uint8_t channels_;
45 };
46
47 typedef image<std::uint8_t>             image8bit;
48 typedef image<std::uint16_t>    image16bit;
49 typedef image<std::uint32_t>    image32bit;
50
51 typedef std::shared_ptr<image8bit>      image8bit_ptr;
52 typedef std::shared_ptr<image16bit>     image16bit_ptr;
53 typedef std::shared_ptr<image32bit>     image32bit_ptr;
54
55 }       //namespace psd
56 }       //namespace caspar