void CTestGdiplusDlg::OnBnClickedButton1()
{
//
CPaintDC* pDC = new CPaintDC(this);
Graphics graphics( pDC->m_hDC );
GraphicsPath path; // 构造一个路径
path.AddEllipse(50, 50, 200, 100);
// 使用路径构造一个画刷
PathGradientBrush pthGrBrush(&path);
// 将路径中心颜色设为蓝色
pthGrBrush.SetCenterColor(Color(255, 0, 0, 255));
// 设置路径周围的颜色为蓝芭,但alpha值为0
Color colors[] = {Color(0, 0, 0, 255)};
INT count = 1;
pthGrBrush.SetSurroundColors(colors, &count);
graphics.FillRectangle(&pthGrBrush, 50, 50, 200, 100);
LinearGradientBrush linGrBrush(
Point(300, 50),
Point(500, 150),
Color(255, 255, 0, 0), // 红色
Color(255, 0, 0, 255)); // 蓝色
graphics.FillRectangle(&linGrBrush, 300, 50, 200, 100);
}
运行结果如下: