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 libohimage.so
31  * @kit ImageKit
32  * @syscap SystemCapability.Multimedia.Image.Core
33  * @since 12
34  */
35 
36 #ifndef INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_H
37 #define INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_H
38 
39 #include "image_common.h"
40 #include "native_buffer/native_buffer.h"
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /**
47  * @brief Defines an <b>OH_ImageNative</b> object.
48  *
49  * @since 12
50  */
51 struct OH_ImageNative;
52 
53 /**
54  * @brief Defines the data type name of a native image.
55  *
56  * @since 12
57  */
58 typedef struct OH_ImageNative OH_ImageNative;
59 
60 /**
61  * @brief Obtains {@link Image_Size} of an {@link OH_ImageNative} object.
62  *
63  * @param image Indicates the pointer to an {@link OH_ImageNative} object.
64  * @param size Indicates the pointer to the {@link Image_Size} object obtained.
65  * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful.
66  * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if invalid parameter.
67  * returns {@link Image_ErrorCode} IMAGE_UNKNOWN_ERROR - inner unknown error.
68  * @since 12
69  */
70 Image_ErrorCode OH_ImageNative_GetImageSize(OH_ImageNative *image, Image_Size *size);
71 
72 /**
73  * @brief Get type arry from an {@link OH_ImageNative} object.
74  *
75  * @param image Indicates the pointer to an {@link OH_ImageNative} object.
76  * @param types Indicates the pointer to an {@link OH_ImageNative} component arry obtained.
77  * @param typeSize Indicates the pointer to the {@link OH_ImageNative} component arry size obtained.
78  * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful.
79  * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter.
80  * @since 12
81  */
82 Image_ErrorCode OH_ImageNative_GetComponentTypes(OH_ImageNative *image,
83     uint32_t **types, size_t *typeSize);
84 
85 /**
86  * @brief Get byte buffer from an {@link OH_ImageNative} object by the component type.
87  *
88  * @param image Indicates the pointer to an {@link OH_ImageNative} object.
89  * @param componentType Indicates the type of component.
90  * @param nativeBuffer Indicates the pointer to the component buffer obtained.
91  * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful.
92  * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter.
93  * @since 12
94  */
95 Image_ErrorCode OH_ImageNative_GetByteBuffer(OH_ImageNative *image,
96     uint32_t componentType, OH_NativeBuffer **nativeBuffer);
97 
98 /**
99  * @brief Get size of buffer from an {@link OH_ImageNative} object by the component type.
100  *
101  * @param image Indicates the pointer to an {@link OH_ImageNative} object.
102  * @param componentType Indicates the type of component.
103  * @param size Indicates the pointer to the size of buffer obtained.
104  * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful.
105  * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter.
106  * @since 12
107  */
108 Image_ErrorCode OH_ImageNative_GetBufferSize(OH_ImageNative *image,
109     uint32_t componentType, size_t *size);
110 
111 /**
112  * @brief Get row stride from an {@link OH_ImageNative} object by the component type.
113  *
114  * @param image Indicates the pointer to an {@link OH_ImageNative} object.
115  * @param componentType Indicates the type of component.
116  * @param rowStride Indicates the pointer to the row stride obtained.
117  * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful.
118  * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter.
119  * @since 12
120  */
121 Image_ErrorCode OH_ImageNative_GetRowStride(OH_ImageNative *image,
122     uint32_t componentType, int32_t *rowStride);
123 
124 /**
125  * @brief Get pixel stride from an {@link OH_ImageNative} object by the component type.
126  *
127  * @param image Indicates the pointer to an {@link OH_ImageNative} object.
128  * @param componentType Indicates the type of component.
129  * @param pixelStride Indicates the pointer to the pixel stride obtained.
130  * @return Returns {@link Image_ErrorCode} IMAGE_SUCCESS - if the operation is successful.
131  * returns {@link Image_ErrorCode} IMAGE_BAD_PARAMETER - if bad parameter.
132  * @since 12
133  */
134 Image_ErrorCode OH_ImageNative_GetPixelStride(OH_ImageNative *image,
135     uint32_t componentType, int32_t *pixelStride);
136 
137 /**
138  * @brief Get timestamp from an {@link OH_ImageNative} object.
139  *
140  * @param image Indicates the pointer to an {@link OH_ImageNative} object.
141  * @param timestamp Indicates the pointer to the timestamp obtained.
142  * @return Image functions result code.
143  *         {@link IMAGE_SUCCESS} if the operation is successful.
144  *         {@link IMAGE_BAD_PARAMETER} if the input parameter is invalid.
145  * @since 12
146  */
147 Image_ErrorCode OH_ImageNative_GetTimestamp(OH_ImageNative *image, 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