Mercurial > hg > orthanc
comparison Core/Images/Font.cpp @ 1654:3727a09e7b53
fix some icc warnings
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 28 Sep 2015 15:03:35 +0200 |
parents | 644c32c07306 |
children | b1291df2f780 |
comparison
equal
deleted
inserted
replaced
1653:0c86b30bb8b2 | 1654:3727a09e7b53 |
---|---|
116 if (value < 0 || value > 255) | 116 if (value < 0 || value > 255) |
117 { | 117 { |
118 throw OrthancException(ErrorCode_BadFont); | 118 throw OrthancException(ErrorCode_BadFont); |
119 } | 119 } |
120 | 120 |
121 c->bitmap_[j] = value; | 121 c->bitmap_[j] = static_cast<uint8_t>(value); |
122 } | 122 } |
123 | 123 |
124 int index = boost::lexical_cast<int>(characters[i]); | 124 int index = boost::lexical_cast<int>(characters[i]); |
125 if (index < 0 || index > 255) | 125 if (index < 0 || index > 255) |
126 { | 126 { |
164 unsigned int left = x < 0 ? -x : 0; | 164 unsigned int left = x < 0 ? -x : 0; |
165 unsigned int top = y < 0 ? -y : 0; | 165 unsigned int top = y < 0 ? -y : 0; |
166 unsigned int width = MyMin(character.width_, target.GetWidth() - x); | 166 unsigned int width = MyMin(character.width_, target.GetWidth() - x); |
167 unsigned int height = MyMin(character.height_, target.GetHeight() - y); | 167 unsigned int height = MyMin(character.height_, target.GetHeight() - y); |
168 | 168 |
169 uint8_t bpp = target.GetBytesPerPixel(); | 169 unsigned int bpp = target.GetBytesPerPixel(); |
170 | 170 |
171 // Blit the font bitmap OVER the target image | 171 // Blit the font bitmap OVER the target image |
172 // https://en.wikipedia.org/wiki/Alpha_compositing | 172 // https://en.wikipedia.org/wiki/Alpha_compositing |
173 | 173 |
174 for (unsigned int cy = top; cy < height; cy++) | 174 for (unsigned int cy = top; cy < height; cy++) |
182 { | 182 { |
183 assert(bpp == 1); | 183 assert(bpp == 1); |
184 for (unsigned int cx = left; cx < width; cx++, pos++, p++) | 184 for (unsigned int cx = left; cx < width; cx++, pos++, p++) |
185 { | 185 { |
186 uint16_t alpha = character.bitmap_[pos]; | 186 uint16_t alpha = character.bitmap_[pos]; |
187 *p = (alpha * static_cast<uint16_t>(color[0]) + (255 - alpha) * static_cast<uint16_t>(*p)) >> 8; | 187 uint16_t value = alpha * static_cast<uint16_t>(color[0]) + (255 - alpha) * static_cast<uint16_t>(*p); |
188 *p = static_cast<uint8_t>(value >> 8); | |
188 } | 189 } |
189 | 190 |
190 break; | 191 break; |
191 } | 192 } |
192 | 193 |
194 { | 195 { |
195 assert(bpp == 3); | 196 assert(bpp == 3); |
196 for (unsigned int cx = left; cx < width; cx++, pos++, p += 3) | 197 for (unsigned int cx = left; cx < width; cx++, pos++, p += 3) |
197 { | 198 { |
198 uint16_t alpha = character.bitmap_[pos]; | 199 uint16_t alpha = character.bitmap_[pos]; |
199 p[0] = (alpha * static_cast<uint16_t>(color[0]) + (255 - alpha) * static_cast<uint16_t>(p[0])) >> 8; | 200 for (uint8_t i = 0; i < 3; i++) |
200 p[1] = (alpha * static_cast<uint16_t>(color[1]) + (255 - alpha) * static_cast<uint16_t>(p[1])) >> 8; | 201 { |
201 p[2] = (alpha * static_cast<uint16_t>(color[2]) + (255 - alpha) * static_cast<uint16_t>(p[2])) >> 8; | 202 uint16_t value = alpha * static_cast<uint16_t>(color[i]) + (255 - alpha) * static_cast<uint16_t>(p[i]); |
203 p[i] = static_cast<uint8_t>(value >> 8); | |
204 } | |
202 } | 205 } |
203 | 206 |
204 break; | 207 break; |
205 } | 208 } |
206 | 209 |