openharmony 鸿蒙 capi-image-pixel-map-mdk-h

2026-08-25 浏览 (1)

image_pixel_map_mdk.h

Overview

The file declares the APIs used to lock, access, and unlock a PixelMap. You are advised to use pixelmap_native.h.

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

Library: libpixelmap_ndk.z.so

System capability: SystemCapability.Multimedia.Image.Core

Since: 10

Related module: Image

Summary

Structs

Nametypedef KeywordDescription
OhosPixelMapInfosOhosPixelMapInfosDescribes the information about a PixelMap.
NativePixelMap_NativePixelMapDescribes the native PixelMap information. It defines the data type name of the PixelMap at the native layer.
OhosPixelMapCreateOps-Describes the options used for creating a PixelMap.

Enums

Nametypedef KeywordDescription
anonymous enum-Enumerates the PixelMap alpha types.
anonymous enum-Enumerates the PixelMap editing types.
OH_PixelMap_AntiAliasingLevelOH_PixelMap_AntiAliasingLevelEnumerates the anti-aliasing levels used for scaling PixelMaps.

Functions

NameDescription
int32_t OH_PixelMap_CreatePixelMap(napi_env env, OhosPixelMapCreateOps info, void* buf, size_t len, napi_value* res)Creates a PixelMap object. Currently, only BGRA input streams are supported.
The buffer passed in by this API does not support the stride.
This function does not support the DMA memory.
int32_t OH_PixelMap_CreatePixelMapWithStride(napi_env env, OhosPixelMapCreateOps info, void* buf, size_t len, int32_t rowStride, napi_value* res)Creates a PixelMap object.
Currently, only BGRA input streams are supported. For a PixelMap in RGBA format (with the size greater than 512*512), DMA memory is used by default.
int32_t OH_PixelMap_CreateAlphaPixelMap(napi_env env, napi_value source, napi_value* alpha)Creates a PixelMap object that contains only alpha channel information.
NativePixelMap* OH_PixelMap_InitNativePixelMap(napi_env env, napi_value source)Initializes a NativePixelMap object.
int32_t OH_PixelMap_GetBytesNumberPerRow(const NativePixelMap* native, int32_t* num)Obtains the number of bytes per row of a NativePixelMap object.
int32_t OH_PixelMap_GetIsEditable(const NativePixelMap* native, int32_t* editable)Checks whether a NativePixelMap object is editable.
int32_t OH_PixelMap_IsSupportAlpha(const NativePixelMap* native, int32_t* alpha)Checks whether a NativePixelMap object supports alpha channels.
int32_t OH_PixelMap_SetAlphaAble(const NativePixelMap* native, int32_t alpha)Sets an alpha channel for a NativePixelMap object.
int32_t OH_PixelMap_GetDensity(const NativePixelMap* native, int32_t* density)Obtains the pixel density of a NativePixelMap object.
int32_t OH_PixelMap_SetDensity(const NativePixelMap* native, int32_t density)Sets the pixel density for a NativePixelMap object.
int32_t OH_PixelMap_SetOpacity(const NativePixelMap* native, float opacity)Sets the opacity for a NativePixelMap object.
int32_t OH_PixelMap_Scale(const NativePixelMap* native, float x, float y)Scales a NativePixelMap object.
You are advised to use the new function OH_PixelmapNative_Scale since API version 12.
int32_t OH_PixelMap_ScaleWithAntiAliasing(const NativePixelMap* native, float x, float y, OH_PixelMap_AntiAliasingLevel level)Scales a NativePixelMap object based on the specified anti-aliasing level, width, and height.
You are advised to use the new function OH_PixelmapNative_ScaleWithAntiAliasing since API version 12.
int32_t OH_PixelMap_Translate(const NativePixelMap* native, float x, float y)Translates a NativePixelMap object.
You are advised to use the new function OH_PixelmapNative_Translate since API version 12.
int32_t OH_PixelMap_Rotate(const NativePixelMap* native, float angle)Rotates a NativePixelMap object.
You are advised to use the new function OH_PixelmapNative_Rotate since API version 12.
int32_t OH_PixelMap_Flip(const NativePixelMap* native, int32_t x, int32_t y)Flips a NativePixelMap object.
You are advised to use the new function OH_PixelmapNative_Flip since API version 12.
int32_t OH_PixelMap_Crop(const NativePixelMap* native, int32_t x, int32_t y, int32_t width, int32_t height)Crops a NativePixelMap object.
You are advised to use the new function OH_PixelmapNative_Crop since API version 12.
int32_t OH_PixelMap_GetImageInfo(const NativePixelMap* native, OhosPixelMapInfos *info)Obtains the image information of a NativePixelMap object.
You are advised to use the new function OH_PixelmapNative_GetImageInfo since API version 12.
int32_t OH_PixelMap_AccessPixels(const NativePixelMap* native, void** addr)Obtains the memory address of a NativePixelMap object and locks the memory.
int32_t OH_PixelMap_UnAccessPixels(const NativePixelMap* native)Unlocks the memory of a NativePixelMap object. This function is used with OH_PixelMap_AccessPixels in pairs.

