1# image_native.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 cropping rectangle, size, and component data of an image. 11 12**Library**: libohimage.so 13 14**System capability**: SystemCapability.Multimedia.Image.Core 15 16**Since**: 12 17 18**Related module**: [Image_NativeModule](capi-image-nativemodule.md) 19 20## Summary 21 22### Structs 23 24| Name| typedef Keyword| Description| 25| -- | -- | -- | 26| [OH_ImageNative](capi-image-nativemodule-oh-imagenative.md) | OH_ImageNative | Describes the alias for an image object at the native layer.| 27 28### Functions 29 30| Name| Description| 31| -- | -- | 32| [Image_ErrorCode OH_ImageNative_GetImageSize(OH_ImageNative *image, Image_Size *size)](#oh_imagenative_getimagesize) | Obtains the [Image_Size](capi-image-nativemodule-image-size.md) information of an [OH_ImageNative](capi-image-nativemodule-oh-imagenative.md) object.| 33| [Image_ErrorCode OH_ImageNative_GetComponentTypes(OH_ImageNative *image,uint32_t **types, size_t *typeSize)](#oh_imagenative_getcomponenttypes) | Obtains the component types of an [OH_ImageNative](capi-image-nativemodule-oh-imagenative.md) object.| 34| [Image_ErrorCode OH_ImageNative_GetByteBuffer(OH_ImageNative *image,uint32_t componentType, OH_NativeBuffer **nativeBuffer)](#oh_imagenative_getbytebuffer) | Obtains the buffer corresponding to a component type in an [OH_ImageNative](capi-image-nativemodule-oh-imagenative.md) object.| 35| [Image_ErrorCode OH_ImageNative_GetBufferSize(OH_ImageNative *image,uint32_t componentType, size_t *size)](#oh_imagenative_getbuffersize) | Obtains the size of the buffer corresponding to a component type in an [OH_ImageNative](capi-image-nativemodule-oh-imagenative.md) object.| 36| [Image_ErrorCode OH_ImageNative_GetRowStride(OH_ImageNative *image,uint32_t componentType, int32_t *rowStride)](#oh_imagenative_getrowstride) | Obtains the row stride corresponding to a component type in an [OH_ImageNative](capi-image-nativemodule-oh-imagenative.md) object.| 37| [Image_ErrorCode OH_ImageNative_GetPixelStride(OH_ImageNative *image,uint32_t componentType, int32_t *pixelStride)](#oh_imagenative_getpixelstride) | Obtains the pixel stride corresponding to a component type in an [OH_ImageNative](capi-image-nativemodule-oh-imagenative.md) object.| 38| [Image_ErrorCode OH_ImageNative_GetTimestamp(OH_ImageNative *image, int64_t *timestamp)](#oh_imagenative_gettimestamp) | Obtains the timestamp of an [OH_ImageNative](capi-image-nativemodule-oh-imagenative.md) object.| 39| [Image_ErrorCode OH_ImageNative_Release(OH_ImageNative *image)](#oh_imagenative_release) | Releases an [OH_ImageNative](capi-image-nativemodule-oh-imagenative.md) object.| 40 41## Function Description 42 43### OH_ImageNative_GetImageSize() 44 45``` 46Image_ErrorCode OH_ImageNative_GetImageSize(OH_ImageNative *image, Image_Size *size) 47``` 48 49**Description** 50 51Obtains the [Image_Size](capi-image-nativemodule-image-size.md) information of an [OH_ImageNative](capi-image-nativemodule-oh-imagenative.md) object. 52 53If the OH_ImageNative object stores the camera preview stream data (YUV image data), the width and height in **Image_Size** obtained correspond to those of the YUV image. If the OH_ImageNative object stores the camera photo stream data (JPEG image data, which is already encoded), the width in **Image_Size** obtained is the JPEG data size, and the height is 1. 54 55The type of data stored in the OH_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). 56 57**Since**: 12 58 59 60**Parameters** 61 62| Name| Description| 63| -- | -- | 64| [OH_ImageNative](capi-image-nativemodule-oh-imagenative.md) *image | Pointer to an OH_ImageNative object.| 65| [Image_Size](capi-image-nativemodule-image-size.md) *size | Pointer to the Image_Size object obtained.| 66 67**Returns** 68 69| Type| Description| 70| -- | -- | 71| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.<br>**IMAGE_UNKNOWN_ERROR**: An unknown error occurs.| 72 73### OH_ImageNative_GetComponentTypes() 74 75``` 76Image_ErrorCode OH_ImageNative_GetComponentTypes(OH_ImageNative *image,uint32_t **types, size_t *typeSize) 77``` 78 79**Description** 80 81Obtains the component types of an [OH_ImageNative](capi-image-nativemodule-oh-imagenative.md) object. 82 83**Since**: 12 84 85 86**Parameters** 87 88| Name| Description| 89| -- | -- | 90| [OH_ImageNative](capi-image-nativemodule-oh-imagenative.md) *image | Pointer to an OH_ImageNative object.| 91| uint32_t **types | Double pointer to the component types obtained.| 92| size_t *typeSize | Pointer to the number of component types obtained.| 93 94**Returns** 95 96| Type| Description| 97| -- | -- | 98| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 99 100### OH_ImageNative_GetByteBuffer() 101 102``` 103Image_ErrorCode OH_ImageNative_GetByteBuffer(OH_ImageNative *image,uint32_t componentType, OH_NativeBuffer **nativeBuffer) 104``` 105 106**Description** 107 108Obtains the buffer corresponding to a component type in an [OH_ImageNative](capi-image-nativemodule-oh-imagenative.md) object. 109 110**Since**: 12 111 112 113**Parameters** 114 115| Name| Description| 116| -- | -- | 117| [OH_ImageNative](capi-image-nativemodule-oh-imagenative.md) *image | Pointer to an OH_ImageNative object.| 118| uint32_t componentType | Component type.| 119| [OH_NativeBuffer](../apis-arkgraphics2d/capi-oh-nativebuffer-oh-nativebuffer.md) **nativeBuffer | Double pointer to the buffer, which is an OH_NativeBuffer object.| 120 121**Returns** 122 123| Type| Description| 124| -- | -- | 125| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 126 127### OH_ImageNative_GetBufferSize() 128 129``` 130Image_ErrorCode OH_ImageNative_GetBufferSize(OH_ImageNative *image,uint32_t componentType, size_t *size) 131``` 132 133**Description** 134 135Obtains the size of the buffer corresponding to a component type in an [OH_ImageNative](capi-image-nativemodule-oh-imagenative.md) object. 136 137**Since**: 12 138 139 140**Parameters** 141 142| Name| Description| 143| -- | -- | 144| [OH_ImageNative](capi-image-nativemodule-oh-imagenative.md) *image | Pointer to an OH_ImageNative object.| 145| uint32_t componentType | Component type.| 146| size_t *size | Pointer to the size of the buffer.| 147 148**Returns** 149 150| Type| Description| 151| -- | -- | 152| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 153 154### OH_ImageNative_GetRowStride() 155 156``` 157Image_ErrorCode OH_ImageNative_GetRowStride(OH_ImageNative *image,uint32_t componentType, int32_t *rowStride) 158``` 159 160**Description** 161 162Obtains the row stride corresponding to a component type in an [OH_ImageNative](capi-image-nativemodule-oh-imagenative.md) object. 163 164Camera preview stream data must be read based on the stride. For details, see [Secondary Processing of Preview Streams (C/C++)](../../media/camera/native-camera-preview-imageReceiver.md). 165 166**Since**: 12 167 168 169**Parameters** 170 171| Name| Description| 172| -- | -- | 173| [OH_ImageNative](capi-image-nativemodule-oh-imagenative.md) *image | Pointer to an OH_ImageNative object.| 174| uint32_t componentType | Component type.| 175| int32_t *rowStride | Pointer to the row stride obtained.| 176 177**Returns** 178 179| Type| Description| 180| -- | -- | 181| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 182 183### OH_ImageNative_GetPixelStride() 184 185``` 186Image_ErrorCode OH_ImageNative_GetPixelStride(OH_ImageNative *image,uint32_t componentType, int32_t *pixelStride) 187 188``` 189 190**Description** 191 192Obtains the pixel stride corresponding to a component type in an [OH_ImageNative](capi-image-nativemodule-oh-imagenative.md) object. 193 194**Since**: 12 195 196 197**Parameters** 198 199| Name| Description| 200| -- | -- | 201| [OH_ImageNative](capi-image-nativemodule-oh-imagenative.md) *image | Pointer to an OH_ImageNative object.| 202| uint32_t componentType | Component type.| 203| int32_t *pixelStride | Pointer to the pixel stride obtained.| 204 205**Returns** 206 207| Type| Description| 208| -- | -- | 209| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 210 211### OH_ImageNative_GetTimestamp() 212 213``` 214Image_ErrorCode OH_ImageNative_GetTimestamp(OH_ImageNative *image, int64_t *timestamp) 215``` 216 217**Description** 218 219Obtains the timestamp of an [OH_ImageNative](capi-image-nativemodule-oh-imagenative.md) object. Timestamps, measured in nanoseconds, are usually monotonically increasing. 220 221The specific meaning and baseline of these timestamps are determined by the image producer, which is the camera in the camera preview and photo scenarios. As a result, images from different producers may carry timestamps with distinct meanings and baselines, making direct comparison between them infeasible. 222 223To obtain the generation time of a photo, you can use [OH_ImageSourceNative_GetImageProperty](capi-image-source-native-h.md#oh_imagesourcenative_getimageproperty) to read the related EXIF information. 224 225**Since**: 12 226 227 228**Parameters** 229 230| Name| Description| 231| -- | -- | 232| [OH_ImageNative](capi-image-nativemodule-oh-imagenative.md) *image | Pointer to an OH_ImageNative object.| 233| int64_t *timestamp | Pointer to the timestamp.| 234 235**Returns** 236 237| Type| Description| 238| -- | -- | 239| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 240 241### OH_ImageNative_Release() 242 243``` 244Image_ErrorCode OH_ImageNative_Release(OH_ImageNative *image) 245``` 246 247**Description** 248 249Releases an [OH_ImageNative](capi-image-nativemodule-oh-imagenative.md) object. 250 251**Since**: 12 252 253 254**Parameters** 255 256| Name| Description| 257| -- | -- | 258| [OH_ImageNative](capi-image-nativemodule-oh-imagenative.md) *image | Pointer to an OH_ImageNative object.| 259 260**Returns** 261 262| Type| Description| 263| -- | -- | 264| [Image_ErrorCode](capi-image-common-h.md#image_errorcode) | **IMAGE_SUCCESS**: The operation is successful.<br>**IMAGE_BAD_PARAMETER**: A parameter is incorrect.| 265<!--no_check-->