From 5c7788f664875e0abca378ebb0403b052b3837a2 Mon Sep 17 00:00:00 2001 From: caochuan Date: Fri, 27 Dec 2024 11:22:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E7=89=87=E6=A1=86=E6=9E=B6=E6=96=B0?= =?UTF-8?q?=E5=A2=9ECreateThumbnail=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: caochuan Change-Id: I9621883398a6664ec853fae45b4c210a89d9b863 --- .../include/image/image_source_native.h | 98 +++++++++++++++++++ .../include/image/picture_native.h | 5 + .../image_framework/libimage_source.ndk.json | 28 ++++++ 3 files changed, 131 insertions(+) diff --git a/multimedia/image_framework/include/image/image_source_native.h b/multimedia/image_framework/include/image/image_source_native.h index 7e54b94ef5f..fbcccf0cb2d 100644 --- a/multimedia/image_framework/include/image/image_source_native.h +++ b/multimedia/image_framework/include/image/image_source_native.h @@ -394,6 +394,104 @@ Image_ErrorCode OH_ImageSourceNative_CreatePixelmapList(OH_ImageSourceNative *so Image_ErrorCode OH_ImageSourceNative_CreatePicture(OH_ImageSourceNative *source, OH_DecodingOptionsForPicture *options, OH_PictureNative **picture); +/** + * @brief Defines the options for decoding the thumbnail. + * It is used in {@link OH_ImageSourceNative_CreateThumbnail}. + * + * @since 18 + */ +struct OH_DecodingOptionsForThumbnail; +typedef struct OH_DecodingOptionsForThumbnail OH_DecodingOptionsForThumbnail; + +/** + * @brief Create a pointer for DecodingOptionsForThumbnail struct. + * + * @param options The DecodingOptionsForThumbnail pointer will be operated. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options is nullptr. + * @since 18 + */ +Image_ErrorCode OH_DecodingOptionsForThumbnail_Create(OH_DecodingOptionsForThumbnail **options); + +/** + * @brief Get desiredSize number for DecodingOptionsForThumbnail struct. + * + * @param options The DecodingOptionsForThumbnail pointer will be operated. + * @param desiredSize The number of image desiredSize. + * @return Returns {@link Image_ErrorCode} + * @since 18 + */ +Image_ErrorCode OH_DecodingOptionsForThumbnail_GetDesiredSize(OH_DecodingOptionsForThumbnail *options, + Image_Size *desiredSize); + +/** + * @brief Set desiredSize number for DecodingOptionsForThumbnail struct. + * + * @param options The DecodingOptionsForThumbnail pointer will be operated. + * @param desiredSize The number of image desiredSize. + * @return Returns {@link Image_ErrorCode} + * @since 18 + */ +Image_ErrorCode OH_DecodingOptionsForThumbnail_SetDesiredSize(OH_DecodingOptionsForThumbnail *options, + Image_Size *desiredSize); + +/** + * @brief Get needGenerate number for DecodingOptionsForThumbnail struct. + * + * @param options The DecodingOptionsForThumbnail pointer will be operated. + * @param needGenerate Whether the thumbnail should be generated, if the image does not have a thumbnail. + * Default is false. + * @return Returns {@link Image_ErrorCode} + * @since 18 + */ +Image_ErrorCode OH_DecodingOptionsForThumbnail_GetNeedGenerate(OH_DecodingOptionsForThumbnail *options, + bool *needGenerate); + +/** + * @brief Set needGenerate number for DecodingOptionsForThumbnail struct. + * + * @param options The DecodingOptionsForThumbnail pointer will be operated. + * @param needGenerate Whether the thumbnail should be generated, if the image does not have a thumbnail. + * Default is false. + * @return Returns {@link Image_ErrorCode} + * @since 18 + */ +Image_ErrorCode OH_DecodingOptionsForThumbnail_SetNeedGenerate(OH_DecodingOptionsForThumbnail *options, + bool *needGenerate); + +/** + * @brief Delete DecodingOptionsForThumbnail pointer. + * + * @param options The DecodingOptionsForThumbnail pointer will be operated. + * @return Returns {@link Image_ErrorCode} + * @since 18 + */ +Image_ErrorCode OH_DecodingOptionsForThumbnail_Release(OH_DecodingOptionsForThumbnail *options); + +/** + * @brief Create Thumbnail pointer from ImageSource + * based on the specified {@link OH_DecodingOptionsForThumbnail} struct. + * + * @param source Indicates a void pointer(from ImageSource pointer convert). + * @param options Indicates a pointer to the options for decoding the image source. + * For details, see {@link OH_DecodingOptionsForThumbnail}. + * @param pixelmap Indicates a void pointer to the Thumbnail Pixelmap object obtained at the C++ native layer. + * @return Error code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} source is nullptr, or picture is nullptr. + * {@link IMAGE_BAD_SOURCE} data source exception. + * {@link IMAGE_SOURCE_UNSUPPORTED_MIMETYPE} unsupported mime type. + * {@link IMAGE_SOURCE_TOO_LARGE} image to large. + * {@link IMAGE_SOURCE_UNSUPPORTED_OPTIONS} unsupported options, + * e.g, cannot convert image into desired pixel format. + * {@link IMAGE_DECODE_FAILED} decode failed. + * {@link IMAGE_SOURCE_ALLOC_FAILED} memory allocation failed. + * @since 18 + */ +Image_ErrorCode OH_ImageSourceNative_CreateThumbnail(OH_ImageSourceNative *source, + OH_DecodingOptionsForThumbnail *options, OH_PixelmapNative **pixelmap); + /** * @brief Obtains the delay time list from some ImageSource objects (such as GIF image sources). * diff --git a/multimedia/image_framework/include/image/picture_native.h b/multimedia/image_framework/include/image/picture_native.h index 42eed506532..c0b4fb438b6 100644 --- a/multimedia/image_framework/include/image/picture_native.h +++ b/multimedia/image_framework/include/image/picture_native.h @@ -114,6 +114,11 @@ typedef enum { * Fragment map */ AUXILIARY_PICTURE_TYPE_FRAGMENT_MAP = 5, + /* + * Thumbnail + * @since 18 + */ + AUXILIARY_PICTURE_TYPE_THUMBNAIL = 6, } Image_AuxiliaryPictureType; /** diff --git a/multimedia/image_framework/libimage_source.ndk.json b/multimedia/image_framework/libimage_source.ndk.json index 37312763efb..975fcbc5e81 100644 --- a/multimedia/image_framework/libimage_source.ndk.json +++ b/multimedia/image_framework/libimage_source.ndk.json @@ -103,6 +103,34 @@ "first_introduced": "13", "name": "OH_ImageSourceNative_CreatePicture" }, + { + "first_introduced": "18", + "name": "OH_DecodingOptionsForThumbnail_Create" + }, + { + "first_introduced": "18", + "name": "OH_DecodingOptionsForThumbnail_GetDesiredSize" + }, + { + "first_introduced": "18", + "name": "OH_DecodingOptionsForThumbnail_SetDesiredSize" + }, + { + "first_introduced": "18", + "name": "OH_DecodingOptionsForThumbnail_GetNeedGenerate" + }, + { + "first_introduced": "18", + "name": "OH_DecodingOptionsForThumbnail_SetNeedGenerate" + }, + { + "first_introduced": "18", + "name": "OH_DecodingOptionsForThumbnail_Release" + }, + { + "first_introduced": "18", + "name": "OH_ImageSourceNative_CreateThumbnail" + }, { "first_introduced": "12", "name": "OH_ImageSourceNative_GetDelayTimeList" -- Gitee