openharmony 鸿蒙 capi-image-native-h

2026-08-25 浏览 (1)

image_native.h

Overview

The file declares the cropping rectangle, size, and component data of an image.

File to include: <multimedia/image_framework/image/image_native.h>

Library: libohimage.so

System capability: SystemCapability.Multimedia.Image.Core

Since: 12

Related module: Image_NativeModule

Summary

Structs

Nametypedef KeywordDescription
OH_ImageBufferDataOH_ImageBufferDataOH_ImageBufferData is the image data struct encapsulated at the native layer.
OH_ImageNativeOH_ImageNativeDescribes the alias for an image object at the native layer.

Functions

NameDescription
Image_ErrorCode OH_ImageNative_GetImageSize(OH_ImageNative *image, Image_Size *size)Obtains the Image_Size information of an OH_ImageNative object.
Image_ErrorCode OH_ImageNative_GetComponentTypes(OH_ImageNative *image, uint32_t **types, size_t *typeSize)Obtains the component types of an OH_ImageNative object.
Image_ErrorCode OH_ImageNative_GetByteBuffer(OH_ImageNative *image, uint32_t componentType, OH_NativeBuffer **nativeBuffer)Obtains the buffer corresponding to a component type in an OH_ImageNative object.
Image_ErrorCode OH_ImageNative_GetBufferSize(OH_ImageNative *image, uint32_t componentType, size_t *size)Obtains the size of the buffer corresponding to a component type in an OH_ImageNative object.
Image_ErrorCode OH_ImageNative_GetRowStride(OH_ImageNative *image, uint32_t componentType, int32_t *rowStride)Obtains the row stride corresponding to a component type in an OH_ImageNative object.
Image_ErrorCode OH_ImageNative_GetPixelStride(OH_ImageNative *image, uint32_t componentType, int32_t *pixelStride)Obtains the pixel stride corresponding to a component type in an OH_ImageNative object.
Image_ErrorCode OH_ImageNative_GetTimestamp(OH_ImageNative *image, int64_t *timestamp)Obtains the timestamp of an OH_ImageNative object.
Image_ErrorCode OH_ImageNative_Release(OH_ImageNative *image)Releases an OH_ImageNative object.
Image_ErrorCode OH_ImageNative_GetColorSpace(OH_ImageNative *image, int32_t *colorSpaceName)Obtains the color space in an OH_ImageNative object.
Image_ErrorCode OH_ImageNative_GetFormat(OH_ImageNative *image, OH_NativeBuffer_Format *format)Obtains the image format in an OH_ImageNative object.
Image_ErrorCode OH_ImageNative_GetBufferData(OH_ImageNative *image, OH_ImageBufferData *imageBufferData)Obtains the image buffer data object in an OH_ImageNative object.

Function Description

OH_ImageNative_GetImageSize()

Image_ErrorCode OH_ImageNative_GetImageSize(OH_ImageNative *image, Image_Size *size)

Description

Obtains the Image_Size information of an OH_ImageNative object.

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

The type of data stored in the OH_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: 12

Parameters

NameDescription
OH_ImageNative *imagePointer to an OH_ImageNative object.
Image_Size *sizePointer to the Image_Size object obtained.

Returns

TypeDescription
Image_ErrorCodeIMAGE_SUCCESS: The operation is successful.
IMAGE_BAD_PARAMETER: A parameter is incorrect.
IMAGE_UNKNOWN_ERROR: An unknown error occurs.

OH_ImageNative_GetComponentTypes()

Image_ErrorCode OH_ImageNative_GetComponentTypes(OH_ImageNative *image,uint32_t **types, size_t *typeSize)

Description

Obtains the component types of an OH_ImageNative object.

Since: 12

Parameters

NameDescription
OH_ImageNative *imagePointer to an OH_ImageNative object.
uint32_t **typesPointer to the component type list object obtained. Since the number of components is uncertain, this API needs to be called twice: first, set types to NULL to obtain the number of components (typeSize); second, allocate corresponding memory for types based on typeSize and then obtain the component type list.
size_t *typeSizePointer to the number of component types obtained.

Returns

TypeDescription
Image_ErrorCodeIMAGE_SUCCESS: The operation is successful.
IMAGE_BAD_PARAMETER: A parameter is incorrect.

OH_ImageNative_GetByteBuffer()

Image_ErrorCode OH_ImageNative_GetByteBuffer(OH_ImageNative *image,uint32_t componentType, OH_NativeBuffer **nativeBuffer)

Description

Obtains the buffer corresponding to a component type in an OH_ImageNative object.

Since: 12

Parameters

NameDescription
OH_ImageNative *imagePointer to an OH_ImageNative object.
uint32_t componentTypeComponent type. The value is obtained using the OH_ImageNative_GetComponentTypes API.
OH_NativeBuffer **nativeBufferDouble pointer to the buffer, which is an OH_NativeBuffer object.

Returns

TypeDescription
Image_ErrorCodeIMAGE_SUCCESS: The operation is successful.
IMAGE_BAD_PARAMETER: A parameter is incorrect.

OH_ImageNative_GetBufferSize()

Image_ErrorCode OH_ImageNative_GetBufferSize(OH_ImageNative *image,uint32_t componentType, size_t *size)

Description

Obtains the size of the buffer corresponding to a component type in an OH_ImageNative object.

Since: 12

Parameters

