views:

423

answers:

1

I have to draw a String on a transparent bitmap at first, then draw A to destination canvas. However on certain case, there is black border around the characters.

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);

The character draw on desGr have black board for some fontsize.

How can I avoid this problem? Many thanks!

A: 

Hello,

I think the problem here is that you are drawing the text onto a transparent background.

You could try adding this line after the call to tempGr.Clear...

tempGr.TextRenderingHint = TextRenderingHint.AntiAlias;

ps - sorry not sure the exact syntax in C++ ;)

fallenidol
many thanks!It works