Enum Description

PixelMap Alpha Types

enum anonymous enum

Description

Enumerates the PixelMap alpha types.

Since: 10

Enum ItemDescription
OHOS_PIXEL_MAP_ALPHA_TYPE_UNKNOWN = 0Unknown format.
OHOS_PIXEL_MAP_ALPHA_TYPE_OPAQUE = 1Opaque format.
OHOS_PIXEL_MAP_ALPHA_TYPE_PREMUL = 2Premultiplied format.
OHOS_PIXEL_MAP_ALPHA_TYPE_UNPREMUL = 3Unpremultiplied format.

PixelMap Editing Types

enum anonymous enum

Description

Enumerates the PixelMap editing types.

Since: 10

Enum ItemDescription
OHOS_PIXEL_MAP_READ_ONLY = 0Read-only.
OHOS_PIXEL_MAP_EDITABLE = 1Editable.

OH_PixelMap_AntiAliasingLevel

enum OH_PixelMap_AntiAliasingLevel

Description

Enumerates the anti-aliasing levels used for scaling PixelMaps.

Since: 12

Enum ItemDescription
OH_PixelMap_AntiAliasing_NONE = 0Nearest neighbor interpolation.
OH_PixelMap_AntiAliasing_LOW = 1Bilinear interpolation.
OH_PixelMap_AntiAliasing_MEDIUM = 2Bilinear interpolation with mipmap enabled. You are advised to use this value when zooming out an image.
OH_PixelMap_AntiAliasing_HIGH = 3Cubic interpolation.

Function Description

OH_PixelMap_CreatePixelMap()

int32_t OH_PixelMap_CreatePixelMap(napi_env env, OhosPixelMapCreateOps info,void* buf, size_t len, napi_value* res)

Description

Creates a PixelMap object. Currently, only BGRA input streams are supported.

The buffer passed in by this API does not support the stride.

This function does not support the DMA memory.

Since: 10

Parameters

NameDescription
napi_env envPointer to the NAPI environment.
OhosPixelMapCreateOps infoOptions for setting the PixelMap object.
void* bufPointer to the buffer of the image.
size_t lenImage size.
napi_value* resPointer to the PixelMap object at the application layer.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_GET_DATA_ABNORMAL: An error occurs during image data retrieval.
IMAGE_RESULT_DECODE_FAILED: Decoding fails.
IMAGE_RESULT_DECODE_HEAD_ABNORMAL: An error occurs during decoding of the image header.
IMAGE_RESULT_CREATE_DECODER_FAILED: The decoder fails to be created.
IMAGE_RESULT_CREATE_ENCODER_FAILED: The encoder fails to be created.
IMAGE_RESULT_CHECK_FORMAT_ERROR: The format check fails.
IMAGE_RESULT_THIRDPART_SKIA_ERROR: Skia decoding fails.
IMAGE_RESULT_DATA_ABNORMAL: The image input data is incorrect.
IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST: Sharing the memory fails.
IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL: Data in the shared memory is incorrect.
IMAGE_RESULT_DECODE_ABNORMAL: Image decoding fails.
IMAGE_RESULT_DECODE_FAILED: Decoding fails.
IMAGE_RESULT_MALLOC_ABNORMAL: An error occurs during memory allocation.
IMAGE_RESULT_DATA_UNSUPPORT: The image data is not supported.
IMAGE_RESULT_INIT_ABNORMAL: The image fails to be initialized.
IMAGE_RESULT_CROP: Cropping fails.
IMAGE_RESULT_UNKNOWN_FORMAT: The image format is unknown.
IMAGE_RESULT_PLUGIN_REGISTER_FAILED: The plugin fails to be registered.
IMAGE_RESULT_PLUGIN_CREATE_FAILED: The plugin fails to be created.
IMAGE_RESULT_ENCODE_FAILED: The image fails to be encoded.
IMAGE_RESULT_HW_DECODE_UNSUPPORT: Hardware decoding is not supported.
IMAGE_RESULT_HW_DECODE_FAILED: Hardware decoding fails.
IMAGE_RESULT_INDEX_INVALID: IPC fails.
IMAGE_RESULT_DATA_UNSUPPORT: A property is invalid.
IMAGE_RESULT_ALPHA_TYPE_ERROR: The alpha type is incorrect.
IMAGE_RESULT_ALLOCATER_TYPE_ERROR: The memory allocator type is incorrect.

