openharmony 鸿蒙 capi-drawing-lattice-h

2026-08-25 浏览 (1)

drawing_lattice.h

Overview

This file declares the functions related to the rectangular lattice object.

File to include: <native_drawing/drawing_lattice.h>

Library: libnative_drawing.so

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 23

Related module: Drawing

Summary

Enums

Nametypedef KeywordDescription
OH_Drawing_LatticeRectTypeOH_Drawing_LatticeRectTypeEnumerates the types of rectangles used to fill the lattices. It is applicable only to rectangular lattice objects.

Functions

NameDescription
OH_Drawing_ErrorCode OH_Drawing_LatticeDestroy(OH_Drawing_Lattice* lattice)Destroys an OH_Drawing_Lattice object and reclaims the memory occupied by the object.
OH_Drawing_ErrorCode OH_Drawing_LatticeCreate(const int* xDivs, const int* yDivs, uint32_t xCount, uint32_t yCount, const OH_Drawing_Rect* bounds, const OH_Drawing_LatticeRectType* rectTypes, uint32_t rectTypeCount, const uint32_t* colors, uint32_t colorCount, OH_Drawing_Lattice** lattice)Divides the image into lattices. The lattices on both even columns and even rows are fixed, and they are drawn at their original size if the target is large enough.
If the target is too small to hold the fixed lattices, all the fixed lattices are scaled down to fit the target, and the lattices that are not on even columns and even rows are scaled to accommodate the remaining space.

Enum Description

OH_Drawing_LatticeRectType

enum OH_Drawing_LatticeRectType

Description

Enumerates the types of rectangles used to fill the lattices. It is applicable only to rectangular lattice objects.

Since: 23

Enum ItemDescription
DEFAULTDraws an image into the rectangular lattice.
TRANSPARENTSets the rectangular lattice to be transparent.
FIXED_COLORDraws the colors from the fColors array of the rectangular lattice object into the lattice.

Function Description

OH_Drawing_LatticeDestroy()

OH_Drawing_ErrorCode OH_Drawing_LatticeDestroy(OH_Drawing_Lattice* lattice)

Description

Destroys an OH_Drawing_Lattice object and reclaims the memory occupied by the object.

Since: 23

Parameters

ParameterDescription
OH_Drawing_Lattice* latticePointer to an OH_Drawing_Lattice object.

Returns

TypeDescription
OH_Drawing_ErrorCodeExecution result.
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INCORRECT_PARAMETER if OHDrawingLattice lattice* is a null pointer.

OH_Drawing_LatticeCreate()

OH_Drawing_ErrorCode OH_Drawing_LatticeCreate(const int* xDivs, const int* yDivs, uint32_t xCount, uint32_t yCount, const OH_Drawing_Rect* bounds, const OH_Drawing_LatticeRectType* rectTypes, uint32_t rectTypeCount, const uint32_t* colors, uint32_t colorCount, OH_Drawing_Lattice** lattice)

Description

Divides the image into lattices. The lattices on both even columns and even rows are fixed, and they are drawn at their original size if the target is large enough. If the target is too small to hold the fixed lattices, all the fixed lattices are scaled down to fit the target, and the lattices that are not on even columns and even rows are scaled to accommodate the remaining space.

Since: 23

Parameters

ParameterDescription
const int* xDivsArray of X coordinates used to divide the image. The value is an integer.
const int* yDivsArray of Y coordinates used to divide the image. The value is an integer.
uint32_t xCountSize of the array that holds the X coordinates. The value range is [0, 5].
uint32_t yCountSize of the array that holds the Y coordinates. The value range is [0, 5].
const OH_Drawing_Rect* boundsThe original bounding rectangle to be drawn, which defaults to the size of the original image rectangle. The value must be an integer and is rounded down.
const OH_Drawing_LatticeRectType* rectTypesArray of rectangle types used to fill the lattice.
uint32_t rectTypeCountSize of the rectTypes array. If rectTypes is not a null pointer, the array size must be (xCount + 1)*(yCount + 1).
If rectTypes is a null pointer, the array size must be 0.
const uint32_t* colorsArray of colors used to fill the lattice.
uint32_t colorCountSize of the colors array. If colors is not a null pointer, the array size must be (xCount + 1)*(yCount + 1).
If colors is a null pointer, the array size must be 0.
OH_Drawing_Lattice** latticeDouble pointer to an OH_Drawing_Lattice object, which serves as an output parameter returned to the caller.

Returns

TypeDescription
OH_Drawing_ErrorCodeExecution result.
Returns OH_DRAWING_SUCCESS if the operation is successful.
Returns OH_DRAWING_ERROR_INCORRECT_PARAMETER for any of the following reasons:
- xDivs or yDivs is a null pointer.
- rectTypes is not a null pointer, and rectTypeCount is not equal to (xCount + 1)*(yCount + 1).
- colors is not a null pointer, and colorCount is not equal to (xCount + 1)*(yCount + 1).
- rectTypes is a null pointer, and rectTypeCount is not equal to 0.
- colors is a null pointer, and colorCount is not equal to 0.
Returns OH_DRAWING_ERROR_PARAMETER_OUT_OF_RANGE, indicating that the enumeration value in rectTypes exceeds the valid enumeration range.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-drawing-gpu-context-h

openharmony 鸿蒙 capi-drawing-nativepixelmap-

openharmony 鸿蒙 capi-nativevsync-oh-nativevsync-expectedraterange

openharmony 鸿蒙 capi-drawing-oh-drawing-brush

openharmony 鸿蒙 capi-drawing-oh-drawing-image-info

openharmony 鸿蒙 capi-drawing-text-linetypography-h

openharmony 鸿蒙 capi-oh-nativeimage-oh-nativeimage

openharmony 鸿蒙 capi-drawing-typeface-h

openharmony 鸿蒙 capi-drawing-brush-h

openharmony 鸿蒙 capi-nativewindow

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/pXmbCPrP