描述
从LinearGradientBrush对象和相应的混合位置混合因子.
C++ Syntax
Status GetInterpolationColors( [out] Color *presetColors, [out] REAL *blendPositions, [in] INT count ) const; |
FreeBASIC 语法
FUNCTION GetInterpolationColors ( _ BYVAL presetColors AS ARGB PTR, _ BYVAL blendPositions AS SINGLE PTR, _ BYVAL count AS LONG _ ) AS GpStatus |
参数
presetColors
[out]指向数组的指针,得到的颜色.一种颜色的一个给定的指标在presetColors阵列对应于同一指标在blendPositions阵列混合位置.
blendPositions
[out]数组指针接收混合位置.阵列中的每个数字表示开始和结束的边界和边界之间的距离的百分比是从哪里0.0通过1.0, 0.0表明梯度和1.0起始边界表示结束的边界范围.0.0和1.0之间的混合位置指示线,平行的边界线,这是一个一定的分数,距离开始到结束边界的边界.例如,对0.7混合位置指示线,从开始到结束的边界,边界的距离百分之70.在平行于边界线的线条上,颜色是恒定的.
count
[in]整数,指定在presetColors数组元素个数.这是因为在blendPositions数组的元素个数.调用一个对象的LinearGradientBrush.GetInterpolationColors LinearGradientBrush方法之前,调用同一LinearGradientBrush对象的LinearGradientBrush.GetInterpolationColorCount方法来确定当前的颜色数.检索的混合位置的数目与检索的颜色数相同.
返回值
如果该方法成功,则返回Ok,这是对Status枚举元素.
如果这个方法失败,它返回一个枚举的其他元素的Status.
引用文件
CGpBrush.inc (include CGdiPlus.inc)
示例
' ========================================================================================
' The following example sets the colors that are interpolated for this linear gradient
' brush to red, blue, and green and sets the blend positions to 0, 0.3, and 1. The code
' calls the LinearGradientBrush::GetInterpolationColorCount method of a LinearGradientBrush
' object to obtain the number of colors currently set to be interpolated for the brush.
' Next, the code gets the colors and their positions. Then, the code fills a small
' rectangle with each color.
' ========================================================================================
SUB Example_GetInterpolationColors (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, and set the colors to be interpolated.
DIM colors(0 TO 2) AS ARGB = {GDIP_ARGB(255, 255, 0, 0), GDIP_ARGB(255, 0, 0, 255), GDIP_ARGB(255, 0, 255, 0)}
DIM positions(0 TO 2) AS SINGLE = {0.0, 0.3, 1.0}
DIM pt1 AS GpPoint = GDIP_POINT(0, 0)
DIM pt2 AS GpPoint = GDIP_POINT(100, 0)
DIM linGrBrush AS CGpLinearGradientBrush = CGpLinearGradientBrush(@pt1, @pt2, GDIP_ARGB(255, 0, 0, 0), GDIP_ARGB(255, 255, 255, 255))
linGrBrush.SetInterpolationColors(@colors(0), @positions(0), 3)
' // Obtain information about the linear gradient brush.
' // How many colors have been specified to be interpolated for this brush?
DIM colorCount AS LONG = linGrBrush.GetInterpolationColorCount
' // Allocate a buffer large enough to hold the set of colors.
DIM rgcolors(0 TO colorCount - 1) AS ARGB
' // Allocate a buffer to hold the relative positions of the colors.
DIM rgPositions(0 TO colorCount - 1) AS SINGLE
' // Get the colors and their relative positions.
linGrBrush.GetInterpolationColors(@rgcolors(0), @rgPositions(0), colorCount)
' // Fill a small rectangle with each of the colors.
DIM pSolidBrush AS CGpSolidBrush PTR
FOR j AS LONG = 0 TO colorCount - 1
pSolidBrush = NEW CGpSolidBrush(rgcolors(j))
graphics.FillRectangle(pSolidBrush, 15 * j, 0, 10, 10)
Delete pSolidBrush
NEXT
END SUB
' ========================================================================================