GdipVectorTransformMatrixPointsIfunction
Multiplies each vector in an array by a matrix. The translation elements of a matrix (third row) are ignored. Each vector is treated as a row matrix. The multiplication is performed with the row matrix on the left and a matrix on the right.
Syntax
FUNCTION GdipVectorTransformMatrixPointsI (BYVAL matrix AS GpMatrix PTR, BYVAL pts AS GpPoint PTR, BYVAL count AS INT_) AS GpStatus
GdipVectorTransformMatrixPoints — one description covers them all.Parameters
| Name | Description | |
|---|---|---|
matrix | [in] Pointer to the Matrix object. | |
pts | [in, out] Pointer to an array of GpPointF objects that, on input, contains the vectors to be transformed and, on output, receives the transformed vectors. Each vector in the array is transformed (multiplied by a matrix) and updated with the result of the transformation. | |
count | [in] Long integer value that specifies the number of points to be transformed. The default value is 1. |
Description
Multiplies each vector in an array by a matrix. The translation elements of a matrix (third row) are ignored. Each vector is treated as a row matrix. The multiplication is performed with the row matrix on the left and a matrix on the right.
Example
' ======================================================================================== ' The following example creates a vector and a point. The tip of the vector and the point ' are at the same location: (100, 50). The code creates a Matrix object and initializes its ' elements so that it represents a clockwise rotation followed by a translation 100 units ' to the right. The code calls the GdipTransformMatrixPoints functioon of the matrix ' to transform the point and calls the GdipVectorTransformMatrixPoints function to transform ' the vector. The entire transformation (rotation followed by translation) is performed on ' the point, but only the rotation part of the transformation is performed on the vector. ' The elements of the matrix that represent translation are ignored by the ' GdipVectorTransformMatrixPoints function ' ======================================================================================== SUB Example_VectorTransformMatrixPoints (BYVAL hdc AS HDC)
DIM hStatus AS LONG
' // Create a graphics object from the device context DIM graphics AS GpGraphics PTR hStatus = GdipCreateFromHDC(hdc, @graphics)
' // Get the DPI scaling ratios DIM dpiX AS SINGLE hStatus = GdipGetDpiX(graphics, @dpiX) DIM rxRatio AS SINGLE = dpiX / 96 DIM dpiY AS SINGLE hStatus = GdipGetDpiY(graphics, @dpiY) Dim ryRatio AS SINGLE = dpiY / 96 hStatus = GdipScaleWorldTransform(graphics, rxRatio, ryRatio, MatrixOrderPrepend)
' // Create pen DIM pen AS GpPen PTR hStatus = GdipCreatePen1(ARGB_BLUE, 2 * rxRatio, UnitPixel, @pen) hStatus = GdipSetPenEndCap(pen, LineCapArrowAnchor)
' // Create a solid brush DIM brush AS GpSolidFill PTR hStatus = GdipCreateSolidFill(ARGB_BLUE, @brush)
' // A point and a vector, same representation but different behavior DIM pt AS GpPointF = (100, 50) DIM vector AS GpPointF = (100, 50)
' // Draw the original point and vector in blue hStatus = GdipFillEllipse(graphics, brush, pt.x - 5.0, pt.y - 5.0, 10.0, 10.0) hStatus = GdipDrawLine(graphics, pen, 0, 0, vector.x, vector.y)
' // Transform DIM matrix AS GpMatrix PTR hStatus = GdipCreateMatrix2(0.8, 0.6, -0.6, 0.8, 100.0, 0.0,@matrix) hStatus = GdipTransformMatrixPoints(matrix, @pt, 1) hStatus = GdipVectorTransformMatrixPoints(matrix, @vector, 1)
' // Draw the transformed point and vector in red. hStatus = GdipSetPenColor(pen, ARGB_RED) hStatus = GdipSetSolidFillColor(brush, ARGB_RED) hStatus = GdipFillEllipse(graphics, brush, pt.X - 5.0, pt.Y - 5.0, 10.0, 10.0) hStatus = GdipDrawLine(graphics, pen, 0, 0, vector.x, vector.y)
' // Cleanup IF pen THEN GdipDeletePen(pen) IF brush THEN GdipDeleteBrush(brush) IF matrix THEN GdipDeleteMatrix(matrix) IF graphics THEN GdipDeleteGraphics(graphics)
END SUB ' ========================================================================================
Reference
- Defined in AfxNova/AfxGdiPlus.bi:2213
- Documented in Graphics/GdiPlus Flat Api/GdiPlusMatrix.md
- Topic: GdiPlusMatrix