]> git.sesse.net Git - casparcg/blob - modules/psd/image.h
* Upgraded to Visual Studio 2013
[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
21 #include <memory>
22 #include <vector>
23
24 namespace caspar { namespace psd {
25
26 template<typename T>
27 class image
28 {
29 public:
30         image(unsigned long width, unsigned long height, unsigned char 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         unsigned char channel_count() const { return channels_; }
38
39         T* data() { return data_.data(); }
40
41 private:
42         std::vector<T> data_;
43         unsigned long width_;
44         unsigned long height_;
45         unsigned char channels_;
46 };
47
48 typedef image<unsigned char> image8bit; 
49 typedef image<unsigned short> image16bit; 
50 typedef image<unsigned long> 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