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

MultiplyTransform

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

描述

 

用自身和另一个矩阵的乘积更新画笔的变换矩阵.

 

C++ Syntax

 

Status MultiplyTransform(

[in]  const Matrix *matrix,

[in]  MatrixOrder order

);

 

FreeBASIC 语法

 

FUNCTION MultiplyTransform ( _

   BYVAL pMatrix AS CGpMatrix PTR, _

   BYVAL order AS MatrixOrder = MatrixOrderPrepend _

) AS GpStatus

 

参数

 

pMatrix

 

[in]指向矩阵乘以刷的电流变换矩阵.

 

order

 

MatrixOrder指定相乘的顺序[in, optional]元.MatrixOrderPrepend指定传递矩阵是在左边,和MatrixOrderAppend指定传递矩阵是正确的.默认值是MatrixOrderPrepend.

 

返回值

 

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

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

 

备注

 

一个3?矩阵可以存储任意序列的仿射变换.如果你有几个3?矩阵,其中每一个表示仿射变换,这些矩阵的产品是一个单一的3?表示整个变换序列的矩阵.该产品表示的变换称为复合变换.例如,假设矩阵R表示一个旋转,和矩阵T代表翻译.如果矩阵M是产品RT,然后矩阵M代表复合变换:先旋转,然后翻译.

矩阵乘法的顺序是重要的.在一般情况下,矩阵的乘积RT不是矩阵的乘积TR相同.在上一段中给出的例子中,由RT复合变换(旋转,然后翻译)不为代表的TR复合变换相同(第一次翻译,然后旋转).

 

引用文件

 

CGpBrush.inc (include CGdiPlus.inc)

 

示例

 

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

' The following example creates a linear gradient brush and uses it to fill a rectangle.

' Next, the code sets the brush's transformation matrix, fills a rectangle with the

' transformed brush, modifies the brush's transformation matrix, and again fills a rectangle

' with the transformed brush.

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

SUB Example_MultiplyTransform (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 S AS CGpMatrix = CGpMatrix(2, 0, 0, 1, 0, 0)    ' // horizontal doubling

  DIM T AS CGpMatrix = CGpMatrix(1, 0, 0, 1, 50, 0)   '  // horizontal translation of 50 units

 

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

  DIM linGrBrush AS CGpLinearGradientBrush = CGpLinearGradientBrush(@rc, _

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

 

  ' // Fill a large area with the gradient brush (no transformation).

  graphics.FillRectangle(@linGrBrush, 0, 0, 800, 100)

 

  ' // Apply the scaling transformation.

  linGrBrush.SetTransform(@S)

 

  ' // Fill a large area with the scaled gradient brush.

  graphics.FillRectangle(@linGrBrush, 0, 150, 800, 100)

 

  ' // Form a composite transformation: first scale, then translate.

  linGrBrush.MultiplyTransform(@T, MatrixOrderAppend)

 

  ' // Fill a large area with the scaled and translated gradient brush.

  graphics.FillRectangle(@linGrBrush, 0, 300, 800, 100)

 

END SUB

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