渐变画刷在本机C + +? [英] Gradient Brush in Native C++?
本文介绍了渐变画刷在本机C + +?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
感谢
解决方案
绘制垂直渐变:
void VerticalGradient(HDC hDC,const RECT& GradientFill,
COLORREF rgbTop,COLORREF rgbBottom)
{
GRADIENT_RECT gradientRect = {0,1};
TRIVERTEX triVertext [2] = {
GradientFill.left - 1,
GradientFill.top - 1,
GetRValue(rgbTop)< 8,
GetGValue(rgbTop)<< 8,
GetBValue(rgbTop)<< 8,
0x0000,
GradientFill.right,
GradientFill.bottom,
GetRValue(rgbBottom)< 8,
GetGValue(rgbBottom)<< 8,
GetBValue(rgbBottom)<< 8,
0x0000
};
GradientFill(hDC,triVertext,2,& gradientRect,1,GRADIENT_FILL_RECT_V);
}
In c#, you can use drawing2d.lineargradientbrush, but in c++ right now I only found the CreateSolidBrush function. Is there a function in the native gdi dll to create a gradient brush? I couldn't find anything like this at msdn. Thanks
解决方案
To draw a vertical gradient:
void VerticalGradient(HDC hDC, const RECT& GradientFill,
COLORREF rgbTop, COLORREF rgbBottom)
{
GRADIENT_RECT gradientRect = { 0, 1 };
TRIVERTEX triVertext[ 2 ] = {
GradientFill.left - 1,
GradientFill.top - 1,
GetRValue(rgbTop) << 8,
GetGValue(rgbTop) << 8,
GetBValue(rgbTop) << 8,
0x0000,
GradientFill.right,
GradientFill.bottom,
GetRValue(rgbBottom) << 8,
GetGValue(rgbBottom) << 8,
GetBValue(rgbBottom) << 8,
0x0000
};
GradientFill(hDC, triVertext, 2, &gradientRect, 1, GRADIENT_FILL_RECT_V);
}
这篇关于渐变画刷在本机C + +?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文