17777dab0Sopenharmony_ci/* 27777dab0Sopenharmony_ci * Copyright (C) 2023 Huawei Device Co., Ltd. 37777dab0Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 47777dab0Sopenharmony_ci * you may not use this file except in compliance with the License. 57777dab0Sopenharmony_ci * You may obtain a copy of the License at 67777dab0Sopenharmony_ci * 77777dab0Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 87777dab0Sopenharmony_ci * 97777dab0Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 107777dab0Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 117777dab0Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 127777dab0Sopenharmony_ci * See the License for the specific language governing permissions and 137777dab0Sopenharmony_ci * limitations under the License. 147777dab0Sopenharmony_ci */ 157777dab0Sopenharmony_ci 167777dab0Sopenharmony_ci/** 177777dab0Sopenharmony_ci * @addtogroup image 187777dab0Sopenharmony_ci * @{ 197777dab0Sopenharmony_ci * 207777dab0Sopenharmony_ci * @brief Provides APIs for access to the image interface. 217777dab0Sopenharmony_ci * 227777dab0Sopenharmony_ci * @Syscap SystemCapability.Multimedia.Image 237777dab0Sopenharmony_ci * @since 10 247777dab0Sopenharmony_ci * @version 2.0 257777dab0Sopenharmony_ci */ 267777dab0Sopenharmony_ci 277777dab0Sopenharmony_ci/** 287777dab0Sopenharmony_ci * @file image_mdk.h 297777dab0Sopenharmony_ci * 307777dab0Sopenharmony_ci * @brief Declares functions that access the image rectangle, size, format, and component data. 317777dab0Sopenharmony_ci * Need link <b>libimagendk.z.so</b> 327777dab0Sopenharmony_ci * 337777dab0Sopenharmony_ci * @kit ImageKit 347777dab0Sopenharmony_ci * @since 10 357777dab0Sopenharmony_ci * @version 2.0 367777dab0Sopenharmony_ci */ 377777dab0Sopenharmony_ci 387777dab0Sopenharmony_ci#ifndef INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_MDK_H_ 397777dab0Sopenharmony_ci#define INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_MDK_H_ 407777dab0Sopenharmony_ci#include "napi/native_api.h" 417777dab0Sopenharmony_ci#include "image_mdk_common.h" 427777dab0Sopenharmony_ci 437777dab0Sopenharmony_ci#ifdef __cplusplus 447777dab0Sopenharmony_ciextern "C" { 457777dab0Sopenharmony_ci#endif 467777dab0Sopenharmony_ci 477777dab0Sopenharmony_cistruct ImageNative_; 487777dab0Sopenharmony_ci 497777dab0Sopenharmony_ci/** 507777dab0Sopenharmony_ci * @brief Defines an image object at the native layer for the image interface. 517777dab0Sopenharmony_ci * 527777dab0Sopenharmony_ci * @since 10 537777dab0Sopenharmony_ci * @version 2.0 547777dab0Sopenharmony_ci */ 557777dab0Sopenharmony_citypedef struct ImageNative_ ImageNative; 567777dab0Sopenharmony_ci 577777dab0Sopenharmony_ci/** 587777dab0Sopenharmony_ci * @brief Enumerates the image formats. 597777dab0Sopenharmony_ci * 607777dab0Sopenharmony_ci * @since 10 617777dab0Sopenharmony_ci * @version 2.0 627777dab0Sopenharmony_ci */ 637777dab0Sopenharmony_cienum { 647777dab0Sopenharmony_ci /** YCbCr422 semi-planar format. */ 657777dab0Sopenharmony_ci OHOS_IMAGE_FORMAT_YCBCR_422_SP = 1000, 667777dab0Sopenharmony_ci /** JPEG encoding format. */ 677777dab0Sopenharmony_ci OHOS_IMAGE_FORMAT_JPEG = 2000 687777dab0Sopenharmony_ci}; 697777dab0Sopenharmony_ci 707777dab0Sopenharmony_ci/** 717777dab0Sopenharmony_ci * @brief Enumerates the image components. 727777dab0Sopenharmony_ci * 737777dab0Sopenharmony_ci * @since 10 747777dab0Sopenharmony_ci * @version 2.0 757777dab0Sopenharmony_ci */ 767777dab0Sopenharmony_cienum { 777777dab0Sopenharmony_ci /** Luminance component. */ 787777dab0Sopenharmony_ci OHOS_IMAGE_COMPONENT_FORMAT_YUV_Y = 1, 797777dab0Sopenharmony_ci /** Chrominance component - blue projection. */ 807777dab0Sopenharmony_ci OHOS_IMAGE_COMPONENT_FORMAT_YUV_U = 2, 817777dab0Sopenharmony_ci /** Chrominance component - red projection. */ 827777dab0Sopenharmony_ci OHOS_IMAGE_COMPONENT_FORMAT_YUV_V = 3, 837777dab0Sopenharmony_ci /** JPEG format. */ 847777dab0Sopenharmony_ci OHOS_IMAGE_COMPONENT_FORMAT_JPEG = 4, 857777dab0Sopenharmony_ci}; 867777dab0Sopenharmony_ci 877777dab0Sopenharmony_ci/** 887777dab0Sopenharmony_ci * @brief Defines the information about an image rectangle. 897777dab0Sopenharmony_ci * 907777dab0Sopenharmony_ci * @since 10 917777dab0Sopenharmony_ci * @version 2.0 927777dab0Sopenharmony_ci */ 937777dab0Sopenharmony_cistruct OhosImageRect { 947777dab0Sopenharmony_ci /** X coordinate of the rectangle. */ 957777dab0Sopenharmony_ci int32_t x; 967777dab0Sopenharmony_ci /** Y coordinate of the rectangle. */ 977777dab0Sopenharmony_ci int32_t y; 987777dab0Sopenharmony_ci /** Width of the rectangle, in pixels. */ 997777dab0Sopenharmony_ci int32_t width; 1007777dab0Sopenharmony_ci /** Height of the rectangle, in pixels. */ 1017777dab0Sopenharmony_ci int32_t height; 1027777dab0Sopenharmony_ci}; 1037777dab0Sopenharmony_ci 1047777dab0Sopenharmony_ci/** 1057777dab0Sopenharmony_ci * @brief Defines the image composition information. 1067777dab0Sopenharmony_ci * 1077777dab0Sopenharmony_ci * @since 10 1087777dab0Sopenharmony_ci * @version 2.0 1097777dab0Sopenharmony_ci */ 1107777dab0Sopenharmony_cistruct OhosImageComponent { 1117777dab0Sopenharmony_ci /** Buffer that stores the pixel data. */ 1127777dab0Sopenharmony_ci uint8_t* byteBuffer; 1137777dab0Sopenharmony_ci /** Size of the pixel data in the memory. */ 1147777dab0Sopenharmony_ci size_t size; 1157777dab0Sopenharmony_ci /** Type of the pixel data. */ 1167777dab0Sopenharmony_ci int32_t componentType; 1177777dab0Sopenharmony_ci /** Row stride of the pixel data. */ 1187777dab0Sopenharmony_ci int32_t rowStride; 1197777dab0Sopenharmony_ci /** Pixel stride of the pixel data */ 1207777dab0Sopenharmony_ci int32_t pixelStride; 1217777dab0Sopenharmony_ci}; 1227777dab0Sopenharmony_ci 1237777dab0Sopenharmony_ci/** 1247777dab0Sopenharmony_ci * @brief Parses an {@link ImageNative} object at the native layer from a JavaScript native API <b>image </b> object. 1257777dab0Sopenharmony_ci * 1267777dab0Sopenharmony_ci * @param env Indicates the pointer to the Java Native Interface (JNI) environment. 1277777dab0Sopenharmony_ci * @param source Indicates a JavaScript native API <b>image </b> object. 1287777dab0Sopenharmony_ci * @return Returns an {@link ImageNative} pointer object if the operation is successful 1297777dab0Sopenharmony_ci * returns a null pointer otherwise. 1307777dab0Sopenharmony_ci * @see ImageNative, OH_Image_Release 1317777dab0Sopenharmony_ci * @since 10 1327777dab0Sopenharmony_ci * @version 2.0 1337777dab0Sopenharmony_ci */ 1347777dab0Sopenharmony_ciImageNative* OH_Image_InitImageNative(napi_env env, napi_value source); 1357777dab0Sopenharmony_ci 1367777dab0Sopenharmony_ci/** 1377777dab0Sopenharmony_ci * @brief Obtains {@link OhosImageRect} of an {@link ImageNative} at the native layer. 1387777dab0Sopenharmony_ci * 1397777dab0Sopenharmony_ci * @param native Indicates the pointer to an {@link ImageNative} object at the native layer. 1407777dab0Sopenharmony_ci * @param rect Indicates the pointer to the {@link OhosImageRect} object obtained. 1417777dab0Sopenharmony_ci * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. 1427777dab0Sopenharmony_ci * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. 1437777dab0Sopenharmony_ci * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. 1447777dab0Sopenharmony_ci * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED - if Failed to obtain parameters for surface. 1457777dab0Sopenharmony_ci * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. 1467777dab0Sopenharmony_ci * @see ImageNative, OhosImageRect 1477777dab0Sopenharmony_ci * @since 10 1487777dab0Sopenharmony_ci * @version 2.0 1497777dab0Sopenharmony_ci */ 1507777dab0Sopenharmony_ciint32_t OH_Image_ClipRect(const ImageNative* native, struct OhosImageRect* rect); 1517777dab0Sopenharmony_ci 1527777dab0Sopenharmony_ci/** 1537777dab0Sopenharmony_ci * @brief Obtains {@link OhosImageSize} of an {@link ImageNative} object at the native layer. 1547777dab0Sopenharmony_ci * 1557777dab0Sopenharmony_ci * @param native Indicates the pointer to an {@link ImageNative} object at the native layer. 1567777dab0Sopenharmony_ci * @param size Indicates the pointer to the {@link OhosImageSize} object obtained. 1577777dab0Sopenharmony_ci * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. 1587777dab0Sopenharmony_ci * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. 1597777dab0Sopenharmony_ci * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. 1607777dab0Sopenharmony_ci * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED - if Failed to obtain parameters for surface. 1617777dab0Sopenharmony_ci * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. 1627777dab0Sopenharmony_ci * @see ImageNative, OhosImageSize 1637777dab0Sopenharmony_ci * @since 10 1647777dab0Sopenharmony_ci * @version 2.0 1657777dab0Sopenharmony_ci */ 1667777dab0Sopenharmony_ciint32_t OH_Image_Size(const ImageNative* native, struct OhosImageSize* size); 1677777dab0Sopenharmony_ci 1687777dab0Sopenharmony_ci/** 1697777dab0Sopenharmony_ci * @brief Obtains the image format of an {@link ImageNative} object at the native layer. 1707777dab0Sopenharmony_ci * 1717777dab0Sopenharmony_ci * @param native Indicates the pointer to an {@link ImageNative} object at the native layer. 1727777dab0Sopenharmony_ci * @param format Indicates the pointer to the image format obtained. 1737777dab0Sopenharmony_ci * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. 1747777dab0Sopenharmony_ci * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. 1757777dab0Sopenharmony_ci * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. 1767777dab0Sopenharmony_ci * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED - if Failed to obtain parameters for surface. 1777777dab0Sopenharmony_ci * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. 1787777dab0Sopenharmony_ci * @see ImageNative 1797777dab0Sopenharmony_ci * @since 10 1807777dab0Sopenharmony_ci * @version 2.0 1817777dab0Sopenharmony_ci */ 1827777dab0Sopenharmony_ciint32_t OH_Image_Format(const ImageNative* native, int32_t* format); 1837777dab0Sopenharmony_ci 1847777dab0Sopenharmony_ci/** 1857777dab0Sopenharmony_ci * @brief Obtains {@link OhosImageComponent} of an {@link ImageNative} object at the native layer. 1867777dab0Sopenharmony_ci * 1877777dab0Sopenharmony_ci * @param native Indicates the pointer to an {@link ImageNative} object at the native layer. 1887777dab0Sopenharmony_ci * @param componentType Indicates the type of the required component. 1897777dab0Sopenharmony_ci * @param componentNative Indicates the pointer to the {@link OhosImageComponent} object obtained. 1907777dab0Sopenharmony_ci * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. 1917777dab0Sopenharmony_ci * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. 1927777dab0Sopenharmony_ci * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. 1937777dab0Sopenharmony_ci * returns {@link IRNdkErrCode} IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED - if Failed to obtain parameters for surface. 1947777dab0Sopenharmony_ci * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. 1957777dab0Sopenharmony_ci * @see ImageNative, OhosImageComponent 1967777dab0Sopenharmony_ci * @since 10 1977777dab0Sopenharmony_ci * @version 2.0 1987777dab0Sopenharmony_ci */ 1997777dab0Sopenharmony_ciint32_t OH_Image_GetComponent(const ImageNative* native, 2007777dab0Sopenharmony_ci int32_t componentType, struct OhosImageComponent* componentNative); 2017777dab0Sopenharmony_ci 2027777dab0Sopenharmony_ci/** 2037777dab0Sopenharmony_ci * @brief Releases an {@link ImageNative} object at the native layer. 2047777dab0Sopenharmony_ci * Note: This API is not used to release a JavaScript native API <b>Image</b> object. 2057777dab0Sopenharmony_ci * It is used to release the object {@link ImageNative} at the native layer 2067777dab0Sopenharmony_ci * parsed by calling {@link OH_Image_InitImageNative}. 2077777dab0Sopenharmony_ci * 2087777dab0Sopenharmony_ci * @param native Indicates the pointer to an {@link ImageNative} object at the native layer. 2097777dab0Sopenharmony_ci * @return Returns {@link IRNdkErrCode} IMAGE_RESULT_SUCCESS - if the operation is successful. 2107777dab0Sopenharmony_ci * returns {@link IRNdkErrCode} IMAGE_RESULT_JNI_ENV_ABNORMAL - if Abnormal JNI environment. 2117777dab0Sopenharmony_ci * returns {@link IRNdkErrCode} IMAGE_RESULT_INVALID_PARAMETER - if invalid parameter. 2127777dab0Sopenharmony_ci * returns {@link IRNdkErrCode} IMAGE_RESULT_BAD_PARAMETER - if bad parameter. 2137777dab0Sopenharmony_ci * @see ImageNative, OH_Image_InitImageNative 2147777dab0Sopenharmony_ci * @since 10 2157777dab0Sopenharmony_ci * @version 2.0 2167777dab0Sopenharmony_ci */ 2177777dab0Sopenharmony_ciint32_t OH_Image_Release(ImageNative* native); 2187777dab0Sopenharmony_ci#ifdef __cplusplus 2197777dab0Sopenharmony_ci}; 2207777dab0Sopenharmony_ci#endif 2217777dab0Sopenharmony_ci/** @} */ 2227777dab0Sopenharmony_ci#endif // INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_MDK_H_ 223