openharmony 鸿蒙 capi-image-effect-filter-h

2026-08-25 浏览 (2)

image_effect_filter.h

Overview

The file declares the APIs related to an image effect filter.
With these APIs, you can quickly implement basic effect processing or connect multiple filters in series in an image effector to implement complex effect processing. The system provides basic effect processing filters such as brightness and crop filters.

File to include: <multimedia/image_effect/image_effect_filter.h>

Library: libimage_effect.so

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Related module: ImageEffect

Summary

Structs

Nametypedef KeywordDescription
ImageEffect_DataValueImageEffect_DataValueDescribes the data values.
ImageEffect_AnyImageEffect_AnyDescribes the image effect parameters.
ImageEffect_FilterNamesImageEffect_FilterNamesDescribes the filter name information.
ImageEffect_FilterDelegateImageEffect_FilterDelegateDescribes the callback functions of a custom filter.
ImageEffect_RegionImageEffect_RegionDescribes the image region.
ImageEffect_SizeImageEffect_SizeDescribes the image size.
OH_EffectFilterOH_EffectFilterDescribes the image effect filter.
OH_EffectFilterInfoOH_EffectFilterInfoDescribes the filter information.
OH_EffectBufferInfoOH_EffectBufferInfoDescribes the buffer information.

Enums

Nametypedef KeywordDescription
ImageEffect_DataTypeImageEffect_DataTypeEnumerates the data types.
ImageEffect_FormatImageEffect_FormatEnumerates the pixel formats.
ImageEffect_BufferTypeImageEffect_BufferTypeEnumerates the buffer types.

Macros

NameDescription
OH_EFFECT_BRIGHTNESS_FILTER "Brightness"Brightness filter. The corresponding parameter is OH_EFFECT_FILTER_INTENSITY_KEY and the parameter type is EFFECT_DATA_TYPE_FLOAT.
Since: 12
System capability: SystemCapability.Multimedia.ImageEffect.Core
OH_EFFECT_CONTRAST_FILTER "Contrast"Contrast filter. The corresponding parameter is OH_EFFECT_FILTER_INTENSITY_KEY and the parameter type is EFFECT_DATA_TYPE_FLOAT.
Since: 12
System capability: SystemCapability.Multimedia.ImageEffect.Core
OH_EFFECT_CROP_FILTER "Crop"Crop filter. The corresponding parameter is OH_EFFECT_FILTER_REGION_KEY, the parameter type is EFFECT_DATA_TYPE_PTR, and the parameter value is ImageEffect_Region.
Since: 12
System capability: SystemCapability.Multimedia.ImageEffect.Core
OH_EFFECT_FILTER_INTENSITY_KEY "FilterIntensity"Intensity filter.
Since: 12
System capability: SystemCapability.Multimedia.ImageEffect.Core
OH_EFFECT_FILTER_REGION_KEY "FilterRegion"Image region filter.
Since: 12
System capability: SystemCapability.Multimedia.ImageEffect.Core

Functions

