Gradient brush in natural C ++?
In C # you can use draw2d.lineargradientbrush, but in C ++ right now I 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 in msdn. Thanks to
+2
jmasterx
source
to share
3 answers
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);
}
+4
Alan
source
to share
You will need a combination of Win32 API GradientFill , CreateCompatibleBitmap and CreatePatternBrush
+2
Brian R. Bondy
source
to share
C # uses GDI + for Drawing2d. You can also use GDI + in C ++ - MSDN Create Linear Gradient
+2
Cristian adam
source
to share