comparison OrthancStone/Sources/Wrappers/CairoSurface.h @ 1512:244ad1e4e76a

reorganization of folders
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 07 Jul 2020 16:21:02 +0200
parents Framework/Wrappers/CairoSurface.h@30deba7bc8e2
children 4fb8fdf03314
comparison
equal deleted inserted replaced
1511:9dfeee74c1e6 1512:244ad1e4e76a
1 /**
2 * Stone of Orthanc
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
6 *
7 * This program is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU Affero General Public License
9 * as published by the Free Software Foundation, either version 3 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Affero General Public License for more details.
16 *
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 **/
20
21
22 #pragma once
23
24 #include <Images/ImageAccessor.h>
25
26 #include <boost/noncopyable.hpp>
27 #include <cairo.h>
28
29 namespace OrthancStone
30 {
31 class CairoSurface : public boost::noncopyable
32 {
33 private:
34 cairo_surface_t* surface_;
35 unsigned int width_;
36 unsigned int height_;
37 unsigned int pitch_;
38 void* buffer_;
39 bool hasAlpha_;
40
41 void Release();
42
43 void Allocate(unsigned int width,
44 unsigned int height,
45 bool hasAlpha);
46
47 public:
48 CairoSurface() :
49 surface_(NULL)
50 {
51 Allocate(0, 0, false);
52 }
53
54 CairoSurface(unsigned int width,
55 unsigned int height,
56 bool hasAlpha) :
57 surface_(NULL)
58 {
59 Allocate(width, height, hasAlpha);
60 }
61
62 CairoSurface(Orthanc::ImageAccessor& accessor,
63 bool hasAlpha);
64
65 ~CairoSurface()
66 {
67 Release();
68 }
69
70 void SetSize(unsigned int width,
71 unsigned int height,
72 bool hasAlpha);
73
74 void Copy(const CairoSurface& other);
75
76 void Copy(const Orthanc::ImageAccessor& source,
77 bool hasAlpha);
78
79 unsigned int GetWidth() const
80 {
81 return width_;
82 }
83
84 unsigned int GetHeight() const
85 {
86 return height_;
87 }
88
89 unsigned int GetPitch() const
90 {
91 return pitch_;
92 }
93
94 const void* GetBuffer() const
95 {
96 return buffer_;
97 }
98
99 void* GetBuffer()
100 {
101 return buffer_;
102 }
103
104 cairo_surface_t* GetObject()
105 {
106 return surface_;
107 }
108
109 bool HasAlpha() const
110 {
111 return hasAlpha_;
112 }
113
114 void GetReadOnlyAccessor(Orthanc::ImageAccessor& target) const;
115
116 void GetWriteableAccessor(Orthanc::ImageAccessor& target);
117 };
118 }