OH_PixelMap_CreatePixelMapWithStride()

int32_t OH_PixelMap_CreatePixelMapWithStride(napi_env env, OhosPixelMapCreateOps info,void* buf, size_t len, int32_t rowStride, napi_value* res)

Description

Creates a PixelMap object.

Currently, only BGRA input streams are supported. For a PixelMap in RGBA format (with the size greater than 512*512), DMA memory is used by default.

Since: 12

Parameters

NameDescription
napi_env envPointer to the NAPI environment.
OhosPixelMapCreateOps infoOptions for setting the PixelMap object.
void* bufPointer to the buffer of the image.
size_t lenBuffer size.
int32_t rowStrideRow stride. The stride is the actual memory size occupied by each row of the image, in bytes. Stride = Width *Number of bytes per pixel + Padding, where padding refers to the extra space added at the end of each row for memory alignment purposes.
napi_value* resPointer to the PixelMap object at the application layer.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_GET_DATA_ABNORMAL: An error occurs during image data retrieval.
IMAGE_RESULT_CHECK_FORMAT_ERROR: The format check fails.
IMAGE_RESULT_DATA_ABNORMAL: The image input data is incorrect.
IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL: Data in the shared memory is incorrect.
IMAGE_RESULT_DATA_UNSUPPORT: The attribute is invalid or the image data is not supported.
IMAGE_RESULT_UNKNOWN_FORMAT: The image format is unknown.

OH_PixelMap_CreateAlphaPixelMap()

int32_t OH_PixelMap_CreateAlphaPixelMap(napi_env env, napi_value source, napi_value* alpha)

Description

Creates a PixelMap object that contains only alpha channel information.

Since: 10

Parameters

NameDescription
napi_env envPointer to the NAPI environment.
napi_value sourcePixelMap object at the application layer.
napi_value* alphaPointer to the alpha channel.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_GET_DATA_ABNORMAL: An error occurs during image data retrieval.
IMAGE_RESULT_DECODE_FAILED: Decoding fails.
IMAGE_RESULT_DECODE_HEAD_ABNORMAL: An error occurs during decoding of the image header.
IMAGE_RESULT_CREATE_DECODER_FAILED: The decoder fails to be created.
IMAGE_RESULT_CREATE_ENCODER_FAILED: The encoder fails to be created.
IMAGE_RESULT_CHECK_FORMAT_ERROR: The format check fails.
IMAGE_RESULT_THIRDPART_SKIA_ERROR: Skia decoding fails.
IMAGE_RESULT_DATA_ABNORMAL: The image input data is incorrect.
IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST: Sharing the memory fails.
IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL: Data in the shared memory is incorrect.
IMAGE_RESULT_DECODE_ABNORMAL: Image decoding fails.
IMAGE_RESULT_MALLOC_ABNORMAL: An error occurs during memory allocation.
IMAGE_RESULT_DATA_UNSUPPORT: The image data is not supported.
IMAGE_RESULT_INIT_ABNORMAL: The image fails to be initialized.
IMAGE_RESULT_CROP: Cropping fails.
IMAGE_RESULT_UNKNOWN_FORMAT: The image format is unknown.
IMAGE_RESULT_PLUGIN_REGISTER_FAILED: The plugin fails to be registered.
IMAGE_RESULT_PLUGIN_CREATE_FAILED: The plugin fails to be created.
IMAGE_RESULT_ENCODE_FAILED: The image fails to be encoded.
IMAGE_RESULT_HW_DECODE_UNSUPPORT: Hardware decoding is not supported.
IMAGE_RESULT_HW_DECODE_FAILED: Hardware decoding fails.
IMAGE_RESULT_INDEX_INVALID: IPC fails.
IMAGE_RESULT_DATA_UNSUPPORT: A property is invalid.
IMAGE_RESULT_ALPHA_TYPE_ERROR: The alpha type is incorrect.
IMAGE_RESULT_ALLOCATER_TYPE_ERROR: The memory allocator type is incorrect.

