描述
获取此路径渐变刷的变换矩阵.
C++ Syntax
Status GetTransform( [out] Matrix *matrix ) const; |
FreeBASIC 语法
FUNCTION GetTransform ( _ BYVAL pMatrix AS CGpMatrix PTR _ ) AS GpStatus |
参数
pMatrix
[out]指向Matrix对象接收变换矩阵.
返回值
如果该方法成功,则返回Ok,这是对Status枚举元素.
如果这个方法失败,它返回一个枚举的其他元素的Status.
备注
一个PathGradientBrush对象维护一个变换矩阵,可以存储任何仿射变换.当你用路径渐变画笔填充的区域,GDI+变换画笔的边界路径根据刷的变换矩阵,然后填充的转化路径的内部.转化的路径只存在在渲染;存储在PathGradientBrush物体边界的路径不改变.
引用文件
CGpBrush.inc (include CGdiPlus.inc)
示例
' ========================================================================================
' The following example creates a PathGradientBrush object based on an array of three points.
' The PathGradientBrush.ScaleTransform and PathGradientBrush.TranslateTransform methods set
' the elements of the brush's transformation matrix so that the matrix represents a composite
' transformation (first scale, then translate). That composite transformation applies to
' the brush's boundary path, so the call to FillRectangle fills the interior of a triangle
' that is the result of scaling and translating the boundary path. The code calls the
' PathGradientBrush.GetTransform method of the PathGradientBrush object to obtain the brush's
' transformation matrix and then calls the GetElements method of the retrieved Matrix object
' to fill an array with 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)
DIM points(0 TO 2) AS GpPoint = {GDIP_POINT(0, 0), GDIP_POINT(50, 0), GDIP_POINT(50, 50)}
DIM pthGrBrush AS CGpPathGradientBrush = CGpPathGradientBrush(@points(0), 3)
pthGrBrush.ScaleTransform(3.0, 1.0)
pthGrBrush.TranslateTransform(10.0, 30.0, MatrixOrderAppend)
graphics.FillRectangle(@pthGrBrush, 0, 0, 200, 200)
' // Obtain information about the path gradient brush.
DIM matrix AS CGpMatrix
DIM elements(0 TO 5) AS SINGLE
pthGrBrush.GetTransform(@matrix)
matrix.GetElements(@elements(0))
FOR j AS LONG = 0 TO 5
' // Inspect or use the value in elements(j)
NEXT
END SUB
' ========================================================================================