描述
得到该线性梯度刷的变换矩阵.
C++ Syntax
Status GetTransform( [out] Matrix *matrix ) const; |
FreeBASIC 语法
FUNCTION GetTransform ( _ BYVAL pMatrix AS CGpMatrix PTR _ ) AS GpStatus |
参数
pMatrix
[out]指向Matrix对象接收变换矩阵.
返回值
如果该方法成功,则返回Ok,这是对Status枚举元素.
如果这个方法失败,它返回一个枚举的其他元素的Status.
备注
一个LinearGradientBrush对象维护一个变换矩阵,可以存储任何仿射变换.当你使用一个线性渐变画笔填充的区域,GDI+变换画笔的边界线根据刷的变换矩阵,然后填充的区域.转化的边界只存在在渲染;没有转化的LinearGradientBrush对象存储的界限.
引用文件
CGpBrush.inc (include CGdiPlus.inc)
示例
' ========================================================================================
' The following example creates a linear gradient brush and sets its transformation matrix.
' Next, the code gets the brush's transformation matrix and proceeds to inspect or use the
' matrix elements.
' ========================================================================================
SUB Example_GetTransform (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 pt1 AS GpPoint = GDIP_POINT(0, 0)
DIM pt2 AS GpPoint = GDIP_POINT(200, 0)
DIM linGrBrush AS CGpLinearGradientBrush = CGpLinearGradientBrush(@pt1, @pt2, _
GDIP_ARGB(255, 0, 0, 0), GDIP_ARGB(255, 0, 0, 255))
DIM matrixSet AS CGpMatrix = CGpMatrix(0, 1, -1, 0, 0, 0)
linGrBrush.SetTransform(@matrixSet)
' // Obtain information about the linear gradient brush.
DIM matrixGet AS CGpMatrix
DIM elements(0 TO 5) AS SINGLE
linGrBrush.GetTransform(@matrixGet)
matrixGet.GetElements(@elements(0))
graphics.FillRectangle(@CGpSolidBrush(GDIP_ARGB(255, 0, 0, 0)), 0, 0, 20, 20)
FOR j AS LONG = 0 TO 5
' // Inspect or use the value in elements[j].
PRINT STR(elements(j))
NEXT
END SUB
' ========================================================================================