OH_PixelMap_InitNativePixelMap()

NativePixelMap* OH_PixelMap_InitNativePixelMap(napi_env env, napi_value source)

Description

Initializes a NativePixelMap object.

Since: 10

Parameters

NameDescription
napi_env envPointer to the NAPI environment.
napi_value sourcePixelMap object at the application layer.

Returns

TypeDescription
NativePixelMap*Pointer to the NativePixelMap object. If the operation fails, an error code is returned.

OH_PixelMap_GetBytesNumberPerRow()

int32_t OH_PixelMap_GetBytesNumberPerRow(const NativePixelMap* native, int32_t* num)

Description

Obtains the number of bytes per row of a NativePixelMap object.

Since: 10

Parameters

NameDescription
const NativePixelMap* nativePointer to a NativePixelMap object.
int32_t* numPointer to the number of bytes per row.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_DATA_ABNORMAL: The image input data is incorrect.
IMAGE_RESULT_DATA_UNSUPPORT: A property is invalid.

OH_PixelMap_GetIsEditable()

int32_t OH_PixelMap_GetIsEditable(const NativePixelMap* native, int32_t* editable)

Description

Checks whether a NativePixelMap object is editable.

Since: 10

Parameters

NameDescription
const NativePixelMap* nativePointer to a NativePixelMap object.
int32_t* editablePointer to the editing type of the NativePixelMap object.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_DATA_ABNORMAL: The image input data is incorrect.
IMAGE_RESULT_DATA_UNSUPPORT: A property is invalid.

OH_PixelMap_IsSupportAlpha()

int32_t OH_PixelMap_IsSupportAlpha(const NativePixelMap* native, int32_t* alpha)

Description

Checks whether a NativePixelMap object supports alpha channels.

Since: 10

Parameters

NameDescription
const NativePixelMap* nativePointer to a NativePixelMap object.
int32_t* alphaPointer to the support for alpha channels.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_DATA_ABNORMAL: The image input data is incorrect.
IMAGE_RESULT_DATA_UNSUPPORT: A property is invalid.

OH_PixelMap_SetAlphaAble()

int32_t OH_PixelMap_SetAlphaAble(const NativePixelMap* native, int32_t alpha)

Description

Sets an alpha channel for a NativePixelMap object.

Since: 10

Parameters

NameDescription
const NativePixelMap* nativePointer to a NativePixelMap object.
int32_t alphaAlpha channel to set.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_DATA_ABNORMAL: The image input data is incorrect.
IMAGE_RESULT_DATA_UNSUPPORT: A property is invalid.

OH_PixelMap_GetDensity()

int32_t OH_PixelMap_GetDensity(const NativePixelMap* native, int32_t* density)

Description

Obtains the pixel density of a NativePixelMap object.

Since: 10

Parameters

NameDescription
const NativePixelMap* nativePointer to a NativePixelMap object.
int32_t* densityPointer to the pixel density.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_DATA_ABNORMAL: The image input data is incorrect.
IMAGE_RESULT_DATA_UNSUPPORT: A property is invalid.

OH_PixelMap_SetDensity()

