导航:  GdiPlus Classes > GdiPlus Classes > CGpBrush Class > CGpLinearGradientBrush Class > LinearGradientBrush Object >

GetLinearColors

上一页返回章节概述下一页

描述

 

获取此线性渐变画笔的起始颜色和结束颜色.

 

C++ Syntax

 

Status GetLinearColors(

[out]  Color* colors

) const;

 

FreeBASIC 语法

 

FUNCTION GetLinearColors ( _

   BYVAL colors AS ARGB PTR _

) AS GpStatus

 

参数

 

colors

 

[out]数组指针接收起始颜色和结束颜色.颜色数组中的第一个颜色是渐变的起始边界线的颜色,颜色数组中的第二个颜色是结束边界的颜色.

 

返回值

 

如果该方法成功,则返回Ok,这是对Status枚举元素.

如果这个方法失败,它返回一个枚举的其他元素的Status.

 

引用文件

 

CGpBrush.inc (include CGdiPlus.inc)

 

示例

 

' ========================================================================================

' The following example creates a linear gradient brush and gets the boundary colors. Next,

' the code uses each of the two colors to create a solid brush. Then, the code fills a

' rectangle with each solid brush.

' ========================================================================================

SUB Example_GetLinearColors (BYVAL hdc AS HDC)

 

  ' // Create a graphics object from the window device context

  DIM graphics AS CGpGraphics = hdc

  ' // Get the DPI scaling ratio

  DIM rxRatio AS SINGLE = graphics.GetDpiX / 96

  DIM ryRatio AS SINGLE = graphics.GetDpiY / 96

  ' // Set the scale transform

  graphics.ScaleTransform(rxRatio, ryRatio)

 

  ' // Create a linear gradient brush.

  DIM rc AS GpRect = GDIP_RECT(0, 0, 100, 50)

  DIM linGrBrush AS CGpLinearGradientBrush = CGpLinearGradientBrush(@rc, _

     GDIP_ARGB(255, 0, 0, 0), GDIP_ARGB(255, 0, 0, 255), LinearGradientModeHorizontal)

 

  ' // Obtain information about the linear gradient brush.

  DIM colors(0 TO 1) AS ARGB

  linGrBrush.GetLinearColors(@colors(0))

 

  ' // Fill a small rectangle with each of the two colors.

  DIM solidBrush0 AS CGpSolidBrush = colors(0)

  DIM solidBrush1 AS CGpSolidBrush = colors(1)

  graphics.FillRectangle(@solidBrush0, 0, 0, 20, 20)

  graphics.FillRectangle(@solidBrush1, 25, 0, 20, 20)

 

END SUB

' ========================================================================================