openharmony 鸿蒙 capi-drawing-image-h

2026-08-25 浏览 (1)

drawing_image.h

Overview

This file declares the functions related to the image in the drawing module.

File to include: <native_drawing/drawing_image.h>

Library: libnative_drawing.so

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Related module: Drawing

Summary

Functions

NameDescription
OH_Drawing_Image* OH_Drawing_ImageCreate(void)Creates an OH_Drawing_Image object that describes an array of two-dimensional pixels to draw.
void OH_Drawing_ImageDestroy(OH_Drawing_Image* image)Destroys an OH_Drawing_Image object and reclaims the memory occupied by the object.
bool OH_Drawing_ImageBuildFromBitmap(OH_Drawing_Image* image, OH_Drawing_Bitmap* bitmap)Builds an image from a bitmap by sharing or copying bitmap pixels. If the bitmap is marked as immutable, the pixel memory is shared, not copied.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either image or bitmap is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
int32_t OH_Drawing_ImageGetWidth(OH_Drawing_Image* image)Obtains the image width, that is, the number of pixels in each line.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If image is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
int32_t OH_Drawing_ImageGetHeight(OH_Drawing_Image* image)Obtains the image height, that is, the number of pixel lines.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If image is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_ImageGetImageInfo(OH_Drawing_Image* image, OH_Drawing_Image_Info* imageInfo)Obtains the image information. After this function is called, the passed-in image information object is filled.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either image or imageInfo is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

Function Description

OH_Drawing_ImageCreate()

OH_Drawing_Image* OH_Drawing_ImageCreate(void)

Description

Creates an OH_Drawing_Image object that describes an array of two-dimensional pixels to draw.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Returns

TypeDescription
OH_Drawing_Image*Returns a pointer to the OH_Drawing_Image object created.

OH_Drawing_ImageDestroy()

void OH_Drawing_ImageDestroy(OH_Drawing_Image* image)

Description

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

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Image* imagePointer to the OH_Drawing_Image object.

OH_Drawing_ImageBuildFromBitmap()

bool OH_Drawing_ImageBuildFromBitmap(OH_Drawing_Image* image, OH_Drawing_Bitmap* bitmap)

Description

Builds an image from a bitmap by sharing or copying bitmap pixels. If the bitmap is marked as immutable, the pixel memory is shared, not copied.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either image or bitmap is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Image* imagePointer to the OH_Drawing_Image object.
OH_Drawing_Bitmap* bitmapPointer to the OH_Drawing_Bitmap object.

Returns

TypeDescription
boolReturns true if the image is built; returns false otherwise.

OH_Drawing_ImageGetWidth()

int32_t OH_Drawing_ImageGetWidth(OH_Drawing_Image* image)

Description

Obtains the image width, that is, the number of pixels in each line.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If image is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Image* imagePointer to the OH_Drawing_Image object.

Returns

TypeDescription
int32_tReturns the width.

OH_Drawing_ImageGetHeight()

int32_t OH_Drawing_ImageGetHeight(OH_Drawing_Image* image)

Description

Obtains the image height, that is, the number of pixel lines.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If image is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Image* imagePointer to the OH_Drawing_Image object.

Returns

TypeDescription
int32_tReturns the height.

OH_Drawing_ImageGetImageInfo()

void OH_Drawing_ImageGetImageInfo(OH_Drawing_Image* image, OH_Drawing_Image_Info* imageInfo)

Description

Obtains the image information. After this function is called, the passed-in image information object is filled.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either image or imageInfo is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Image* imagePointer to the OH_Drawing_Image object.
OH_Drawing_Image_Info* imageInfoPointer to an OH_Drawing_Image_Info object, which can be created by calling OH_Drawing_Image_Info.

你可能感兴趣的鸿蒙文章

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