int32_t OH_PixelMap_SetDensity(const NativePixelMap* native, int32_t density)

Description

Sets the pixel density for a NativePixelMap object.

Since: 10

Parameters

NameDescription
const NativePixelMap* nativePointer to a NativePixelMap object.
int32_t densityPixel density to set.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_DATA_ABNORMAL: The image input data is incorrect.
IMAGE_RESULT_DATA_UNSUPPORT: A property is invalid.

OH_PixelMap_SetOpacity()

int32_t OH_PixelMap_SetOpacity(const NativePixelMap* native, float opacity)

Description

Sets the opacity for a NativePixelMap object.

Since: 10

Parameters

NameDescription
const NativePixelMap* nativePointer to a NativePixelMap object.
float opacityOpacity to set.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_DATA_ABNORMAL: The image input data is incorrect.
IMAGE_RESULT_DATA_UNSUPPORT: A property is invalid.

OH_PixelMap_Scale()

int32_t OH_PixelMap_Scale(const NativePixelMap* native, float x, float y)

Description

Scales a NativePixelMap object.

You are advised to use the new function OH_PixelmapNative_Scale since API version 12.

Since: 10

Parameters

NameDescription
const NativePixelMap* nativePointer to a NativePixelMap object.
float xScale ratio of the width.
float yScale ratio of the height.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_GET_DATA_ABNORMAL: An error occurs during image data retrieval.
IMAGE_RESULT_DECODE_FAILED: Decoding fails.
IMAGE_RESULT_CHECK_FORMAT_ERROR: The format check fails.
IMAGE_RESULT_THIRDPART_SKIA_ERROR: Skia decoding fails.
IMAGE_RESULT_DATA_ABNORMAL: The image input data is incorrect.
IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST: Sharing the memory fails.
IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL: Data in the shared memory is incorrect.
IMAGE_RESULT_MALLOC_ABNORMAL: An error occurs during memory allocation.
IMAGE_RESULT_DATA_UNSUPPORT: The image data is not supported.
IMAGE_RESULT_INIT_ABNORMAL: The image fails to be initialized.
IMAGE_RESULT_CROP: Cropping fails.
IMAGE_RESULT_UNKNOWN_FORMAT: The image format is unknown.
IMAGE_RESULT_PLUGIN_REGISTER_FAILED: The plugin fails to be registered.
IMAGE_RESULT_PLUGIN_CREATE_FAILED: The plugin fails to be created.
IMAGE_RESULT_DATA_UNSUPPORT: A property is invalid.
IMAGE_RESULT_ALPHA_TYPE_ERROR: The alpha type is incorrect.
IMAGE_RESULT_ALLOCATER_TYPE_ERROR: The memory allocator type is incorrect.

OH_PixelMap_ScaleWithAntiAliasing()

int32_t OH_PixelMap_ScaleWithAntiAliasing(const NativePixelMap* native, float x, float y,OH_PixelMap_AntiAliasingLevel level)

Description

Scales a NativePixelMap object based on the specified anti-aliasing level, width, and height.

You are advised to use the new function OH_PixelmapNative_ScaleWithAntiAliasing since API version 12.

Since: 12

Parameters

NameDescription
const NativePixelMap* nativePointer to a NativePixelMap object.
float xScale ratio of the width.
float yScale ratio of the height.
OH_PixelMap_AntiAliasingLevel levelAnti-aliasing level.

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_GET_DATA_ABNORMAL: An error occurs during image data retrieval.
IMAGE_RESULT_CHECK_FORMAT_ERROR: The format check fails.
IMAGE_RESULT_THIRDPART_SKIA_ERROR: Skia decoding fails.
IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL: Data in the shared memory is incorrect.
IMAGE_RESULT_MALLOC_ABNORMAL: An error occurs during memory allocation.
IMAGE_RESULT_UNKNOWN_FORMAT: The image format is unknown.

OH_PixelMap_Translate()

int32_t OH_PixelMap_Translate(const NativePixelMap* native, float x, float y)

Description

Translates a NativePixelMap object.

You are advised to use the new function OH_PixelmapNative_Translate since API version 12.

Since: 10

Parameters

