openharmony 鸿蒙 capi-drawing-types-h

2026-08-25 浏览 (1)

drawing_types.h

Overview

This file declares the data types of the canvas, brush, pen, bitmap, and path used to draw 2D graphics.

File to include: <native_drawing/drawing_types.h>

Library: libnative_drawing.so

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 8

Related module: Drawing

Summary

Structs

Nametypedef KeywordDescription
OH_Drawing_Point2DOH_Drawing_Point2DDefines a two-dimensional coordinate point.
OH_Drawing_Point2DOH_Drawing_Corner_RadiiDefines a struct for the radii of a rounded corner. The radii consist of the x-axis radius and y-axis radius.
OH_Drawing_Point3DOH_Drawing_Point3DDefines a three-dimensional coordinate point.
OH_Drawing_Image_InfoOH_Drawing_Image_InfoDescribes the image information.
OH_Drawing_RectStyle_InfoOH_Drawing_RectStyle_InfoDescribes the style of a rectangle.
OH_Drawing_StringOH_Drawing_StringDescribes a string of characters encoded in UTF-16.
OH_Drawing_CanvasOH_Drawing_CanvasDefines a struct for a rectangular canvas, on which various shapes, images, and texts can be drawn by using the brush and pen.
OH_Drawing_PenOH_Drawing_PenDefines a struct for a pen, which is used to describe the style and color to outline a shape.
OH_Drawing_RegionOH_Drawing_RegionDefines a struct for a region, which represents a closed area on the canvas for more accurate graphic control.
OH_Drawing_BrushOH_Drawing_BrushDefines a struct for a brush, which is used to describe the style and color to fill in a shape.
OH_Drawing_PathOH_Drawing_PathDefines a struct for a path, which is used to customize various shapes.
OH_Drawing_PathIteratorOH_Drawing_PathIteratorDefines a path operation iterator. You can read path operation instructions by traversing the iterator.
OH_Drawing_LatticeOH_Drawing_LatticeDefines a struct for a rectangle grid, which is used to divide an image by rectangle grid.
OH_Drawing_BitmapOH_Drawing_BitmapDefines a struct for a bitmap, which is a memory area that contains the pixel data of a shape.
OH_Drawing_PointOH_Drawing_PointDefines a struct for a coordinate point.
OH_Drawing_PixelMapOH_Drawing_PixelMapDefines a struct for a pixel map, which is used to wrap the real pixel map supported by the image framework.
OH_Drawing_ColorSpaceOH_Drawing_ColorSpaceDefines a struct for a color space, which is used to describe the color information.
OH_Drawing_PathEffectOH_Drawing_PathEffectDefines a struct for a path effect that affects the stroke.
OH_Drawing_RectOH_Drawing_RectDefines a struct for a rectangle.
OH_Drawing_RoundRectOH_Drawing_RoundRectDefines a struct for a rounded rectangle.
OH_Drawing_MatrixOH_Drawing_MatrixDefines a struct for a matrix, which is used to describe coordinate transformation.
OH_Drawing_ShaderEffectOH_Drawing_ShaderEffectDefines a struct for a shader effect, which is used to describe the source color of the drawn content.
OH_Drawing_ShadowLayerOH_Drawing_ShadowLayerDefines a struct for a shadow, which is used to describe the shadow layer of the drawn content.
OH_Drawing_FilterOH_Drawing_FilterDefines a struct for a filter, which consists of a color filter, mask filter, and image filter.
OH_Drawing_MaskFilterOH_Drawing_MaskFilterDefines a struct for a mask filter.
OH_Drawing_ColorFilterOH_Drawing_ColorFilterDefines a struct for a color filter, which is used to convert a color into a new one.
OH_Drawing_FontOH_Drawing_FontDefines a struct for a font.
OH_Drawing_FontFeaturesOH_Drawing_FontFeaturesDefines a struct for font features, which are typesetting rules within a font that determine how glyphs look, such as ligatures, alternates, and superscripts/subscripts.
OH_Drawing_MemoryStreamOH_Drawing_MemoryStreamDefines a struct for a memory stream.
OH_Drawing_FontArgumentsOH_Drawing_FontArgumentsDefines a struct for font arguments.
OH_Drawing_TypefaceOH_Drawing_TypefaceDefines a struct for a typeface.
OH_Drawing_TextBlobOH_Drawing_TextBlobDefines a struct for a text blob, an immutable container that holds multiple texts. Each text blob consists of glyphs and position.
OH_Drawing_ImageOH_Drawing_ImageDefines a struct for an image that describes a two-dimensional pixel array.
OH_Drawing_ImageFilterOH_Drawing_ImageFilterDefines a struct for an image filter, which is used to operate all color bits that make up image pixels.
OH_Drawing_SamplingOptionsOH_Drawing_SamplingOptionsDefines a struct for sampling options, which describe the sampling methods for images and bitmaps.
OH_Drawing_TextBlobBuilderOH_Drawing_TextBlobBuilderDefines a struct for a text blob builder, which is used to build a text blob.
OH_Drawing_GpuContextOH_Drawing_GpuContextDefines a struct for the GPU context, which is used to describe the GPU backend context.
OH_Drawing_SurfaceOH_Drawing_SurfaceDefines a struct for a surface, which is used to manage the content drawn on the canvas.
OH_Drawing_FontMgrOH_Drawing_FontMgrDefines a struct for the font manager, which is used for font management.
OH_Drawing_FontStyleSetOH_Drawing_FontStyleSetDefines a struct for a font style set, which is used for font style family matching.
OH_Drawing_RecordCmdUtilsOH_Drawing_RecordCmdUtilsDefines the recording command tool, which is used to generate recording commands.
OH_Drawing_RecordCmdOH_Drawing_RecordCmdDefines the recording command class, which is used to store the set of recording commands.
OH_Drawing_ArrayOH_Drawing_ArrayDefines a struct for an array object, which is used to store multiple objects of the same type.

