Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Fonts/GlyphTextureAlphabet.cpp @ 1571:85e117739eca
cppcheck
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 21 Sep 2020 17:46:39 +0200 |
parents | 244ad1e4e76a |
children | 4fb8fdf03314 |
comparison
equal
deleted
inserted
replaced
1570:9a04f42098a3 | 1571:85e117739eca |
---|---|
54 maxHeight_(0) | 54 maxHeight_(0) |
55 { | 55 { |
56 } | 56 } |
57 | 57 |
58 virtual void Visit(uint32_t unicode, | 58 virtual void Visit(uint32_t unicode, |
59 const Glyph& glyph) | 59 const Glyph& glyph) ORTHANC_OVERRIDE |
60 { | 60 { |
61 maxWidth_ = std::max(maxWidth_, glyph.GetWidth()); | 61 maxWidth_ = std::max(maxWidth_, glyph.GetWidth()); |
62 maxHeight_ = std::max(maxHeight_, glyph.GetHeight()); | 62 maxHeight_ = std::max(maxHeight_, glyph.GetHeight()); |
63 } | 63 } |
64 | 64 |
123 Orthanc::ImageProcessing::Set(*texture_, 0, 0, 0, 0); | 123 Orthanc::ImageProcessing::Set(*texture_, 0, 0, 0, 0); |
124 } | 124 } |
125 | 125 |
126 | 126 |
127 virtual void Visit(uint32_t unicode, | 127 virtual void Visit(uint32_t unicode, |
128 const Glyph& glyph) | 128 const Glyph& glyph) ORTHANC_OVERRIDE |
129 { | 129 { |
130 if (!glyph.HasPayload()) | 130 if (!glyph.HasPayload()) |
131 { | 131 { |
132 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | 132 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
133 } | 133 } |
136 row_ >= countRows_) | 136 row_ >= countRows_) |
137 { | 137 { |
138 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | 138 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
139 } | 139 } |
140 | 140 |
141 unsigned int x = column_ * glyphMaxWidth_; | |
142 unsigned int y = row_ * glyphMaxHeight_; | |
143 | |
144 const Orthanc::ImageAccessor& source = dynamic_cast<const DynamicBitmap&>(glyph.GetPayload()).GetBitmap(); | 141 const Orthanc::ImageAccessor& source = dynamic_cast<const DynamicBitmap&>(glyph.GetPayload()).GetBitmap(); |
145 | 142 |
146 if (source.GetFormat() != Orthanc::PixelFormat_Grayscale8) | 143 if (source.GetFormat() != Orthanc::PixelFormat_Grayscale8) |
147 { | 144 { |
148 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | 145 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
149 } | 146 } |
150 | 147 |
151 targetAlphabet_.Register(unicode, glyph, new TextureLocation(x, y)); | |
152 | |
153 Orthanc::ImageAccessor target; | 148 Orthanc::ImageAccessor target; |
154 texture_->GetRegion(target, x, y, source.GetWidth(), source.GetHeight()); | 149 |
150 { | |
151 unsigned int x = column_ * glyphMaxWidth_; | |
152 unsigned int y = row_ * glyphMaxHeight_; | |
153 targetAlphabet_.Register(unicode, glyph, new TextureLocation(x, y)); | |
154 texture_->GetRegion(target, x, y, source.GetWidth(), source.GetHeight()); | |
155 } | |
155 | 156 |
156 //Orthanc::ImageProcessing::Copy(target, bitmap->GetBitmap()); | 157 //Orthanc::ImageProcessing::Copy(target, bitmap->GetBitmap()); |
157 | 158 |
158 for (unsigned int y = 0; y < source.GetHeight(); y++) | 159 for (unsigned int y = 0; y < source.GetHeight(); y++) |
159 { | 160 { |
212 virtual void Visit(uint32_t unicode, | 213 virtual void Visit(uint32_t unicode, |
213 int x, | 214 int x, |
214 int y, | 215 int y, |
215 unsigned int width, | 216 unsigned int width, |
216 unsigned int height, | 217 unsigned int height, |
217 const Orthanc::IDynamicObject* payload) | 218 const Orthanc::IDynamicObject* payload) ORTHANC_OVERRIDE |
218 { | 219 { |
219 int left = x + offsetX_; | 220 int left = x + offsetX_; |
220 int top = y + offsetY_; | 221 int top = y + offsetY_; |
221 | 222 |
222 assert(payload != NULL); | 223 assert(payload != NULL); |