3

我必须首先在透明位图上绘制一个字符串,然后将 A 绘制到目标画布。但是在某些情况下,字符周围有黑色边框。

Bitmap* tempImg = new Bitmap(1000, 1000, PixelFormat32bppARGB);
Graphics tempGr(tempImg);
tempGr.Clear(Color(0, 255,255,255));
Gdiplus::SolidBrush* brush = new SolidBrush(Color(255, 255, 0, 0 ));
Gdiplus::FontFamily  fontFamily(L"Times New Roman");
Gdiplus::Font*  font = new Gdiplus::Font(&fontFamily, 19, FontStyleRegular, UnitPixel);
RectF rec(400, 400, 1000, 10000);
tempGr.DrawString(
    L"Merry Chrismas", 
    -1,
    font,
    rec,
    NULL,
    brush
    );

Graphics desGr(hdc);
desGr.Clear(Color::Gray);
desGr.DrawImage(tempImg , 0,0, 1000, 1000);

desGr 上的字符绘制有一些字体大小的黑板。

我怎样才能避免这个问题?非常感谢!

4

2 回答 2

2

我认为这里的问题是您将文本绘制到透明背景上。

您可以尝试在调用 tempGr.Clear 后添加此行...

tempGr.TextRenderingHint = TextRenderingHint.AntiAlias;

ps - 抱歉不确定 C++ 中的确切语法;)

于 2009-11-11T15:37:25.727 回答
1

我刚刚在 XNA 中解决了这个问题:

清除背景与前景色相同。唯一的区别是背景应该有 Alpha=0,而前景应该有 Alpha >> 0

The black border comes from blending of your background and foreground of different colors. Try to clear the background to some contrasting color to fully appreciate the phenomenon.

于 2013-05-10T06:58:28.757 回答