Nametypedef KeywordDescription
OH_EffectFilterInfo *OH_EffectFilterInfo_Create()-Creates an OH_EffectFilterInfo instance. The instance must be released by calling OH_EffectFilterInfo_Release when it is no longer needed.
ImageEffect_ErrorCode OH_EffectFilterInfo_SetFilterName(OH_EffectFilterInfo *info, const char *name)-Sets a filter name.
ImageEffect_ErrorCode OH_EffectFilterInfo_GetFilterName(OH_EffectFilterInfo *info, char **name)-Obtains a filter name.
ImageEffect_ErrorCode OH_EffectFilterInfo_SetSupportedBufferTypes(OH_EffectFilterInfo *info, uint32_t size, ImageEffect_BufferType *bufferTypeArray)-Sets the buffer types supported by a filter.
ImageEffect_ErrorCode OH_EffectFilterInfo_GetSupportedBufferTypes(OH_EffectFilterInfo *info, uint32_t *size, ImageEffect_BufferType **bufferTypeArray)-Obtains the buffer types supported by a filter.
ImageEffect_ErrorCode OH_EffectFilterInfo_SetSupportedFormats(OH_EffectFilterInfo *info, uint32_t size, ImageEffect_Format *formatArray)-Sets the pixel formats supported by a filter.
ImageEffect_ErrorCode OH_EffectFilterInfo_GetSupportedFormats(OH_EffectFilterInfo *info, uint32_t *size, ImageEffect_Format **formatArray)-Obtains the pixel formats supported by a filter.
ImageEffect_ErrorCode OH_EffectFilterInfo_Release(OH_EffectFilterInfo *info)-Destroys an OH_EffectFilterInfo instance.
OH_EffectBufferInfo *OH_EffectBufferInfo_Create()-Creates an OH_EffectBufferInfo instance. The instance must be released by calling OH_EffectBufferInfo_Release when it is no longer needed.
ImageEffect_ErrorCode OH_EffectBufferInfo_SetAddr(OH_EffectBufferInfo *info, void *addr)-Sets the address of an effect buffer.
ImageEffect_ErrorCode OH_EffectBufferInfo_GetAddr(OH_EffectBufferInfo *info, void **addr)-Obtains the address of an effect buffer.
ImageEffect_ErrorCode OH_EffectBufferInfo_SetWidth(OH_EffectBufferInfo *info, int32_t width)-Sets the image width.
ImageEffect_ErrorCode OH_EffectBufferInfo_GetWidth(OH_EffectBufferInfo *info, int32_t *width)-Obtains the image width.
ImageEffect_ErrorCode OH_EffectBufferInfo_SetHeight(OH_EffectBufferInfo *info, int32_t height)-Sets the image height.
ImageEffect_ErrorCode OH_EffectBufferInfo_GetHeight(OH_EffectBufferInfo *info, int32_t *height)-Obtains the image height.
ImageEffect_ErrorCode OH_EffectBufferInfo_SetRowSize(OH_EffectBufferInfo *info, int32_t rowSize)-Sets the number of bytes per row for an image.
ImageEffect_ErrorCode OH_EffectBufferInfo_GetRowSize(OH_EffectBufferInfo *info, int32_t *rowSize)-Obtains the number of bytes per row of an image.
ImageEffect_ErrorCode OH_EffectBufferInfo_SetEffectFormat(OH_EffectBufferInfo *info, ImageEffect_Format format)-Sets the pixel format for an image.
ImageEffect_ErrorCode OH_EffectBufferInfo_GetEffectFormat(OH_EffectBufferInfo *info, ImageEffect_Format *format)-Obtains the pixel format of an image.
ImageEffect_ErrorCode OH_EffectBufferInfo_SetTextureId(OH_EffectBufferInfo *info, int32_t textureId)-Sets the texture ID of the image for an OH_EffectBufferInfo struct.
ImageEffect_ErrorCode OH_EffectBufferInfo_GetTextureId(OH_EffectBufferInfo *info, int32_t *textureId)-Obtains the texture ID of an image from an OH_EffectBufferInfo struct.
ImageEffect_ErrorCode OH_EffectBufferInfo_Release(OH_EffectBufferInfo *info)-Destroys an OH_EffectBufferInfo instance.
typedef bool (*OH_EffectFilterDelegate_SetValue)(OH_EffectFilter *filter, const char *key, const ImageEffect_Any *value)OH_EffectFilterDelegate_SetValueDefines a pointer to the callback function for setting parameters of a custom filter. It is used to verify parameters and parameter values.
typedef void (*OH_EffectFilterDelegate_PushData)(OH_EffectFilter *filter, OH_EffectBufferInfo *info)OH_EffectFilterDelegate_PushDataDefines a pointer to the callback function used by a custom filter to push image data to the next-level filter. The function pointer must be actively called in the callback of OH_EffectFilterDelegate_Render.
typedef bool (*OH_EffectFilterDelegate_Render)(OH_EffectFilter *filter, OH_EffectBufferInfo *info, OH_EffectFilterDelegate_PushData pushData)OH_EffectFilterDelegate_RenderDefines a pointer to the callback function for rendering an image using a custom filter.
typedef bool (*OH_EffectFilterDelegate_Save)(OH_EffectFilter *filter, char **info)OH_EffectFilterDelegate_SaveDefines a pointer to the callback function for serializing a custom filter. Filters are serialized in JSON format.
typedef OH_EffectFilter *(*OH_EffectFilterDelegate_Restore)(const char *info)OH_EffectFilterDelegate_RestoreDefines a pointer to the callback function for deserializing a custom filter.
OH_EffectFilter *OH_EffectFilter_Create(const char *name)-Creates an OH_EffectFilter instance. The instance must be released by calling OH_EffectFilter_Release when it is no longer needed.
ImageEffect_ErrorCode OH_EffectFilter_SetValue(OH_EffectFilter *filter, const char *key, const ImageEffect_Any *value)-Sets a filter parameter.
ImageEffect_ErrorCode OH_EffectFilter_GetValue(OH_EffectFilter *filter, const char *key, ImageEffect_Any *value)-Obtains a filter parameter.
ImageEffect_ErrorCode OH_EffectFilter_Register(const OH_EffectFilterInfo *info, const ImageEffect_FilterDelegate *delegate)-Registers a custom filter.
ImageEffect_FilterNames *OH_EffectFilter_LookupFilters(const char *key)-Obtains filters that meet given conditions.
void OH_EffectFilter_ReleaseFilterNames()-Releases filter name memory resources.
ImageEffect_ErrorCode OH_EffectFilter_LookupFilterInfo(const char *name, OH_EffectFilterInfo *info)-Obtains the filter information.
ImageEffect_ErrorCode OH_EffectFilter_Render(OH_EffectFilter *filter, OH_PixelmapNative *inputPixelmap, OH_PixelmapNative *outputPixelmap)-Starts image rendering.
ImageEffect_ErrorCode OH_EffectFilter_RenderWithTextureId(OH_EffectFilter *filter, int32_t inputTextureId, int32_t outputTextureId, int32_t colorSpace)-Applies the filter effect using texture IDs. This function does not support using the same texture for both input and output.
ImageEffect_ErrorCode OH_EffectFilter_Release(OH_EffectFilter *filter)-Destroys an OH_EffectFilter instance.
ImageEffect_ErrorCode OH_EffectBufferInfo_SetTimestamp(OH_EffectBufferInfo *info, int64_t timestamp)-Sets the filter timestamp.
ImageEffect_ErrorCode OH_EffectBufferInfo_GetTimestamp(OH_EffectBufferInfo *info, int64_t *timestamp)-Obtains the filter timestamp.

