diff --git a/graphic/graphic_2d/native_effect/BUILD.gn b/graphic/graphic_2d/native_effect/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..df42b50d13b736eb5c54ebc7f877dd1420d516a4
--- /dev/null
+++ b/graphic/graphic_2d/native_effect/BUILD.gn
@@ -0,0 +1,34 @@
+# 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.
+
+import("//build/ohos.gni")
+import("//build/ohos/ndk/ndk.gni")
+
+ohos_ndk_headers("native_effect_header") {
+ dest_dir = "$ndk_headers_out_dir/native_effect"
+ sources = [
+ "./effect_filter.h",
+ "./effect_types.h",
+ ]
+}
+
+ohos_ndk_library("libnative_effect_ndk") {
+ output_name = "native_effect"
+ output_extension = "so"
+ ndk_description_file = "./libnative_effect.ndk.json"
+ system_capability = "SystemCapability.Multimedia.Image.Core"
+ system_capability_headers = [
+ "native_effect/effect_filter.h",
+ "native_effect/effect_types.h",
+ ]
+}
diff --git a/graphic/graphic_2d/native_effect/effect_filter.h b/graphic/graphic_2d/native_effect/effect_filter.h
new file mode 100644
index 0000000000000000000000000000000000000000..66634293d3fe5159166d5af1b658f312db1d1f55
--- /dev/null
+++ b/graphic/graphic_2d/native_effect/effect_filter.h
@@ -0,0 +1,142 @@
+/*
+ * 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 Provides APIs for obtaining effect filter and information.
+ *
+ * @syscap SystemCapability.Multimedia.Image.Core
+ * @since 12
+ */
+
+/**
+ * @file effect_filter.h
+ *
+ * @brief Declares the APIs that can access a effect filter.
+ *
+ * @library libnative_effect.so
+ * @syscap SystemCapability.Multimedia.Image.Core
+ * @since 12
+ */
+
+#include "effect_types.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Creates an OH_Filter object.
+ *
+ * @syscap SystemCapability.Multimedia.Image.Core
+ * @param pixelmap The pixelmap pointer to create filter.
+ * @param filter The OH_Filter pointer will be operated.
+ * @return Returns {@link EffectErrorCode}.
+ * @since 12
+ * @version 1.0
+ */
+EffectErrorCode OH_Filter_CreateEffect(OH_PixelmapNative* pixelmap, OH_Filter** filter);
+
+/**
+ * @brief Release an OH_Filter object.
+ *
+ * @syscap SystemCapability.Multimedia.Image.Core
+ * @param filter The OH_Filter pointer will be operated.
+ * @return Returns {@link EffectErrorCode}
+ * @since 12
+ * @version 1.0
+ */
+EffectErrorCode OH_Filter_Release(OH_Filter* filter);
+
+/**
+ * @brief Creates a blur effect and then add to the filter.
+ *
+ * @syscap SystemCapability.Multimedia.Image.Core
+ * @param filter The OH_Filter pointer will be operated.
+ * @param radius The radius of the blur effect.
+ * @return Returns {@link EffectErrorCode}.
+ * @since 12
+ * @version 1.0
+ */
+EffectErrorCode OH_Filter_Blur(OH_Filter* filter, float radius);
+
+/**
+ * @brief Creates a brighten effect and then add to the filter.
+ *
+ * @syscap SystemCapability.Multimedia.Image.Core
+ * @param filter The OH_Filter pointer will be operated.
+ * @param brightness The brightness of the brighten effect.
+ * @return Returns {@link EffectErrorCode}.
+ * @since 12
+ * @version 1.0
+ */
+EffectErrorCode OH_Filter_Brighten(OH_Filter* filter, float brightness);
+
+/**
+ * @brief Creates a gray scale effect and then add to the filter.
+ *
+ * @syscap SystemCapability.Multimedia.Image.Core
+ * @param filter The OH_Filter pointer will be operated.
+ * @return Returns {@link EffectErrorCode}.
+ * @since 12
+ * @version 1.0
+ */
+EffectErrorCode OH_Filter_GrayScale(OH_Filter* filter);
+
+/**
+ * @brief Creates a invert effect and then add to the filter.
+ *
+ * @syscap SystemCapability.Multimedia.Image.Core
+ * @param filter The OH_Filter pointer will be operated.
+ * @return Returns {@link EffectErrorCode}.
+ * @since 12
+ * @version 1.0
+ */
+EffectErrorCode OH_Filter_Invert(OH_Filter* filter);
+
+/**
+ * @brief Creates a effect with a matrix and then add to the filter.
+ *
+ * @syscap SystemCapability.Multimedia.Image.Core
+ * @param filter The OH_Filter pointer will be operated.
+ * @param matrix The {@link OH_Filter_ColorMatrix} pointer to create a custom effect.
+ * @return Returns {@link EffectErrorCode}.
+ * @since 12
+ * @version 1.0
+ */
+EffectErrorCode OH_Filter_SetColorMatrix(OH_Filter* filter, OH_Filter_ColorMatrix* matrix);
+
+/**
+ * @brief Get a pixelmap with the filter effect.
+ *
+ * @syscap SystemCapability.Multimedia.Image.Core
+ * @param filter The OH_Filter pointer will be operated.
+ * @param pixelmap The pixelmap pointer wiil be operated.
+ * @return Returns {@link EffectErrorCode}.
+ * @since 12
+ * @version 1.0
+ */
+EffectErrorCode OH_Filter_GetEffectPixelMap(OH_Filter* filter, OH_PixelmapNative** pixelmap);
+
+#ifdef __cplusplus
+}
+#endif
+
+/** @} */
+#endif
\ No newline at end of file
diff --git a/graphic/graphic_2d/native_effect/effect_types.h b/graphic/graphic_2d/native_effect/effect_types.h
new file mode 100644
index 0000000000000000000000000000000000000000..e73052533dd4159b8d0b5a2af0fe24ff1823a883
--- /dev/null
+++ b/graphic/graphic_2d/native_effect/effect_types.h
@@ -0,0 +1,94 @@
+/*
+ * 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 Provides APIs for obtaining effect filter and information.
+ *
+ * @syscap SystemCapability.Multimedia.Image.Core
+ * @since 12
+ */
+
+/**
+ * @file effect_types.h
+ *
+ * @brief Declares the data types for effect filter.
+ *
+ * @library libnative_effect.so
+ * @syscap SystemCapability.Multimedia.Image.Core
+ * @since 12
+ */
+
+#include
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Defines a effect filter.
+ *
+ * @since 12
+ * @version 1.0
+ */
+typedef struct OH_Filter OH_Filter;
+
+/**
+ * @brief Defines a pixelmap.
+ *
+ * @since 12
+ * @version 1.0
+ */
+typedef struct OH_PixelmapNative OH_PixelmapNative;
+
+/**
+ * @brief Defines a matrix for create effect filter.
+ *
+ * @since 12
+ * @version 1.0
+ */
+struct OH_Filter_ColorMatrix {
+ /** val mast be 5*4 */
+ float val[20];
+};
+
+/**
+ * @brief Defines a effect filter error code.
+ *
+ * @since 12
+ * @version 1.0
+ */
+typedef enum {
+ /** success */
+ EFFECT_SUCCESS = 0,
+ /** invalid parameter */
+ EFFECT_BAD_PARAMETER = 401,
+ /** unsupported operations */
+ EFFECT_UNSUPPORTED_OPERATION = 7600201,
+ /** unknown error */
+ EFFECT_UNKNOWN_ERROR = 7600901,
+} EffectErrorCode;
+
+#ifdef __cplusplus
+}
+#endif
+/** @} */
+#endif
\ No newline at end of file
diff --git a/graphic/graphic_2d/native_effect/libnative_effect.ndk.json b/graphic/graphic_2d/native_effect/libnative_effect.ndk.json
new file mode 100644
index 0000000000000000000000000000000000000000..83a34f0a782411e09fdb9a8c930070d29465e94c
--- /dev/null
+++ b/graphic/graphic_2d/native_effect/libnative_effect.ndk.json
@@ -0,0 +1,10 @@
+[
+ { "name": "OH_Filter_CreateEffect" },
+ { "name": "OH_Filter_Release" },
+ { "name": "OH_Filter_Blur" },
+ { "name": "OH_Filter_Brighten" },
+ { "name": "OH_Filter_GrayScale" },
+ { "name": "OH_Filter_Invert" },
+ { "name": "OH_Filter_SetColorMatrix" },
+ { "name": "OH_Filter_GetEffectPixelMap" }
+]
\ No newline at end of file
diff --git a/multimedia/image_framework/include/image/pixelmap_native.h b/multimedia/image_framework/include/image/pixelmap_native.h
index 5f176d8215926e024cc745955f917f877d2b97ed..8b763da24375134506f8c2f3b09bb028a9c77afc 100644
--- a/multimedia/image_framework/include/image/pixelmap_native.h
+++ b/multimedia/image_framework/include/image/pixelmap_native.h
@@ -67,6 +67,10 @@ typedef enum {
* Premultiplied format
*/
PIXELMAP_ALPHA_TYPE_PREMULTIPLIED = 2,
+ /*
+ * Unpremultiplied format
+ */
+ PIXELMAP_ALPHA_TYPE_UNPREMULTIPLIED = 3,
}PIXELMAP_ALPHA_TYPE;
typedef enum {
@@ -191,6 +195,28 @@ Image_ErrorCode OH_PixelmapInitializationOptions_GetPixelFormat(OH_Pixelmap_Init
Image_ErrorCode OH_PixelmapInitializationOptions_SetPixelFormat(OH_Pixelmap_InitializationOptions *options,
int32_t pixelFormat);
+/**
+ * @brief Get pixelFormat number for InitializationOtions struct.
+ *
+ * @param options The InitializationOtions pointer will be operated.
+ * @param srcpixelFormat the number of image srcpixelFormat.
+ * @return Returns {@link Image_ErrorCode}
+ * @since 12
+ */
+Image_ErrorCode OH_PixelmapInitializationOptions_GetSrcPixelFormat(OH_Pixelmap_InitializationOptions *options,
+ int32_t *srcpixelFormat);
+
+/**
+ * @brief Set pixelFormat number for InitializationOtions struct.
+ *
+ * @param options The InitializationOtions pointer will be operated.
+ * @param srcpixelFormat the number of image srcpixelFormat.
+ * @return Returns {@link Image_ErrorCode}
+ * @since 12
+ */
+Image_ErrorCode OH_PixelmapInitializationOptions_SetSrcPixelFormat(OH_Pixelmap_InitializationOptions *options,
+ int32_t srcpixelFormat);
+
/**
* @brief Get alphaType number for InitializationOtions struct.
*
@@ -416,6 +442,28 @@ Image_ErrorCode OH_PixelmapNative_Crop(OH_PixelmapNative *pixelmap, Image_Region
*/
Image_ErrorCode OH_PixelmapNative_Release(OH_PixelmapNative *pixelmap);
+/**
+ * @brief Converting images to alpha format
+ *
+ * @param srcpixelmap The source pixel map pointer will be operated.
+ * @param dstpixelmap The destination pixel map pointer will be operated.
+ * @param isPremul Whether it is pre-multiplied, true for prediction, false for non-pre-multiplied.
+ * @return Returns {@link Image_ErrorCode}
+ * @since 12
+ */
+Image_ErrorCode OH_PixelmapNative_ConvertAlphaFormat(OH_PixelmapNative* srcpixelmap,
+ OH_PixelmapNative* dstpixelmap, const bool isPremul);
+
+/**
+ * @brief Create a empty PixelMap object.
+ *
+ * @param options IPixel properties, including the alpha type, size, pixel format, and editable.
+ * @param pixelmap Pixelmap pointer for created.
+ * @return Returns {@link Image_ErrorCode}
+ * @since 12
+ */
+Image_ErrorCode OH_PixelmapNative_CreateEmptyPixelmap(
+ OH_Pixelmap_InitializationOptions *options, OH_PixelmapNative **pixelmap);
#ifdef __cplusplus
};
diff --git a/multimedia/image_framework/libpixelmap.ndk.json b/multimedia/image_framework/libpixelmap.ndk.json
index c1c138185be864f8aa50f7d16654b9a88e060caa..811ff4dae0304f11d0f0a8883e144329d807e3ee 100644
--- a/multimedia/image_framework/libpixelmap.ndk.json
+++ b/multimedia/image_framework/libpixelmap.ndk.json
@@ -27,6 +27,14 @@
"first_introduced": "12",
"name": "OH_PixelmapInitializationOptions_SetPixelFormat"
},
+ {
+ "first_introduced": "12",
+ "name": "OH_PixelmapInitializationOptions_GetSrcPixelFormat"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_PixelmapInitializationOptions_SetSrcPixelFormat"
+ },
{
"first_introduced": "12",
"name": "OH_PixelmapInitializationOptions_GetAlphaType"
@@ -110,5 +118,13 @@
{
"first_introduced": "12",
"name": "OH_PixelmapNative_Release"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_PixelmapNative_ConvertAlphaFormat"
+ },
+ {
+ "first_introduced": "12",
+ "name": "OH_PixelmapNative_CreateEmptyPixelmap"
}
]
\ No newline at end of file