From b4f1e9e43352a8fa9e0c90c638e8fe83a32810a6 Mon Sep 17 00:00:00 2001 From: Cao Chuan Date: Tue, 17 Oct 2023 16:37:11 +0800 Subject: [PATCH 01/10] Add image packer ndk feature Signed-off-by: Cao Chuan --- multimedia/image_framework/BUILD.gn | 11 ++ .../include/image_packer_mdk.h | 155 ++++++++++++++++++ .../libimage_packer_ndk.ndk.json | 18 ++ 3 files changed, 184 insertions(+) create mode 100644 multimedia/image_framework/include/image_packer_mdk.h create mode 100644 multimedia/image_framework/libimage_packer_ndk.ndk.json diff --git a/multimedia/image_framework/BUILD.gn b/multimedia/image_framework/BUILD.gn index 833b5fb7326..51b89e0cd0a 100644 --- a/multimedia/image_framework/BUILD.gn +++ b/multimedia/image_framework/BUILD.gn @@ -62,3 +62,14 @@ ohos_ndk_headers("image_source_ndk_header") { dest_dir = "$ndk_headers_out_dir/multimedia/image_framework" sources = [ "./include/image_source_mdk.h" ] } + +ohos_ndk_library("libimage_packer_ndk") { + ndk_description_file = "./libimage_packer_ndk.ndk.json" + min_compact_version = "1" + output_name = "image_packer_ndk" +} + +ohos_ndk_headers("image_packer_ndk_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/image_framework" + sources = [ "./include/image_packer_mdk.h" ] +} diff --git a/multimedia/image_framework/include/image_packer_mdk.h b/multimedia/image_framework/include/image_packer_mdk.h new file mode 100644 index 00000000000..3596a1d0e9d --- /dev/null +++ b/multimedia/image_framework/include/image_packer_mdk.h @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2023 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. + */ + +/** + * @addtogroup image + * @{ + * + * @brief Provides native APIs for encoding image data + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 5.0 + */ + +/** + * @file image_packer_mdk.h + * + * @brief Declares APIs for encoding image data into buffer or file. + * Need link libimage_packerndk.z.so + * + * @since 10 + * @version 5.0 + */ + +#ifndef INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PACKER_MDK_H_ +#define INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PACKER_MDK_H_ +#include "napi/native_api.h" +#include "image_mdk_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct ImagePackerNative_; + +/** + * @brief Defines an image packer object at the native layer for the image packer interface. + * + * @since 10 + * @version 5.0 + */ +typedef struct ImagePackerNative_ ImagePackerNative; + +/** + * @brief Defines the image packing options. + * + * @since 10 + * @version 5.0 + */ +struct OhosImagePackerOpts { + /** Encoding format. */ + const char* format; + /** Encoding quality. */ + int quality; + /** Encoding source, a JS pixel map object or a JS image source object. */ + napi_value source; +}; + +/** + * @brief Creates an ImagePacker object at the JavaScript native layer. + * + * @param env Indicates a pointer to the JavaScript Native Interface (JNI) environment. + * @param res Indicates a pointer to the ImagePacker object created at the JavaScript native layer. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal NAPI environment. + * @see {@link ImagePackerNative} + * + * @Syscap SystemCapability.Multimedia.Image + * @since 10 + * @version 5.0 + */ +int32_t OH_ImagePacker_Create(napi_env env, napi_value *res); + +/** + * @brief Parses an {@link ImagePackerNative} object at the native layer + * from a JavaScript native API ImagePacker object. + * + * @param env Indicates the pointer to the JavaScript Native Interface (JNI) environment. + * @param packer Indicates a JavaScript native API ImagePacker object. + * @return Returns an {@link ImagePackerNative} pointer object if the operation is successful + * returns a null pointer otherwise. + * @see ImagePackerNative, OH_ImagePacker_Release + * @since 10 + * @version 5.0 + */ +ImagePackerNative* OH_ImagePacker_InitNative(napi_env env, napi_value packer); + +/** + * @brief Encoding an ImageSource or a PixelMap into the buffer with required format + * + * @param native Indicates the pointer to an {@link ImagePacker} object at the native layer. + * @param opts Indicates the encoding {@link OhosImagePackerOpts} . + * @param outBuffer Indicates the pointer to the encoded data. + * @param size Indicates the pointer to the {@link OhosImageComponent} object obtained. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * 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_BAD_PARAMETER - if bad parameter. + * @see ImageNative, OhosImageComponent + * @since 10 + * @version 5.0 + */ +int32_t OH_ImagePacker_Packing(ImagePackerNative* native, struct OhosImagePackerOpts* opts, + uint8_t* outBuffer, size_t* size); + +/** + * @brief Encoding an ImageSource or a PixelMap into the a file with fd with required format + * + * @param native Indicates the pointer to an {@link ImagePacker} object at the native layer. + * @param opts Indicates the encoding {@link OhosImagePackerOpts} . + * @param fd Indicates the a writable file descriptor. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * 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_BAD_PARAMETER - if bad parameter. + * @see ImageNative, OhosImageComponent + * @since 10 + * @version 5.0 + */ +int32_t OH_ImagePacker_PackingToFile(ImagePackerNative* native, struct OhosImagePackerOpts* opts, int fd); + + +/** + * @brief Releases an {@link ImagePackerNative} object at the native layer. + * Note: This API is not used to release a JavaScript native API ImagePacker object. + * It is used to release the object {@link ImagePackerNative} at the native layer + * parsed by calling {@link OH_ImagePacker_InitNative}. + * + * @param native Indicates the pointer to an {@link ImageNative} object at the native layer. + * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. + * 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_BAD_PARAMETER - if bad parameter. + * @see ImageNative, OH_Image_InitImageNative + * @since 10 + * @version 5.0 + */ +int32_t OH_ImagePacker_Release(ImagePackerNative* native); +#ifdef __cplusplus +}; +#endif +/** @} */ +#endif // INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PACKER_MDK_H_ diff --git a/multimedia/image_framework/libimage_packer_ndk.ndk.json b/multimedia/image_framework/libimage_packer_ndk.ndk.json new file mode 100644 index 00000000000..c8d242a205a --- /dev/null +++ b/multimedia/image_framework/libimage_packer_ndk.ndk.json @@ -0,0 +1,18 @@ +[ + { + "first_introduced": "1", + "name": "OH_ImagePacker_Create" + }, + { + "name": "OH_ImagePacker_InitNative" + }, + { + "name": "OH_ImagePacker_Packing" + }, + { + "name": "OH_ImagePacker_PackingToFile" + }, + { + "name": "OH_ImagePacker_Release" + } +] \ No newline at end of file -- Gitee From d0f4b317199b080ea5de581e02f40fca4a371529 Mon Sep 17 00:00:00 2001 From: Cao Chuan Date: Wed, 18 Oct 2023 21:08:30 +0800 Subject: [PATCH 02/10] Fix for api review recommend Signed-off-by: Cao Chuan --- multimedia/image_framework/include/image_packer_mdk.h | 11 ++++++----- .../image_framework/libimage_packer_ndk.ndk.json | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/multimedia/image_framework/include/image_packer_mdk.h b/multimedia/image_framework/include/image_packer_mdk.h index 3596a1d0e9d..2e7520c08e4 100644 --- a/multimedia/image_framework/include/image_packer_mdk.h +++ b/multimedia/image_framework/include/image_packer_mdk.h @@ -64,8 +64,6 @@ struct OhosImagePackerOpts { const char* format; /** Encoding quality. */ int quality; - /** Encoding source, a JS pixel map object or a JS image source object. */ - napi_value source; }; /** @@ -101,6 +99,7 @@ ImagePackerNative* OH_ImagePacker_InitNative(napi_env env, napi_value packer); * @brief Encoding an ImageSource or a PixelMap into the buffer with required format * * @param native Indicates the pointer to an {@link ImagePacker} object at the native layer. + * @param source Indicates an encoding source, a JS pixel map object or a JS image source object . * @param opts Indicates the encoding {@link OhosImagePackerOpts} . * @param outBuffer Indicates the pointer to the encoded data. * @param size Indicates the pointer to the {@link OhosImageComponent} object obtained. @@ -112,13 +111,14 @@ ImagePackerNative* OH_ImagePacker_InitNative(napi_env env, napi_value packer); * @since 10 * @version 5.0 */ -int32_t OH_ImagePacker_Packing(ImagePackerNative* native, struct OhosImagePackerOpts* opts, - uint8_t* outBuffer, size_t* size); +int32_t OH_ImagePacker_PackingToBuffer(ImagePackerNative* native, napi_value source, + struct OhosImagePackerOpts* opts, uint8_t* outBuffer, size_t* size); /** * @brief Encoding an ImageSource or a PixelMap into the a file with fd with required format * * @param native Indicates the pointer to an {@link ImagePacker} object at the native layer. + * @param source Indicates an encoding source, a JS pixel map object or a JS image source object . * @param opts Indicates the encoding {@link OhosImagePackerOpts} . * @param fd Indicates the a writable file descriptor. * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. @@ -129,7 +129,8 @@ int32_t OH_ImagePacker_Packing(ImagePackerNative* native, struct OhosImagePacker * @since 10 * @version 5.0 */ -int32_t OH_ImagePacker_PackingToFile(ImagePackerNative* native, struct OhosImagePackerOpts* opts, int fd); +int32_t OH_ImagePacker_PackingToFile(ImagePackerNative* native, napi_value source, + struct OhosImagePackerOpts* opts, int fd); /** diff --git a/multimedia/image_framework/libimage_packer_ndk.ndk.json b/multimedia/image_framework/libimage_packer_ndk.ndk.json index c8d242a205a..01d2734ddf0 100644 --- a/multimedia/image_framework/libimage_packer_ndk.ndk.json +++ b/multimedia/image_framework/libimage_packer_ndk.ndk.json @@ -7,7 +7,7 @@ "name": "OH_ImagePacker_InitNative" }, { - "name": "OH_ImagePacker_Packing" + "name": "OH_ImagePacker_PackingToBuffer" }, { "name": "OH_ImagePacker_PackingToFile" -- Gitee From 4b1c9865c031a5654eeae3268672ec8a32b17a85 Mon Sep 17 00:00:00 2001 From: Cao Chuan Date: Thu, 26 Oct 2023 17:48:00 +0800 Subject: [PATCH 03/10] Modify api name Signed-off-by: Cao Chuan --- multimedia/image_framework/include/image_packer_mdk.h | 4 ++-- multimedia/image_framework/libimage_packer_ndk.ndk.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/multimedia/image_framework/include/image_packer_mdk.h b/multimedia/image_framework/include/image_packer_mdk.h index 2e7520c08e4..8d190219497 100644 --- a/multimedia/image_framework/include/image_packer_mdk.h +++ b/multimedia/image_framework/include/image_packer_mdk.h @@ -111,7 +111,7 @@ ImagePackerNative* OH_ImagePacker_InitNative(napi_env env, napi_value packer); * @since 10 * @version 5.0 */ -int32_t OH_ImagePacker_PackingToBuffer(ImagePackerNative* native, napi_value source, +int32_t OH_ImagePacker_PackToBuffer(ImagePackerNative* native, napi_value source, struct OhosImagePackerOpts* opts, uint8_t* outBuffer, size_t* size); /** @@ -129,7 +129,7 @@ int32_t OH_ImagePacker_PackingToBuffer(ImagePackerNative* native, napi_value sou * @since 10 * @version 5.0 */ -int32_t OH_ImagePacker_PackingToFile(ImagePackerNative* native, napi_value source, +int32_t OH_ImagePacker_PackToFile(ImagePackerNative* native, napi_value source, struct OhosImagePackerOpts* opts, int fd); diff --git a/multimedia/image_framework/libimage_packer_ndk.ndk.json b/multimedia/image_framework/libimage_packer_ndk.ndk.json index 01d2734ddf0..814585e8ec5 100644 --- a/multimedia/image_framework/libimage_packer_ndk.ndk.json +++ b/multimedia/image_framework/libimage_packer_ndk.ndk.json @@ -7,10 +7,10 @@ "name": "OH_ImagePacker_InitNative" }, { - "name": "OH_ImagePacker_PackingToBuffer" + "name": "OH_ImagePacker_PackToBuffer" }, { - "name": "OH_ImagePacker_PackingToFile" + "name": "OH_ImagePacker_PackToFile" }, { "name": "OH_ImagePacker_Release" -- Gitee From 90ba2e58a38866876697ed882221638dabf35043 Mon Sep 17 00:00:00 2001 From: Cao Chuan Date: Fri, 3 Nov 2023 18:54:39 +0800 Subject: [PATCH 04/10] Modify api name changed and result codes Signed-off-by: Cao Chuan --- .../include/image_packer_mdk.h | 49 ++++++++++--------- .../libimage_packer_ndk.ndk.json | 2 +- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/multimedia/image_framework/include/image_packer_mdk.h b/multimedia/image_framework/include/image_packer_mdk.h index 8d190219497..530096e9acd 100644 --- a/multimedia/image_framework/include/image_packer_mdk.h +++ b/multimedia/image_framework/include/image_packer_mdk.h @@ -20,7 +20,7 @@ * @brief Provides native APIs for encoding image data * * @Syscap SystemCapability.Multimedia.Image - * @since 10 + * @since 11 * @version 5.0 */ @@ -30,7 +30,7 @@ * @brief Declares APIs for encoding image data into buffer or file. * Need link libimage_packerndk.z.so * - * @since 10 + * @since 11 * @version 5.0 */ @@ -48,7 +48,7 @@ struct ImagePackerNative_; /** * @brief Defines an image packer object at the native layer for the image packer interface. * - * @since 10 + * @since 11 * @version 5.0 */ typedef struct ImagePackerNative_ ImagePackerNative; @@ -56,7 +56,7 @@ typedef struct ImagePackerNative_ ImagePackerNative; /** * @brief Defines the image packing options. * - * @since 10 + * @since 11 * @version 5.0 */ struct OhosImagePackerOpts { @@ -72,11 +72,11 @@ struct OhosImagePackerOpts { * @param env Indicates a pointer to the JavaScript Native Interface (JNI) environment. * @param res Indicates a pointer to the ImagePacker object created at the JavaScript native layer. * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal NAPI environment. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. * @see {@link ImagePackerNative} * * @Syscap SystemCapability.Multimedia.Image - * @since 10 + * @since 11 * @version 5.0 */ int32_t OH_ImagePacker_Create(napi_env env, napi_value *res); @@ -90,29 +90,32 @@ int32_t OH_ImagePacker_Create(napi_env env, napi_value *res); * @return Returns an {@link ImagePackerNative} pointer object if the operation is successful * returns a null pointer otherwise. * @see ImagePackerNative, OH_ImagePacker_Release - * @since 10 + * @since 11 * @version 5.0 */ ImagePackerNative* OH_ImagePacker_InitNative(napi_env env, napi_value packer); /** - * @brief Encoding an ImageSource or a PixelMap into the buffer with required format + * @brief Encoding an ImageSource or a PixelMap into the data with required format * * @param native Indicates the pointer to an {@link ImagePacker} object at the native layer. * @param source Indicates an encoding source, a JS pixel map object or a JS image source object . * @param opts Indicates the encoding {@link OhosImagePackerOpts} . - * @param outBuffer Indicates the pointer to the encoded data. + * @param outData Indicates the pointer to the encoded data. * @param size Indicates the pointer to the {@link OhosImageComponent} object obtained. * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * 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_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} ERR_IMAGE_DATA_ABNORMAL - if output target abnormal + * returns {@link IRNdkErrCode} ERR_IMAGE_MISMATCHED_FORMAT - if format mismatched + * returns {@link IRNdkErrCode} ERR_IMAGE_MALLOC_ABNORMAL - if malloc internal buffer error + * returns {@link IRNdkErrCode} ERR_IMAGE_DECODE_ABNORMAL - if init codec internal error + * returns {@link IRNdkErrCode} ERR_IMAGE_ENCODE_FAILED - if encoder occur error during encoding * @see ImageNative, OhosImageComponent - * @since 10 + * @since 11 * @version 5.0 */ -int32_t OH_ImagePacker_PackToBuffer(ImagePackerNative* native, napi_value source, - struct OhosImagePackerOpts* opts, uint8_t* outBuffer, size_t* size); +int32_t OH_ImagePacker_PackToData(ImagePackerNative* native, napi_value source, + struct OhosImagePackerOpts* opts, uint8_t* outData, size_t* size); /** * @brief Encoding an ImageSource or a PixelMap into the a file with fd with required format @@ -122,11 +125,14 @@ int32_t OH_ImagePacker_PackToBuffer(ImagePackerNative* native, napi_value source * @param opts Indicates the encoding {@link OhosImagePackerOpts} . * @param fd Indicates the a writable file descriptor. * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * 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_BAD_PARAMETER - if bad parameter. + * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. + * returns {@link IRNdkErrCode} ERR_IMAGE_DATA_ABNORMAL - if output target abnormal + * returns {@link IRNdkErrCode} ERR_IMAGE_MISMATCHED_FORMAT - if format mismatched + * returns {@link IRNdkErrCode} ERR_IMAGE_MALLOC_ABNORMAL - if malloc internal buffer error + * returns {@link IRNdkErrCode} ERR_IMAGE_DECODE_ABNORMAL - if init codec internal error + * returns {@link IRNdkErrCode} ERR_IMAGE_ENCODE_FAILED - if encoder occur error during encoding * @see ImageNative, OhosImageComponent - * @since 10 + * @since 11 * @version 5.0 */ int32_t OH_ImagePacker_PackToFile(ImagePackerNative* native, napi_value source, @@ -141,11 +147,8 @@ int32_t OH_ImagePacker_PackToFile(ImagePackerNative* native, napi_value source, * * @param native Indicates the pointer to an {@link ImageNative} object at the native layer. * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * 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_BAD_PARAMETER - if bad parameter. * @see ImageNative, OH_Image_InitImageNative - * @since 10 + * @since 11 * @version 5.0 */ int32_t OH_ImagePacker_Release(ImagePackerNative* native); diff --git a/multimedia/image_framework/libimage_packer_ndk.ndk.json b/multimedia/image_framework/libimage_packer_ndk.ndk.json index 814585e8ec5..4879feac539 100644 --- a/multimedia/image_framework/libimage_packer_ndk.ndk.json +++ b/multimedia/image_framework/libimage_packer_ndk.ndk.json @@ -7,7 +7,7 @@ "name": "OH_ImagePacker_InitNative" }, { - "name": "OH_ImagePacker_PackToBuffer" + "name": "OH_ImagePacker_PackToData" }, { "name": "OH_ImagePacker_PackToFile" -- Gitee From 10368288215e90001bb4a1f1230c13187209f3a9 Mon Sep 17 00:00:00 2001 From: Cao Chuan Date: Tue, 7 Nov 2023 09:31:56 +0800 Subject: [PATCH 05/10] Fix for code review Signed-off-by: Cao Chuan --- multimedia/image_framework/BUILD.gn | 1 - .../include/image_packer_mdk.h | 20 +++++++++---------- .../libimage_packer_ndk.ndk.json | 1 - 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/multimedia/image_framework/BUILD.gn b/multimedia/image_framework/BUILD.gn index 51b89e0cd0a..22c7d1fb908 100644 --- a/multimedia/image_framework/BUILD.gn +++ b/multimedia/image_framework/BUILD.gn @@ -65,7 +65,6 @@ ohos_ndk_headers("image_source_ndk_header") { ohos_ndk_library("libimage_packer_ndk") { ndk_description_file = "./libimage_packer_ndk.ndk.json" - min_compact_version = "1" output_name = "image_packer_ndk" } diff --git a/multimedia/image_framework/include/image_packer_mdk.h b/multimedia/image_framework/include/image_packer_mdk.h index 530096e9acd..260d19dc452 100644 --- a/multimedia/image_framework/include/image_packer_mdk.h +++ b/multimedia/image_framework/include/image_packer_mdk.h @@ -21,17 +21,17 @@ * * @Syscap SystemCapability.Multimedia.Image * @since 11 - * @version 5.0 + * @version 4.1 */ /** * @file image_packer_mdk.h * - * @brief Declares APIs for encoding image data into buffer or file. + * @brief Declares APIs for encoding image data into data or file. * Need link libimage_packerndk.z.so * * @since 11 - * @version 5.0 + * @version 4.1 */ #ifndef INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PACKER_MDK_H_ @@ -49,7 +49,7 @@ struct ImagePackerNative_; * @brief Defines an image packer object at the native layer for the image packer interface. * * @since 11 - * @version 5.0 + * @version 4.1 */ typedef struct ImagePackerNative_ ImagePackerNative; @@ -57,7 +57,7 @@ typedef struct ImagePackerNative_ ImagePackerNative; * @brief Defines the image packing options. * * @since 11 - * @version 5.0 + * @version 4.1 */ struct OhosImagePackerOpts { /** Encoding format. */ @@ -77,7 +77,7 @@ struct OhosImagePackerOpts { * * @Syscap SystemCapability.Multimedia.Image * @since 11 - * @version 5.0 + * @version 4.1 */ int32_t OH_ImagePacker_Create(napi_env env, napi_value *res); @@ -91,7 +91,7 @@ int32_t OH_ImagePacker_Create(napi_env env, napi_value *res); * returns a null pointer otherwise. * @see ImagePackerNative, OH_ImagePacker_Release * @since 11 - * @version 5.0 + * @version 4.1 */ ImagePackerNative* OH_ImagePacker_InitNative(napi_env env, napi_value packer); @@ -112,7 +112,7 @@ ImagePackerNative* OH_ImagePacker_InitNative(napi_env env, napi_value packer); * returns {@link IRNdkErrCode} ERR_IMAGE_ENCODE_FAILED - if encoder occur error during encoding * @see ImageNative, OhosImageComponent * @since 11 - * @version 5.0 + * @version 4.1 */ int32_t OH_ImagePacker_PackToData(ImagePackerNative* native, napi_value source, struct OhosImagePackerOpts* opts, uint8_t* outData, size_t* size); @@ -133,7 +133,7 @@ int32_t OH_ImagePacker_PackToData(ImagePackerNative* native, napi_value source, * returns {@link IRNdkErrCode} ERR_IMAGE_ENCODE_FAILED - if encoder occur error during encoding * @see ImageNative, OhosImageComponent * @since 11 - * @version 5.0 + * @version 4.1 */ int32_t OH_ImagePacker_PackToFile(ImagePackerNative* native, napi_value source, struct OhosImagePackerOpts* opts, int fd); @@ -149,7 +149,7 @@ int32_t OH_ImagePacker_PackToFile(ImagePackerNative* native, napi_value source, * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. * @see ImageNative, OH_Image_InitImageNative * @since 11 - * @version 5.0 + * @version 4.1 */ int32_t OH_ImagePacker_Release(ImagePackerNative* native); #ifdef __cplusplus diff --git a/multimedia/image_framework/libimage_packer_ndk.ndk.json b/multimedia/image_framework/libimage_packer_ndk.ndk.json index 4879feac539..cb9b3173043 100644 --- a/multimedia/image_framework/libimage_packer_ndk.ndk.json +++ b/multimedia/image_framework/libimage_packer_ndk.ndk.json @@ -1,6 +1,5 @@ [ { - "first_introduced": "1", "name": "OH_ImagePacker_Create" }, { -- Gitee From 68902a7d11c98c3bec42bbd44584065f73e25bcd Mon Sep 17 00:00:00 2001 From: Cao Chuan Date: Tue, 7 Nov 2023 09:46:35 +0800 Subject: [PATCH 06/10] Fix for code review 2 Signed-off-by: Cao Chuan --- multimedia/image_framework/include/image_packer_mdk.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multimedia/image_framework/include/image_packer_mdk.h b/multimedia/image_framework/include/image_packer_mdk.h index 260d19dc452..69154558a54 100644 --- a/multimedia/image_framework/include/image_packer_mdk.h +++ b/multimedia/image_framework/include/image_packer_mdk.h @@ -27,7 +27,7 @@ /** * @file image_packer_mdk.h * - * @brief Declares APIs for encoding image data into data or file. + * @brief Declares APIs for encoding image into data or file. * Need link libimage_packerndk.z.so * * @since 11 -- Gitee From a1a82851e8cd2941d1ee71d139557dd3e868afa2 Mon Sep 17 00:00:00 2001 From: Cao Chuan Date: Tue, 7 Nov 2023 12:08:32 +0800 Subject: [PATCH 07/10] Adjusting annotations following with the docs native-template.md Signed-off-by: Cao Chuan --- .../include/image_packer_mdk.h | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/multimedia/image_framework/include/image_packer_mdk.h b/multimedia/image_framework/include/image_packer_mdk.h index 69154558a54..53eb122eda4 100644 --- a/multimedia/image_framework/include/image_packer_mdk.h +++ b/multimedia/image_framework/include/image_packer_mdk.h @@ -19,7 +19,9 @@ * * @brief Provides native APIs for encoding image data * - * @Syscap SystemCapability.Multimedia.Image + * The encoding image data module part of image module. + * It used to pack pixel data infomation into a target like data or file. + * * @since 11 * @version 4.1 */ @@ -28,8 +30,18 @@ * @file image_packer_mdk.h * * @brief Declares APIs for encoding image into data or file. - * Need link libimage_packerndk.z.so * + * The packing image data module used to pack pixel data into a target. + * + * The following steps are recommended for packing process: + * Create a image packer object by calling OH_ImagePacker_Create function. + * And then covert the image packer object to ImagePakcerNative by OH_ImagePacker_InitNative. + * Next using OH_ImagePacker_PackToData or OH_ImagePacker_PackToFile to pack source to target area with + * requird packing options. + * Finally, release the ImagePakcerNative by OH_ImagePacker_Release. + * + * @library libimage_packerndk.z.so + * @syscap SystemCapability.Multimedia.Image * @since 11 * @version 4.1 */ @@ -73,7 +85,6 @@ struct OhosImagePackerOpts { * @param res Indicates a pointer to the ImagePacker object created at the JavaScript native layer. * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. - * @see {@link ImagePackerNative} * * @Syscap SystemCapability.Multimedia.Image * @since 11 @@ -89,7 +100,7 @@ int32_t OH_ImagePacker_Create(napi_env env, napi_value *res); * @param packer Indicates a JavaScript native API ImagePacker object. * @return Returns an {@link ImagePackerNative} pointer object if the operation is successful * returns a null pointer otherwise. - * @see ImagePackerNative, OH_ImagePacker_Release + * @see {@link OH_ImagePacker_Release} * @since 11 * @version 4.1 */ @@ -110,7 +121,7 @@ ImagePackerNative* OH_ImagePacker_InitNative(napi_env env, napi_value packer); * returns {@link IRNdkErrCode} ERR_IMAGE_MALLOC_ABNORMAL - if malloc internal buffer error * returns {@link IRNdkErrCode} ERR_IMAGE_DECODE_ABNORMAL - if init codec internal error * returns {@link IRNdkErrCode} ERR_IMAGE_ENCODE_FAILED - if encoder occur error during encoding - * @see ImageNative, OhosImageComponent + * @see {@link OH_ImagePacker_PackToFile} * @since 11 * @version 4.1 */ @@ -131,7 +142,7 @@ int32_t OH_ImagePacker_PackToData(ImagePackerNative* native, napi_value source, * returns {@link IRNdkErrCode} ERR_IMAGE_MALLOC_ABNORMAL - if malloc internal buffer error * returns {@link IRNdkErrCode} ERR_IMAGE_DECODE_ABNORMAL - if init codec internal error * returns {@link IRNdkErrCode} ERR_IMAGE_ENCODE_FAILED - if encoder occur error during encoding - * @see ImageNative, OhosImageComponent + * @see {@link OH_ImagePacker_PackToData} * @since 11 * @version 4.1 */ @@ -147,7 +158,7 @@ int32_t OH_ImagePacker_PackToFile(ImagePackerNative* native, napi_value source, * * @param native Indicates the pointer to an {@link ImageNative} object at the native layer. * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * @see ImageNative, OH_Image_InitImageNative + * @see {@link OH_Image_InitImageNative} * @since 11 * @version 4.1 */ -- Gitee From cb899731431636591dbd2a1c115af03fa18e18c8 Mon Sep 17 00:00:00 2001 From: Cao Chuan Date: Tue, 7 Nov 2023 14:21:41 +0800 Subject: [PATCH 08/10] Modify lib name Signed-off-by: Cao Chuan --- multimedia/image_framework/include/image_packer_mdk.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multimedia/image_framework/include/image_packer_mdk.h b/multimedia/image_framework/include/image_packer_mdk.h index 53eb122eda4..5b956470745 100644 --- a/multimedia/image_framework/include/image_packer_mdk.h +++ b/multimedia/image_framework/include/image_packer_mdk.h @@ -40,7 +40,7 @@ * requird packing options. * Finally, release the ImagePakcerNative by OH_ImagePacker_Release. * - * @library libimage_packerndk.z.so + * @library libimage_packer_ndk.z.so * @syscap SystemCapability.Multimedia.Image * @since 11 * @version 4.1 -- Gitee From b5de67f16154fb3a3c10dc644f423c09f92111f2 Mon Sep 17 00:00:00 2001 From: Cao Chuan Date: Wed, 8 Nov 2023 08:48:18 +0800 Subject: [PATCH 09/10] Modify docs review comments Signed-off-by: Cao Chuan --- multimedia/image_framework/include/image_packer_mdk.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multimedia/image_framework/include/image_packer_mdk.h b/multimedia/image_framework/include/image_packer_mdk.h index 5b956470745..3d1fe360c11 100644 --- a/multimedia/image_framework/include/image_packer_mdk.h +++ b/multimedia/image_framework/include/image_packer_mdk.h @@ -156,7 +156,7 @@ int32_t OH_ImagePacker_PackToFile(ImagePackerNative* native, napi_value source, * It is used to release the object {@link ImagePackerNative} at the native layer * parsed by calling {@link OH_ImagePacker_InitNative}. * - * @param native Indicates the pointer to an {@link ImageNative} object at the native layer. + * @param native Indicates the pointer to an {@link ImagePackerNative} object at the native layer. * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. * @see {@link OH_Image_InitImageNative} * @since 11 -- Gitee From dff45ffbd1291ee75fd8472c6387a38595c6c970 Mon Sep 17 00:00:00 2001 From: Cao Chuan Date: Wed, 8 Nov 2023 09:21:50 +0800 Subject: [PATCH 10/10] Fix for docs review comments 2 Signed-off-by: Cao Chuan --- multimedia/image_framework/include/image_packer_mdk.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multimedia/image_framework/include/image_packer_mdk.h b/multimedia/image_framework/include/image_packer_mdk.h index 3d1fe360c11..258533ca791 100644 --- a/multimedia/image_framework/include/image_packer_mdk.h +++ b/multimedia/image_framework/include/image_packer_mdk.h @@ -158,7 +158,7 @@ int32_t OH_ImagePacker_PackToFile(ImagePackerNative* native, napi_value source, * * @param native Indicates the pointer to an {@link ImagePackerNative} object at the native layer. * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. - * @see {@link OH_Image_InitImageNative} + * @see {@link OH_ImagePacker_InitNative} * @since 11 * @version 4.1 */ -- Gitee