Enum Description

ImageEffect_DataType

enum ImageEffect_DataType

Description

Enumerates the data types.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Enum ItemDescription
EFFECT_DATA_TYPE_UNKNOWN = 0Undefined.
EFFECT_DATA_TYPE_INT32 = 1Integer.
EFFECT_DATA_TYPE_FLOAT = 2Single-precision floating point.
EFFECT_DATA_TYPE_DOUBLE = 3Double-precision floating point.
EFFECT_DATA_TYPE_CHAR = 4Byte.
EFFECT_DATA_TYPE_LONG = 5Long integer.
EFFECT_DATA_TYPE_BOOL = 6Boolean.
EFFECT_DATA_TYPE_PTR = 7Pointer.

ImageEffect_Format

enum ImageEffect_Format

Description

Enumerates the pixel formats.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Enum ItemDescription
EFFECT_PIXEL_FORMAT_UNKNOWN = 0Undefined.
EFFECT_PIXEL_FORMAT_RGBA8888 = 1RGBA8888.
EFFECT_PIXEL_FORMAT_NV21 = 2NV21.
EFFECT_PIXEL_FORMAT_NV12 = 3NV12.
EFFECT_PIXEL_FORMAT_RGBA1010102 = 410-bit RGBA.
EFFECT_PIXEL_FORMAT_YCBCR_P010 = 510-bit YCBCR420.
EFFECT_PIXEL_FORMAT_YCRCB_P010 = 610-bit YCRCB420.

ImageEffect_BufferType

enum ImageEffect_BufferType

Description

Enumerates the buffer types.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Enum ItemDescription
EFFECT_BUFFER_TYPE_UNKNOWN = 0Undefined.
EFFECT_BUFFER_TYPE_PIXEL = 1Pixel image type.
EFFECT_BUFFER_TYPE_TEXTURE = 2Texture type.

Function Description

OH_EffectFilterInfo_Create()

OH_EffectFilterInfo *OH_EffectFilterInfo_Create()

Description

Creates an OH_EffectFilterInfo instance. The instance must be released by calling OH_EffectFilterInfo_Release when it is no longer needed.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Returns

TypeDescription
OH_EffectFilterInfo *Pointer to the OH_EffectFilterInfo instance created. If the operation fails, a null pointer is returned.

OH_EffectFilterInfo_SetFilterName()

ImageEffect_ErrorCode OH_EffectFilterInfo_SetFilterName(OH_EffectFilterInfo *info, const char *name)

Description

Sets a filter name.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
OH_EffectFilterInfo *infoPointer to the filter information.
const char *namePointer to the filter name, for example, OH_EFFECT_BRIGHTNESS_FILTER.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is a null pointer.

OH_EffectFilterInfo_GetFilterName()

ImageEffect_ErrorCode OH_EffectFilterInfo_GetFilterName(OH_EffectFilterInfo *info, char **name)

Description

Obtains a filter name.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
OH_EffectFilterInfo *infoPointer to the filter information.
char **nameDouble pointer to the char array holding the filter name.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is a null pointer.

OH_EffectFilterInfo_SetSupportedBufferTypes()

ImageEffect_ErrorCode OH_EffectFilterInfo_SetSupportedBufferTypes(OH_EffectFilterInfo *info, uint32_t size, ImageEffect_BufferType *bufferTypeArray)

Description

Sets the buffer types supported by a filter.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
OH_EffectFilterInfo *infoPointer to the filter information.
uint32_t sizeNumber of buffer types supported, each of which is ImageEffect_BufferType.
ImageEffect_BufferType *bufferTypeArrayPointer to the array holding the buffer types supported, each of which is ImageEffect_BufferType.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is a null pointer.

OH_EffectFilterInfo_GetSupportedBufferTypes()

ImageEffect_ErrorCode OH_EffectFilterInfo_GetSupportedBufferTypes(OH_EffectFilterInfo *info, uint32_t *size, ImageEffect_BufferType **bufferTypeArray)

Description

Obtains the buffer types supported by a filter.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
OH_EffectFilterInfo *infoPointer to the filter information.
uint32_t *sizeNumber of buffer types supported, each of which is ImageEffect_BufferType.
ImageEffect_BufferType **bufferTypeArrayDouble pointer to the array holding the buffer types supported, each of which is ImageEffect_BufferType.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is a null pointer.

OH_EffectFilterInfo_SetSupportedFormats()

ImageEffect_ErrorCode OH_EffectFilterInfo_SetSupportedFormats(OH_EffectFilterInfo *info, uint32_t size, ImageEffect_Format *formatArray)

Description

Sets the pixel formats supported by a filter.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
OH_EffectFilterInfo *infoPointer to the filter information.
uint32_t sizeNumber of pixel formats supported, each of which is ImageEffect_Format.
ImageEffect_Format *formatArrayPointer to the array holding the pixel formats supported, each of which is ImageEffect_Format.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is a null pointer.

OH_EffectFilterInfo_GetSupportedFormats()

ImageEffect_ErrorCode OH_EffectFilterInfo_GetSupportedFormats(OH_EffectFilterInfo *info, uint32_t *size, ImageEffect_Format **formatArray)

Description

Obtains the pixel formats supported by a filter.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
OH_EffectFilterInfo *infoPointer to the filter information.
uint32_t *sizePointer to the number of pixel formats supported, each of which is ImageEffect_Format.
ImageEffect_Format **formatArrayDouble pointer to the array holding the pixel formats supported, each of which is ImageEffect_Format.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is a null pointer.

OH_EffectFilterInfo_Release()

ImageEffect_ErrorCode OH_EffectFilterInfo_Release(OH_EffectFilterInfo *info)

Description

Destroys an OH_EffectFilterInfo instance.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
OH_EffectFilterInfo *infoPointer to the filter information.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is a null pointer.

OH_EffectBufferInfo_Create()

OH_EffectBufferInfo *OH_EffectBufferInfo_Create()

Description

Creates an OH_EffectBufferInfo instance. The instance must be released by calling OH_EffectBufferInfo_Release when it is no longer needed.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Returns

TypeDescription
OH_EffectBufferInfo *Pointer to the OH_EffectBufferInfo instance created. If the operation fails, a null pointer is returned.

OH_EffectBufferInfo_SetAddr()

ImageEffect_ErrorCode OH_EffectBufferInfo_SetAddr(OH_EffectBufferInfo *info, void *addr)

Description

Sets the address of an effect buffer.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
OH_EffectBufferInfo *infoPointer to the image information.
void *addrPointer to the virtual address of the image buffer.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is a null pointer.

