Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

GradientFill (gdi32)
 
.
Summary
Performs GDI32 based gradient fills of rectangles and triangles
NOTE
GradientFill uses colors of 64 bits, i.e. 16 bits per component (16 bits each for the red, for the green, for the blue and for the alpha), so the type of R, G and B fields in the TRIVERTEX struct are ushort, and not byte.

For strongest red or/and green or/and blue or/and alpha, use ushort.MaxValue. For white color, set all R, G and B to ushort.MaxValue!

C# Signature:

[DllImport("gdi32.dll", EntryPoint = "GdiGradientFill", ExactSpelling = true)]
public static extern bool GradientFill(
    IntPtr hdc,           // handle to DC
    IntPtr pVertex,    // array of vertices
    uint dwNumVertex,     // number of vertices
    IntPtr pMesh,           // array of gradients
    uint dwNumMesh,       // size of gradient array
    GRADIENT_FILL dwMode);           // gradient fill mode

Overload
Performs GDI32 based gradient fills of rectangles only

C# Signature:

[DllImport("gdi32.dll", EntryPoint = "GdiGradientFill", ExactSpelling = true)]
public static extern bool GradientFill(
    IntPtr hdc,           // handle to DC
    TRIVERTEX[] pVertex,    // array of vertices
    uint dwNumVertex,     // number of vertices
    GRADIENT_RECT[] pMesh,    // array of gradient rectangles, that each one keeps two indices in pVertex array, to determine its bounds
    uint dwNumMesh,       // number of gradient rectangles to draw
    GRADIENT_FILL dwMode);           // Use either GRADIENT_FILL.RECT_H or GRADIENT_FILL.RECT_V. Using the value GRADIENT_FILL.TRIANGLE is wrong in this overload!

Overload
Performs GDI32 based gradient fills of triangles only

C# Signature:

[DllImport("gdi32.dll", EntryPoint = "GdiGradientFill", ExactSpelling = true)]
public static extern bool GradientFill(
    IntPtr hdc,           // handle to DC
    TRIVERTEX[] pVertex,    // array of vertices
    uint dwNumVertex,     // number of vertices
    GRADIENT_TRIANGLE[] pMesh, // array of gradient triangles, that each one keeps three indices in pVertex array, to determine its bounds
    uint dwNumMesh,       // number of gradient triangles to draw
    GRADIENT_FILL dwMode);           // Use only GRADIENT_FILL.TRIANGLE. Both values GRADIENT_FILL.RECT_H and GRADIENT_FILL.RECT_V are wrong in this overload!

VB Signature:

Declare Function GradientFill Lib "gdi32.dll" (TODO) As TODO

User-Defined Types:

TRIVERTEX

GRADIENT_RECT

GRADIENT_TRIANGLE

GRADIENT_FILL

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

The GDI32.dll does not contain a GradientFill() function. The actual entry point is GdiGradientFill(). That's why the 'EntryPoint' attribute is present.

This method creates one entry each for rectangles and triangles. It's just a matter of convenience and error checking by the compiler.

Tips & Tricks:

Please add some!

Sample Code:

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions