• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# image_mdk.h
2<!--Kit: Image Kit-->
3<!--Subsystem: Multimedia-->
4<!--Owner: @aulight02-->
5<!--SE: @liyang_bryan-->
6<!--TSE: @xchaosioda-->
7
8## Overview
9
10The file declares the APIs used to access the image rectangle, size, format, and component data.
11
12**Library**: libimage_ndk.z.so
13
14**System capability**: SystemCapability.Multimedia.Image
15
16**Since**: 10
17
18**Related module**: [Image](capi-image.md)
19
20## Summary
21
22### Structs
23
24| Name| typedef Keyword| Description|
25| -- | -- | -- |
26| [OhosImageRect](capi-image-ohosimagerect.md) | - | Describes the information about an image rectangle.|
27| [ImageNative_](capi-image-imagenative-.md) | ImageNative | Describes an image object at the native layer.|
28| [OhosImageComponent](capi-image-ohosimagecomponent.md) | - | Describes the information about an image component.|
29
30### Enums
31
32| Name| Description|
33| -- | -- |
34| [Image Formats](#image-formats)| Enumerates the image formats.|
35| [Image Color Channel Types](#image-color-channel-types)| Enumerates the image color channel types.|
36
37### Functions
38
39| Name| Description|
40| -- | -- |
41| [ImageNative* OH_Image_InitImageNative(napi_env env, napi_value source)](#oh_image_initimagenative) | Converts an Image object at the JavaScript native layer into an ImageNative object.|
42| [int32_t OH_Image_ClipRect(const ImageNative* native, struct OhosImageRect* rect)](#oh_image_cliprect) | Obtains OhosImageRect of an ImageNative object.|
43| [int32_t OH_Image_Size(const ImageNative* native, struct OhosImageSize* size)](#oh_image_size) | Obtains OhosImageSize of an ImageNative object.|
44| [int32_t OH_Image_Format(const ImageNative* native, int32_t* format)](#oh_image_format) | Obtains the format of an ImageNative object.|
45| [int32_t OH_Image_GetComponent(const ImageNative* native, int32_t componentType, struct OhosImageComponent* componentNative)](#oh_image_getcomponent) |  Obtains OhosImageComponent of an ImageNative object.|
46| [int32_t OH_Image_Release(ImageNative* native)](#oh_image_release) | Releases an ImageNative object.<br>This function is not used to release an Image object at the JavaScript native API. It is used to release an ImageNative object parsed by calling [OH_Image_InitImageNative](capi-image-mdk-h.md#oh_image_initimagenative).|
47
48## Enum Description
49
50### Image Formats
51
52```
53enum anonymous enum
54```
55
56**Description**
57
58Enumerates the image formats.
59
60**Since**: 10
61
62| Enum Item| Description|
63| -- | -- |
64| OHOS_IMAGE_FORMAT_YCBCR_422_SP = 1000 | YCbCr422 semi-planar format.|
65| OHOS_IMAGE_FORMAT_JPEG = 2000 | JPEG encoding format.|
66
67### Image Color Channel Types
68
69```
70enum anonymous enum
71```
72
73**Description**
74
75Enumerates the image color channel types.
76
77**Since**: 10
78
79| Enum Item| Description|
80| -- | -- |
81| OHOS_IMAGE_COMPONENT_FORMAT_YUV_Y = 1 | Luminance component.|
82| OHOS_IMAGE_COMPONENT_FORMAT_YUV_U = 2 | Chrominance component - blue projection.|
83| OHOS_IMAGE_COMPONENT_FORMAT_YUV_V = 3 | Chrominance component - red projection.|
84| OHOS_IMAGE_COMPONENT_FORMAT_JPEG = 4 | JPEG format.|
85
86
87## Function Description
88
89### OH_Image_InitImageNative()
90
91```
92ImageNative* OH_Image_InitImageNative(napi_env env, napi_value source)
93```
94
95**Description**
96
97Parses an ImageNative object from an Image object at the JavaScript native layer.
98
99**Since**: 10
100
101
102**Parameters**
103
104| Name| Description|
105| -- | -- |
106| napi_env env | Pointer to the JNI environment.|
107| napi_value source | Image object at the JavaScript native layer.|
108
109**Returns**
110
111| Type| Description|
112| -- | -- |
113| [ImageNative](capi-image-imagenative-.md)* | Pointer to the ImageNative object. If the operation fails, a null pointer is returned.|
114
115**See also**
116
117[OH_Image_Release](#oh_image_release)
118
119### OH_Image_ClipRect()
120
121```
122int32_t OH_Image_ClipRect(const ImageNative* native, struct OhosImageRect* rect)
123```
124
125**Description**
126
127Obtains OhosImageRect of an ImageNative object.
128
129**Since**: 10
130
131
132**Parameters**
133
134| Name| Description|
135| -- | -- |
136| const [ImageNative](capi-image-imagenative-.md)* native | Pointer to an ImageNative object.|
137| struct [OhosImageRect](capi-image-ohosimagerect.md)* rect | Pointer to the OhosImageRect object obtained.|
138
139**Returns**
140
141| Type| Description|
142| -- | -- |
143| int32_t | Result code defined in [IRNdkErrCode](capi-image-mdk-common-h.md#irndkerrcode):<br>**IMAGE_RESULT_SUCCESS**: The operation is successful.<br> **IMAGE_RESULT_JNI_ENV_ABNORMAL**: The JNI environment is abnormal.<br> **IMAGE_RESULT_INVALID_PARAMETER**: A parameter is invalid.<br>**IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED**: Obtaining parameters from the surface fails.<br> **IMAGE_RESULT_BAD_PARAMETER**: A parameter is incorrect.|
144
145### OH_Image_Size()
146
147```
148int32_t OH_Image_Size(const ImageNative* native, struct OhosImageSize* size)
149```
150
151**Description**
152
153Obtains OhosImageSize of an ImageNative object.
154
155If the ImageNative object stores the camera preview stream data (YUV image data), the width and height in **OhosImageSize** obtained correspond to those of the YUV image. If the ImageNative object stores the camera photo stream data (JPEG image data, which is already encoded), the width in **OhosImageSize** obtained is the JPEG data size, and the height is 1.
156
157The type of data stored in the ImageNative object depends on whether the application passes the surface ID in the receiver to a previewOutput or captureOutput object of the camera. For details about the best practices of camera preview and photo capture, see [Secondary Processing of Preview Streams (C/C++)](../../media/camera/native-camera-preview-imageReceiver.md) and [Photo Capture (C/C++)](../../media/camera/native-camera-shooting.md).
158
159**Since**: 10
160
161
162**Parameters**
163
164| Name| Description|
165| -- | -- |
166| const [ImageNative](capi-image-imagenative-.md)* native | Pointer to an ImageNative object.|
167| struct [OhosImageSize](capi-image-ohosimagesize.md)* size | Pointer to the OhosImageSize object obtained.|
168
169**Returns**
170
171| Type| Description|
172| -- | -- |
173| int32_t | Result code defined in [IRNdkErrCode](capi-image-mdk-common-h.md#irndkerrcode):<br>**IMAGE_RESULT_SUCCESS**: The operation is successful.<br> **IMAGE_RESULT_JNI_ENV_ABNORMAL**: The JNI environment is abnormal.<br> **IMAGE_RESULT_INVALID_PARAMETER**: A parameter is invalid.<br>**IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED**: Obtaining parameters from the surface fails.<br> **IMAGE_RESULT_BAD_PARAMETER**: A parameter is incorrect.|
174
175### OH_Image_Format()
176
177```
178int32_t OH_Image_Format(const ImageNative* native, int32_t* format)
179```
180
181**Description**
182
183Obtains the format of an ImageNative object.
184
185**Since**: 10
186
187
188**Parameters**
189
190| Name| Description|
191| -- | -- |
192| const [ImageNative](capi-image-imagenative-.md)* native | Pointer to an ImageNative object.|
193| int32_t* format | Pointer to the image format obtained.|
194
195**Returns**
196
197| Type| Description|
198| -- | -- |
199| int32_t | Result code defined in [IRNdkErrCode](capi-image-mdk-common-h.md#irndkerrcode):<br>**IMAGE_RESULT_SUCCESS**: The operation is successful.<br> **IMAGE_RESULT_JNI_ENV_ABNORMAL**: The JNI environment is abnormal.<br> **IMAGE_RESULT_INVALID_PARAMETER**: A parameter is invalid.<br>**IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED**: Obtaining parameters from the surface fails.<br> **IMAGE_RESULT_BAD_PARAMETER**: A parameter is incorrect.|
200
201### OH_Image_GetComponent()
202
203```
204int32_t OH_Image_GetComponent(const ImageNative* native, int32_t componentType, struct OhosImageComponent* componentNative)
205```
206
207**Description**
208
209Obtains OhosImageComponent of an ImageNative object.
210
211**Since**: 10
212
213
214**Parameters**
215
216| Name| Description|
217| -- | -- |
218| const [ImageNative](capi-image-imagenative-.md)* native | Pointer to an ImageNative object.|
219| int32_t componentType | Type of the component.|
220| struct [OhosImageComponent](capi-image-ohosimagecomponent.md)* componentNative | Pointer to the OhosImageComponent object obtained.|
221
222**Returns**
223
224| Type| Description|
225| -- | -- |
226| int32_t | Result code defined in [IRNdkErrCode](capi-image-mdk-common-h.md#irndkerrcode):<br>**IMAGE_RESULT_SUCCESS**: The operation is successful.<br> **IMAGE_RESULT_JNI_ENV_ABNORMAL**: The JNI environment is abnormal.<br> **IMAGE_RESULT_INVALID_PARAMETER**: A parameter is invalid.<br>**IMAGE_RESULT_SURFACE_GET_PARAMETER_FAILED**: Obtaining parameters from the surface fails.<br> **IMAGE_RESULT_BAD_PARAMETER**: A parameter is incorrect.|
227
228### OH_Image_Release()
229
230```
231int32_t OH_Image_Release(ImageNative* native)
232```
233
234**Description**
235
236Releases an ImageNative object.
237
238This function is not used to release an Image object at the JavaScript native API. It is used to release an ImageNative object parsed by calling [OH_Image_InitImageNative](capi-image-mdk-h.md#oh_image_initimagenative).
239
240**Since**: 10
241
242
243**Parameters**
244
245| Name| Description|
246| -- | -- |
247| [ImageNative](capi-image-imagenative-.md)* native | Pointer to an ImageNative object.|
248
249**Returns**
250
251| Type| Description|
252| -- | -- |
253| int32_t | Result code defined in [IRNdkErrCode](capi-image-mdk-common-h.md#irndkerrcode):<br>**IMAGE_RESULT_SUCCESS**: The operation is successful.<br> **IMAGE_RESULT_JNI_ENV_ABNORMAL**: The JNI environment is abnormal.<br> **IMAGE_RESULT_INVALID_PARAMETER**: A parameter is invalid.<br> **IMAGE_RESULT_BAD_PARAMETER**: A parameter is incorrect.|
254
255**See also**
256
257[OH_Image_InitImageNative](#oh_image_initimagenative)
258