harmony 鸿蒙image_effect_filter.h

  • 2025-06-12
  • 浏览 (4)

image_effect_filter.h

Overview

The image_effect_filter.h 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.

Library: libimage_effect.so

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

System capability: SystemCapability.Multimedia.ImageEffect.Core

Since: 12

Related module: ImageEffect

Summary

Structs

Name Description
union ImageEffect_DataValue Describes the data values.
struct ImageEffect_Any Describes the image effect parameters.
struct ImageEffect_FilterNames Describes the filter name information.
struct ImageEffect_FilterDelegate Describes the callback functions of a custom filter.
struct ImageEffect_Region Describes the image region.
struct ImageEffect_Size Describes the image size.

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.
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.
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.
OH_EFFECT_FILTER_INTENSITY_KEY “FilterIntensity” Intensity filter.
OH_EFFECT_FILTER_REGION_KEY “FilterRegion” Image region filter.

Types

Name Description
typedef struct OH_EffectFilter OH_EffectFilter Defines a struct for the image effect filter.
typedef enum ImageEffect_DataType ImageEffect_DataType Defines an enum for the data types.
typedef union ImageEffect_DataValue ImageEffect_DataValue Defines a union for the data values.
typedef struct ImageEffect_Any ImageEffect_Any Defines a struct for the image effect parameters.
typedef enum ImageEffect_Format ImageEffect_Format Defines an enum for the pixel formats.
typedef enum ImageEffect_BufferType ImageEffect_BufferType Defines an enum for the buffer types.
typedef struct OH_EffectFilterInfo OH_EffectFilterInfo Defines a struct for the filter information.
typedef struct ImageEffect_FilterNames ImageEffect_FilterNames Defines a struct for the filter name information.
typedef struct OH_EffectBufferInfo OH_EffectBufferInfo Defines a struct for the buffer information.
typedef bool(* OH_EffectFilterDelegate_SetValue) (OH_EffectFilter *filter, const char *key, const ImageEffect_Any *value) Defines 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) Defines a pointer to the callback function used by a custom filter to push image data to the next-level filter.
typedef bool(* OH_EffectFilterDelegate_Render) (OH_EffectFilter *filter, OH_EffectBufferInfo *info, OH_EffectFilterDelegate_PushData pushData) Defines a pointer to the callback function for rendering an image using a custom filter.
typedef bool(* OH_EffectFilterDelegate_Save) (OH_EffectFilter *filter, char **info) Defines 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) Defines a pointer to the callback function for deserializing a custom filter.
typedef struct ImageEffect_FilterDelegate ImageEffect_FilterDelegate Describes the callback functions of a custom filter.
typedef struct ImageEffect_Region ImageEffect_Region Defines a struct for the image region.
typedef struct ImageEffect_Size ImageEffect_Size Defines a struct for the image size.

Enums

Name Description
ImageEffect_DataType {
EFFECT_DATA_TYPE_UNKNOWN = 0, EFFECT_DATA_TYPE_INT32 = 1,
EFFECT_DATA_TYPE_FLOAT = 2, EFFECT_DATA_TYPE_DOUBLE = 3,
EFFECT_DATA_TYPE_CHAR = 4, EFFECT_DATA_TYPE_LONG = 5,
EFFECT_DATA_TYPE_BOOL = 6, EFFECT_DATA_TYPE_PTR = 7
}
Enumerates the data types.
ImageEffect_Format {
EFFECT_PIXEL_FORMAT_UNKNOWN = 0, EFFECT_PIXEL_FORMAT_RGBA8888 = 1,
EFFECT_PIXEL_FORMAT_NV21 = 2, EFFECT_PIXEL_FORMAT_NV12 = 3,
EFFECT_PIXEL_FORMAT_RGBA1010102 = 4, EFFECT_PIXEL_FORMAT_YCBCR_P010 = 5,
EFFECT_PIXEL_FORMAT_YCRCB_P010 = 6
}
Enumerates the pixel formats.
ImageEffect_BufferType { EFFECT_BUFFER_TYPE_UNKNOWN = 0,
EFFECT_BUFFER_TYPE_PIXEL = 1, EFFECT_BUFFER_TYPE_TEXTURE = 2 }
Enumerates the buffer types.

Functions

Name Description
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_Release (OH_EffectBufferInfo *info) Destroys an OH_EffectBufferInfo instance.
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_Release (OH_EffectFilter *filter) Destroys an OH_EffectFilter instance.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Image Kit

harmony 鸿蒙_image___native_module

harmony 鸿蒙Image_Region

harmony 鸿蒙Image_Size

harmony 鸿蒙Image_String

harmony 鸿蒙ImageEffect

harmony 鸿蒙ImageEffect_Any

harmony 鸿蒙ImageEffect_FilterDelegate

harmony 鸿蒙ImageEffect_FilterNames

harmony 鸿蒙ImageEffect_Region

0  赞