OH_EffectBufferInfo_GetAddr()

ImageEffect_ErrorCode OH_EffectBufferInfo_GetAddr(OH_EffectBufferInfo *info, void **addr)

Description

Obtains the address of an effect buffer.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
OH_EffectBufferInfo *infoPointer to the image information.
void **addrDouble pointer to the virtual address of the image buffer.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is a null pointer.

OH_EffectBufferInfo_SetWidth()

ImageEffect_ErrorCode OH_EffectBufferInfo_SetWidth(OH_EffectBufferInfo *info, int32_t width)

Description

Sets the image width.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
OH_EffectBufferInfo *infoPointer to the image information.
int32_t widthImage width, in px.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is a null pointer.

OH_EffectBufferInfo_GetWidth()

ImageEffect_ErrorCode OH_EffectBufferInfo_GetWidth(OH_EffectBufferInfo *info, int32_t *width)

Description

Obtains the image width.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
OH_EffectBufferInfo *infoPointer to the image information.
int32_t *widthPointer to the image width, in px.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is a null pointer.

OH_EffectBufferInfo_SetHeight()

ImageEffect_ErrorCode OH_EffectBufferInfo_SetHeight(OH_EffectBufferInfo *info, int32_t height)

Description

Sets the image height.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
OH_EffectBufferInfo *infoPointer to the image information.
int32_t heightImage height, in px.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is a null pointer.

OH_EffectBufferInfo_GetHeight()

ImageEffect_ErrorCode OH_EffectBufferInfo_GetHeight(OH_EffectBufferInfo *info, int32_t *height)

Description

Obtains the image height.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
OH_EffectBufferInfo *infoPointer to the image information.
int32_t *heightPointer to the image height, in px.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is a null pointer.

OH_EffectBufferInfo_SetRowSize()

ImageEffect_ErrorCode OH_EffectBufferInfo_SetRowSize(OH_EffectBufferInfo *info, int32_t rowSize)

Description

Sets the number of bytes per row for an image.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
OH_EffectBufferInfo *infoPointer to the image information.
int32_t rowSizeNumber of bytes per row, in bytes.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is a null pointer.

OH_EffectBufferInfo_GetRowSize()

ImageEffect_ErrorCode OH_EffectBufferInfo_GetRowSize(OH_EffectBufferInfo *info, int32_t *rowSize)

Description

Obtains the number of bytes per row of an image.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
OH_EffectBufferInfo *infoPointer to the image information.
int32_t *rowSizePointer to the number of bytes per row, in bytes.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is a null pointer.

OH_EffectBufferInfo_SetEffectFormat()

ImageEffect_ErrorCode OH_EffectBufferInfo_SetEffectFormat(OH_EffectBufferInfo *info, ImageEffect_Format format)

Description

Sets the pixel format for an image.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
OH_EffectBufferInfo *infoPointer to the image information.
ImageEffect_Format formatPixel format.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is a null pointer.

OH_EffectBufferInfo_GetEffectFormat()

ImageEffect_ErrorCode OH_EffectBufferInfo_GetEffectFormat(OH_EffectBufferInfo *info, ImageEffect_Format *format)

Description

Obtains the pixel format of an image.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
OH_EffectBufferInfo *infoPointer to the image information.
ImageEffect_Format *formatPointer to the pixel format.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is a null pointer.

OH_EffectBufferInfo_SetTextureId()

ImageEffect_ErrorCode OH_EffectBufferInfo_SetTextureId(OH_EffectBufferInfo *info, int32_t textureId)

Description

Sets the texture ID of the image for an OH_EffectBufferInfo struct.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 20

Parameters

NameDescription
OH_EffectBufferInfo *infoPointer to an instance of the OH_EffectBufferInfo struct.
int32_t textureIdTexture ID of the image.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is missing.

OH_EffectBufferInfo_GetTextureId()

ImageEffect_ErrorCode OH_EffectBufferInfo_GetTextureId(OH_EffectBufferInfo *info, int32_t *textureId)

Description

Obtains the texture ID of an image from an OH_EffectBufferInfo struct.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 20

Parameters

NameDescription
OH_EffectBufferInfo *infoPointer to an instance of the OH_EffectBufferInfo struct.
int32_t *textureIdPointer to the texture ID of the image.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is missing.

