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
| Name | typedef Keyword | Description |
|---|---|---|
| ImageEffect_DataValue | ImageEffect_DataValue | Describes the data values. |
| ImageEffect_Any | ImageEffect_Any | Describes the image effect parameters. |
| ImageEffect_FilterNames | ImageEffect_FilterNames | Describes the filter name information. |
| ImageEffect_FilterDelegate | ImageEffect_FilterDelegate | Describes the callback functions of a custom filter. |
| ImageEffect_Region | ImageEffect_Region | Describes the image region. |
| ImageEffect_Size | ImageEffect_Size | Describes the image size. |
| OH_EffectFilter | OH_EffectFilter | Describes the image effect filter. |
| OH_EffectFilterInfo | OH_EffectFilterInfo | Describes the filter information. |
| OH_EffectBufferInfo | OH_EffectBufferInfo | Describes the buffer information. |
Enums
| Name | typedef Keyword | Description |
|---|---|---|
| ImageEffect_DataType | ImageEffect_DataType | Enumerates the data types. |
| ImageEffect_Format | ImageEffect_Format | Enumerates the pixel formats. |
| ImageEffect_BufferType | ImageEffect_BufferType | Enumerates the buffer types. |
Macros
| Name | Description |
|---|---|
| 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
Enum Description
ImageEffect_DataType
enum ImageEffect_DataType
Description
Enumerates the data types.
System capability: SystemCapability.Multimedia.ImageEffect.Core
Since: 12
| Enum Item | Description |
|---|---|
| EFFECT_DATA_TYPE_UNKNOWN = 0 | Undefined. |
| EFFECT_DATA_TYPE_INT32 = 1 | Integer. |
| EFFECT_DATA_TYPE_FLOAT = 2 | Single-precision floating point. |
| EFFECT_DATA_TYPE_DOUBLE = 3 | Double-precision floating point. |
| EFFECT_DATA_TYPE_CHAR = 4 | Byte. |
| EFFECT_DATA_TYPE_LONG = 5 | Long integer. |
| EFFECT_DATA_TYPE_BOOL = 6 | Boolean. |
| EFFECT_DATA_TYPE_PTR = 7 | Pointer. |
ImageEffect_Format
enum ImageEffect_Format
Description
Enumerates the pixel formats.
System capability: SystemCapability.Multimedia.ImageEffect.Core
Since: 12
| Enum Item | Description |
|---|---|
| EFFECT_PIXEL_FORMAT_UNKNOWN = 0 | Undefined. |
| EFFECT_PIXEL_FORMAT_RGBA8888 = 1 | RGBA8888. |
| EFFECT_PIXEL_FORMAT_NV21 = 2 | NV21. |
| EFFECT_PIXEL_FORMAT_NV12 = 3 | NV12. |
| EFFECT_PIXEL_FORMAT_RGBA1010102 = 4 | 10-bit RGBA. |
| EFFECT_PIXEL_FORMAT_YCBCR_P010 = 5 | 10-bit YCBCR420. |
| EFFECT_PIXEL_FORMAT_YCRCB_P010 = 6 | 10-bit YCRCB420. |
ImageEffect_BufferType
enum ImageEffect_BufferType
Description
Enumerates the buffer types.
System capability: SystemCapability.Multimedia.ImageEffect.Core
Since: 12
| Enum Item | Description |
|---|---|
| EFFECT_BUFFER_TYPE_UNKNOWN = 0 | Undefined. |
| EFFECT_BUFFER_TYPE_PIXEL = 1 | Pixel image type. |
| EFFECT_BUFFER_TYPE_TEXTURE = 2 | Texture 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
| Type | Description |
|---|---|
| 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
| Name | Description |
|---|---|
| OH_EffectFilterInfo *info | Pointer to the filter information. |
| const char *name | Pointer to the filter name, for example, OH_EFFECT_BRIGHTNESS_FILTER. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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
| Name | Description |
|---|---|
| OH_EffectFilterInfo *info | Pointer to the filter information. |
| char **name | Double pointer to the char array holding the filter name. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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
| Name | Description |
|---|---|
| OH_EffectFilterInfo *info | Pointer to the filter information. |
| uint32_t size | Number of buffer types supported, each of which is ImageEffect_BufferType. |
| ImageEffect_BufferType *bufferTypeArray | Pointer to the array holding the buffer types supported, each of which is ImageEffect_BufferType. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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
| Name | Description |
|---|---|
| OH_EffectFilterInfo *info | Pointer to the filter information. |
| uint32_t *size | Number of buffer types supported, each of which is ImageEffect_BufferType. |
| ImageEffect_BufferType **bufferTypeArray | Double pointer to the array holding the buffer types supported, each of which is ImageEffect_BufferType. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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
| Name | Description |
|---|---|
| OH_EffectFilterInfo *info | Pointer to the filter information. |
| uint32_t size | Number of pixel formats supported, each of which is ImageEffect_Format. |
| ImageEffect_Format *formatArray | Pointer to the array holding the pixel formats supported, each of which is ImageEffect_Format. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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
| Name | Description |
|---|---|
| OH_EffectFilterInfo *info | Pointer to the filter information. |
| uint32_t *size | Pointer to the number of pixel formats supported, each of which is ImageEffect_Format. |
| ImageEffect_Format **formatArray | Double pointer to the array holding the pixel formats supported, each of which is ImageEffect_Format. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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
| Name | Description |
|---|---|
| OH_EffectFilterInfo *info | Pointer to the filter information. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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
| Type | Description |
|---|---|
| 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
| Name | Description |
|---|---|
| OH_EffectBufferInfo *info | Pointer to the image information. |
| void *addr | Pointer to the virtual address of the image buffer. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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
| Name | Description |
|---|---|
| OH_EffectBufferInfo *info | Pointer to the image information. |
| void **addr | Double pointer to the virtual address of the image buffer. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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
| Name | Description |
|---|---|
| OH_EffectBufferInfo *info | Pointer to the image information. |
| int32_t width | Image width, in px. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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
| Name | Description |
|---|---|
| OH_EffectBufferInfo *info | Pointer to the image information. |
| int32_t *width | Pointer to the image width, in px. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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
| Name | Description |
|---|---|
| OH_EffectBufferInfo *info | Pointer to the image information. |
| int32_t height | Image height, in px. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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
| Name | Description |
|---|---|
| OH_EffectBufferInfo *info | Pointer to the image information. |
| int32_t *height | Pointer to the image height, in px. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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
| Name | Description |
|---|---|
| OH_EffectBufferInfo *info | Pointer to the image information. |
| int32_t rowSize | Number of bytes per row, in bytes. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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
| Name | Description |
|---|---|
| OH_EffectBufferInfo *info | Pointer to the image information. |
| int32_t *rowSize | Pointer to the number of bytes per row, in bytes. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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
| Name | Description |
|---|---|
| OH_EffectBufferInfo *info | Pointer to the image information. |
| ImageEffect_Format format | Pixel format. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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
| Name | Description |
|---|---|
| OH_EffectBufferInfo *info | Pointer to the image information. |
| ImageEffect_Format *format | Pointer to the pixel format. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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
| Name | Description |
|---|---|
| OH_EffectBufferInfo *info | Pointer to an instance of the OH_EffectBufferInfo struct. |
| int32_t textureId | Texture ID of the image. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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
| Name | Description |
|---|---|
| OH_EffectBufferInfo *info | Pointer to an instance of the OH_EffectBufferInfo struct. |
| int32_t *textureId | Pointer to the texture ID of the image. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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
| Name | Description |
|---|---|
| OH_EffectBufferInfo *info | Pointer to the image information. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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
| Name | Description |
|---|---|
| OH_EffectFilter *filter | Pointer to the filter. |
| const char *key | Pointer to the key of a filter parameter. |
| const ImageEffect_Any *value | Pointer to the value of the filter parameter. |
Returns
| Type | Description |
|---|---|
| bool | true: 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
| Name | Description |
|---|---|
| OH_EffectFilter *filter | Pointer to the filter. |
| OH_EffectBufferInfo *info | Pointer 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
| Name | Description |
|---|---|
| OH_EffectFilter *filter | Pointer to the filter. |
| OH_EffectBufferInfo *info | Pointer to the buffer information, which is OH_EffectBufferInfo. |
| OH_EffectFilterDelegate_PushData pushData | Callback function OH_EffectFilterDelegate_PushData used by the custom filter to push image data to the next-level filter. |
Returns
| Type | Description |
|---|---|
| bool | true: 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
| Name | Description |
|---|---|
| OH_EffectFilter *filter | Pointer to the filter. |
| char **info | Double pointer to a char array holding a serialized JSON string. |
Returns
| Type | Description |
|---|---|
| bool | true: 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
| Name | Description |
|---|---|
| const char *info | Pointer to a serialized JSON string. |
Returns
| Type | Description |
|---|---|
| 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
| Name | Description |
|---|---|
| const char *name | Pointer to the filter name, for example, OH_EFFECT_BRIGHTNESS_FILTER. |
Returns
| Type | Description |
|---|---|
| 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
| Name | Description |
|---|---|
| OH_EffectFilter *filter | Pointer to the filter. |
| const char *key | Pointer to the key of the filter parameter, for example, OH_EFFECT_FILTER_INTENSITY_KEY. |
| const ImageEffect_Any *value | Pointer to the value of the filter parameter. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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
| Name | Description |
|---|---|
| OH_EffectFilter *filter | Pointer to the filter. |
| const char *key | Pointer to the key of the filter parameter, for example, OH_EFFECT_FILTER_INTENSITY_KEY. |
| ImageEffect_Any *value | Pointer to the value of the filter parameter. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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
| Name | Description |
|---|---|
| const OH_EffectFilterInfo *info | Pointer to the filter information, which is OH_EffectFilterInfo. |
| const ImageEffect_FilterDelegate *delegate | Pointer to the callback function ImageEffect_FilterDelegate of the filter. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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
| Name | Description |
|---|---|
| const char *key | Pointer to the conditions. You can use the keyword Default to obtain all filters. |
Returns
| Type | Description |
|---|---|
| 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
| Name | Description |
|---|---|
| const char *name | Pointer to the filter name. |
| OH_EffectFilterInfo *info | Pointer to the filter information, which is OH_EffectFilterInfo. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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
| Name | Description |
|---|---|
| OH_EffectFilter *filter | Pointer to the filter. |
| OH_PixelmapNative *inputPixelmap | Pointer to the input image. |
| OH_PixelmapNative *outputPixelmap | Pointer to the output image. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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
| Name | Description |
|---|---|
| OH_EffectFilter *filter | Pointer to an instance of the OH_EffectFilter struct. |
| int32_t inputTextureId | ID of the input texture. This ID must be valid and bound to a texture of the GL_TEXTURE_2D type. |
| int32_t outputTextureId | ID 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 colorSpace | Color space of the image. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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
| Name | Description |
|---|---|
| OH_EffectFilter *filter | Pointer to the filter. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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
| Name | Description |
|---|---|
| OH_EffectBufferInfo *info | Pointer to the image information. |
| int64_t timestamp | Timestamp of the image frame data. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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
| Name | Description |
|---|---|
| OH_EffectBufferInfo *info | Pointer to the image information. |
| int64_t *timestamp | Pointer to the timestamp of the image frame data. |
Returns
| Type | Description |
|---|---|
| ImageEffect_ErrorCode | EFFECT_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