Text drawing now uses an AColor instead of a normal Color, so transparent text is possible.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@848 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2008-05-16 20:07:11 +00:00
parent d70c3d6d74
commit fdb3bda26e
7 changed files with 26 additions and 14 deletions
+8 -2
View File
@@ -165,7 +165,9 @@ void blur_image_alpha(Image& img) {
// Draw text by first drawing it using a larger font and then downsampling it
// optionally rotated by an angle
void draw_resampled_text(DC& dc, const RealPoint& pos, const RealRect& rect, double stretch, int angle, const String& text, int blur_radius, int repeat) {
void draw_resampled_text(DC& dc, const RealPoint& pos, const RealRect& rect, double stretch, int angle, AColor color, const String& text, int blur_radius, int repeat) {
// transparent text can be ignored
if (color.alpha == 0) return;
// enlarge slightly; some fonts are larger then the GetTextExtent tells us (especially italic fonts)
int w = static_cast<int>(rect.width) + 3 + 2 * blur_radius, h = static_cast<int>(rect.height) + 1 + 2 * blur_radius;
// determine sub-pixel position
@@ -188,8 +190,12 @@ void draw_resampled_text(DC& dc, const RealPoint& pos, const RealRect& rect, dou
if (!sideways(angle)) w = int(w * stretch); // GCC makes annoying conversion warnings if *= is used here.
else h = int(h * stretch);
Image img_small(w, h, false);
fill_image(img_small, dc.GetTextForeground());
fill_image(img_small, color);
downsample_to_alpha(buffer, img_small);
// multiply alpha
if (color.alpha != 255) {
set_alpha(img_small, color.alpha / 255.);
}
// blur
for (int i = 0 ; i < blur_radius ; ++i) {
blur_image_alpha(img_small);