Skip to content

Latest commit

 

History

History
156 lines (108 loc) · 7 KB

nf-gdipluspath-pathgradientbrush-getinterpolationcolorcount.md

File metadata and controls

156 lines (108 loc) · 7 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist req.product ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:gdipluspath.PathGradientBrush.GetInterpolationColorCount
PathGradientBrush::GetInterpolationColorCount (gdipluspath.h)
The PathGradientBrush::GetInterpolationColorCount method gets the number of preset colors currently specified for this path gradient brush.
GetInterpolationColorCount
GetInterpolationColorCount method [GDI+]
GetInterpolationColorCount method [GDI+]
PathGradientBrush class
PathGradientBrush class [GDI+]
GetInterpolationColorCount method
PathGradientBrush.GetInterpolationColorCount
PathGradientBrush::GetInterpolationColorCount
_gdiplus_CLASS_PathGradientBrush_GetInterpolationColorCount_
gdiplus._gdiplus_CLASS_PathGradientBrush_GetInterpolationColorCount_
gdiplus\_gdiplus_CLASS_PathGradientBrush_GetInterpolationColorCount_.htm
gdiplus
VS|gdicpp|~\gdiplus\gdiplusreference\classes\pathgradientbrushclass\pathgradientbrushmethods\getinterpolationcolorcount_80.htm
12/05/2018
GetInterpolationColorCount, GetInterpolationColorCount method [GDI+], GetInterpolationColorCount method [GDI+],PathGradientBrush class, PathGradientBrush class [GDI+],GetInterpolationColorCount method, PathGradientBrush.GetInterpolationColorCount, PathGradientBrush::GetInterpolationColorCount, _gdiplus_CLASS_PathGradientBrush_GetInterpolationColorCount_, gdiplus._gdiplus_CLASS_PathGradientBrush_GetInterpolationColorCount_
gdipluspath.h
Gdiplus.h
Windows
Windows XP, Windows 2000 Professional [desktop apps only]
Windows 2000 Server [desktop apps only]
Gdiplus.lib
Gdiplus.dll
Windows
GDI+ 1.0
19H1
PathGradientBrush::GetInterpolationColorCount
gdipluspath/PathGradientBrush::GetInterpolationColorCount
c++
APIRef
kbSyntax
COM
Gdiplus.dll
PathGradientBrush.GetInterpolationColorCount

PathGradientBrush::GetInterpolationColorCount

-description

The PathGradientBrush::GetInterpolationColorCount method gets the number of preset colors currently specified for this path gradient brush.

-returns

Type: INT

This method returns the number of preset colors currently specified for this path gradient brush.

-remarks

A simple path gradient brush has two colors: a boundary color and a center color. When you paint with such a brush, the color changes gradually from the boundary color to the center color as you move from the boundary path to the center point. You can create a more complex gradient by specifying an array of preset colors and an array of blend positions.

You can obtain the interpolation colors and interpolation positions currently set for a PathGradientBrush object by calling the PathGradientBrush::GetInterpolationColors method of that PathGradientBrush object. Before you call the PathGradientBrush::GetInterpolationColors method, you must allocate two buffers: one to hold the array of interpolation colors and one to hold the array of interpolation positions. You can call the PathGradientBrush::GetInterpolationColorCount method of the PathGradientBrush object to determine the required size of those buffers. The size of the color buffer is the return value of GetInterpolationColorCount multiplied by sizeof(Color). The size of the position buffer is the value of PathGradientBrush::GetInterpolationColorCount multiplied by sizeof( REAL).

Examples

The following example creates a PathGradientBrush object from a triangular path. The code sets the preset colors to red, blue, and aqua and sets the blend positions to 0, 0.6, and 1. The code calls the PathGradientBrush::GetInterpolationColorCount method of the PathGradientBrush object to obtain the number of preset colors currently set for the brush. Next, the code allocates two buffers: one to hold the array of preset colors, and one to hold the array of blend positions. The call to the PathGradientBrush::GetInterpolationColors method of the PathGradientBrush object fills the buffers with the preset colors and the blend positions. Finally the code fills a small square with each of the preset colors.

VOID Example_GetInterpColors(HDC hdc)
{
   Graphics graphics(hdc);

   // Create a path gradient brush from an array of points, and
   // set the interpolation colors for that brush.

   Point points[] = {Point(100, 0), Point(200, 200), Point(0, 200)};
   PathGradientBrush pthGrBrush(points, 3);

   Color col[] = {
      Color(255, 255, 0, 0),     // red
      Color(255, 0, 0, 255),     // blue
      Color(255, 0, 255, 255)};  // aqua

   REAL pos[] = {
      0.0f,    // red at the boundary
      0.6f,    // blue 60 percent of the way from the boundary to the center
      1.0f};   // aqua at the center

   pthGrBrush.SetInterpolationColors(col, pos, 3);

   // Obtain information about the path gradient brush.
   INT colorCount = pthGrBrush.GetInterpolationColorCount();
   Color* colors = new Color[colorCount];
   REAL* positions = new REAL[colorCount];
   pthGrBrush.GetInterpolationColors(colors, positions, colorCount);

   // Fill a small square with each of the interpolation colors.
   SolidBrush solidBrush(Color(255, 255, 255, 255));

   for(INT j = 0; j < colorCount; ++j)
   {
      solidBrush.SetColor(colors[j]);
      graphics.FillRectangle(&solidBrush, 15*j, 0, 10, 10);
   }

   delete [] colors;
   delete [] positions; 
}

-see-also

Brushes and Filled Shapes

Color

Creating a Path Gradient

Filling a Shape with a Color Gradient

PathGradientBrush

PathGradientBrush::GetInterpolationColors

PathGradientBrush::SetInterpolationColors