如何在Native Win32 C++中绘制一个蓝色矩形,并设置透明度为0.5(即50%透明度)?
使用RGBA()等宏失败,我不确定如何指定画刷的 alpha 值。
SetDCPenColor(hdc, RGBA(255,255,0,127));
SetDCBrushColor(hdc, RGBA(255,255,0,127));
Rectangle(hdc, 0, 0, width, height);
我非常确定你需要使用GDI+来完成这个操作,但是在GDI中应该有它:
//in rendering function
using namespace Gdiplus;
Graphics g (hdc);
SolidBrush brush (Color (127 /*A*/, 0 /*R*/, 0 /*G*/, 255 /*B*/));
g.FillRectangle (&brush, 0, 0, width, height);