diff --git a/multimedia/image_framework/include/image/pixelmap_native.h b/multimedia/image_framework/include/image/pixelmap_native.h index fccadfd990a27688157db057e8cbf40443fdf4e4..a196d47132f8cefd0778429640afab738abda15f 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/include/image_pixel_map_mdk.h b/multimedia/image_framework/include/image_pixel_map_mdk.h index b5cf58c3a993432a666fd1cab7b7126e44b73723..9ae4c77386f5b0ed5452ae0c08352f5c4c4fab9c 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. * @@ -387,6 +412,40 @@ 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 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. + * 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 Scale + * @since 12 + * @version 1.0 + */ +int32_t OH_PixelMap_Scale_AntiAliasing(const NativePixelMap* native, float x, float y, + OH_PixelMap_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 64800fe826282f2c62c68ee354f432af18ea4fed..0338a55a094d77faa0f427d409ae88a8551a44d4 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_Scale_AntiAliasing" + }, { "name": "OH_PixelMap_Translate" }, diff --git a/multimedia/image_framework/libpixelmap.ndk.json b/multimedia/image_framework/libpixelmap.ndk.json index c2b1ca51855a39578a673daca166aa73395ac735..1538fdb307db2cf597af6d24c1ee4d10134b273d 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"