diff --git a/zh-cn/native_sdk/graphic/native_effect/effect_filter.h b/zh-cn/native_sdk/graphic/native_effect/effect_filter.h new file mode 100644 index 0000000000000000000000000000000000000000..da83c0f77a89fd34d2fbf07067f79c8d42616cad --- /dev/null +++ b/zh-cn/native_sdk/graphic/native_effect/effect_filter.h @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef C_INCLUDE_EFFECT_FILTER_H +#define C_INCLUDE_EFFECT_FILTER_H + +/** + * @addtogroup image + * @{ + * + * @brief 提供image接口的访问。 + * + * @syscap SystemCapability.Multimedia.Image.Core + * @since 12 + */ + +/** + * @file effect_filter.h + * + * @brief 声明滤镜效果的接口。 + * + * @library libnative_effect.so + * @syscap SystemCapability.Multimedia.Image.Core + * @since 12 + */ + +#include "effect_types.h" +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief 创建一个 OH_Filter 对象。 + * + * @syscap SystemCapability.Multimedia.Image.Core + * @param pixelmap 创建滤镜的位图。 + * @param filter 用来接收滤镜的二级指针。 + * @return 返回 {@link EffectErrorCode}。 + * @since 12 + * @version 1.0 + */ +EffectErrorCode OH_Filter_CreateEffect(OH_PixelmapNative* pixelmap, OH_Filter** filter); + +/** + * @brief 释放 OH_Filter 对象。 + * + * @syscap SystemCapability.Multimedia.Image.Core + * @param filter 被释放的对象指针。 + * @return 返回 {@link EffectErrorCode}。 + * @since 12 + * @version 1.0 + */ +EffectErrorCode OH_Filter_Release(OH_Filter* filter); + +/** + * @brief 创建一个毛玻璃滤镜效果,然后加入到滤镜里面。 + * + * @syscap SystemCapability.Multimedia.Image.Core + * @param filter 滤镜指针。 + * @param radius 毛玻璃效果的模糊半径。 + * @return 返回 {@link EffectErrorCode}。 + * @since 12 + * @version 1.0 + */ +EffectErrorCode OH_Filter_Blur(OH_Filter* filter, float radius); + +/** + * @brief 创建一个提亮效果并且加入到滤镜中。 + * + * @syscap SystemCapability.Multimedia.Image.Core + * @param filter 滤镜指针。 + * @param brightness 提亮效果的亮度值。 + * @return 返回 {@link EffectErrorCode}。 + * @since 12 + * @version 1.0 + */ +EffectErrorCode OH_Filter_Brighten(OH_Filter* filter, float brightness); + +/** + * @brief 创建一个灰度效果并且添加到滤镜中。 + * + * @syscap SystemCapability.Multimedia.Image.Core + * @param filter 滤镜指针。 + * @return 返回 {@link EffectErrorCode}。 + * @since 12 + * @version 1.0 + */ +EffectErrorCode OH_Filter_GrayScale(OH_Filter* filter); + +/** + * @brief 创建一个反色效果并且添加到滤镜中。 + * + * @syscap SystemCapability.Multimedia.Image.Core + * @param filter 滤镜指针。 + * @return 返回 {@link EffectErrorCode}。 + * @since 12 + * @version 1.0 + */ +EffectErrorCode OH_Filter_Invert(OH_Filter* filter); + +/** + * @brief 通过矩阵创建一个自定义的效果并且添加到滤镜中。 + * + * @syscap SystemCapability.Multimedia.Image.Core + * @param filter 滤镜指针。 + * @param matrix 用来创建滤镜的自定义矩阵 {@link OH_Filter_ColorMatrix}。 + * @return Returns {@link EffectErrorCode}. + * @since 12 + * @version 1.0 + */ +EffectErrorCode OH_Filter_SetColorMatrix(OH_Filter* filter, OH_Filter_ColorMatrix* matrix); + +/** + * @brief 获取滤镜生成的位图。 + * + * @syscap SystemCapability.Multimedia.Image.Core + * @param filter 用来创建位图的滤镜指针。 + * @param pixelmap 用来接收位图的二级指针。 + * @return 返回 {@link EffectErrorCode}。 + * @since 12 + * @version 1.0 + */ +EffectErrorCode OH_Filter_GetEffectPixelMap(OH_Filter* filter, OH_PixelmapNative** pixelmap); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif diff --git a/zh-cn/native_sdk/graphic/native_effect/effect_types.h b/zh-cn/native_sdk/graphic/native_effect/effect_types.h new file mode 100644 index 0000000000000000000000000000000000000000..d5573d06fe0630c9976d8bef06bb44b5132339c6 --- /dev/null +++ b/zh-cn/native_sdk/graphic/native_effect/effect_types.h @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef C_INCLUDE_EFFECT_TYPES_H +#define C_INCLUDE_EFFECT_TYPES_H + +/** + * @addtogroup image + * @{ + * + * @brief 提供image接口的访问。 + * @brief + * + * @syscap SystemCapability.Multimedia.Image.Core + * @since 12 + */ + +/** + * @file effect_types.h + * + * @brief 声明滤镜效果的数据类型。 + * + * @library libnative_effect.so + * @syscap SystemCapability.Multimedia.Image.Core + * @since 12 + */ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief . + * + * @since 12 + * @version 1.0 + */ +typedef struct OH_Filter OH_Filter; + +/** + * @brief 定义一个位图。 + * + * @since 12 + * @version 1.0 + */ +typedef struct OH_PixelmapNative OH_PixelmapNative; + +/** + * @brief 定义一个用来创建滤镜效果的矩阵。 + * + * @since 12 + * @version 1.0 + */ +struct OH_Filter_ColorMatrix { + /** 值是一个5*4的数组 */ + float val[20]; +}; + +/** + * @brief 定义滤镜效果的错误码。 + * + * @since 12 + * @version 1.0 + */ +typedef enum { + /** 成功 */ + EFFECT_SUCCESS = 0, + /** 无效的参数 */ + EFFECT_BAD_PARAMETER = 401, + /** 不支持的操作 */ + EFFECT_UNSUPPORTED_OPERATION = 7600201, + /** 未知错误 */ + EFFECT_UNKNOWN_ERROR = 7600901, +} EffectErrorCode; + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif \ No newline at end of file