NameDescription
const NativePixelMap* nativePointer to a NativePixelMap object.
float xHorizontal distance to translate.
float yVertical distance to translate.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_GET_DATA_ABNORMAL: An error occurs during image data retrieval.
IMAGE_RESULT_DECODE_FAILED: Decoding fails.
IMAGE_RESULT_CHECK_FORMAT_ERROR: The format check fails.
IMAGE_RESULT_THIRDPART_SKIA_ERROR: Skia decoding fails.
IMAGE_RESULT_DATA_ABNORMAL: The image input data is incorrect.
IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST: Sharing the memory fails.
IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL: Data in the shared memory is incorrect.
IMAGE_RESULT_MALLOC_ABNORMAL: An error occurs during memory allocation.
IMAGE_RESULT_DATA_UNSUPPORT: The image data is not supported.
IMAGE_RESULT_CROP: Cropping fails.
IMAGE_RESULT_UNKNOWN_FORMAT: The image format is unknown.
IMAGE_RESULT_PLUGIN_REGISTER_FAILED: The plugin fails to be registered.
IMAGE_RESULT_PLUGIN_CREATE_FAILED: The plugin fails to be created.
IMAGE_RESULT_DATA_UNSUPPORT: A property is invalid.
IMAGE_RESULT_ALPHA_TYPE_ERROR: The alpha type is incorrect.
IMAGE_RESULT_ALLOCATER_TYPE_ERROR: The memory allocator type is incorrect.

OH_PixelMap_Rotate()

int32_t OH_PixelMap_Rotate(const NativePixelMap* native, float angle)

Description

Rotates a NativePixelMap object.

You are advised to use the new function OH_PixelmapNative_Rotate since API version 12.

Since: 10

Parameters

NameDescription
const NativePixelMap* nativePointer to a NativePixelMap object.
float angleAngle to rotate.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_GET_DATA_ABNORMAL: An error occurs during image data retrieval.
IMAGE_RESULT_DECODE_FAILED: Decoding fails.
IMAGE_RESULT_CHECK_FORMAT_ERROR: The format check fails.
IMAGE_RESULT_THIRDPART_SKIA_ERROR: Skia decoding fails.
IMAGE_RESULT_DATA_ABNORMAL: The image input data is incorrect.
IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST: Sharing the memory fails.
IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL: Data in the shared memory is incorrect.
IMAGE_RESULT_MALLOC_ABNORMAL: An error occurs during memory allocation.
IMAGE_RESULT_DATA_UNSUPPORT: The image data is not supported.
IMAGE_RESULT_CROP: Cropping fails.
IMAGE_RESULT_UNKNOWN_FORMAT: The image format is unknown.
IMAGE_RESULT_PLUGIN_REGISTER_FAILED: The plugin fails to be registered.
IMAGE_RESULT_PLUGIN_CREATE_FAILED: The plugin fails to be created.
IMAGE_RESULT_DATA_UNSUPPORT: A property is invalid.
IMAGE_RESULT_ALPHA_TYPE_ERROR: The alpha type is incorrect.
IMAGE_RESULT_ALLOCATER_TYPE_ERROR: The memory allocator type is incorrect.

OH_PixelMap_Flip()

int32_t OH_PixelMap_Flip(const NativePixelMap* native, int32_t x, int32_t y)

Description

Flips a NativePixelMap object.

You are advised to use the new function OH_PixelmapNative_Flip since API version 12.

Since: 10

Parameters

