1 /*
2  * Copyright (C) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * @addtogroup image
18  * @{
19  *
20  * @brief Provides APIs for access to the image interface.
21  *
22  * @since 12
23  */
24 
25 /**
26  * @file image_native.h
27  *
28  * @brief Declares functions that access the image rectangle, size, format, and component data.
29  *
30  * @library libimage.so
31  * @syscap SystemCapability.Multimedia.Image.Core
32  * @since 12
33  */
34 
35 #ifndef INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_H
36 #define INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_H
37 
38 #include "image_common.h"
39 #include "native_buffer.h"
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 /**
46  * @brief Defines an <b>OH_ImageNative</b> object.
47  *
48  * @since 12
49  */
50 struct OH_ImageNative;
51 
52 /**
53  * @brief Defines the data type name of a native image.
54  *
55  * @since 12
56  */
57 typedef struct OH_ImageNative OH_ImageNative;
58 
59 /**
60  * @brief Obtains {@link Image_Size} of an {@link OH_ImageNative} object.
61  *
62  * @param image Indicates the pointer to an {@link OH_ImageNative} object.
63  * @param size Indicates the pointer to the {@link Image_Size} object obtained.
64  * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful.
65  * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if invalid parameter.
66  * returns {@link Image_ErrorCode} IMAGE_UNKNOWN_ERROR - inner unknown error.
67  * @since 12
68  */
69 Image_ErrorCode OH_ImageNative_GetImageSize(OH_ImageNative *image, Image_Size *size);
70 
71 /**
72  * @brief Get type arry from an {@link OH_ImageNative} object.
73  *
74  * @param image Indicates the pointer to an {@link OH_ImageNative} object.
75  * @param types Indicates the pointer to an {@link OH_ImageNative} component arry obtained.
76  * @param typeSize Indicates the pointer to the {@link OH_ImageNative} component arry size obtained.
77  * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful.
78  * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter.
79  * @since 12
80  */
81 Image_ErrorCode OH_ImageNative_GetComponentTypes(OH_ImageNative *image,
82     uint32_t **types, size_t *typeSize);
83 
84 /**
85  * @brief Get byte buffer from an {@link OH_ImageNative} object by the component type.
86  *
87  * @param image Indicates the pointer to an {@link OH_ImageNative} object.
88  * @param componentType Indicates the type of component.
89  * @param nativeBuffer Indicates the pointer to the component buffer obtained.
90  * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful.
91  * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter.
92  * @since 12
93  */
94 Image_ErrorCode OH_ImageNative_GetByteBuffer(OH_ImageNative *image,
95     uint32_t componentType, OH_NativeBuffer **nativeBuffer);
96 
97 /**
98  * @brief Get size of buffer from an {@link OH_ImageNative} object by the component type.
99  *
100  * @param image Indicates the pointer to an {@link OH_ImageNative} object.
101  * @param componentType Indicates the type of component.
102  * @param size Indicates the pointer to the size of buffer obtained.
103  * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful.
104  * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter.
105  * @since 12
106  */
107 Image_ErrorCode OH_ImageNative_GetBufferSize(OH_ImageNative *image,
108     uint32_t componentType, size_t *size);
109 
110 /**
111  * @brief Get row stride from an {@link OH_ImageNative} object by the component type.
112  *
113  * @param image Indicates the pointer to an {@link OH_ImageNative} object.
114  * @param componentType Indicates the type of component.
115  * @param rowStride Indicates the pointer to the row stride obtained.
116  * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful.
117  * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter.
118  * @since 12
119  */
120 Image_ErrorCode OH_ImageNative_GetRowStride(OH_ImageNative *image,
121     uint32_t componentType, int32_t *rowStride);
122 
123 /**
124  * @brief Get pixel stride from an {@link OH_ImageNative} object by the component type.
125  *
126  * @param image Indicates the pointer to an {@link OH_ImageNative} object.
127  * @param componentType Indicates the type of component.
128  * @param pixelStride Indicates the pointer to the pixel stride obtained.
129  * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful.
130  * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter.
131  * @since 12
132  */
133 Image_ErrorCode OH_ImageNative_GetPixelStride(OH_ImageNative *image,
134     uint32_t componentType, int32_t *pixelStride);
135 
136 /**
137 * @brief Get timestamp from an {@link OH_ImageNative} object.
138 *
139 * @param image Indicates the pointer to an {@link OH_ImageNative} object.
140 * @param timestamp Indicates the pointer to the timestamp obtained.
141 * @return image functions result code.
142 *     {@link IMAGE_SUCCESS} if the operation is successful.
143 *     {@link IMAGE_BAD_PARAMETER} if the input parameter is invalid.
144 * @since 12
145 */
146 Image_ErrorCode OH_ImageNative_GetTimestamp(OH_ImageNative *image,
147     int64_t *timestamp);
148 
149 /**
150  * @brief Releases an {@link OH_ImageNative} object.
151  * It is used to release the object {@link OH_ImageNative}.
152  *
153  * @param image Indicates the pointer to an {@link OH_ImageNative} object.
154  * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful.
155  * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter.
156  * @since 12
157  */
158 Image_ErrorCode OH_ImageNative_Release(OH_ImageNative *image);
159 
160 #ifdef __cplusplus
161 };
162 #endif
163 /** @} */
164 #endif // INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_H
165