Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Wrappers/CairoSurface.h @ 1681:f2e8b3ac1dcd
handling multiple windowing presets in the Stone web viewer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 24 Nov 2020 18:08:07 +0100 |
parents | 8563ea5d8ae4 |
children | 9ac2a65d4172 |
rev | line source |
---|---|
0 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1270
2d8ab34c8c91
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
807
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
47 | 9 * as published by the Free Software Foundation, either version 3 of |
10 * the License, or (at your option) any later version. | |
0 | 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 | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
15 * Lesser General Public License for more details. |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
16 * |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
18 * License along with this program. If not, see |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
0 | 20 **/ |
21 | |
22 | |
23 #pragma once | |
24 | |
1455
30deba7bc8e2
simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1270
diff
changeset
|
25 #include <Images/ImageAccessor.h> |
0 | 26 |
27 #include <boost/noncopyable.hpp> | |
28 #include <cairo.h> | |
29 | |
30 namespace OrthancStone | |
31 { | |
32 class CairoSurface : public boost::noncopyable | |
33 { | |
34 private: | |
35 cairo_surface_t* surface_; | |
36 unsigned int width_; | |
37 unsigned int height_; | |
38 unsigned int pitch_; | |
39 void* buffer_; | |
560
aaeec7be8fb7
add support for alpha channel in CairoSurface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
556
diff
changeset
|
40 bool hasAlpha_; |
0 | 41 |
42 void Release(); | |
43 | |
44 void Allocate(unsigned int width, | |
560
aaeec7be8fb7
add support for alpha channel in CairoSurface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
556
diff
changeset
|
45 unsigned int height, |
aaeec7be8fb7
add support for alpha channel in CairoSurface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
556
diff
changeset
|
46 bool hasAlpha); |
0 | 47 |
48 public: | |
49 CairoSurface() : | |
50 surface_(NULL) | |
51 { | |
560
aaeec7be8fb7
add support for alpha channel in CairoSurface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
556
diff
changeset
|
52 Allocate(0, 0, false); |
0 | 53 } |
54 | |
55 CairoSurface(unsigned int width, | |
560
aaeec7be8fb7
add support for alpha channel in CairoSurface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
556
diff
changeset
|
56 unsigned int height, |
aaeec7be8fb7
add support for alpha channel in CairoSurface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
556
diff
changeset
|
57 bool hasAlpha) : |
0 | 58 surface_(NULL) |
59 { | |
560
aaeec7be8fb7
add support for alpha channel in CairoSurface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
556
diff
changeset
|
60 Allocate(width, height, hasAlpha); |
0 | 61 } |
62 | |
560
aaeec7be8fb7
add support for alpha channel in CairoSurface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
556
diff
changeset
|
63 CairoSurface(Orthanc::ImageAccessor& accessor, |
aaeec7be8fb7
add support for alpha channel in CairoSurface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
556
diff
changeset
|
64 bool hasAlpha); |
0 | 65 |
66 ~CairoSurface() | |
67 { | |
68 Release(); | |
69 } | |
70 | |
71 void SetSize(unsigned int width, | |
560
aaeec7be8fb7
add support for alpha channel in CairoSurface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
556
diff
changeset
|
72 unsigned int height, |
aaeec7be8fb7
add support for alpha channel in CairoSurface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
556
diff
changeset
|
73 bool hasAlpha); |
0 | 74 |
75 void Copy(const CairoSurface& other); | |
76 | |
560
aaeec7be8fb7
add support for alpha channel in CairoSurface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
556
diff
changeset
|
77 void Copy(const Orthanc::ImageAccessor& source, |
aaeec7be8fb7
add support for alpha channel in CairoSurface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
556
diff
changeset
|
78 bool hasAlpha); |
556
b1e1eccee214
CairoSurface::Copy()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
439
diff
changeset
|
79 |
0 | 80 unsigned int GetWidth() const |
81 { | |
82 return width_; | |
83 } | |
84 | |
85 unsigned int GetHeight() const | |
86 { | |
87 return height_; | |
88 } | |
89 | |
90 unsigned int GetPitch() const | |
91 { | |
92 return pitch_; | |
93 } | |
94 | |
95 const void* GetBuffer() const | |
96 { | |
97 return buffer_; | |
98 } | |
99 | |
100 void* GetBuffer() | |
101 { | |
102 return buffer_; | |
103 } | |
104 | |
105 cairo_surface_t* GetObject() | |
106 { | |
107 return surface_; | |
108 } | |
109 | |
560
aaeec7be8fb7
add support for alpha channel in CairoSurface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
556
diff
changeset
|
110 bool HasAlpha() const |
aaeec7be8fb7
add support for alpha channel in CairoSurface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
556
diff
changeset
|
111 { |
aaeec7be8fb7
add support for alpha channel in CairoSurface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
556
diff
changeset
|
112 return hasAlpha_; |
aaeec7be8fb7
add support for alpha channel in CairoSurface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
556
diff
changeset
|
113 } |
aaeec7be8fb7
add support for alpha channel in CairoSurface
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
556
diff
changeset
|
114 |
316
ce48c3b3b0e9
fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
115 void GetReadOnlyAccessor(Orthanc::ImageAccessor& target) const; |
0 | 116 |
316
ce48c3b3b0e9
fix for new ImageAccessor API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
212
diff
changeset
|
117 void GetWriteableAccessor(Orthanc::ImageAccessor& target); |
0 | 118 }; |
119 } |