From 9672a4781f53dc582de3cb24609ba97008c39bdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E4=B9=94=E5=BC=82?= Date: Thu, 4 Jul 2024 16:44:02 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=B0=20Scale=20?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈乔异 --- .../include/image_pixel_map_mdk.h | 58 +++++++++++++++++++ .../libimage_pixelmap_napi.ndk.json | 3 + 2 files changed, 61 insertions(+) diff --git a/multimedia/image_framework/include/image_pixel_map_mdk.h b/multimedia/image_framework/include/image_pixel_map_mdk.h index b5cf58c3a..e4d2eb30c 100644 --- a/multimedia/image_framework/include/image_pixel_map_mdk.h +++ b/multimedia/image_framework/include/image_pixel_map_mdk.h @@ -117,6 +117,31 @@ enum { OHOS_PIXEL_MAP_EDITABLE = 1, }; +/** + * @brief Enumerates the anti-aliasing options. + * + * @since 12 + * @version 1.0 + */ +typedef enum { + /** + * Nearest-neighbor interpolation. + */ + OHOS_ANTI_ALIASING_NONE = 0, + /** + * Bilinear interpolation, without mipmap linear filtering. + */ + OHOS_ANTI_ALIASING_LOW = 1, + /** + * Bilinear interpolation, with mipmap linear filtering. + */ + OHOS_ANTI_ALIASING_MEDIUM = 2, + /** + * Cubic interpolation. + */ + OHOS_ANTI_ALIASING_HIGH = 3, +} OHOS_ANTI_ALIASING_OPTION; + /** * @brief Defines the options used for creating a pixel map. * @@ -387,6 +412,39 @@ int32_t OH_PixelMap_SetOpacity(const NativePixelMap* native, float opacity); */ int32_t OH_PixelMap_Scale(const NativePixelMap* native, float x, float y); +/** + * @brief Scales a PixelMap object with anti-aliasing. + * + * @param native Indicates the pointer to a NativePixelMap object. + * @param x Indicates the scaling ratio of the width. + * @param y Indicates the scaling ratio of the height. + * @param antiAliasing Indicates the anti-aliasing method used for the scaling. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_GET_DATA_ABNORMAL - if image get data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DECODE_FAILED - if decode fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CHECK_FORMAT_ERROR - if check format failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_THIRDPART_SKIA_ERROR - if skia error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_ABNORMAL - if image input data error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_NOT_EXIST - if sharememory error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ERR_SHAMEM_DATA_ABNORMAL - if sharememory data abnormal. + * returns {@link IRNdkErrCode} IMAGE_RESULT_MALLOC_ABNORMAL - if image malloc error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_DATA_UNSUPPORT - if image init error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_CROP - if crop error. + * returns {@link IRNdkErrCode} IMAGE_RESULT_UNKNOWN_FORMAT - if image unknown format. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_REGISTER_FAILED - if register plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_PLUGIN_CREATE_FAILED - if create plugin fail. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ALPHA_TYPE_ERROR - if hard decode failed. + * returns {@link IRNdkErrCode} IMAGE_RESULT_ALLOCATER_TYPE_ERROR - if hard decode failed. + * @see SmoothScale + * @since 12 + * @version 1.0 + */ +int32_t OH_PixelMap_SmoothScale(const NativePixelMap* native, float x, float y, OHOS_ANTI_ALIASING_OPTION antiAliasing); + /** * @brief Translates a PixelMap object. * diff --git a/multimedia/image_framework/libimage_pixelmap_napi.ndk.json b/multimedia/image_framework/libimage_pixelmap_napi.ndk.json index 64800fe82..a5c65ce4d 100644 --- a/multimedia/image_framework/libimage_pixelmap_napi.ndk.json +++ b/multimedia/image_framework/libimage_pixelmap_napi.ndk.json @@ -42,6 +42,9 @@ { "name": "OH_PixelMap_Scale" }, + { + "name": "OH_PixelMap_SmoothScale" + }, { "name": "OH_PixelMap_Translate" }, -- Gitee From f23e1c34ef12ce681af2ab234706c7eb66843eef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E4=B9=94=E5=BC=82?= Date: Fri, 5 Jul 2024 10:24:25 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈乔异 --- .../include/image_pixel_map_mdk.h | 17 +++++++++-------- .../libimage_pixelmap_napi.ndk.json | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/multimedia/image_framework/include/image_pixel_map_mdk.h b/multimedia/image_framework/include/image_pixel_map_mdk.h index e4d2eb30c..0e09e54fd 100644 --- a/multimedia/image_framework/include/image_pixel_map_mdk.h +++ b/multimedia/image_framework/include/image_pixel_map_mdk.h @@ -127,20 +127,20 @@ typedef enum { /** * Nearest-neighbor interpolation. */ - OHOS_ANTI_ALIASING_NONE = 0, + OH_PixelmapNative_AntiAliasingOption_NONE = 0, /** * Bilinear interpolation, without mipmap linear filtering. */ - OHOS_ANTI_ALIASING_LOW = 1, + OH_PixelmapNative_AntiAliasingOption_LOW = 1, /** * Bilinear interpolation, with mipmap linear filtering. */ - OHOS_ANTI_ALIASING_MEDIUM = 2, + OH_PixelmapNative_AntiAliasingOption_MEDIUM = 2, /** * Cubic interpolation. */ - OHOS_ANTI_ALIASING_HIGH = 3, -} OHOS_ANTI_ALIASING_OPTION; + OH_PixelmapNative_AntiAliasingOption_HIGH = 3, +} OH_PixelmapNative_AntiAliasingOption; /** * @brief Defines the options used for creating a pixel map. @@ -418,7 +418,7 @@ int32_t OH_PixelMap_Scale(const NativePixelMap* native, float x, float y); * @param native Indicates the pointer to a NativePixelMap object. * @param x Indicates the scaling ratio of the width. * @param y Indicates the scaling ratio of the height. - * @param antiAliasing Indicates the anti-aliasing method used for the scaling. + * @param opts Indicates the anti-aliasing algorithm to be used. * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. @@ -439,11 +439,12 @@ int32_t OH_PixelMap_Scale(const NativePixelMap* native, float x, float y); * returns {@link IRNdkErrCode} IMAGE_RESULT_INDEX_INVALID - if invalid index. * returns {@link IRNdkErrCode} IMAGE_RESULT_ALPHA_TYPE_ERROR - if hard decode failed. * returns {@link IRNdkErrCode} IMAGE_RESULT_ALLOCATER_TYPE_ERROR - if hard decode failed. - * @see SmoothScale + * @see Scale * @since 12 * @version 1.0 */ -int32_t OH_PixelMap_SmoothScale(const NativePixelMap* native, float x, float y, OHOS_ANTI_ALIASING_OPTION antiAliasing); +int32_t OH_PixelMap_Scale_AntiAliasing(const NativePixelMap* native, float x, float y, + OH_PixelmapNative_AntiAliasingOption opts); /** * @brief Translates a PixelMap object. diff --git a/multimedia/image_framework/libimage_pixelmap_napi.ndk.json b/multimedia/image_framework/libimage_pixelmap_napi.ndk.json index a5c65ce4d..0338a55a0 100644 --- a/multimedia/image_framework/libimage_pixelmap_napi.ndk.json +++ b/multimedia/image_framework/libimage_pixelmap_napi.ndk.json @@ -43,7 +43,7 @@ "name": "OH_PixelMap_Scale" }, { - "name": "OH_PixelMap_SmoothScale" + "name": "OH_PixelMap_Scale_AntiAliasing" }, { "name": "OH_PixelMap_Translate" -- Gitee From 6f07c86176b663883ad7b448642343fb3d84795c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E4=B9=94=E5=BC=82?= Date: Fri, 5 Jul 2024 11:54:01 +0800 Subject: [PATCH 3/5] =?UTF-8?q?NDK=20=E6=96=B0=E6=8E=A5=E5=8F=A3=E6=8E=A5?= =?UTF-8?q?=E5=85=A5=20Scale=20=E6=8A=97=E9=94=AF=E9=BD=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈乔异 --- .../include/image/pixelmap_native.h | 38 +++++++++++++++++++ .../image_framework/libpixelmap.ndk.json | 4 ++ 2 files changed, 42 insertions(+) diff --git a/multimedia/image_framework/include/image/pixelmap_native.h b/multimedia/image_framework/include/image/pixelmap_native.h index fccadfd99..a196d4713 100644 --- a/multimedia/image_framework/include/image/pixelmap_native.h +++ b/multimedia/image_framework/include/image/pixelmap_native.h @@ -112,6 +112,30 @@ typedef enum { PIXEL_FORMAT_NV12 = 9, } PIXEL_FORMAT; +/** + * @brief Defines the anti-aliasing options. + * + * @since 12 + */ +typedef enum { + /** + * Nearest-neighbor interpolation algorithm + */ + OH_PixelmapNative_AntiAliasingOption_NONE = 0, + /** + * Bilinear interpolation algorithm + */ + OH_PixelmapNative_AntiAliasingOption_LOW = 1, + /** + * Bilinear interpolation algorithm with mipmap linear filtering + */ + OH_PixelmapNative_AntiAliasingOption_MEDIUM = 2, + /** + * Cubic interpolation algorithm + */ + OH_PixelmapNative_AntiAliasingOption_HIGH = 3, +} OH_PixelmapNative_AntiAliasingOption; + /** * @brief Defines the options used for creating a pixel map. * @@ -413,6 +437,20 @@ Image_ErrorCode OH_PixelmapNative_Opacity(OH_PixelmapNative *pixelmap, float rat */ Image_ErrorCode OH_PixelmapNative_Scale(OH_PixelmapNative *pixelmap, float scaleX, float scaleY); +/** + * @brief Scales this image based on the input width and height with anti-aliasing. + * + * @param pixelmap The Pixelmap pointer will be operated. + * @param scaleX Scaling ratio of the width. + * @param scaleY Scaling ratio of the height. + * @param opts The anti-aliasing algorithm to be used. + * @return Returns {@link Image_ErrorCode} + * @see OH_PixelmapNative + * @since 12 + */ +Image_ErrorCode OH_PixelmapNative_Scale_AntiAliasing(OH_PixelmapNative *pixelmap, float scaleX, float scaleY, + OH_PixelmapNative_AntiAliasingOption *opts); + /** * @brief Translates this image based on the input coordinates. * diff --git a/multimedia/image_framework/libpixelmap.ndk.json b/multimedia/image_framework/libpixelmap.ndk.json index c2b1ca518..1538fdb30 100644 --- a/multimedia/image_framework/libpixelmap.ndk.json +++ b/multimedia/image_framework/libpixelmap.ndk.json @@ -107,6 +107,10 @@ "first_introduced": "12", "name": "OH_PixelmapNative_Scale" }, + { + "first_introduced": "12", + "name": "OH_PixelmapNative_Scale_AntiAliasing" + }, { "first_introduced": "12", "name": "OH_PixelmapNative_Translate" -- Gitee From 1b3dfaa16042167e2a62c4dea8a4571eaae82a2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E4=B9=94=E5=BC=82?= Date: Fri, 5 Jul 2024 14:40:44 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=87=8D=E5=AE=9A?= =?UTF-8?q?=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈乔异 --- .../include/image_pixel_map_mdk.h | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/multimedia/image_framework/include/image_pixel_map_mdk.h b/multimedia/image_framework/include/image_pixel_map_mdk.h index 0e09e54fd..834f52872 100644 --- a/multimedia/image_framework/include/image_pixel_map_mdk.h +++ b/multimedia/image_framework/include/image_pixel_map_mdk.h @@ -117,31 +117,6 @@ enum { OHOS_PIXEL_MAP_EDITABLE = 1, }; -/** - * @brief Enumerates the anti-aliasing options. - * - * @since 12 - * @version 1.0 - */ -typedef enum { - /** - * Nearest-neighbor interpolation. - */ - OH_PixelmapNative_AntiAliasingOption_NONE = 0, - /** - * Bilinear interpolation, without mipmap linear filtering. - */ - OH_PixelmapNative_AntiAliasingOption_LOW = 1, - /** - * Bilinear interpolation, with mipmap linear filtering. - */ - OH_PixelmapNative_AntiAliasingOption_MEDIUM = 2, - /** - * Cubic interpolation. - */ - OH_PixelmapNative_AntiAliasingOption_HIGH = 3, -} OH_PixelmapNative_AntiAliasingOption; - /** * @brief Defines the options used for creating a pixel map. * -- Gitee From ec929f4f8bf8983e19ed12ef8a4973c631f71371 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E4=B9=94=E5=BC=82?= Date: Fri, 5 Jul 2024 16:03:41 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈乔异 --- .../include/image_pixel_map_mdk.h | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/multimedia/image_framework/include/image_pixel_map_mdk.h b/multimedia/image_framework/include/image_pixel_map_mdk.h index 834f52872..9ae4c7738 100644 --- a/multimedia/image_framework/include/image_pixel_map_mdk.h +++ b/multimedia/image_framework/include/image_pixel_map_mdk.h @@ -117,6 +117,31 @@ enum { OHOS_PIXEL_MAP_EDITABLE = 1, }; +/** + * @brief Enumerates the anti-aliasing options. + * + * @since 12 + * @version 1.0 + */ +typedef enum { + /** + * Nearest-neighbor interpolation. + */ + OH_PixelMap_AntiAliasingOption_NONE = 0, + /** + * Bilinear interpolation, without mipmap linear filtering. + */ + OH_PixelMap_AntiAliasingOption_LOW = 1, + /** + * Bilinear interpolation, with mipmap linear filtering. + */ + OH_PixelMap_AntiAliasingOption_MEDIUM = 2, + /** + * Cubic interpolation. + */ + OH_PixelMap_AntiAliasingOption_HIGH = 3, +} OH_PixelMap_AntiAliasingOption; + /** * @brief Defines the options used for creating a pixel map. * @@ -419,7 +444,7 @@ int32_t OH_PixelMap_Scale(const NativePixelMap* native, float x, float y); * @version 1.0 */ int32_t OH_PixelMap_Scale_AntiAliasing(const NativePixelMap* native, float x, float y, - OH_PixelmapNative_AntiAliasingOption opts); + OH_PixelMap_AntiAliasingOption* opts); /** * @brief Translates a PixelMap object. -- Gitee