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

2026-08-25 浏览 (1)

drawing_image_filter.h

Overview

This file declares the functions related to the image filter in the drawing module.

File to include: <native_drawing/drawing_image_filter.h>

Library: libnative_drawing.so

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Related module: Drawing

Summary

Functions

NameDescription
OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateBlur(float sigmaX, float sigmaY, OH_Drawing_TileMode tileMode,OH_Drawing_ImageFilter* imageFilter)Creates an image filter with a given blur effect.
OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateBlurWithCrop(float sigmaX, float sigmaY,OH_Drawing_TileMode tileMode, OH_Drawing_ImageFilter* input, const OH_Drawing_Rect* rect)Creates an image filter with a given blur effect.
You can pass a cropping rectangle to limit the blur effect to take effect only in the specified rectangular area of the image.​
OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateFromColorFilter(OH_Drawing_ColorFilter* colorFilter,OH_Drawing_ImageFilter* imageFilter)Creates an OH_Drawing_ImageFilter object with a color filter effect. This API may return an error code. For details, call OH_Drawing_ErrorCodeGet. If colorFilter is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateOffset(float x, float y, OH_Drawing_ImageFilter* imageFilter)Creates an offset filter to translate the input filter based on the specified vector.
OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateFromShaderEffect(OH_Drawing_ShaderEffect* shaderEffect)Creates an ImageFilter object based on a shader.
void OH_Drawing_ImageFilterDestroy(OH_Drawing_ImageFilter* imageFilter)Destroys an OH_Drawing_ImageFilter object and reclaims the memory occupied by the object.

Function Description

OH_Drawing_ImageFilterCreateBlur()

OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateBlur(float sigmaX, float sigmaY, OH_Drawing_TileMode tileMode,OH_Drawing_ImageFilter* imageFilter)

Description

Creates an image filter with a given blur effect.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
float sigmaXStandard deviation of the Gaussian blur to apply along the X axis. The value must be greater than 0.
float sigmaYStandard deviation of the Gaussian blur to apply along the Y axis. The value must be greater than 0.
OH_Drawing_TileMode tileModeTile mode of the shader effect. For details about the available options, see OH_Drawing_TileMode.
OH_Drawing_ImageFilter* imageFilterPointer to the filter to which the image filter will be applied. If NULL is passed in, the image filter is directly applied to the original image.

Return value

TypeDescription
OH_Drawing_ImageFilter*Returns the pointer to the OH_Drawing_ImageFilter object created. If NULL is returned, the creation fails. The possible failure cause is that no memory is available.

OH_Drawing_ImageFilterCreateBlurWithCrop()

OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateBlurWithCrop(float sigmaX, float sigmaY, OH_Drawing_TileMode tileMode, OH_Drawing_ImageFilter* input, const OH_Drawing_Rect* rect)

Description

Creates an image filter with a given blur effect.

You can pass a cropping rectangle to limit the blur effect to take effect only in the specified rectangular area of the image.​

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 20

Parameters

NameDescription
float sigmaXStandard deviation of the Gaussian blur to apply along the X axis. The value must be greater than 0.0.
float sigmaYStandard deviation of the Gaussian blur to apply along the Y axis. The value must be greater than 0.0.
OH_Drawing_TileMode tileModeTile mode of the shader effect. For details about the available options, see OH_Drawing_TileMode.
OH_Drawing_ImageFilter* inputPointer to the filter to which the image filter will be applied. If NULL is passed in, the image filter is directly applied to the original image.
const OH_Drawing_Rect* rectPointer to the rectangular region to be cropped. If NULL is passed in, the blur effect is directly applied to the entire image.

Return value

TypeDescription
OH_Drawing_ImageFilter*Returns the pointer to the OH_Drawing_ImageFilter object created. If NULL is returned, the creation fails. The possible failure cause is that no memory is available.

OH_Drawing_ImageFilterCreateFromColorFilter()

OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateFromColorFilter(OH_Drawing_ColorFilter* colorFilter,OH_Drawing_ImageFilter* imageFilter)

Description

Creates an OH_Drawing_ImageFilter object with a color filter effect. This API may return an error code. For details, call OH_Drawing_ErrorCodeGet. If colorFilter is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_ColorFilter* colorFilterPointer to an OH_Drawing_ColorFilter object.
OH_Drawing_ImageFilter* imageFilterPointer to the filter to which the image filter will be applied. If NULL is passed in, the image filter is directly applied to the original image.

Return value

TypeDescription
OH_Drawing_ImageFilter*Returns the pointer to the OH_Drawing_ImageFilter object created. If NULL is returned, the creation fails. The possible failure cause is that no memory is available or colorFilter is NULL.

OH_Drawing_ImageFilterCreateOffset()

OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateOffset(float x, float y, OH_Drawing_ImageFilter* imageFilter)

Description

Creates an offset filter to translate the input filter based on the specified vector.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 20

Parameters

NameDescription
float xDistance to translate on the X axis.
float yDistance to translate on the Y axis.
OH_Drawing_ImageFilter* imageFilterFilter to be translated. If NULL is passed in, the drawing result without the filtering effect is translated.

Return value

TypeDescription
OH_Drawing_ImageFilter*Returns the pointer to the OH_Drawing_ImageFilter object created. If NULL is returned, the creation fails. The possible failure cause is that no memory is available.

OH_Drawing_ImageFilterCreateFromShaderEffect()

OH_Drawing_ImageFilter* OH_Drawing_ImageFilterCreateFromShaderEffect(OH_Drawing_ShaderEffect* shaderEffect)

Description

Creates an ImageFilter object based on a shader.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 20

Parameters

NameDescription
OH_Drawing_ShaderEffect* shaderEffectShader effect to be applied to the image.

Return value

TypeDescription
OH_Drawing_ImageFilter*Returns the pointer to the OH_Drawing_ImageFilter object created. If NULL is returned, the creation fails. The possible failure cause is that no memory is available.

OH_Drawing_ImageFilterDestroy()

void OH_Drawing_ImageFilterDestroy(OH_Drawing_ImageFilter* imageFilter)

Description

Destroys an OH_Drawing_ImageFilter object and reclaims the memory occupied by the object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_ImageFilter* imageFilterPointer to an OH_Drawing_ImageFilter object.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-drawing-gpu-context-h

openharmony 鸿蒙 capi-drawing-nativepixelmap-

openharmony 鸿蒙 capi-nativevsync-oh-nativevsync-expectedraterange

openharmony 鸿蒙 capi-drawing-oh-drawing-brush

openharmony 鸿蒙 capi-drawing-oh-drawing-image-info

openharmony 鸿蒙 capi-drawing-text-linetypography-h

openharmony 鸿蒙 capi-oh-nativeimage-oh-nativeimage

openharmony 鸿蒙 capi-drawing-typeface-h

openharmony 鸿蒙 capi-drawing-brush-h

openharmony 鸿蒙 capi-nativewindow

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