1# drawing_rect.h 2 3## 概述 4 5文件中定义了与矩形相关的功能函数。 6 7<!--RP1--> 8**相关示例:** [NDKAPIDrawing (API14)](https://gitcode.com/openharmony/applications_app_samples/tree/master/code/DocsSample/Drawing/NDKAPIDrawing)<!--RP1End--> 9 10**引用文件:** <native_drawing/drawing_rect.h> 11 12**库:** libnative_drawing.so 13 14**起始版本:** 11 15 16**相关模块:** [Drawing](capi-drawing.md) 17 18## 汇总 19 20### 函数 21 22| 名称 | 描述 | 23| -- | -- | 24| [OH_Drawing_Rect* OH_Drawing_RectCreate(float left, float top, float right, float bottom)](#oh_drawing_rectcreate) | 用于创建一个矩形对象,不会对设置的坐标排序,即允许矩形设置的左上角坐标大于对应的矩形右下角坐标。 | 25| [bool OH_Drawing_RectIntersect(OH_Drawing_Rect* rect, const OH_Drawing_Rect* other)](#oh_drawing_rectintersect) | 用于判断两个矩形是否相交,若相交,将rect设置为两个矩形的交集。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>rect、other任意一个为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 | 26| [bool OH_Drawing_RectJoin(OH_Drawing_Rect* rect, const OH_Drawing_Rect* other)](#oh_drawing_rectjoin) | 将两个矩形取并集。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>rect、other任意一个为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。<br> | 27| [void OH_Drawing_RectSetLeft(OH_Drawing_Rect* rect, float left)](#oh_drawing_rectsetleft) | 用于设置矩形左上角的横坐标。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>rect为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 | 28| [void OH_Drawing_RectSetTop(OH_Drawing_Rect* rect, float top)](#oh_drawing_rectsettop) | 用于设置矩形左上角的纵坐标。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>rect为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 | 29| [void OH_Drawing_RectSetRight(OH_Drawing_Rect* rect, float right)](#oh_drawing_rectsetright) | 用于设置矩形右下角的横坐标。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>rect为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 | 30| [void OH_Drawing_RectSetBottom(OH_Drawing_Rect* rect, float bottom)](#oh_drawing_rectsetbottom) | 用于设置矩形右下角的纵坐标。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>rect为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 | 31| [float OH_Drawing_RectGetLeft(OH_Drawing_Rect* rect)](#oh_drawing_rectgetleft) | 用于获取给矩形设置的左上角的横坐标。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>rect为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 | 32| [float OH_Drawing_RectGetTop(OH_Drawing_Rect* rect)](#oh_drawing_rectgettop) | 用于获取给矩形设置的左上角的纵坐标。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>rect为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 | 33| [float OH_Drawing_RectGetRight(OH_Drawing_Rect* rect)](#oh_drawing_rectgetright) | 用于获取给矩形设置的右下角的横坐标。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>rect为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 | 34| [float OH_Drawing_RectGetBottom(OH_Drawing_Rect* rect)](#oh_drawing_rectgetbottom) | 用于获取给矩形设置的右下角的纵坐标。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>rect为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 | 35| [float OH_Drawing_RectGetHeight(OH_Drawing_Rect* rect)](#oh_drawing_rectgetheight) | 用于获取矩形对象高度,计算方式为设置的矩形的右下角纵坐标减去左上角纵坐标。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>rect为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 | 36| [float OH_Drawing_RectGetWidth(OH_Drawing_Rect* rect)](#oh_drawing_rectgetwidth) | 用于获取矩形对象的宽度,计算方式为设置的矩形的右下角横坐标减去左上角横坐标。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>rect为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 | 37| [void OH_Drawing_RectCopy(OH_Drawing_Rect* sRect, OH_Drawing_Rect* dRect)](#oh_drawing_rectcopy) | 用于将源矩形对象复制到目标矩形对象。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>sRect、dRect任意一个为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 | 38| [void OH_Drawing_RectDestroy(OH_Drawing_Rect* rect)](#oh_drawing_rectdestroy) | 用于销毁矩形对象并回收该对象占有的内存。 | 39| [OH_Drawing_Array* OH_Drawing_RectCreateArray(size_t size)](#oh_drawing_rectcreatearray) | 用于创建一个矩形数组对象,用来存储多个矩形对象。不再需要[OH_Drawing_Array](capi-drawing-oh-drawing-array.md)时,请使用[OH_Drawing_RectDestroyArray](capi-drawing-rect-h.md#oh_drawing_rectdestroyarray)接口释放该对象的指针。 | 40| [OH_Drawing_ErrorCode OH_Drawing_RectGetArraySize(OH_Drawing_Array* rectArray, size_t* pSize)](#oh_drawing_rectgetarraysize) | 用于获取矩形数组对象[OH_Drawing_Array](capi-drawing-oh-drawing-array.md)的大小。 | 41| [OH_Drawing_ErrorCode OH_Drawing_RectGetArrayElement(OH_Drawing_Array* rectArray, size_t index,OH_Drawing_Rect** rect)](#oh_drawing_rectgetarrayelement) | 用于获取矩形数组对象中指定索引的矩形对象。 | 42| [OH_Drawing_ErrorCode OH_Drawing_RectDestroyArray(OH_Drawing_Array* rectArray)](#oh_drawing_rectdestroyarray) | 用于销毁矩形数组对象并回收该对象占有的内存。 | 43 44## 函数说明 45 46### OH_Drawing_RectCreate() 47 48``` 49OH_Drawing_Rect* OH_Drawing_RectCreate(float left, float top, float right, float bottom) 50``` 51 52**描述** 53 54用于创建一个矩形对象,不会对设置的坐标排序,即允许矩形设置的左上角坐标大于对应的矩形右下角坐标。 55 56**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing 57 58**起始版本:** 11 59 60 61**参数:** 62 63| 参数项 | 描述 | 64| -- | -- | 65| float left | 矩形左上角的横坐标。 | 66| float top | 矩形左上角的纵坐标。 | 67| float right | 矩形右下角的横坐标。 | 68| float bottom | 矩形右下角的纵坐标。 | 69 70**返回:** 71 72| 类型 | 说明 | 73| -- | -- | 74| [OH_Drawing_Rect](capi-drawing-oh-drawing-rect.md)* | 函数会返回一个指针,指针指向创建的矩形对象。 | 75 76### OH_Drawing_RectIntersect() 77 78``` 79bool OH_Drawing_RectIntersect(OH_Drawing_Rect* rect, const OH_Drawing_Rect* other) 80``` 81 82**描述** 83 84用于判断两个矩形是否相交,若相交,将rect设置为两个矩形的交集。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>rect、other任意一个为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 85 86**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing 87 88**起始版本:** 12 89 90 91**参数:** 92 93| 参数项 | 描述 | 94| -- | -- | 95| [OH_Drawing_Rect](capi-drawing-oh-drawing-rect.md)* rect | 指向矩形对象的指针。 | 96| const [OH_Drawing_Rect](capi-drawing-oh-drawing-rect.md)* other | 指向矩形对象的指针。 | 97 98**返回:** 99 100| 类型 | 说明 | 101| -- | -- | 102| bool | 返回两个矩形是否相交的结果。true表示这两个矩形相交,rect被设置为两个矩形的交集;false表示不相交,rect保持不变。 | 103 104### OH_Drawing_RectJoin() 105 106``` 107bool OH_Drawing_RectJoin(OH_Drawing_Rect* rect, const OH_Drawing_Rect* other) 108``` 109 110**描述** 111 112将两个矩形取并集。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>rect、other任意一个为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。<br> 113 114**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing 115 116**起始版本:** 12 117 118 119**参数:** 120 121| 参数项 | 描述 | 122| -- | -- | 123| [OH_Drawing_Rect](capi-drawing-oh-drawing-rect.md)* rect | 指向矩形对象的指针。 | 124| const [OH_Drawing_Rect](capi-drawing-oh-drawing-rect.md)* other | 指向矩形对象的指针。 | 125 126**返回:** 127 128| 类型 | 说明 | 129| -- | -- | 130| bool | 返回两个矩形取并集的结果。true表示成功,false表示失败,失败的原因可能是两个矩形至少有一个为NULL或者other矩形大小为空。 | 131 132### OH_Drawing_RectSetLeft() 133 134``` 135void OH_Drawing_RectSetLeft(OH_Drawing_Rect* rect, float left) 136``` 137 138**描述** 139 140用于设置矩形左上角的横坐标。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>rect为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 141 142**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing 143 144**起始版本:** 12 145 146 147**参数:** 148 149| 参数项 | 描述 | 150| -- | -- | 151| [OH_Drawing_Rect](capi-drawing-oh-drawing-rect.md)* rect | 指向矩形对象的指针。 | 152| float left | 矩形左上角的横坐标。 | 153 154### OH_Drawing_RectSetTop() 155 156``` 157void OH_Drawing_RectSetTop(OH_Drawing_Rect* rect, float top) 158``` 159 160**描述** 161 162用于设置矩形左上角的纵坐标。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>rect为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 163 164**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing 165 166**起始版本:** 12 167 168 169**参数:** 170 171| 参数项 | 描述 | 172| -- | -- | 173| [OH_Drawing_Rect](capi-drawing-oh-drawing-rect.md)* rect | 指向矩形对象的指针。 | 174| float top | 矩形左上角的纵坐标。 | 175 176### OH_Drawing_RectSetRight() 177 178``` 179void OH_Drawing_RectSetRight(OH_Drawing_Rect* rect, float right) 180``` 181 182**描述** 183 184用于设置矩形右下角的横坐标。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>rect为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 185 186**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing 187 188**起始版本:** 12 189 190 191**参数:** 192 193| 参数项 | 描述 | 194| -- | -- | 195| [OH_Drawing_Rect](capi-drawing-oh-drawing-rect.md)* rect | 指向矩形对象的指针。 | 196| float right | 矩形右下角的横坐标。 | 197 198### OH_Drawing_RectSetBottom() 199 200``` 201void OH_Drawing_RectSetBottom(OH_Drawing_Rect* rect, float bottom) 202``` 203 204**描述** 205 206用于设置矩形右下角的纵坐标。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>rect为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 207 208**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing 209 210**起始版本:** 12 211 212 213**参数:** 214 215| 参数项 | 描述 | 216| -- | -- | 217| [OH_Drawing_Rect](capi-drawing-oh-drawing-rect.md)* rect | 指向矩形对象的指针。 | 218| float bottom | 矩形右下角的纵坐标。 | 219 220### OH_Drawing_RectGetLeft() 221 222``` 223float OH_Drawing_RectGetLeft(OH_Drawing_Rect* rect) 224``` 225 226**描述** 227 228用于获取给矩形设置的左上角的横坐标。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>rect为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 229 230**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing 231 232**起始版本:** 12 233 234 235**参数:** 236 237| 参数项 | 描述 | 238| -- | -- | 239| [OH_Drawing_Rect](capi-drawing-oh-drawing-rect.md)* rect | 指向矩形对象的指针。 | 240 241**返回:** 242 243| 类型 | 说明 | 244| -- | -- | 245| float | 矩形左上角的横坐标。 | 246 247### OH_Drawing_RectGetTop() 248 249``` 250float OH_Drawing_RectGetTop(OH_Drawing_Rect* rect) 251``` 252 253**描述** 254 255用于获取给矩形设置的左上角的纵坐标。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>rect为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 256 257**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing 258 259**起始版本:** 12 260 261 262**参数:** 263 264| 参数项 | 描述 | 265| -- | -- | 266| [OH_Drawing_Rect](capi-drawing-oh-drawing-rect.md)* rect | 指向矩形对象的指针。 | 267 268**返回:** 269 270| 类型 | 说明 | 271| -- | -- | 272| float | 矩形左上角的纵坐标。 | 273 274### OH_Drawing_RectGetRight() 275 276``` 277float OH_Drawing_RectGetRight(OH_Drawing_Rect* rect) 278``` 279 280**描述** 281 282用于获取给矩形设置的右下角的横坐标。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>rect为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 283 284**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing 285 286**起始版本:** 12 287 288 289**参数:** 290 291| 参数项 | 描述 | 292| -- | -- | 293| [OH_Drawing_Rect](capi-drawing-oh-drawing-rect.md)* rect | 指向矩形对象的指针。 | 294 295**返回:** 296 297| 类型 | 说明 | 298| -- | -- | 299| float | 矩形右下角的横坐标。 | 300 301### OH_Drawing_RectGetBottom() 302 303``` 304float OH_Drawing_RectGetBottom(OH_Drawing_Rect* rect) 305``` 306 307**描述** 308 309用于获取给矩形设置的右下角的纵坐标。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>rect为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 310 311**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing 312 313**起始版本:** 12 314 315 316**参数:** 317 318| 参数项 | 描述 | 319| -- | -- | 320| [OH_Drawing_Rect](capi-drawing-oh-drawing-rect.md)* rect | 指向矩形对象的指针。 | 321 322**返回:** 323 324| 类型 | 说明 | 325| -- | -- | 326| float | 矩形右下角的纵坐标。 | 327 328### OH_Drawing_RectGetHeight() 329 330``` 331float OH_Drawing_RectGetHeight(OH_Drawing_Rect* rect) 332``` 333 334**描述** 335 336用于获取矩形对象高度,计算方式为设置的矩形的右下角纵坐标减去左上角纵坐标。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>rect为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 337 338**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing 339 340**起始版本:** 12 341 342 343**参数:** 344 345| 参数项 | 描述 | 346| -- | -- | 347| [OH_Drawing_Rect](capi-drawing-oh-drawing-rect.md)* rect | 指向矩形对象的指针。 | 348 349**返回:** 350 351| 类型 | 说明 | 352| -- | -- | 353| float | 返回矩形对象的高度,单位为像素。 | 354 355### OH_Drawing_RectGetWidth() 356 357``` 358float OH_Drawing_RectGetWidth(OH_Drawing_Rect* rect) 359``` 360 361**描述** 362 363用于获取矩形对象的宽度,计算方式为设置的矩形的右下角横坐标减去左上角横坐标。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>rect为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 364 365**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing 366 367**起始版本:** 12 368 369 370**参数:** 371 372| 参数项 | 描述 | 373| -- | -- | 374| [OH_Drawing_Rect](capi-drawing-oh-drawing-rect.md)* rect | 指向矩形对象的指针。 | 375 376**返回:** 377 378| 类型 | 说明 | 379| -- | -- | 380| float | 返回矩形对象的宽度,单位为像素。 | 381 382### OH_Drawing_RectCopy() 383 384``` 385void OH_Drawing_RectCopy(OH_Drawing_Rect* sRect, OH_Drawing_Rect* dRect) 386``` 387 388**描述** 389 390用于将源矩形对象复制到目标矩形对象。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>sRect、dRect任意一个为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 391 392**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing 393 394**起始版本:** 12 395 396 397**参数:** 398 399| 参数项 | 描述 | 400| -- | -- | 401| [OH_Drawing_Rect](capi-drawing-oh-drawing-rect.md)* sRect | 指向源矩形对象的指针。 | 402| [OH_Drawing_Rect](capi-drawing-oh-drawing-rect.md)* dRect | 指向目标矩形对象的指针。 | 403 404### OH_Drawing_RectDestroy() 405 406``` 407void OH_Drawing_RectDestroy(OH_Drawing_Rect* rect) 408``` 409 410**描述** 411 412用于销毁矩形对象并回收该对象占有的内存。 413 414**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing 415 416**起始版本:** 11 417 418 419**参数:** 420 421| 参数项 | 描述 | 422| -- | -- | 423| [OH_Drawing_Rect](capi-drawing-oh-drawing-rect.md)* rect | 指向矩形对象的指针。 | 424 425### OH_Drawing_RectCreateArray() 426 427``` 428OH_Drawing_Array* OH_Drawing_RectCreateArray(size_t size) 429``` 430 431**描述** 432 433用于创建一个矩形数组对象,用来存储多个矩形对象。不再需要[OH_Drawing_Array](capi-drawing-oh-drawing-array.md)时,请使用[OH_Drawing_RectDestroyArray](capi-drawing-rect-h.md#oh_drawing_rectdestroyarray)接口释放该对象的指针。 434 435**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing 436 437**起始版本:** 18 438 439 440**参数:** 441 442| 参数项 | 描述 | 443| -- | -- | 444| size_t size | 指定矩形数组的大小,不超过字形索引数量最大值65536。 | 445 446**返回:** 447 448| 类型 | 说明 | 449| -- | -- | 450| [OH_Drawing_Array](capi-drawing-oh-drawing-array.md)* | 返回创建的数组对象[OH_Drawing_Array](capi-drawing-oh-drawing-array.md)指针,如果返回的对象指针为空,表示创建失败。<br> 失败的原因可能为:没有可用的内存或参数错误。 | 451 452### OH_Drawing_RectGetArraySize() 453 454``` 455OH_Drawing_ErrorCode OH_Drawing_RectGetArraySize(OH_Drawing_Array* rectArray, size_t* pSize) 456``` 457 458**描述** 459 460用于获取矩形数组对象[OH_Drawing_Array](capi-drawing-oh-drawing-array.md)的大小。 461 462**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing 463 464**起始版本:** 18 465 466 467**参数:** 468 469| 参数项 | 描述 | 470| -- | -- | 471| [OH_Drawing_Array](capi-drawing-oh-drawing-array.md)* rectArray | 指向矩形数组对象[OH_Drawing_Array](capi-drawing-oh-drawing-array.md)的指针。 | 472| size_t* pSize | 指向size_t类型的指针,用于存储矩形数组大小,作为出参使用。 | 473 474**返回:** 475 476| 类型 | 说明 | 477| -- | -- | 478| [OH_Drawing_ErrorCode](capi-drawing-error-code-h.md#oh_drawing_errorcode) | 函数返回执行错误码。<br> 返回OH_DRAWING_SUCCESS,表示执行成功。<br> 返回OH_DRAWING_ERROR_INVALID_PARAMETER,表示参数rectArray或者pSize为空。 | 479 480### OH_Drawing_RectGetArrayElement() 481 482``` 483OH_Drawing_ErrorCode OH_Drawing_RectGetArrayElement(OH_Drawing_Array* rectArray, size_t index,OH_Drawing_Rect** rect) 484``` 485 486**描述** 487 488用于获取矩形数组对象中指定索引的矩形对象。 489 490**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing 491 492**起始版本:** 18 493 494 495**参数:** 496 497| 参数项 | 描述 | 498| -- | -- | 499| [OH_Drawing_Array](capi-drawing-oh-drawing-array.md)* rectArray | 指向矩形数组对象[OH_Drawing_Array](capi-drawing-oh-drawing-array.md)的指针。 | 500| size_t index | 矩形数组的索引。 | 501| [OH_Drawing_Rect](capi-drawing-oh-drawing-rect.md)** rect | 指向[OH_Drawing_Rect](capi-drawing-oh-drawing-rect.md)的二级指针,作为出参,返回给调用者。 | 502 503**返回:** 504 505| 类型 | 说明 | 506| -- | -- | 507| [OH_Drawing_ErrorCode](capi-drawing-error-code-h.md#oh_drawing_errorcode) | 函数返回执行错误码。<br> 返回OH_DRAWING_SUCCESS,表示执行成功。<br> 返回OH_DRAWING_ERROR_INVALID_PARAMETER,表示参数rectArray或者rect为空,或者index越界。 | 508 509### OH_Drawing_RectDestroyArray() 510 511``` 512OH_Drawing_ErrorCode OH_Drawing_RectDestroyArray(OH_Drawing_Array* rectArray) 513``` 514 515**描述** 516 517用于销毁矩形数组对象并回收该对象占有的内存。 518 519**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing 520 521**起始版本:** 18 522 523 524**参数:** 525 526| 参数项 | 描述 | 527| -- | -- | 528| [OH_Drawing_Array](capi-drawing-oh-drawing-array.md)* rectArray | 指向矩形数组对象[OH_Drawing_Array](capi-drawing-oh-drawing-array.md)的指针。 | 529 530**返回:** 531 532| 类型 | 说明 | 533| -- | -- | 534| [OH_Drawing_ErrorCode](capi-drawing-error-code-h.md#oh_drawing_errorcode) | 函数返回执行错误码。<br> 返回OH_DRAWING_SUCCESS,表示执行成功。<br> 返回OH_DRAWING_ERROR_INVALID_PARAMETER,表示参数rectArray为空。 | 535 536 537