NameDescription
OH_ImageNative *imagePointer to an OH_ImageNative object.
uint32_t componentTypeComponent type. The value is obtained using the OH_ImageNative_GetComponentTypes API.
size_t *sizePointer to the size of the buffer.

Returns

TypeDescription
Image_ErrorCodeIMAGE_SUCCESS: The operation is successful.
IMAGE_BAD_PARAMETER: A parameter is incorrect.

OH_ImageNative_GetRowStride()

Image_ErrorCode OH_ImageNative_GetRowStride(OH_ImageNative *image,uint32_t componentType, int32_t *rowStride)

Description

Obtains the row stride corresponding to a component type in an OH_ImageNative object.

Camera preview stream data must be read based on the stride. For details, see Secondary Processing of Preview Streams (C/C++).

Since: 12

Parameters

NameDescription
OH_ImageNative *imagePointer to an OH_ImageNative object.
uint32_t componentTypeComponent type. The value is obtained using the OH_ImageNative_GetComponentTypes API.
int32_t *rowStridePointer to the row stride obtained.

Returns

TypeDescription
Image_ErrorCodeIMAGE_SUCCESS: The operation is successful.
IMAGE_BAD_PARAMETER: A parameter is incorrect.

OH_ImageNative_GetPixelStride()

Image_ErrorCode OH_ImageNative_GetPixelStride(OH_ImageNative *image,uint32_t componentType, int32_t *pixelStride)

Description

Obtains the pixel stride corresponding to a component type in an OH_ImageNative object.

Since: 12

Parameters

NameDescription
OH_ImageNative *imagePointer to an OH_ImageNative object.
uint32_t componentTypeComponent type. The value is obtained using the OH_ImageNative_GetComponentTypes API.
int32_t *pixelStridePointer to the pixel stride obtained.

Returns

TypeDescription
Image_ErrorCodeIMAGE_SUCCESS: The operation is successful.
IMAGE_BAD_PARAMETER: A parameter is incorrect.

OH_ImageNative_GetTimestamp()

Image_ErrorCode OH_ImageNative_GetTimestamp(OH_ImageNative *image, int64_t *timestamp)

Description

Obtains the timestamp of an OH_ImageNative object. Timestamps, measured in nanoseconds, are usually monotonically increasing.

The specific meaning and baseline of these timestamps are determined by the image producer, which is the camera in the camera preview and photo scenarios. As a result, images from different producers may carry timestamps with distinct meanings and baselines, making direct comparison between them infeasible.

To obtain the generation time of a photo, you can use OH_ImageSourceNative_GetImageProperty to read the related Exif information.

Since: 12

Parameters

NameDescription
OH_ImageNative *imagePointer to an OH_ImageNative object.
int64_t *timestampPointer to the timestamp.

Returns

TypeDescription
Image_ErrorCodeIMAGE_SUCCESS: The operation is successful.
IMAGE_BAD_PARAMETER: A parameter is incorrect.

OH_ImageNative_Release()

Image_ErrorCode OH_ImageNative_Release(OH_ImageNative *image)

Description

Releases an OH_ImageNative object.

Since: 12

Parameters

NameDescription
OH_ImageNative *imagePointer to an OH_ImageNative object.

Returns

TypeDescription
Image_ErrorCodeIMAGE_SUCCESS: The operation is successful.
IMAGE_BAD_PARAMETER: A parameter is incorrect.

OH_ImageNative_GetColorSpace()

Image_ErrorCode OH_ImageNative_GetColorSpace(OH_ImageNative *image, int32_t *colorSpaceName)

Description

Obtains the color space in an OH_ImageNative object.

Since: 23

Parameters

NameDescription
OH_ImageNative *imagePointer to an OH_ImageNative object.
int32_t *colorSpaceNamePointer to the image color space. For details about the color space corresponding to colorSpaceName, see ColorSpaceName.

Returns

TypeDescription
Image_ErrorCodeIMAGE_SUCCESS: The operation is successful.
IMAGE_BAD_PARAMETER: A parameter is incorrect.

OH_ImageNative_GetFormat()

Image_ErrorCode OH_ImageNative_GetFormat(OH_ImageNative *image, OH_NativeBuffer_Format *format)

Description

Obtains the image format in an OH_ImageNative object.

Since: 23

Parameters

NameDescription
OH_ImageNative *imagePointer to an OH_ImageNative object.
OH_NativeBuffer_Format *formatPointer to the image format.

Returns

TypeDescription
Image_ErrorCodeIMAGE_SUCCESS: The operation is successful.
IMAGE_BAD_PARAMETER: A parameter is incorrect.

OH_ImageNative_GetBufferData()

Image_ErrorCode OH_ImageNative_GetBufferData(OH_ImageNative *image, OH_ImageBufferData *imageBufferData)

Description

Obtains the image buffer data object in an OH_ImageNative object.

Since: 23

Parameters

NameDescription
OH_ImageNative *imagePointer to an OH_ImageNative object.
OH_ImageBufferData *imageBufferDataPointer to the image buffer data object.

Returns

TypeDescription
Image_ErrorCodeIMAGE_SUCCESS: The operation is successful.
IMAGE_BAD_PARAMETER: A parameter is incorrect.

你可能感兴趣的鸿蒙文章

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-mdk-h

openharmony 鸿蒙 capi-image-ohosimagesourcedelaytimelist

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