OH_EffectBufferInfo_Release()

ImageEffect_ErrorCode OH_EffectBufferInfo_Release(OH_EffectBufferInfo *info)

Description

Destroys an OH_EffectBufferInfo instance.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
OH_EffectBufferInfo *infoPointer to the image information.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is a null pointer.

OH_EffectFilterDelegate_SetValue()

typedef bool (*OH_EffectFilterDelegate_SetValue)(OH_EffectFilter *filter, const char *key, const ImageEffect_Any *value)

Description

Defines a pointer to the callback function for setting parameters of a custom filter. It is used to verify parameters and parameter values.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
OH_EffectFilter *filterPointer to the filter.
const char *keyPointer to the key of a filter parameter.
const ImageEffect_Any *valuePointer to the value of the filter parameter.

Returns

TypeDescription
booltrue: The parameter is valid.
false: The parameter is invalid.

OH_EffectFilterDelegate_PushData()

typedef void (*OH_EffectFilterDelegate_PushData)(OH_EffectFilter *filter, OH_EffectBufferInfo *info)

Description

Defines a pointer to the callback function used by a custom filter to push image data to the next-level filter. The function pointer must be actively called in the callback of OH_EffectFilterDelegate_Render.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
OH_EffectFilter *filterPointer to the filter.
OH_EffectBufferInfo *infoPointer to the buffer information, which is OH_EffectBufferInfo.

OH_EffectFilterDelegate_Render()

typedef bool (*OH_EffectFilterDelegate_Render)(OH_EffectFilter *filter, OH_EffectBufferInfo *info, OH_EffectFilterDelegate_PushData pushData)

Description

Defines a pointer to the callback function for rendering an image using a custom filter.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
OH_EffectFilter *filterPointer to the filter.
OH_EffectBufferInfo *infoPointer to the buffer information, which is OH_EffectBufferInfo.
OH_EffectFilterDelegate_PushData pushDataCallback function OH_EffectFilterDelegate_PushData used by the custom filter to push image data to the next-level filter.

Returns

TypeDescription
booltrue: The operation is successful.
false: The operation fails.

OH_EffectFilterDelegate_Save()

typedef bool (*OH_EffectFilterDelegate_Save)(OH_EffectFilter *filter, char **info)

Description

Defines a pointer to the callback function for serializing a custom filter. Filters are serialized in JSON format.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
OH_EffectFilter *filterPointer to the filter.
char **infoDouble pointer to a char array holding a serialized JSON string.

Returns

TypeDescription
booltrue: The operation is successful.
false: The operation fails.

OH_EffectFilterDelegate_Restore()

typedef OH_EffectFilter *(*OH_EffectFilterDelegate_Restore)(const char *info)

Description

Defines a pointer to the callback function for deserializing a custom filter.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
const char *infoPointer to a serialized JSON string.

Returns

TypeDescription
OH_EffectFilter *OH_EffectFilter instance. If the operation fails, a null pointer is returned.

OH_EffectFilter_Create()

OH_EffectFilter *OH_EffectFilter_Create(const char *name)

Description

Creates an OH_EffectFilter instance. The instance must be released by calling OH_EffectFilter_Release when it is no longer needed.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
const char *namePointer to the filter name, for example, OH_EFFECT_BRIGHTNESS_FILTER.

Returns

TypeDescription
OH_EffectFilter *Pointer to the OH_EffectFilter instance created. If the operation fails, a null pointer is returned.

OH_EffectFilter_SetValue()

ImageEffect_ErrorCode OH_EffectFilter_SetValue(OH_EffectFilter *filter, const char *key, const ImageEffect_Any *value)

Description

Sets a filter parameter.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
OH_EffectFilter *filterPointer to the filter.
const char *keyPointer to the key of the filter parameter, for example, OH_EFFECT_FILTER_INTENSITY_KEY.
const ImageEffect_Any *valuePointer to the value of the filter parameter.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is a null pointer.
EFFECT_KEY_ERROR: A parameter is invalid.
EFFECT_PARAM_ERROR: A parameter value is invalid.

OH_EffectFilter_GetValue()

ImageEffect_ErrorCode OH_EffectFilter_GetValue(OH_EffectFilter *filter, const char *key, ImageEffect_Any *value)

Description

