GdiGradientFill function (wingdi.h)
The GdiGradientFill function fills rectangle and triangle structures.
Syntax
BOOL GdiGradientFill(
[in] HDC hdc,
[in] PTRIVERTEX pVertex,
[in] ULONG nVertex,
[in] PVOID pMesh,
[in] ULONG nCount,
[in] ULONG ulMode
);
Parameters
[in] hdc
A handle to the destination device context.
[in] pVertex
A pointer to an array of TRIVERTEX structures that each define a triangle vertex.
[in] nVertex
The number of vertices in pVertex.
[in] pMesh
An array of GRADIENT_TRIANGLE structures in triangle mode, or an array of GRADIENT_RECT structures in rectangle mode.
[in] nCount
The number of elements (triangles or rectangles) in pMesh.
[in] ulMode
The gradient fill mode. This parameter can be one of the following values.
Value | Meaning |
---|---|
|
In this mode, two endpoints describe a rectangle. The rectangle is defined to have a constant color (specified by the TRIVERTEX structure) for the left and right edges. GDI interpolates the color from the left to right edge and fills the interior. |
|
In this mode, two endpoints describe a rectangle. The rectangle is defined to have a constant color (specified by the TRIVERTEX structure) for the top and bottom edges. GDI interpolates the color from the top to bottom edge and fills the interior. |
|
In this mode, an array of TRIVERTEX structures is passed to GDI along with a list of array indexes that describe separate triangles. GDI performs linear interpolation between triangle vertices and fills the interior. Drawing is done directly in 24- and 32-bpp modes. Dithering is performed in 16-, 8-, 4-, and 1-bpp mode. |
Return value
If the function succeeds, the return value is TRUE.
If the function fails, the return value is FALSE.
Remarks
![Illustration of a triangle that fills from orange at the top point to magenta on the bottom line](images/gradientfilltriangle.png)
![Illustration of a rectangle that shades from dark on the left side to light on the right side](images/gradientfillrectangle.png)
![Illustration of a rectangle that shades from dark on the top to light on the bottom](images/gradientfillrectangle2.png)
In the case of filling a triangle, pMesh points to an array of GRADIENT_TRIANGLE structures. Each GRADIENT_TRIANGLE structure specifies the index of three vertices in the pVertex array. These three vertices form one triangle.
To simplify hardware acceleration, this routine is not required to be pixel-perfect in the triangle interior.
Note that GdiGradientFill does not use the Alpha member of the TRIVERTEX structure. To use GdiGradientFill with transparency, call GdiGradientFill and then call GdiAlphaBlend with the desired values for the alpha channel of each vertex.
For more information, see Smooth Shading, Drawing a Shaded Triangle, and Drawing a Shaded Rectangle.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Target Platform | Windows |
Header | wingdi.h (include Windows.h) |
Library | Gdi32.lib |
DLL | Gdi32.dll |