When I use DirectWrite to draw text on a GDI hdc, how to set a transparent back ground?

  • Thread starter Thread starter Southwind2016
  • Start date Start date
S

Southwind2016

Guest
Now I am working on a legacy product which use GDI to draw text in screen. Now I try to use DirectWrite to draw text for better appearance and accurancy of font. I am very curious that has anyone done this before? I meet a problem that when I use DirectWrite to draw text on a GDI hdc, the background color is always white, I need a transparent background, is it possible? it seems that the SetBkMode is useless

The sample code is as below,

SetBkMode(hdc, TRANSPARENT); //hDC is the target GDI dc
SIZE size = {};
HDC memoryHdc = NULL;
memoryHdc = g_pBitmapRenderTarget->
GetMemoryDC();
SetBkMode(memoryHdc, TRANSPARENT);
hr = g_pBitmapRenderTarget->
GetSize(&size);
Rectangle(memoryHdc, 0, 0, size1.cx , size1.cy );

if (SUCCEEDED(hr)) {
hr = g_pTextLayout->
Draw(NULL, g_pGdiTextRenderer, 0, 0);
}
BitBlt(hdc, x, y, width + 1, height + 1, memoryHdc, 0, 0, SRCCOPY | NOMIRRORBITMAP);


Continue reading...
 
Back
Top