annotate OrthancStone/Sources/Fonts/GlyphTextureAlphabet.cpp @ 1808:797633f48a9c

display series description if hovering pdf or video
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 20 May 2021 17:28:16 +0200
parents 9ac2a65d4172
children 3889ae96d2e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
577
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
1739
9ac2a65d4172 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1624
diff changeset
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
577
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
577
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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: 1571
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/>.
577
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #include "GlyphTextureAlphabet.h"
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include "TextBoundingBox.h"
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "../Toolbox/DynamicBitmap.h"
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
1455
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1300
diff changeset
28 #include <Images/Image.h>
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1300
diff changeset
29 #include <Images/ImageProcessing.h>
30deba7bc8e2 simplifying include_directories
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1300
diff changeset
30 #include <OrthancException.h>
577
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
1242
b9b5d4378874 working of WebAssemblyOracle
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 958
diff changeset
32 #if defined(__EMSCRIPTEN__)
958
769249e1f3b4 added guards to prevent calling methods on a dead controller (see comment in diff for expl.) + build fix
Benjamin Golinvaux <bgo@osimis.io>
parents: 693
diff changeset
33 /*
769249e1f3b4 added guards to prevent calling methods on a dead controller (see comment in diff for expl.) + build fix
Benjamin Golinvaux <bgo@osimis.io>
parents: 693
diff changeset
34 Avoid this error:
769249e1f3b4 added guards to prevent calling methods on a dead controller (see comment in diff for expl.) + build fix
Benjamin Golinvaux <bgo@osimis.io>
parents: 693
diff changeset
35 .../boost/math/special_functions/round.hpp:86:12: warning: implicit conversion from 'std::__2::numeric_limits<int>::type' (aka 'int') to 'float' changes value from 2147483647 to 2147483648 [-Wimplicit-int-float-conversion]
769249e1f3b4 added guards to prevent calling methods on a dead controller (see comment in diff for expl.) + build fix
Benjamin Golinvaux <bgo@osimis.io>
parents: 693
diff changeset
36 .../boost/math/special_functions/round.hpp:93:11: note: in instantiation of function template specialization 'boost::math::iround<float, boost::math::policies::policy<boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy> >' requested here
769249e1f3b4 added guards to prevent calling methods on a dead controller (see comment in diff for expl.) + build fix
Benjamin Golinvaux <bgo@osimis.io>
parents: 693
diff changeset
37 .../orthanc-stone/Framework/Fonts/GlyphTextureAlphabet.cpp:92:28: note: in instantiation of function template specialization 'boost::math::iround<float>' requested here
769249e1f3b4 added guards to prevent calling methods on a dead controller (see comment in diff for expl.) + build fix
Benjamin Golinvaux <bgo@osimis.io>
parents: 693
diff changeset
38 */
769249e1f3b4 added guards to prevent calling methods on a dead controller (see comment in diff for expl.) + build fix
Benjamin Golinvaux <bgo@osimis.io>
parents: 693
diff changeset
39 #pragma GCC diagnostic ignored "-Wimplicit-int-float-conversion"
769249e1f3b4 added guards to prevent calling methods on a dead controller (see comment in diff for expl.) + build fix
Benjamin Golinvaux <bgo@osimis.io>
parents: 693
diff changeset
40 #endif
769249e1f3b4 added guards to prevent calling methods on a dead controller (see comment in diff for expl.) + build fix
Benjamin Golinvaux <bgo@osimis.io>
parents: 693
diff changeset
41
577
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 #include <boost/math/special_functions/round.hpp>
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 namespace OrthancStone
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 class GlyphTextureAlphabet::GlyphSizeVisitor : public GlyphAlphabet::IGlyphVisitor
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 private:
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 unsigned int maxWidth_;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 unsigned int maxHeight_;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 public:
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 GlyphSizeVisitor() :
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 maxWidth_(0),
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 maxHeight_(0)
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 }
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 virtual void Visit(uint32_t unicode,
1571
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
60 const Glyph& glyph) ORTHANC_OVERRIDE
577
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 maxWidth_ = std::max(maxWidth_, glyph.GetWidth());
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 maxHeight_ = std::max(maxHeight_, glyph.GetHeight());
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 }
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 unsigned int GetMaxWidth() const
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 return maxWidth_;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 }
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 unsigned int GetMaxHeight() const
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 return maxHeight_;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 }
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 };
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 class GlyphTextureAlphabet::TextureGenerator : public GlyphAlphabet::IGlyphVisitor
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 private:
1298
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
81 std::unique_ptr<Orthanc::ImageAccessor> texture_;
577
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 unsigned int countColumns_;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 unsigned int countRows_;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 GlyphAlphabet& targetAlphabet_;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 unsigned int glyphMaxWidth_;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 unsigned int glyphMaxHeight_;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 unsigned int column_;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 unsigned int row_;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 public:
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 TextureGenerator(GlyphAlphabet& targetAlphabet,
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 unsigned int countGlyphs,
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 unsigned int glyphMaxWidth,
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 unsigned int glyphMaxHeight) :
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 targetAlphabet_(targetAlphabet),
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 glyphMaxWidth_(glyphMaxWidth),
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 glyphMaxHeight_(glyphMaxHeight),
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 column_(0),
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 row_(0)
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 {
693
9a474e90e832 Fixed a bunch of truncation warnings in various parts of the library
Benjamin Golinvaux <bgo@osimis.io>
parents: 577
diff changeset
102 int c = boost::math::iround<float>(sqrt(static_cast<float>(countGlyphs)));
577
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 if (c <= 0)
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 countColumns_ = 1;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 }
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 else
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 countColumns_ = static_cast<unsigned int>(c);
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 }
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 countRows_ = countGlyphs / countColumns_;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 if (countGlyphs % countColumns_ != 0)
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 countRows_++;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 }
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 texture_.reset(new Orthanc::Image(Orthanc::PixelFormat_RGBA32,
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 countColumns_ * glyphMaxWidth_,
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 countRows_ * glyphMaxHeight_,
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 true /* force minimal pitch */));
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 Orthanc::ImageProcessing::Set(*texture_, 0, 0, 0, 0);
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 }
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 virtual void Visit(uint32_t unicode,
1571
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
129 const Glyph& glyph) ORTHANC_OVERRIDE
577
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 if (!glyph.HasPayload())
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 }
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 if (column_ >= countColumns_ ||
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 row_ >= countRows_)
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140 }
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 const Orthanc::ImageAccessor& source = dynamic_cast<const DynamicBitmap&>(glyph.GetPayload()).GetBitmap();
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144 if (source.GetFormat() != Orthanc::PixelFormat_Grayscale8)
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 }
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148
1571
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
149 Orthanc::ImageAccessor target;
577
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150
1571
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
151 {
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
152 unsigned int x = column_ * glyphMaxWidth_;
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
153 unsigned int y = row_ * glyphMaxHeight_;
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
154 targetAlphabet_.Register(unicode, glyph, new TextureLocation(x, y));
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
155 texture_->GetRegion(target, x, y, source.GetWidth(), source.GetHeight());
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
156 }
577
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 //Orthanc::ImageProcessing::Copy(target, bitmap->GetBitmap());
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159
1624
59f95b9ea858 fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
160 const unsigned int width = source.GetWidth();
59f95b9ea858 fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
161 const unsigned int height = source.GetHeight();
59f95b9ea858 fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
162
59f95b9ea858 fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
163 for (unsigned int y = 0; y < height; y++)
577
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165 const uint8_t* p = reinterpret_cast<const uint8_t*>(source.GetConstRow(y));
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 uint8_t* q = reinterpret_cast<uint8_t*>(target.GetRow(y));
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167
1624
59f95b9ea858 fix build
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1598
diff changeset
168 for (unsigned int x = 0; x < width; x++)
577
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170 // Premultiplied alpha
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 q[0] = 0;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172 q[1] = 0;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 q[2] = 0;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 q[3] = *p;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 p++;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 q += 4;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178 }
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 }
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 column_++;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 if (column_ == countColumns_)
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184 column_ = 0;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185 row_++;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 }
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 }
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190 Orthanc::ImageAccessor* ReleaseTexture()
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 return texture_.release();
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 }
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 };
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 class GlyphTextureAlphabet::RenderTextVisitor : public GlyphAlphabet::ITextVisitor
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 private:
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 Orthanc::ImageAccessor& target_;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 const Orthanc::ImageAccessor& texture_;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 int offsetX_;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 int offsetY_;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 public:
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 RenderTextVisitor(Orthanc::ImageAccessor& target,
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 const GlyphTextureAlphabet& that,
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 int offsetX,
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 int offsetY) :
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 target_(target),
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 texture_(that.GetTexture()),
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212 offsetX_(offsetX),
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 offsetY_(offsetY)
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 }
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 virtual void Visit(uint32_t unicode,
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 int x,
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 int y,
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220 unsigned int width,
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 unsigned int height,
1571
85e117739eca cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
222 const Orthanc::IDynamicObject* payload) ORTHANC_OVERRIDE
577
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 int left = x + offsetX_;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 int top = y + offsetY_;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 assert(payload != NULL);
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228 const TextureLocation& location = *dynamic_cast<const TextureLocation*>(payload);
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 assert(left >= 0 &&
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231 top >= 0 &&
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 static_cast<unsigned int>(left) + width <= target_.GetWidth() &&
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 static_cast<unsigned int>(top) + height <= target_.GetHeight());
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236 Orthanc::ImageAccessor to;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237 target_.GetRegion(to, left, top, width, height);
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 Orthanc::ImageAccessor from;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240 texture_.GetRegion(from, location.GetX(), location.GetY(), width, height);
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 Orthanc::ImageProcessing::Copy(to, from);
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 }
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 }
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 };
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248 GlyphTextureAlphabet::GlyphTextureAlphabet(const GlyphBitmapAlphabet& sourceAlphabet) :
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249 textureWidth_(0),
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250 textureHeight_(0)
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 GlyphSizeVisitor size;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253 sourceAlphabet.GetAlphabet().Apply(size);
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255 TextureGenerator generator(alphabet_,
693
9a474e90e832 Fixed a bunch of truncation warnings in various parts of the library
Benjamin Golinvaux <bgo@osimis.io>
parents: 577
diff changeset
256 static_cast<unsigned int>(sourceAlphabet.GetAlphabet().GetSize()),
9a474e90e832 Fixed a bunch of truncation warnings in various parts of the library
Benjamin Golinvaux <bgo@osimis.io>
parents: 577
diff changeset
257 size.GetMaxWidth(),
9a474e90e832 Fixed a bunch of truncation warnings in various parts of the library
Benjamin Golinvaux <bgo@osimis.io>
parents: 577
diff changeset
258 size.GetMaxHeight());
577
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 sourceAlphabet.GetAlphabet().Apply(generator);
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 texture_.reset(generator.ReleaseTexture());
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 textureWidth_ = texture_->GetWidth();
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263 textureHeight_ = texture_->GetHeight();
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 }
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 const Orthanc::ImageAccessor& GlyphTextureAlphabet::GetTexture() const
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 if (texture_.get() == NULL)
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272 }
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 else
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 return *texture_;
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 }
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 }
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 Orthanc::ImageAccessor* GlyphTextureAlphabet::ReleaseTexture()
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 if (texture_.get() == NULL)
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 }
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 else
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 return texture_.release();
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 }
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 }
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 Orthanc::ImageAccessor* GlyphTextureAlphabet::RenderText(const std::string& utf8)
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294 {
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 TextBoundingBox box(alphabet_, utf8);
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296
1298
8a0a62189f46 replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1270
diff changeset
297 std::unique_ptr<Orthanc::ImageAccessor> bitmap(
577
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 new Orthanc::Image(Orthanc::PixelFormat_RGBA32,
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299 box.GetWidth(), box.GetHeight(),
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300 true /* force minimal pitch */));
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 Orthanc::ImageProcessing::Set(*bitmap, 0, 0, 0, 0);
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304 RenderTextVisitor visitor(*bitmap, *this, -box.GetLeft(), -box.GetTop());
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 alphabet_.Apply(visitor, utf8);
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307 return bitmap.release();
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308 }
b098a3aaf694 alphabet of glyphs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309 }