Obtains a filter parameter.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
OH_EffectFilter *filterPointer to the filter.
const char *keyPointer to the key of the filter parameter, for example, OH_EFFECT_FILTER_INTENSITY_KEY.
ImageEffect_Any *valuePointer to the value of the filter parameter.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is a null pointer.
EFFECT_KEY_ERROR: A parameter is invalid.

OH_EffectFilter_Register()

ImageEffect_ErrorCode OH_EffectFilter_Register(const OH_EffectFilterInfo *info, const ImageEffect_FilterDelegate *delegate)

Description

Registers a custom filter.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
const OH_EffectFilterInfo *infoPointer to the filter information, which is OH_EffectFilterInfo.
const ImageEffect_FilterDelegate *delegatePointer to the callback function ImageEffect_FilterDelegate of the filter.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is a null pointer.

OH_EffectFilter_LookupFilters()

ImageEffect_FilterNames *OH_EffectFilter_LookupFilters(const char *key)

Description

Obtains filters that meet given conditions.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
const char *keyPointer to the conditions. You can use the keyword Default to obtain all filters.

Returns

TypeDescription
ImageEffect_FilterNames *Pointer to a list of filter names.

OH_EffectFilter_ReleaseFilterNames()

void OH_EffectFilter_ReleaseFilterNames()

Description

Releases filter name memory resources.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

OH_EffectFilter_LookupFilterInfo()

ImageEffect_ErrorCode OH_EffectFilter_LookupFilterInfo(const char *name, OH_EffectFilterInfo *info)

Description

Obtains the filter information.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
const char *namePointer to the filter name.
OH_EffectFilterInfo *infoPointer to the filter information, which is OH_EffectFilterInfo.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is a null pointer or an invalid value.

OH_EffectFilter_Render()

ImageEffect_ErrorCode OH_EffectFilter_Render(OH_EffectFilter *filter, OH_PixelmapNative *inputPixelmap, OH_PixelmapNative *outputPixelmap)

Description

Starts image rendering.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
OH_EffectFilter *filterPointer to the filter.
OH_PixelmapNative *inputPixelmapPointer to the input image.
OH_PixelmapNative *outputPixelmapPointer to the output image.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is a null pointer.

OH_EffectFilter_RenderWithTextureId()

ImageEffect_ErrorCode OH_EffectFilter_RenderWithTextureId(OH_EffectFilter *filter, int32_t inputTextureId, int32_t outputTextureId, int32_t colorSpace)

Description

Applies the filter effect using texture IDs. This function does not support using the same texture for both input and output.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 20

Parameters

NameDescription
OH_EffectFilter *filterPointer to an instance of the OH_EffectFilter struct.
int32_t inputTextureIdID of the input texture. This ID must be valid and bound to a texture of the GL_TEXTURE_2D type.
int32_t outputTextureIdID of the output texture. This ID must be valid.
If it is not bound to a texture, it will automatically be bound to a GL_TEXTURE_2D type.
If the texture is already bound and the size is inappropriate, the rendered result may be cropped or partially filled into this texture.
int32_t colorSpaceColor space of the image.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is missing.

OH_EffectFilter_Release()

ImageEffect_ErrorCode OH_EffectFilter_Release(OH_EffectFilter *filter)

Description

Destroys an OH_EffectFilter instance.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
OH_EffectFilter *filterPointer to the filter.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is a null pointer.

OH_EffectBufferInfo_SetTimestamp()

ImageEffect_ErrorCode OH_EffectBufferInfo_SetTimestamp(OH_EffectBufferInfo *info, int64_t timestamp)

Description

Sets the filter timestamp.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
OH_EffectBufferInfo *infoPointer to the image information.
int64_t timestampTimestamp of the image frame data.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is a null pointer.

OH_EffectBufferInfo_GetTimestamp()

ImageEffect_ErrorCode OH_EffectBufferInfo_GetTimestamp(OH_EffectBufferInfo *info, int64_t *timestamp)

Description

Obtains the filter timestamp.

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Parameters

NameDescription
OH_EffectBufferInfo *infoPointer to the image information.
int64_t *timestampPointer to the timestamp of the image frame data.

Returns

TypeDescription
ImageEffect_ErrorCodeEFFECT_SUCCESS: The function is successfully called.
EFFECT_ERROR_PARAM_INVALID: A parameter is a null pointer.

你可能感兴趣的鸿蒙文章

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