NameDescription
const NativePixelMap* nativePointer to a NativePixelMap object.
int32_t xWhether to flip around the x axis.
int32_t yWhether to flip around the y axis.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_GET_DATA_ABNORMAL: An error occurs during image data retrieval.
IMAGE_RESULT_DECODE_FAILED: Decoding fails.
IMAGE_RESULT_CHECK_FORMAT_ERROR: The format check fails.
IMAGE_RESULT_THIRDPART_SKIA_ERROR: Skia decoding fails.
IMAGE_RESULT_DATA_ABNORMAL: The image input data is incorrect.
IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST: Sharing the memory fails.
IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL: Data in the shared memory is incorrect.
IMAGE_RESULT_MALLOC_ABNORMAL: An error occurs during memory allocation.
IMAGE_RESULT_DATA_UNSUPPORT: The image data is not supported.
IMAGE_RESULT_CROP: Cropping fails.
IMAGE_RESULT_UNKNOWN_FORMAT: The image format is unknown.
IMAGE_RESULT_PLUGIN_REGISTER_FAILED: The plugin fails to be registered.
IMAGE_RESULT_PLUGIN_CREATE_FAILED: The plugin fails to be created.
IMAGE_RESULT_DATA_UNSUPPORT: A property is invalid.
IMAGE_RESULT_ALPHA_TYPE_ERROR: The alpha type is incorrect.
IMAGE_RESULT_ALLOCATER_TYPE_ERROR: The memory allocator type is incorrect.

OH_PixelMap_Crop()

int32_t OH_PixelMap_Crop(const NativePixelMap* native, int32_t x, int32_t y, int32_t width, int32_t height)

Description

Crops a NativePixelMap object.

You are advised to use the new function OH_PixelmapNative_Crop since API version 12.

Since: 10

Parameters

NameDescription
const NativePixelMap* nativePointer to a NativePixelMap object.
int32_t xX-coordinate of the upper left corner of the target image.
int32_t yY-coordinate of the upper left corner of the target image.
int32_t widthWidth of the cropped region.
int32_t heightHeight of the cropped region.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_GET_DATA_ABNORMAL: An error occurs during image data retrieval.
IMAGE_RESULT_DECODE_FAILED: Decoding fails.
IMAGE_RESULT_CHECK_FORMAT_ERROR: The format check fails.
IMAGE_RESULT_THIRDPART_SKIA_ERROR: Skia decoding fails.
IMAGE_RESULT_DATA_ABNORMAL: The image input data is incorrect.
IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST: Sharing the memory fails.
IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL: Data in the shared memory is incorrect.
IMAGE_RESULT_MALLOC_ABNORMAL: An error occurs during memory allocation.
IMAGE_RESULT_DATA_UNSUPPORT: The image data is not supported.
IMAGE_RESULT_CROP: Cropping fails.
IMAGE_RESULT_UNKNOWN_FORMAT: The image format is unknown.
IMAGE_RESULT_PLUGIN_REGISTER_FAILED: The plugin fails to be registered.
IMAGE_RESULT_PLUGIN_CREATE_FAILED: The plugin fails to be created.
IMAGE_RESULT_DATA_UNSUPPORT: A property is invalid.
IMAGE_RESULT_ALPHA_TYPE_ERROR: The alpha type is incorrect.
IMAGE_RESULT_ALLOCATER_TYPE_ERROR: The memory allocator type is incorrect.

OH_PixelMap_GetImageInfo()

int32_t OH_PixelMap_GetImageInfo(const NativePixelMap* native, OhosPixelMapInfos *info)

Description

Obtains the image information of a NativePixelMap object.

You are advised to use the new function OH_PixelmapNative_GetImageInfo since API version 12.

Since: 10

Parameters

NameDescription
const NativePixelMap* nativePointer to a NativePixelMap object.
OhosPixelMapInfos *infoPointer to the image information.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_GET_DATA_ABNORMAL: An error occurs during image data retrieval.
IMAGE_RESULT_DECODE_FAILED: Decoding fails.
IMAGE_RESULT_CHECK_FORMAT_ERROR: The format check fails.
IMAGE_RESULT_THIRDPART_SKIA_ERROR: Skia decoding fails.
IMAGE_RESULT_DATA_ABNORMAL: The image input data is incorrect.
IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST: Sharing the memory fails.
IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL: Data in the shared memory is incorrect.
IMAGE_RESULT_MALLOC_ABNORMAL: An error occurs during memory allocation.
IMAGE_RESULT_DATA_UNSUPPORT: The image data is not supported.
IMAGE_RESULT_CROP: Cropping fails.
IMAGE_RESULT_UNKNOWN_FORMAT: The image format is unknown.
IMAGE_RESULT_PLUGIN_REGISTER_FAILED: The plugin fails to be registered.
IMAGE_RESULT_PLUGIN_CREATE_FAILED: The plugin fails to be created.
IMAGE_RESULT_DATA_UNSUPPORT: A property is invalid.
IMAGE_RESULT_ALPHA_TYPE_ERROR: The alpha type is incorrect.
IMAGE_RESULT_ALLOCATER_TYPE_ERROR: The memory allocator type is incorrect.

