Метод PathGradientBrush::GetBlendCount (gdipluspath.h)

Метод PathGradientBrush::GetBlendCount получает количество коэффициентов смешения, заданных в настоящее время для этой кисти градиента пути.

Синтаксис

INT GetBlendCount();

Возвращаемое значение

Тип: INT

Этот метод возвращает количество коэффициентов смешения, установленных в настоящее время для этой кисти градиента пути.

Комментарии

Перед вызовом метода PathGradientBrush::GetBlend объекта PathGradientBrush необходимо выделить два буфера: один для получения массива коэффициентов смешения, а другой для получения массива позиций смешения. Чтобы определить размер необходимых буферов, вызовите метод PathGradientBrush::GetBlendCount объекта PathGradientBrush . Размер (в байтах) каждого буфера должен быть возвращаемым значением PathGradientBrush::GetBlendCount , умноженным на sizeof( REAL).

Примеры

В следующем примере демонстрируется несколько методов класса PathGradientBrush , включая PathGradientBrush::SetBlend, PathGradientBrush::GetBlendCount и PathGradientBrush::GetBlend. Код создает объект PathGradientBrush и вызывает метод PathGradientBrush::SetBlend для определения набора факторов смешения и положений смешения для кисти. Затем код вызывает метод PathGradientBrush::GetBlendCount для получения количества коэффициентов смешения. После получения количества коэффициентов смешения код выделяет два буфера: один для получения массива коэффициентов смешения, а другой для получения массива позиций смешения. Затем код вызывает метод PathGradientBrush::GetBlend для получения коэффициентов смешения и позиций смешения.

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

   // Create a path that consists of a single ellipse.
   GraphicsPath path;
   path.AddEllipse(0, 0, 200, 100);

   // Use the path to construct a brush.
   PathGradientBrush pthGrBrush(&path);

   // Set the color at the center of the path to blue.
   pthGrBrush.SetCenterColor(Color(255, 0, 0, 255));

   // Set the color along the entire boundary of the path to aqua.
   Color colors[] = {Color(255, 0, 255, 255)};
   INT count = 1;
   pthGrBrush.SetSurroundColors(colors, &count);

   // Set blend factors and positions for the path gradient brush.
   REAL fac[] = {
      0.0f, 
      0.4f,     // 40 percent of the way from aqua to blue
      0.8f,     // 80 percent of the way from aqua to blue
      1.0f};

   REAL pos[] = {
      0.0f, 
      0.3f,   // 30 percent of the way from the boundary to the center
      0.7f,   // 70 percent of the way from the boundary to the center
      1.0f};

   pthGrBrush.SetBlend(fac, pos, 4);

   // Fill the ellipse with the path gradient brush.
   graphics.FillEllipse(&pthGrBrush, 0, 0, 200, 100);

   // Obtain information about the path gradient brush.
   INT blendCount = pthGrBrush.GetBlendCount();
   REAL* factors = new REAL[blendCount];
   REAL* positions = new REAL[blendCount];

   pthGrBrush.GetBlend(factors, positions, blendCount);

   for(INT j = 0; j < blendCount; ++j)
   {
      // Inspect or use the value in factors[j].
      // Inspect or use the value in positions[j].    
   }

   delete [] factors;
   delete [] positions; 
}

Требования

   
Минимальная версия клиента Windows XP, Windows 2000 Профессиональная [только классические приложения]
Минимальная версия сервера Windows 2000 Server [только классические приложения]
Целевая платформа Windows
Header gdipluspath.h (включая Gdiplus.h)
Библиотека Gdiplus.lib
DLL Gdiplus.dll

См. также раздел

Кисти и закрашенные фигуры

Создание градиента пути

Заполнение фигуры цветным градиентом

PathGradientBrush

PathGradientBrush::GetBlend

PathGradientBrush::SetBlend