Programming Tips - gdiplus: display opaque text

Date: 2022jun7 OS: Windows Library: GDI+ Language: C++ Q. gdiplus: display opaque text A.
void TextDemo() { // Make sure the bitmap supports alpha, eg: int width = 200; int height = 100; Bitmap bitmap(width, height, PixelFormat32bppARGB); // Make some graphics on that bitmap Gdiplus::Graphics graphics(&bitmap); // When creating the brush for the text use an alpha component: BYTE alpha = 0x10; // Less than 0xff for some transparency BYTE red = 0xff; // Example color BYTE green = 0x00; BYTE blue = 0xff; Gdiplus::SolidBrush brush(Color::MakeARGB(alpha, red, green, blue)); // Draw the text graphics.DrawString( ..., ..., ..., ..., ..., &brush); }