Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Scene2D/Internals/CairoColorTextureRenderer.cpp @ 1862:63587fdeec69
added 'SkipSeriesFromModalities' to ignore series from modality types
author | Alain Mazy <am@osimis.io> |
---|---|
date | Thu, 23 Sep 2021 14:38:42 +0200 |
parents | 9ac2a65d4172 |
children | 3889ae96d2e9 |
rev | line source |
---|---|
597 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1739
9ac2a65d4172
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
597 | 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 |
597 | 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 | |
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/>. |
597 | 20 **/ |
21 | |
22 | |
23 #include "CairoColorTextureRenderer.h" | |
24 | |
25 #include "../ColorTextureSceneLayer.h" | |
26 | |
27 namespace OrthancStone | |
28 { | |
29 namespace Internals | |
30 { | |
31 CairoColorTextureRenderer::CairoColorTextureRenderer(ICairoContextProvider& target, | |
32 const ISceneLayer& layer) : | |
33 target_(target) | |
34 { | |
35 Update(layer); | |
36 } | |
37 | |
38 | |
39 void CairoColorTextureRenderer::Update(const ISceneLayer& layer) | |
40 { | |
41 const ColorTextureSceneLayer& l = dynamic_cast<const ColorTextureSceneLayer&>(layer); | |
42 | |
43 texture_.Copy(l.GetTexture(), true); | |
44 textureTransform_ = l.GetTransform(); | |
45 isLinearInterpolation_ = l.IsLinearInterpolation(); | |
46 } | |
47 | |
768
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
597
diff
changeset
|
48 |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
597
diff
changeset
|
49 void CairoColorTextureRenderer::RenderColorTexture(ICairoContextProvider& target, |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
597
diff
changeset
|
50 const AffineTransform2D& transform, |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
597
diff
changeset
|
51 CairoSurface& texture, |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
597
diff
changeset
|
52 const AffineTransform2D& textureTransform, |
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
597
diff
changeset
|
53 bool isLinearInterpolation) |
597 | 54 { |
768
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
597
diff
changeset
|
55 cairo_t* cr = target.GetCairoContext(); |
597 | 56 |
57 AffineTransform2D t = | |
768
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
597
diff
changeset
|
58 AffineTransform2D::Combine(transform, textureTransform); |
597 | 59 Matrix h = t.GetHomogeneousMatrix(); |
60 | |
61 cairo_save(cr); | |
62 | |
63 cairo_matrix_t m; | |
64 cairo_matrix_init(&m, h(0, 0), h(1, 0), h(0, 1), h(1, 1), h(0, 2), h(1, 2)); | |
65 cairo_transform(cr, &m); | |
66 | |
67 cairo_set_operator(cr, CAIRO_OPERATOR_OVER); | |
768
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
597
diff
changeset
|
68 cairo_set_source_surface(cr, texture.GetObject(), 0, 0); |
597 | 69 |
768
55411e7da2f7
LookupTableTextureSceneLayer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
597
diff
changeset
|
70 if (isLinearInterpolation) |
597 | 71 { |
72 cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_BILINEAR); | |
73 } | |
74 else | |
75 { | |
76 cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_NEAREST); | |
77 } | |
78 | |
79 cairo_paint(cr); | |
80 | |
81 cairo_restore(cr); | |
82 } | |
83 } | |
84 } |