OH_PixelMap_AccessPixels()

int32_t OH_PixelMap_AccessPixels(const NativePixelMap* native, void** addr)

Description

Obtains the memory address of a NativePixelMap object and locks the memory.

Since: 10

Parameters

NameDescription
const NativePixelMap* nativePointer to a NativePixelMap object.
void** addrDouble pointer to the memory address.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_GET_DATA_ABNORMAL: An error occurs during image data retrieval.
IMAGE_RESULT_DECODE_FAILED: Decoding fails.
IMAGE_RESULT_CHECK_FORMAT_ERROR: The format check fails.
IMAGE_RESULT_THIRDPART_SKIA_ERROR: Skia decoding fails.
IMAGE_RESULT_DATA_ABNORMAL: The image input data is incorrect.
IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST: Sharing the memory fails.
IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL: Data in the shared memory is incorrect.
IMAGE_RESULT_MALLOC_ABNORMAL: An error occurs during memory allocation.
IMAGE_RESULT_DATA_UNSUPPORT: The image data is not supported.
IMAGE_RESULT_CROP: Cropping fails.
IMAGE_RESULT_UNKNOWN_FORMAT: The image format is unknown.
IMAGE_RESULT_PLUGIN_REGISTER_FAILED: The plugin fails to be registered.
IMAGE_RESULT_PLUGIN_CREATE_FAILED: The plugin fails to be created.
IMAGE_RESULT_DATA_UNSUPPORT: A property is invalid.
IMAGE_RESULT_ALPHA_TYPE_ERROR: The alpha type is incorrect.
IMAGE_RESULT_ALLOCATER_TYPE_ERROR: The memory allocator type is incorrect.

OH_PixelMap_UnAccessPixels()

int32_t OH_PixelMap_UnAccessPixels(const NativePixelMap* native)

Description

Unlocks the memory of a NativePixelMap object. This function is used with OH_PixelMap_AccessPixels in pairs.

Since: 10

Parameters

NameDescription
const NativePixelMap* nativePointer to a NativePixelMap object.

Returns

TypeDescription
int32_tResult code defined in IRNdkErrCode:
IMAGE_RESULT_SUCCESS: The operation is successful.
IMAGE_RESULT_BAD_PARAMETER: A parameter is incorrect.
IMAGE_RESULT_JNI_ENV_ABNORMAL: The JNI environment is abnormal.
IMAGE_RESULT_INVALID_PARAMETER: A parameter is invalid.
IMAGE_RESULT_GET_DATA_ABNORMAL: An error occurs during image data retrieval.
IMAGE_RESULT_DECODE_FAILED: Decoding fails.
IMAGE_RESULT_CHECK_FORMAT_ERROR: The format check fails.
IMAGE_RESULT_THIRDPART_SKIA_ERROR: Skia decoding fails.
IMAGE_RESULT_DATA_ABNORMAL: The image input data is incorrect.
IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST: Sharing the memory fails.
IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL: Data in the shared memory is incorrect.
IMAGE_RESULT_MALLOC_ABNORMAL: An error occurs during memory allocation.
IMAGE_RESULT_DATA_UNSUPPORT: The image data is not supported.
IMAGE_RESULT_CROP: Cropping fails.
IMAGE_RESULT_UNKNOWN_FORMAT: The image format is unknown.
IMAGE_RESULT_PLUGIN_REGISTER_FAILED: The plugin fails to be registered.
IMAGE_RESULT_PLUGIN_CREATE_FAILED: The plugin fails to be created.
IMAGE_RESULT_DATA_UNSUPPORT: A property is invalid.
IMAGE_RESULT_ALPHA_TYPE_ERROR: The alpha type is incorrect.
IMAGE_RESULT_ALLOCATER_TYPE_ERROR: The memory allocator type 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/Xmjdcfos