Enumerated value

Nametypedef KeywordDescription
OH_Drawing_ColorFormatOH_Drawing_ColorFormatDefines an enum for the storage formats of bitmap pixels.
OH_Drawing_AlphaFormatOH_Drawing_AlphaFormatDefines an enum for the alpha formats of bitmap pixels.
OH_Drawing_BlendModeOH_Drawing_BlendModeDefines an enum for blend modes. In blend mode, each operation generates a new color from two colors (source color and destination color).
These operations are the same for the red, green, and blue color channels (the alpha channel follows a different rule).
For simplicity, the following description uses the alpha channel as an example rather than naming each channel individually. For brevity, the following abbreviations are used:
s: source.
d: destination.
sa: source alpha.
da: destination alpha.
The following abbreviations are used in the calculation result:
r: The calculation methods of the four channels are the same.
ra: used when only the alpha channel is manipulated.
rc: used when the other three color channels are manipulated.
OH_Drawing_TextEncodingOH_Drawing_TextEncodingDefines an enum for the text encoding types.

Enum Description

OH_Drawing_ColorFormat

enum OH_Drawing_ColorFormat

Description

Defines an enum for the storage formats of bitmap pixels.

Since: 8

ValueDescription
COLOR_FORMAT_UNKNOWNUnknown format.
COLOR_FORMAT_ALPHA_8Each pixel is represented by 8 bits, which together indicate alpha.
COLOR_FORMAT_RGB_565Each pixel is represented by 16 bits. From the most significant bit to the least significant bit, the first 5 bits indicate red, the subsequent 6 bits indicate green, and the last 5 bits indicate blue.
COLOR_FORMAT_ARGB_4444Each pixel is represented by 16 bits. From the most significant bit to the least significant bit, every 4 bits indicate alpha, red, green, and blue, respectively.
COLOR_FORMAT_RGBA_8888Each pixel is represented by 32 bits. From the most significant bit to the least significant bit, every 8 bits indicate alpha, red, green, and blue, respectively.
COLOR_FORMAT_BGRA_8888Each pixel is represented by 32 bits. From the most significant bit to the least significant bit, every 8 bits indicate blue, green, red, and alpha, respectively.

OH_Drawing_AlphaFormat

