openharmony 鸿蒙 capi-image-mdk-h

2026-08-25 浏览 (1)

image_mdk.h

Overview

The file declares the APIs used to access the image rectangle, size, format, and component data.

File to include: <multimedia/image_framework/image_mdk.h>

Library: libimage_ndk.z.so

System capability: SystemCapability.Multimedia.Image.Core

Since: 10

Related module: Image

Summary

Structs

Nametypedef KeywordDescription
OhosImageRect-Describes the information about an image rectangle.
ImageNative_ImageNativeDescribes an image object at the native layer.
OhosImageComponent-Describes the information about an image component.

Enums

NameDescription
Image FormatsEnumerates the image formats.
Image Color Channel TypesEnumerates the image color channel types.

Functions

NameDescription
ImageNative* OH_Image_InitImageNative(napi_env env, napi_value source)Converts an Image object at the JavaScript native layer into an ImageNative object.
int32_t OH_Image_ClipRect(const ImageNative* native, struct OhosImageRect* rect)Obtains OhosImageRect of an ImageNative object.
int32_t OH_Image_Size(const ImageNative* native, struct OhosImageSize* size)Obtains OhosImageSize of an ImageNative object.
int32_t OH_Image_Format(const ImageNative* native, int32_t* format)Obtains the format of an ImageNative object.
int32_t OH_Image_GetComponent(const ImageNative* native, int32_t componentType, struct OhosImageComponent* componentNative)Obtains OhosImageComponent of an ImageNative object.
int32_t OH_Image_Release(ImageNative* native)Releases an ImageNative object.
This function is not used to release an Image object at the JavaScript native API. It is used to release an ImageNative object parsed by calling OH_Image_InitImageNative.

Enum Description

Image Formats

enum anonymous enum

Description

Enumerates the image formats.

Since: 10

Enum ItemDescription
OHOS_IMAGE_FORMAT_YCBCR_422_SP = 1000YCbCr422 semi-planar format.
OHOS_IMAGE_FORMAT_JPEG = 2000JPEG encoding format.

Image Color Channel Types

enum anonymous enum

Description

Enumerates the image color channel types.

Since: 10

Enum ItemDescription
OHOS_IMAGE_COMPONENT_FORMAT_YUV_Y = 1Luminance component.
OHOS_IMAGE_COMPONENT_FORMAT_YUV_U = 2Chrominance component - blue projection.
OHOS_IMAGE_COMPONENT_FORMAT_YUV_V = 3Chrominance component - red projection.
OHOS_IMAGE_COMPONENT_FORMAT_JPEG = 4JPEG.

Function Description

OH_Image_InitImageNative()

ImageNative* OH_Image_InitImageNative(napi_env env, napi_value source)

Description

Parses an ImageNative object from an Image object at the JavaScript native layer.

Since: 10

Parameters

NameDescription
napi_env envPointer to the JNI environment.
napi_value sourceImage object at the JavaScript native layer.

Returns

TypeDescription
ImageNative*Pointer to the ImageNative object. If the operation fails, a null pointer is returned.

See also

OH_Image_Release

OH_Image_ClipRect()

int32_t OH_Image_ClipRect(const ImageNative* native, struct OhosImageRect* rect)

Description

Obtains OhosImageRect of an ImageNative object.

Since: 10

Parameters

NameDescription
const ImageNative* nativePointer to an ImageNative object.
struct OhosImageRect* rectPointer to the OhosImageRect object obtained.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED: Obtaining parameters from the surface fails.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.

OH_Image_Size()

int32_t OH_Image_Size(const ImageNative* native, struct OhosImageSize* size)

Description

Obtains OhosImageSize of an ImageNative object.

If the ImageNative object stores the camera preview stream data (YUV image data), the width and height in OhosImageSize obtained correspond to those of the YUV image. If the ImageNative object stores the camera photo stream data (JPEG image data, which is already encoded), the width in OhosImageSize obtained is the JPEG data size, and the height is 1.

The type of data stored in the ImageNative object depends on whether the application passes the surface ID in the receiver to a previewOutput or captureOutput object of the camera. For details about the best practices of camera preview and photo capture, see Secondary Processing of Preview Streams (C/C++) and Photo Capture (C/C++).

Since: 10

Parameters

NameDescription
const ImageNative* nativePointer to an ImageNative object.
struct OhosImageSize* sizePointer to the OhosImageSize object obtained.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED: Obtaining parameters from the surface fails.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.

OH_Image_Format()

int32_t OH_Image_Format(const ImageNative* native, int32_t* format)

Description

Obtains the format of an ImageNative object.

Since: 10

Parameters

NameDescription
const ImageNative* nativePointer to an ImageNative object.
int32_t* formatPointer to the image format obtained.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED: Obtaining parameters from the surface fails.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.

OH_Image_GetComponent()

int32_t OH_Image_GetComponent(const ImageNative* native, int32_t componentType, struct OhosImageComponent* componentNative)

Description

Obtains OhosImageComponent of an ImageNative object.

Since: 10

Parameters

NameDescription
const ImageNative* nativePointer to an ImageNative object.
int32_t componentTypeType of the component.
struct OhosImageComponent* componentNativePointer to the OhosImageComponent object obtained.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED: Obtaining parameters from the surface fails.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.

OH_Image_Release()

int32_t OH_Image_Release(ImageNative* native)

Description

Releases an ImageNative object.

This function is not used to release an Image object at the JavaScript native API. It is used to release an ImageNative object parsed by calling OH_Image_InitImageNative.

Since: 10

Parameters

NameDescription
ImageNative* nativePointer to an ImageNative object.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.

See also

OH_Image_InitImageNative

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-image-nativemodule-oh-pixelmap-hdrmetadatavalue

openharmony 鸿蒙 capi-image-imagepacker-opts-

openharmony 鸿蒙 capi-image-nativemodule-image-region

openharmony 鸿蒙 capi-image-imagepacker-native-

openharmony 鸿蒙 capi-image-imagenative-

openharmony 鸿蒙 capi-image-processing-h

openharmony 鸿蒙 capi-image-ohosimagesourcesupportedformat

openharmony 鸿蒙 capi-image-nativemodule-image-size

openharmony 鸿蒙 capi-image-ohosimagesourcedelaytimelist

openharmony 鸿蒙 capi-image-nativemodule-image-scale

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