1e41f4b71Sopenharmony_ci# drawing_matrix.h 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ci## Overview 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ciThe **drawing_matrix.h** file declares the functions related to the matrix in the drawing module. 7e41f4b71Sopenharmony_ci 8e41f4b71Sopenharmony_ci**File to include**: <native_drawing/drawing_matrix.h> 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci**Library**: libnative_drawing.so 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci**Since**: 11 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci**Related module**: [Drawing](_drawing.md) 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci## Summary 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci 20e41f4b71Sopenharmony_ci### Types 21e41f4b71Sopenharmony_ci 22e41f4b71Sopenharmony_ci| Name| Description| 23e41f4b71Sopenharmony_ci| -------- | -------- | 24e41f4b71Sopenharmony_ci| typedef enum [OH_Drawing_ScaleToFit](_drawing.md#oh_drawing_scaletofit) [OH_Drawing_ScaleToFit](_drawing.md#oh_drawing_scaletofit) | Defines an enum for the matrix scaling modes.| 25e41f4b71Sopenharmony_ci 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci### Enums 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci| Name| Description| 30e41f4b71Sopenharmony_ci| -------- | -------- | 31e41f4b71Sopenharmony_ci| [OH_Drawing_ScaleToFit](_drawing.md#oh_drawing_scaletofit) { SCALE_TO_FIT_FILL, SCALE_TO_FIT_START, SCALE_TO_FIT_CENTER, SCALE_TO_FIT_END } | Enumerates the matrix scaling modes.| 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci 34e41f4b71Sopenharmony_ci### Functions 35e41f4b71Sopenharmony_ci 36e41f4b71Sopenharmony_ci| Name| Description| 37e41f4b71Sopenharmony_ci| -------- | -------- | 38e41f4b71Sopenharmony_ci| [OH_Drawing_ErrorCode](_drawing.md#oh_drawing_errorcode) [OH_Drawing_MatrixGetAll](_drawing.md#oh_drawing_matrixgetall) ([OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \*matrix, float value[9]) | Obtains all element values of a matrix.| 39e41f4b71Sopenharmony_ci| [OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \* [OH_Drawing_MatrixCreate](_drawing.md#oh_drawing_matrixcreate) (void) | Creates an **OH_Drawing_Matrix** object.| 40e41f4b71Sopenharmony_ci| [OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \* [OH_Drawing_MatrixCreateRotation](_drawing.md#oh_drawing_matrixcreaterotation) (float deg, float x, float y) | Creates an **OH_Drawing_Matrix** with the rotation attribute. The matrix is obtained by rotating an identity matrix by a given degree around the rotation point (x, y).| 41e41f4b71Sopenharmony_ci| [OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \* [OH_Drawing_MatrixCreateScale](_drawing.md#oh_drawing_matrixcreatescale) (float sx, float sy, float px, float py) | Creates an **OH_Drawing_Matrix** with the scale attribute. The matrix is obtained by scaling an identity matrix with the factor (sx, sy) at the rotation point (px, py).| 42e41f4b71Sopenharmony_ci| [OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \* [OH_Drawing_MatrixCreateTranslation](_drawing.md#oh_drawing_matrixcreatetranslation) (float dx, float dy) | Creates an **OH_Drawing_Matrix** with the translation attribute. The matrix is obtained by translating the identity matrix by the distance (dx, dy).| 43e41f4b71Sopenharmony_ci| void [OH_Drawing_MatrixSetMatrix](_drawing.md#oh_drawing_matrixsetmatrix) ([OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \*, float scaleX, float skewX, float transX, float skewY, float scaleY, float transY, float persp0, float persp1, float persp2) | Sets matrix parameters for an **OH_Drawing_Matrix** object.| 44e41f4b71Sopenharmony_ci| bool [OH_Drawing_MatrixSetRectToRect](_drawing.md#oh_drawing_matrixsetrecttorect) ([OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \*, const [OH_Drawing_Rect](_drawing.md#oh_drawing_rect) \*src, const [OH_Drawing_Rect](_drawing.md#oh_drawing_rect) \*dst, [OH_Drawing_ScaleToFit](_drawing.md#oh_drawing_scaletofit) stf) | Scales a matrix to map a source rectangle to a destination rectangle.| 45e41f4b71Sopenharmony_ci| void [OH_Drawing_MatrixPreRotate](_drawing.md#oh_drawing_matrixprerotate) ([OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \*, float degree, float px, float py) | Premultiplies a matrix by an identity matrix that rotates by a given degree around the rotation point (px, py).| 46e41f4b71Sopenharmony_ci| void [OH_Drawing_MatrixPreScale](_drawing.md#oh_drawing_matrixprescale) ([OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \*, float sx, float sy, float px, float py) | Premultiplies a matrix by an identity matrix that scales with the factor (sx, sy) at the scale point (px, py).| 47e41f4b71Sopenharmony_ci| void [OH_Drawing_MatrixPreTranslate](_drawing.md#oh_drawing_matrixpretranslate) ([OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \*, float dx, float dy) | Premultiplies a matrix by an identity matrix that translates by a given distance (dx, dy).| 48e41f4b71Sopenharmony_ci| void [OH_Drawing_MatrixPostRotate](_drawing.md#oh_drawing_matrixpostrotate) ([OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \*, float degree, float px, float py) | Post multiplies a matrix by an identity matrix that rotates a given degree around the rotation point (px, py). | 49e41f4b71Sopenharmony_ci| void [OH_Drawing_MatrixPostScale](_drawing.md#oh_drawing_matrixpostscale) ([OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \*, float sx, float sy, float px, float py) | Post multiplies a matrix by an identity matrix that scales with the factor (sx, sy) at the scale point (px, py).| 50e41f4b71Sopenharmony_ci| void [OH_Drawing_MatrixPostTranslate](_drawing.md#oh_drawing_matrixposttranslate) ([OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \*, float dx, float dy) | Post multiplies a matrix by an identity matrix that translates by a given distance (dx, dy).| 51e41f4b71Sopenharmony_ci| void [OH_Drawing_MatrixReset](_drawing.md#oh_drawing_matrixreset) ([OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \*) | Resets a matrix to an identity matrix.| 52e41f4b71Sopenharmony_ci| void [OH_Drawing_MatrixConcat](_drawing.md#oh_drawing_matrixconcat) ([OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \*total, const [OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \*a, const [OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \*b) | Multiplies two matrices to produce a new matrix.| 53e41f4b71Sopenharmony_ci| float [OH_Drawing_MatrixGetValue](_drawing.md#oh_drawing_matrixgetvalue) ([OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \*, int index) | Obtains a matrix value of a given index. The index ranges from 0 to 8.| 54e41f4b71Sopenharmony_ci| void [OH_Drawing_MatrixRotate](_drawing.md#oh_drawing_matrixrotate) ([OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \*, float degree, float px, float py) | Sets a matrix as an identity matrix and rotates it by a given degree around the rotation point (px, py).| 55e41f4b71Sopenharmony_ci| void [OH_Drawing_MatrixTranslate](_drawing.md#oh_drawing_matrixtranslate) ([OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \*, float dx, float dy) | Sets a matrix as an identity matrix and translates it by a given distance (dx, dy).| 56e41f4b71Sopenharmony_ci| void [OH_Drawing_MatrixScale](_drawing.md#oh_drawing_matrixscale) ([OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \*, float sx, float sy, float px, float py) | Sets a matrix as an identity matrix and scales it with the factor (sx, sy) at the rotation point (px, py).| 57e41f4b71Sopenharmony_ci| bool [OH_Drawing_MatrixInvert](_drawing.md#oh_drawing_matrixinvert) ([OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \*, [OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \*inverse) | Inverts a matrix and returns the result.| 58e41f4b71Sopenharmony_ci| bool [OH_Drawing_MatrixSetPolyToPoly](_drawing.md#oh_drawing_matrixsetpolytopoly) ([OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \*, const [OH_Drawing_Point2D](_o_h___drawing___point2_d.md) \*src, const [OH_Drawing_Point2D](_o_h___drawing___point2_d.md) \*dst, uint32_t count) | Generates a transform matrix by setting source points and destination points. Both the number of source points and that of destination points must be in the range [0, 4].| 59e41f4b71Sopenharmony_ci| void [OH_Drawing_MatrixMapPoints](_drawing.md#oh_drawing_matrixmappoints) (const [OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \*, const [OH_Drawing_Point2D](_o_h___drawing___point2_d.md) \*src, [OH_Drawing_Point2D](_o_h___drawing___point2_d.md) \*dst, int count) | Maps a source point array to a destination point array by means of matrix transformation.| 60e41f4b71Sopenharmony_ci| bool [OH_Drawing_MatrixMapRect](_drawing.md#oh_drawing_matrixmaprect) (const [OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \*, const [OH_Drawing_Rect](_drawing.md#oh_drawing_rect) \*src, [OH_Drawing_Rect](_drawing.md#oh_drawing_rect) \*dst) | Maps a rectangle to the smallest rectangle that can enclose the vertices to which the four source vertices are mapped by means of matrix transformation.| 61e41f4b71Sopenharmony_ci| bool [OH_Drawing_MatrixIsEqual](_drawing.md#oh_drawing_matrixisequal) ([OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \*, [OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \*other) | Checks whether two **OH_Drawing_Matrix** objects are equal.| 62e41f4b71Sopenharmony_ci| bool [OH_Drawing_MatrixIsIdentity](_drawing.md#oh_drawing_matrixisidentity) ([OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \*) | Checks whether an **OH_Drawing_Matrix** object is an identity matrix.| 63e41f4b71Sopenharmony_ci| void [OH_Drawing_MatrixDestroy](_drawing.md#oh_drawing_matrixdestroy) ([OH_Drawing_Matrix](_drawing.md#oh_drawing_matrix) \*) | Destroys an **OH_Drawing_Matrix** object and reclaims the memory occupied by the object.| 64