enum OH_Drawing_AlphaFormat

Description

Defines an enum for the alpha formats of bitmap pixels.

Since: 8

ValueDescription
ALPHA_FORMAT_UNKNOWNUnknown format.
ALPHA_FORMAT_OPAQUEThe bitmap does not have the alpha component.
ALPHA_FORMAT_PREMULThe color component of each pixel is premultiplied by the alpha component.
ALPHA_FORMAT_UNPREMULThe color component of each pixel is not premultiplied by the alpha component.

OH_Drawing_BlendMode

enum OH_Drawing_BlendMode

Description

Defines an enum for blend modes. In blend mode, each operation generates a new color from two colors (source color and destination color).
These operations are the same for the red, green, and blue color channels (the alpha channel follows a different rule).
For simplicity, the following description uses the alpha channel as an example rather than naming each channel individually. For brevity, the following abbreviations are used:
s: source.
d: destination.
sa: source alpha.
da: destination alpha.
The following abbreviations are used in the calculation result:
r: The calculation methods of the four channels are the same.
ra: used when only the alpha channel is manipulated.
rc: used when the other three color channels are manipulated.

Since: 11

ValueDescription
BLEND_MODE_CLEARClear mode. r = 0.
BLEND_MODE_SRCr = s (The four channels of result are equal to the four channels of source, that is, the result is equal to the source.)
BLEND_MODE_DSTr = d (The four channels of result are equal to the four channels of destination, that is, the result is equal to the destination.)
BLEND_MODE_SRC_OVERr = s + (1 - sa) * d.
BLEND_MODE_DST_OVERr = d + (1 - da) * s.
BLEND_MODE_SRC_INr = s * da.
BLEND_MODE_DST_INr = d * sa.
BLEND_MODE_SRC_OUTr = s * (1 - da).
BLEND_MODE_DST_OUTr = d * (1 - sa).
BLEND_MODE_SRC_ATOPr = s * da + d * (1 - sa).
BLEND_MODE_DST_ATOPr = d * sa + s * (1 - da).
BLEND_MODE_XORr = s * (1 - da) + d * (1 - sa).
BLEND_MODE_PLUSr = min(s + d, 1).
BLEND_MODE_MODULATEr = s * d.
BLEND_MODE_SCREENScreen mode. r = s + d - s * d.
BLEND_MODE_OVERLAYOverlay mode.
BLEND_MODE_DARKENDarken mode. rc = s + d - max(s * da, d * sa), ra = s + (1 - sa) * d.
BLEND_MODE_LIGHTENLighten mode. rc = rc = s + d - min(s * da, d * sa), ra = s + (1 - sa) * d.
BLEND_MODE_COLOR_DODGEColor dodge mode.
BLEND_MODE_COLOR_BURNColor burn mode.
BLEND_MODE_HARD_LIGHTHard light mode.
BLEND_MODE_SOFT_LIGHTSoft light mode.
BLEND_MODE_DIFFERENCEDifference mode. rc = s + d - 2 * (min(s * da, d * sa)), ra = s + (1 - sa) * d.
BLEND_MODE_EXCLUSIONExclusion mode. rc = s + d - two(s * d), ra = s + (1 - sa) * d.
BLEND_MODE_MULTIPLYMultiply mode. r = s * (1 - da) + d * (1 - sa) + s * d.
BLEND_MODE_HUEHue mode.
BLEND_MODE_SATURATIONSaturation mode.
BLEND_MODE_COLORColor mode.
BLEND_MODE_LUMINOSITYLuminosity mode.

OH_Drawing_TextEncoding

enum OH_Drawing_TextEncoding

Description

Defines an enum for the text encoding types.

Since: 12

ValueDescription
TEXT_ENCODING_UTF8One byte used to indicate UTF-8 or ASCII characters.
TEXT_ENCODING_UTF16Two bytes used to indicate most Unicode characters.
TEXT_ENCODING_UTF32Four bytes used to indicate all Unicode characters.
TEXT_ENCODING_GLYPH_IDTwo bytes used to indicate the glyph index.

你可能感兴趣的鸿蒙文章

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/lTENMzPG