Black border around symbols when drawing. Image in transparent bitmap.

I need to first draw a string on a transparent bitmap and then draw A to the destination. However, in a specific case, a black frame 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);

When drawing characters on desGr, there is a blackboard for some fonts.

How can I avoid this problem? Many thanks!

+3
source share
2 answers

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

You can try adding this line after calling tempGr.Clear ...

tempGr.TextRenderingHint = TextRenderingHint.AntiAlias;

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

+2
source

I just solved this problem in XNA:

. , Alpha = 0, Alpha → 0

. - , .

+1

Source: https://habr.com/ru/post/1720655/


All Articles