1e41f4b71Sopenharmony_ci# OH_NativeImage 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ci## Overview 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ciThe **OH_NativeImage** module provides the capabilities of **NativeImage**. Functioning as a data consumer, it is used to associate data with the OpenGL texture. It is used in the OpenGL environment. 7e41f4b71Sopenharmony_ci 8e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeImage 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci**Since**: 9 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ci## Summary 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci### Files 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci| Name| Description| 19e41f4b71Sopenharmony_ci| -------- | -------- | 20e41f4b71Sopenharmony_ci| [native_image.h](native__image_8h.md) | Defines the functions for obtaining and using **NativeImage**.| 21e41f4b71Sopenharmony_ci 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci### Structs 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci| Name| Description| 26e41f4b71Sopenharmony_ci| -------- | -------- | 27e41f4b71Sopenharmony_ci| [OH_OnFrameAvailableListener](_o_h___on_frame_available_listener.md) | Defines an **OH_NativeImage** listener, which is registered through **OH_NativeImage_SetOnFrameAvailableListener**. The listener triggers a callback when a frame is available.| 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci 30e41f4b71Sopenharmony_ci### Types 31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_ci| Name| Description| 33e41f4b71Sopenharmony_ci| -------- | -------- | 34e41f4b71Sopenharmony_ci| typedef struct [OH_NativeImage](#oh_nativeimage) [OH_NativeImage](#oh_nativeimage) | Provides the declaration of an **OH_NativeImage** struct. | 35e41f4b71Sopenharmony_ci| typedef struct NativeWindow [OHNativeWindow](#ohnativewindow) | Provides the capability of accessing the **NativeWindow**. | 36e41f4b71Sopenharmony_ci| typedef struct NativeWindowBuffer [OHNativeWindowBuffer](#ohnativewindowbuffer) | Provides the declaration of a **NativeWindowBuffer** struct.| 37e41f4b71Sopenharmony_ci| typedef void(\* [OH_OnFrameAvailable](#oh_onframeavailable)) (void \*context) | Defines the callback function triggered when a frame is available. | 38e41f4b71Sopenharmony_ci| typedef struct [OH_OnFrameAvailableListener](_o_h___on_frame_available_listener.md) [OH_OnFrameAvailableListener](#oh_onframeavailablelistener) | Defines an **OH_NativeImage** listener, which is registered through **OH_NativeImage_SetOnFrameAvailableListener**. The listener triggers a callback when a frame is available. | 39e41f4b71Sopenharmony_ci| typedef enum [OHNativeErrorCode](#ohnativeerrorcode) [OHNativeErrorCode](#ohnativeerrorcode) | Defines an enum for the error codes. | 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci### Enums 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ci| Name| Description| 44e41f4b71Sopenharmony_ci| -------- | -------- | 45e41f4b71Sopenharmony_ci| [OHNativeErrorCode](#ohnativeerrorcode-1) {<br>NATIVE_ERROR_OK = 0, NATIVE_ERROR_INVALID_ARGUMENTS = 40001000, NATIVE_ERROR_NO_PERMISSION = 40301000, NATIVE_ERROR_NO_BUFFER = 40601000,<br>NATIVE_ERROR_NO_CONSUMER = 41202000, NATIVE_ERROR_NOT_INIT = 41203000, NATIVE_ERROR_CONSUMER_CONNECTED = 41206000, NATIVE_ERROR_BUFFER_STATE_INVALID = 41207000,<br>NATIVE_ERROR_BUFFER_IN_CACHE = 41208000, NATIVE_ERROR_BUFFER_QUEUE_FULL = 41209000, NATIVE_ERROR_BUFFER_NOT_IN_CACHE = 41210000, NATIVE_ERROR_CONSUMER_DISCONNECTED = 41211000,NATIVE_ERROR_CONSUMER_NO_LISTENER_REGISTERED = 41212000,NATIVE_ERROR_UNSUPPORTED = 50102000,<br>NATIVE_ERROR_UNKNOWN = 50002000, NATIVE_ERROR_HDI_ERROR = 50007000,NATIVE_ERROR_BINDER_ERROR = 50401000,NATIVE_ERROR_EGL_STATE_UNKNOWN = 60001000, NATIVE_ERROR_EGL_API_FAILED = 60002000<br>} | Enumerates the error codes. | 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci### Functions 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ci| Name| Description| 50e41f4b71Sopenharmony_ci| -------- | -------- | 51e41f4b71Sopenharmony_ci| [OH_NativeImage](#oh_nativeimage) \* [OH_NativeImage_Create](#oh_nativeimage_create) (uint32_t textureId, uint32_t textureTarget) | Creates an **OH_NativeImage** instance to be associated with the OpenGL ES texture ID and target.<br>This function must be used in pair with [OH_NativeImage_Destroy](#oh_nativeimage_destroy). Otherwise, memory leak occurs.<br>This function is not thread-safe.| 52e41f4b71Sopenharmony_ci| [OHNativeWindow](_native_window.md#ohnativewindow) \* [OH_NativeImage_AcquireNativeWindow](#oh_nativeimage_acquirenativewindow) ([OH_NativeImage](#oh_nativeimage) \*image) | Obtains an **OHNativeWindow** instance associated with an **OH_NativeImage** instance.<br>This function is not thread-safe.<br>When **OH_NativeImage** is being destructed, the corresponding **OHNativeWindow** instance is released. If the **OHNativeWindow** pointer is obtained by using this function, set the pointer to null when releasing the **OH_NativeImage** instance, so as to prevent subsequent wild pointers.| 53e41f4b71Sopenharmony_ci| int32_t [OH_NativeImage_AttachContext](#oh_nativeimage_attachcontext) ([OH_NativeImage](#oh_nativeimage) \*image, uint32_t textureId) | Attaches an **OH_NativeImage** instance to the current OpenGL ES context. The OpenGL ES texture will be bound to an **GL_TEXTURE_EXTERNAL_OES** instance and updated through the **OH_NativeImage** instance.<br>This function is not thread-safe.| 54e41f4b71Sopenharmony_ci| int32_t [OH_NativeImage_DetachContext](#oh_nativeimage_detachcontext) ([OH_NativeImage](#oh_nativeimage) \*image) | Detaches an **OH_NativeImage** instance from the current OpenGL ES context.<br>This function is not thread-safe.| 55e41f4b71Sopenharmony_ci| int32_t [OH_NativeImage_UpdateSurfaceImage](#oh_nativeimage_updatesurfaceimage) ([OH_NativeImage](#oh_nativeimage) \*image) | Updates the OpenGL ES texture associated with the latest frame through an **OH_NativeImage** instance.<br>This function must be called in a thread of the OpenGL ES context.<br>This function must be called after the [OH_OnFrameAvailableListener](_o_h___on_frame_available_listener.md) callback is triggered.<br>This function is not thread-safe.| 56e41f4b71Sopenharmony_ci| int64_t [OH_NativeImage_GetTimestamp](#oh_nativeimage_gettimestamp) ([OH_NativeImage](#oh_nativeimage) \*image) | Obtains the timestamp of the texture image that recently called the **OH_NativeImage_UpdateSurfaceImage** function.<br>This function is not thread-safe.| 57e41f4b71Sopenharmony_ci| int32_t [OH_NativeImage_GetTransformMatrix](#oh_nativeimage_gettransformmatrix) ([OH_NativeImage](#oh_nativeimage) \*image, float matrix[16]) | Obtains the transformation matrix of the texture image that recently called the **OH_NativeImage_UpdateSurfaceImage** function.| 58e41f4b71Sopenharmony_ci| int32_t [OH_NativeImage_GetSurfaceId](#oh_nativeimage_getsurfaceid) ([OH_NativeImage](#oh_nativeimage) \*image, uint64_t \*surfaceId) | Obtains the surface ID of an **OH_NativeImage** instance.<br>This function is not thread-safe.| 59e41f4b71Sopenharmony_ci| int32_t [OH_NativeImage_SetOnFrameAvailableListener](#oh_nativeimage_setonframeavailablelistener) ([OH_NativeImage](#oh_nativeimage) \*image, [OH_OnFrameAvailableListener](_o_h___on_frame_available_listener.md) listener) | Registers a listener to listen for frame availability events.<br>Do not call other functions of this module in the callback.<br>This function is not thread-safe.| 60e41f4b71Sopenharmony_ci| int32_t [OH_NativeImage_UnsetOnFrameAvailableListener](#oh_nativeimage_unsetonframeavailablelistener) ([OH_NativeImage](#oh_nativeimage) \*image) | Deregisters the listener used to listen for frame availability events.<br>This function is not thread-safe.| 61e41f4b71Sopenharmony_ci| void [OH_NativeImage_Destroy](#oh_nativeimage_destroy) ([OH_NativeImage](#oh_nativeimage) \*\*image) | Destroys an **OH_NativeImage** instance created by calling **OH_NativeImage_Create**. After the instance is destroyed,<br>the pointer to the **OH_NativeImage** instance is assigned **NULL**.<br>This function is not thread-safe.| 62e41f4b71Sopenharmony_ci| int32_t [OH_NativeImage_GetTransformMatrixV2](#oh_nativeimage_gettransformmatrixv2) ([OH_NativeImage](#oh_nativeimage) \*image, float matrix[16]) | Obtains, based on the rotation angle set by the producer, the transform matrix of the texture image that recently called the **OH_NativeImage_UpdateSurfaceImage** function.<br>The matrix is updated only after [OH_NativeImage_UpdateSurfaceImage](#oh_nativeimage_updatesurfaceimage) is called.<br>This function is not thread-safe.| 63e41f4b71Sopenharmony_ci| int32_t [OH_NativeImage_AcquireNativeWindowBuffer](#oh_nativeimage_acquirenativewindowbuffer) ([OH_NativeImage](#oh_nativeimage) \*image, [OHNativeWindowBuffer](_native_window.md#ohnativewindowbuffer) \*\*nativeWindowBuffer, int \*fenceFd) | Obtains an **OHNativeWindowBuffer** instance through an **OH_NativeImage** instance on the consumer side.<br>This function cannot be used together with [OH_NativeImage_UpdateSurfaceImage](#oh_nativeimage_updatesurfaceimage).<br>This function creates an **OHNativeWindowBuffer**.<br>When using the **OHNativeWindowBuffer**, call [OH_NativeWindow_NativeObjectReference](_native_window.md#oh_nativewindow_nativeobjectreference) to increase its reference count by one.<br>When finishing using the **OHNativeWindowBuffer**, call [OH_NativeWindow_NativeObjectUnreference](_native_window.md#oh_nativewindow_nativeobjectunreference) to decrease the reference count by one.<br>This function must be used in pair with [OH_NativeImage_ReleaseNativeWindowBuffer](#oh_nativeimage_releasenativewindowbuffer). Otherwise, memory leak occurs.<br>When **fenceFd** is used up, you must close it.<br>This function is not thread-safe.| 64e41f4b71Sopenharmony_ci| int32_t [OH_NativeImage_ReleaseNativeWindowBuffer](#oh_nativeimage_releasenativewindowbuffer) ([OH_NativeImage](#oh_nativeimage) \*image, [OHNativeWindowBuffer](_native_window.md#ohnativewindowbuffer) \*nativeWindowBuffer, int fenceFd) | Releases an **OHNativeWindowBuffer** instance through an **OH_NativeImage** instance.<br>The system will close **fenFd**. You do not need to close it.<br>This function is not thread-safe.| 65e41f4b71Sopenharmony_ci| [OH_NativeImage](#oh_nativeimage) \* [OH_ConsumerSurface_Create](#oh_consumersurface_create) () | Creates an **OH_NativeImage** instance as the consumer of the surface.<br>This function is used only for memory cycling of the surface consumer. Memory rendering is not proactively performed in the created **OH_NativeImage** instance.<br>This function cannot be used together with [OH_NativeImage_UpdateSurfaceImage](#oh_nativeimage_updatesurfaceimage).<br>This function must be used in pair with **OH_NativeImage_AcquireNativeWindowBuffer** and **OH_NativeImage_ReleaseNativeWindowBuffer**.<br>This function must be used in pair with [OH_NativeImage_Destroy](#oh_nativeimage_destroy). Otherwise, memory leak occurs.<br>This function is not thread-safe.| 66e41f4b71Sopenharmony_ci| int32_t [OH_ConsumerSurface_SetDefaultUsage](#oh_consumersurface_setdefaultusage) ([OH_NativeImage](#oh_nativeimage) \*image, uint64_t usage) | Sets the default read/write mode. This function is not thread-safe.| 67e41f4b71Sopenharmony_ci| int32_t [OH_ConsumerSurface_SetDefaultSize](#oh_consumersurface_setdefaultsize) ([OH_NativeImage](#oh_nativeimage) \*image, int32_t width, int32_t height) | Sets the default size of a geometric shape. This function is not thread-safe.| 68e41f4b71Sopenharmony_ci 69e41f4b71Sopenharmony_ci## Type Description 70e41f4b71Sopenharmony_ci 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ci### OH_NativeImage 73e41f4b71Sopenharmony_ci 74e41f4b71Sopenharmony_ci``` 75e41f4b71Sopenharmony_citypedef struct OH_NativeImage OH_NativeImage 76e41f4b71Sopenharmony_ci``` 77e41f4b71Sopenharmony_ci 78e41f4b71Sopenharmony_ci**Description** 79e41f4b71Sopenharmony_ci 80e41f4b71Sopenharmony_ciProvides the declaration of an **OH_NativeImage** struct. 81e41f4b71Sopenharmony_ci 82e41f4b71Sopenharmony_ci**Since**: 9 83e41f4b71Sopenharmony_ci 84e41f4b71Sopenharmony_ci 85e41f4b71Sopenharmony_ci### OH_OnFrameAvailable 86e41f4b71Sopenharmony_ci 87e41f4b71Sopenharmony_ci``` 88e41f4b71Sopenharmony_citypedef void(* OH_OnFrameAvailable) (void *context) 89e41f4b71Sopenharmony_ci``` 90e41f4b71Sopenharmony_ci 91e41f4b71Sopenharmony_ci**Description** 92e41f4b71Sopenharmony_ci 93e41f4b71Sopenharmony_ciDefines the callback function triggered when a frame is available. 94e41f4b71Sopenharmony_ci 95e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeImage 96e41f4b71Sopenharmony_ci 97e41f4b71Sopenharmony_ci**Since**: 11 98e41f4b71Sopenharmony_ci 99e41f4b71Sopenharmony_ci**Parameters** 100e41f4b71Sopenharmony_ci 101e41f4b71Sopenharmony_ci| Name| Description| 102e41f4b71Sopenharmony_ci| -------- | -------- | 103e41f4b71Sopenharmony_ci| context | User-defined context information, which is returned when the callback is triggered.| 104e41f4b71Sopenharmony_ci 105e41f4b71Sopenharmony_ci 106e41f4b71Sopenharmony_ci### OH_OnFrameAvailableListener 107e41f4b71Sopenharmony_ci 108e41f4b71Sopenharmony_ci``` 109e41f4b71Sopenharmony_citypedef struct OH_OnFrameAvailableListener OH_OnFrameAvailableListener 110e41f4b71Sopenharmony_ci``` 111e41f4b71Sopenharmony_ci 112e41f4b71Sopenharmony_ci**Description** 113e41f4b71Sopenharmony_ci 114e41f4b71Sopenharmony_ciDefines an **OH_NativeImage** listener, which is registered through [OH_NativeImage_SetOnFrameAvailableListener](#oh_nativeimage_setonframeavailablelistener). The listener triggers a callback when a frame is available. 115e41f4b71Sopenharmony_ci 116e41f4b71Sopenharmony_ci**Since**: 11 117e41f4b71Sopenharmony_ci 118e41f4b71Sopenharmony_ci 119e41f4b71Sopenharmony_ci### OHNativeErrorCode 120e41f4b71Sopenharmony_ci 121e41f4b71Sopenharmony_ci``` 122e41f4b71Sopenharmony_citypedef enum OHNativeErrorCode OHNativeErrorCode 123e41f4b71Sopenharmony_ci``` 124e41f4b71Sopenharmony_ci**Description** 125e41f4b71Sopenharmony_ci 126e41f4b71Sopenharmony_ciDefines an enum for the error codes. 127e41f4b71Sopenharmony_ci 128e41f4b71Sopenharmony_ci**Since**: 12 129e41f4b71Sopenharmony_ci 130e41f4b71Sopenharmony_ci 131e41f4b71Sopenharmony_ci### OHNativeWindow 132e41f4b71Sopenharmony_ci 133e41f4b71Sopenharmony_ci``` 134e41f4b71Sopenharmony_citypedef struct NativeWindow OHNativeWindow 135e41f4b71Sopenharmony_ci``` 136e41f4b71Sopenharmony_ci 137e41f4b71Sopenharmony_ci**Description** 138e41f4b71Sopenharmony_ci 139e41f4b71Sopenharmony_ciProvides the capability of accessing the **NativeWindow**. 140e41f4b71Sopenharmony_ci 141e41f4b71Sopenharmony_ci**Since**: 9 142e41f4b71Sopenharmony_ci 143e41f4b71Sopenharmony_ci### OHNativeWindowBuffer 144e41f4b71Sopenharmony_ci 145e41f4b71Sopenharmony_ci``` 146e41f4b71Sopenharmony_citypedef struct NativeWindowBuffer OHNativeWindowBuffer 147e41f4b71Sopenharmony_ci``` 148e41f4b71Sopenharmony_ci 149e41f4b71Sopenharmony_ci**Description** 150e41f4b71Sopenharmony_ci 151e41f4b71Sopenharmony_ciProvides the declaration of a **NativeWindowBuffer** struct. 152e41f4b71Sopenharmony_ci 153e41f4b71Sopenharmony_ci**Since**: 12 154e41f4b71Sopenharmony_ci 155e41f4b71Sopenharmony_ci 156e41f4b71Sopenharmony_ci## Enum Description 157e41f4b71Sopenharmony_ci 158e41f4b71Sopenharmony_ci 159e41f4b71Sopenharmony_ci### OHNativeErrorCode 160e41f4b71Sopenharmony_ci 161e41f4b71Sopenharmony_ci``` 162e41f4b71Sopenharmony_cienum OHNativeErrorCode 163e41f4b71Sopenharmony_ci``` 164e41f4b71Sopenharmony_ci**Description** 165e41f4b71Sopenharmony_ci 166e41f4b71Sopenharmony_ciEnumerates the error codes. 167e41f4b71Sopenharmony_ci 168e41f4b71Sopenharmony_ci**Since**: 12 169e41f4b71Sopenharmony_ci 170e41f4b71Sopenharmony_ci| Value| Description| 171e41f4b71Sopenharmony_ci| -------- | -------- | 172e41f4b71Sopenharmony_ci| NATIVE_ERROR_OK | The operation is successful. | 173e41f4b71Sopenharmony_ci| NATIVE_ERROR_INVALID_ARGUMENTS | An input parameter is invalid. | 174e41f4b71Sopenharmony_ci| NATIVE_ERROR_NO_PERMISSION | You do not have the permission to perform the operation. | 175e41f4b71Sopenharmony_ci| NATIVE_ERROR_NO_BUFFER | No buffer is available. | 176e41f4b71Sopenharmony_ci| NATIVE_ERROR_NO_CONSUMER | The consumer does not exist. | 177e41f4b71Sopenharmony_ci| NATIVE_ERROR_NOT_INIT | Not initialized. | 178e41f4b71Sopenharmony_ci| NATIVE_ERROR_CONSUMER_CONNECTED | The consumer is connected. | 179e41f4b71Sopenharmony_ci| NATIVE_ERROR_BUFFER_STATE_INVALID | The buffer status does not meet the expectation. | 180e41f4b71Sopenharmony_ci| NATIVE_ERROR_BUFFER_IN_CACHE | The buffer is already in the buffer queue. | 181e41f4b71Sopenharmony_ci| NATIVE_ERROR_BUFFER_QUEUE_FULL | The queue is full. | 182e41f4b71Sopenharmony_ci| NATIVE_ERROR_BUFFER_NOT_IN_CACHE | The buffer is not in the buffer queue. | 183e41f4b71Sopenharmony_ci| NATIVE_ERROR_CONSUMER_DISCONNECTED | The consumer is disconnected.| 184e41f4b71Sopenharmony_ci| NATIVE_ERROR_CONSUMER_NO_LISTENER_REGISTERED | No listener is registered on the consumer side.| 185e41f4b71Sopenharmony_ci| NATIVE_ERROR_UNSUPPORTED | The device or platform does not support the operation. | 186e41f4b71Sopenharmony_ci| NATIVE_ERROR_UNKNOWN | Unknown error. Check the log. | 187e41f4b71Sopenharmony_ci| NATIVE_ERROR_HDI_ERROR | Failed to call the HDI. | 188e41f4b71Sopenharmony_ci| NATIVE_ERROR_BINDER_ERROR | Cross-process communication failed. | 189e41f4b71Sopenharmony_ci| NATIVE_ERROR_EGL_STATE_UNKNOWN | The EGL environment is abnormal. | 190e41f4b71Sopenharmony_ci| NATIVE_ERROR_EGL_API_FAILED | Failed to call the EGL APIs. | 191e41f4b71Sopenharmony_ci 192e41f4b71Sopenharmony_ci 193e41f4b71Sopenharmony_ci## Function Description 194e41f4b71Sopenharmony_ci 195e41f4b71Sopenharmony_ci 196e41f4b71Sopenharmony_ci### OH_ConsumerSurface_SetDefaultUsage() 197e41f4b71Sopenharmony_ci 198e41f4b71Sopenharmony_ci``` 199e41f4b71Sopenharmony_ciint32_t OH_ConsumerSurface_SetDefaultUsage (OH_NativeImage* image, uint64_t usage ) 200e41f4b71Sopenharmony_ci``` 201e41f4b71Sopenharmony_ci 202e41f4b71Sopenharmony_ci**Description** 203e41f4b71Sopenharmony_ci 204e41f4b71Sopenharmony_ciSets the default read/write mode. This function is not thread-safe. 205e41f4b71Sopenharmony_ci 206e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeImage 207e41f4b71Sopenharmony_ci 208e41f4b71Sopenharmony_ci**Since**: 13 209e41f4b71Sopenharmony_ci 210e41f4b71Sopenharmony_ci**Parameters** 211e41f4b71Sopenharmony_ci 212e41f4b71Sopenharmony_ci| Name| Description| 213e41f4b71Sopenharmony_ci| -------- | -------- | 214e41f4b71Sopenharmony_ci| image | Pointer to an **OH_NativeImage** instance.| 215e41f4b71Sopenharmony_ci| usage | Read/write mode. For details about the available options, see **OH_NativeBuffer_Usage**.| 216e41f4b71Sopenharmony_ci 217e41f4b71Sopenharmony_ci**Returns** 218e41f4b71Sopenharmony_ci 219e41f4b71Sopenharmony_ciReturns **NATIVE_ERROR_OK** if the operation is successful. 220e41f4b71Sopenharmony_ci 221e41f4b71Sopenharmony_ciReturns **NATIVE_ERROR_INVALID_ARGUMENTS** if **image** is a null pointer. 222e41f4b71Sopenharmony_ci 223e41f4b71Sopenharmony_ci 224e41f4b71Sopenharmony_ci### OH_ConsumerSurface_SetDefaultSize() 225e41f4b71Sopenharmony_ci 226e41f4b71Sopenharmony_ci``` 227e41f4b71Sopenharmony_ciint32_t OH_ConsumerSurface_SetDefaultSize (OH_NativeImage* image, int32_t width, int32_t height ) 228e41f4b71Sopenharmony_ci``` 229e41f4b71Sopenharmony_ci 230e41f4b71Sopenharmony_ci**Description** 231e41f4b71Sopenharmony_ci 232e41f4b71Sopenharmony_ciSets the default size of a geometric shape. This function is not thread-safe. 233e41f4b71Sopenharmony_ci 234e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeImage 235e41f4b71Sopenharmony_ci 236e41f4b71Sopenharmony_ci**Since**: 13 237e41f4b71Sopenharmony_ci 238e41f4b71Sopenharmony_ci**Parameters** 239e41f4b71Sopenharmony_ci 240e41f4b71Sopenharmony_ci| Name| Description| 241e41f4b71Sopenharmony_ci| -------- | -------- | 242e41f4b71Sopenharmony_ci| image | Pointer to an **OH_NativeImage** instance.| 243e41f4b71Sopenharmony_ci| width | Width of the geometric shape. The value is greater than 0, in pixels.| 244e41f4b71Sopenharmony_ci| height | Height of the geometric shape. The value is greater than 0, in pixels.| 245e41f4b71Sopenharmony_ci 246e41f4b71Sopenharmony_ci**Returns** 247e41f4b71Sopenharmony_ci 248e41f4b71Sopenharmony_ciReturns **NATIVE_ERROR_OK** if the operation is successful. 249e41f4b71Sopenharmony_ci 250e41f4b71Sopenharmony_ciReturns **NATIVE_ERROR_INVALID_ARGUMENTS** if **image** is a null pointer or **width** or **height** is less than 0. 251e41f4b71Sopenharmony_ci 252e41f4b71Sopenharmony_ci### OH_ConsumerSurface_Create() 253e41f4b71Sopenharmony_ci 254e41f4b71Sopenharmony_ci``` 255e41f4b71Sopenharmony_ciOH_NativeImage* OH_ConsumerSurface_Create () 256e41f4b71Sopenharmony_ci``` 257e41f4b71Sopenharmony_ci 258e41f4b71Sopenharmony_ci**Description** 259e41f4b71Sopenharmony_ci 260e41f4b71Sopenharmony_ciCreates an **OH_NativeImage** instance as the consumer of the surface. 261e41f4b71Sopenharmony_ci 262e41f4b71Sopenharmony_ciThis function is used only for memory cycling of the surface consumer. Memory rendering is not proactively performed in the created **OH_NativeImage** instance. 263e41f4b71Sopenharmony_ci 264e41f4b71Sopenharmony_ciThis function cannot be used together with [OH_NativeImage_UpdateSurfaceImage](#oh_nativeimage_updatesurfaceimage). 265e41f4b71Sopenharmony_ci 266e41f4b71Sopenharmony_ciThis function must be used in pair with **OH_NativeImage_AcquireNativeWindowBuffer** and **OH_NativeImage_ReleaseNativeWindowBuffer**. 267e41f4b71Sopenharmony_ci 268e41f4b71Sopenharmony_ciThis function must be used in pair with [OH_NativeImage_Destroy](#oh_nativeimage_destroy). Otherwise, memory leak occurs. 269e41f4b71Sopenharmony_ci 270e41f4b71Sopenharmony_ciThis function is not thread-safe. 271e41f4b71Sopenharmony_ci 272e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeImage 273e41f4b71Sopenharmony_ci 274e41f4b71Sopenharmony_ci**Since**: 12 275e41f4b71Sopenharmony_ci 276e41f4b71Sopenharmony_ci**Returns** 277e41f4b71Sopenharmony_ci 278e41f4b71Sopenharmony_ciReturns a pointer to the **OH_NativeImage** instance if the operation is successful; returns **NULL** otherwise. 279e41f4b71Sopenharmony_ci 280e41f4b71Sopenharmony_ci 281e41f4b71Sopenharmony_ci### OH_NativeImage_AcquireNativeWindowBuffer() 282e41f4b71Sopenharmony_ci 283e41f4b71Sopenharmony_ci``` 284e41f4b71Sopenharmony_ciint32_t OH_NativeImage_AcquireNativeWindowBuffer (OH_NativeImage* image, OHNativeWindowBuffer** nativeWindowBuffer, int* fenceFd ) 285e41f4b71Sopenharmony_ci``` 286e41f4b71Sopenharmony_ci 287e41f4b71Sopenharmony_ci**Description** 288e41f4b71Sopenharmony_ci 289e41f4b71Sopenharmony_ciObtains an **OHNativeWindowBuffer** instance through an **OH_NativeImage** instance on the consumer side. 290e41f4b71Sopenharmony_ci 291e41f4b71Sopenharmony_ciThis function cannot be used together with [OH_NativeImage_UpdateSurfaceImage](#oh_nativeimage_updatesurfaceimage). 292e41f4b71Sopenharmony_ci 293e41f4b71Sopenharmony_ciThis function creates an **OHNativeWindowBuffer**. 294e41f4b71Sopenharmony_ci 295e41f4b71Sopenharmony_ciWhen using the **OHNativeWindowBuffer**, call **OH_NativeWindow_NativeObjectReference** to increase its reference count by one. 296e41f4b71Sopenharmony_ci 297e41f4b71Sopenharmony_ciWhen finishing using the **OHNativeWindowBuffer**, call **OH_NativeWindow_NativeObjectUnreference** to decrease the reference count by one. 298e41f4b71Sopenharmony_ci 299e41f4b71Sopenharmony_ciThis function must be used in pair with [OH_NativeImage_ReleaseNativeWindowBuffer](#oh_nativeimage_releasenativewindowbuffer). Otherwise, memory leak occurs. 300e41f4b71Sopenharmony_ci 301e41f4b71Sopenharmony_ciWhen **fenceFd** is used up, you must close it. 302e41f4b71Sopenharmony_ci 303e41f4b71Sopenharmony_ciThis function is not thread-safe. 304e41f4b71Sopenharmony_ci 305e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeImage 306e41f4b71Sopenharmony_ci 307e41f4b71Sopenharmony_ci**Since**: 12 308e41f4b71Sopenharmony_ci 309e41f4b71Sopenharmony_ci**Parameters** 310e41f4b71Sopenharmony_ci 311e41f4b71Sopenharmony_ci| Name| Description| 312e41f4b71Sopenharmony_ci| -------- | -------- | 313e41f4b71Sopenharmony_ci| image | Pointer to an **OH_NativeImage** instance.| 314e41f4b71Sopenharmony_ci| nativeWindowBuffer | Double pointer to the **OHNativeWindowBuffer** instance obtained.| 315e41f4b71Sopenharmony_ci| fenceFd | Pointer to the file descriptor handle.| 316e41f4b71Sopenharmony_ci 317e41f4b71Sopenharmony_ci**Returns** 318e41f4b71Sopenharmony_ci 319e41f4b71Sopenharmony_ciReturns **NATIVE_ERROR_OK** if the operation is successful. 320e41f4b71Sopenharmony_ci 321e41f4b71Sopenharmony_ciReturns **NATIVE_ERROR_INVALID_ARGUMENTS** if **image**, **nativeWindowBuffer**, or **fenceFd** is a null pointer. 322e41f4b71Sopenharmony_ci 323e41f4b71Sopenharmony_ciReturns **NATIVE_ERROR_NO_BUFFER** if no buffer is available for consumption. 324e41f4b71Sopenharmony_ci 325e41f4b71Sopenharmony_ci 326e41f4b71Sopenharmony_ci### OH_NativeImage_ReleaseNativeWindowBuffer() 327e41f4b71Sopenharmony_ci 328e41f4b71Sopenharmony_ci``` 329e41f4b71Sopenharmony_ciint32_t OH_NativeImage_ReleaseNativeWindowBuffer (OH_NativeImage* image, OHNativeWindowBuffer* nativeWindowBuffer, int fenceFd ) 330e41f4b71Sopenharmony_ci``` 331e41f4b71Sopenharmony_ci 332e41f4b71Sopenharmony_ci**Description** 333e41f4b71Sopenharmony_ci 334e41f4b71Sopenharmony_ciReleases an **OHNativeWindowBuffer** instance through an **OH_NativeImage** instance. 335e41f4b71Sopenharmony_ci 336e41f4b71Sopenharmony_ciThe system will close **fenFd**. You do not need to close it. 337e41f4b71Sopenharmony_ci 338e41f4b71Sopenharmony_ciThis function is not thread-safe. 339e41f4b71Sopenharmony_ci 340e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeImage 341e41f4b71Sopenharmony_ci 342e41f4b71Sopenharmony_ci**Since**: 12 343e41f4b71Sopenharmony_ci 344e41f4b71Sopenharmony_ci**Parameters** 345e41f4b71Sopenharmony_ci 346e41f4b71Sopenharmony_ci| Name| Description| 347e41f4b71Sopenharmony_ci| -------- | -------- | 348e41f4b71Sopenharmony_ci| image | Pointer to an **OH_NativeImage** instance.| 349e41f4b71Sopenharmony_ci| nativeWindowBuffer | Pointer to an **OHNativeWindowBuffer** instance.| 350e41f4b71Sopenharmony_ci| fenceFd | File descriptor handle, which is used for concurrent synchronization control.| 351e41f4b71Sopenharmony_ci 352e41f4b71Sopenharmony_ci**Returns** 353e41f4b71Sopenharmony_ci 354e41f4b71Sopenharmony_ciReturns **NATIVE_ERROR_OK** if the operation is successful. 355e41f4b71Sopenharmony_ci 356e41f4b71Sopenharmony_ciReturns **NATIVE_ERROR_INVALID_ARGUMENTS** if **image** or **nativeWindowBuffer** is a null pointer. 357e41f4b71Sopenharmony_ci 358e41f4b71Sopenharmony_ciReturns **NATIVE_ERROR_BUFFER_STATE_INVALID** if the status of **nativeWindowBuffer** is invalid. 359e41f4b71Sopenharmony_ci 360e41f4b71Sopenharmony_ciReturns **NATIVE_ERROR_BUFFER_NOT_IN_CACHE** if **nativeWindowBuffer** is not in the cache. 361e41f4b71Sopenharmony_ci 362e41f4b71Sopenharmony_ci 363e41f4b71Sopenharmony_ci 364e41f4b71Sopenharmony_ci### OH_NativeImage_AcquireNativeWindow() 365e41f4b71Sopenharmony_ci 366e41f4b71Sopenharmony_ci``` 367e41f4b71Sopenharmony_ciOHNativeWindow* OH_NativeImage_AcquireNativeWindow (OH_NativeImage * image) 368e41f4b71Sopenharmony_ci``` 369e41f4b71Sopenharmony_ci 370e41f4b71Sopenharmony_ci**Description** 371e41f4b71Sopenharmony_ci 372e41f4b71Sopenharmony_ciObtains an **OHNativeWindow** instance associated with an **OH_NativeImage** instance. 373e41f4b71Sopenharmony_ci 374e41f4b71Sopenharmony_ciThis function is not thread-safe. 375e41f4b71Sopenharmony_ci 376e41f4b71Sopenharmony_ciWhen **OH_NativeImage** is being destructed, the corresponding **OHNativeWindow** instance is released. If the **OHNativeWindow** pointer is obtained by using this function, set the pointer to null when releasing the **OH_NativeImage** instance, so as to prevent subsequent wild pointers. 377e41f4b71Sopenharmony_ci 378e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeImage 379e41f4b71Sopenharmony_ci 380e41f4b71Sopenharmony_ci**Since**: 9 381e41f4b71Sopenharmony_ci 382e41f4b71Sopenharmony_ci**Parameters** 383e41f4b71Sopenharmony_ci 384e41f4b71Sopenharmony_ci| Name| Description| 385e41f4b71Sopenharmony_ci| -------- | -------- | 386e41f4b71Sopenharmony_ci| image | Pointer to an **OH_NativeImage** instance.| 387e41f4b71Sopenharmony_ci 388e41f4b71Sopenharmony_ci**Returns** 389e41f4b71Sopenharmony_ci 390e41f4b71Sopenharmony_ciReturns a pointer to the **OHNativeWindow** instance if the operation is successful; returns **NULL** otherwise. 391e41f4b71Sopenharmony_ci 392e41f4b71Sopenharmony_ci 393e41f4b71Sopenharmony_ci### OH_NativeImage_AttachContext() 394e41f4b71Sopenharmony_ci 395e41f4b71Sopenharmony_ci``` 396e41f4b71Sopenharmony_ciint32_t OH_NativeImage_AttachContext (OH_NativeImage * image, uint32_t textureId ) 397e41f4b71Sopenharmony_ci``` 398e41f4b71Sopenharmony_ci 399e41f4b71Sopenharmony_ci**Description** 400e41f4b71Sopenharmony_ci 401e41f4b71Sopenharmony_ciAttaches an **OH_NativeImage** instance to the current OpenGL ES context. 402e41f4b71Sopenharmony_ci 403e41f4b71Sopenharmony_ciThe OpenGL ES texture will be bound to an **GL_TEXTURE_EXTERNAL_OES** instance and updated through the **OH_NativeImage** instance. 404e41f4b71Sopenharmony_ci 405e41f4b71Sopenharmony_ciThis function is not thread-safe. 406e41f4b71Sopenharmony_ci 407e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeImage 408e41f4b71Sopenharmony_ci 409e41f4b71Sopenharmony_ci**Since**: 9 410e41f4b71Sopenharmony_ci 411e41f4b71Sopenharmony_ci**Parameters** 412e41f4b71Sopenharmony_ci 413e41f4b71Sopenharmony_ci| Name| Description| 414e41f4b71Sopenharmony_ci| -------- | -------- | 415e41f4b71Sopenharmony_ci| image | Pointer to an **OH_NativeImage** instance.| 416e41f4b71Sopenharmony_ci| textureId | ID of the OpenGL ES texture to which the **OH_NativeImage** instance is to be attached.| 417e41f4b71Sopenharmony_ci 418e41f4b71Sopenharmony_ci**Returns** 419e41f4b71Sopenharmony_ci 420e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise. 421e41f4b71Sopenharmony_ci 422e41f4b71Sopenharmony_ci 423e41f4b71Sopenharmony_ci### OH_NativeImage_Create() 424e41f4b71Sopenharmony_ci 425e41f4b71Sopenharmony_ci``` 426e41f4b71Sopenharmony_ciOH_NativeImage* OH_NativeImage_Create (uint32_t textureId, uint32_t textureTarget ) 427e41f4b71Sopenharmony_ci``` 428e41f4b71Sopenharmony_ci 429e41f4b71Sopenharmony_ci**Description** 430e41f4b71Sopenharmony_ci 431e41f4b71Sopenharmony_ciCreates an **OH_NativeImage** instance to be associated with the OpenGL ES texture ID and target. 432e41f4b71Sopenharmony_ci 433e41f4b71Sopenharmony_ciThis function must be used in pair with **OH_NativeImage_Destroy**. Otherwise, memory leak occurs. 434e41f4b71Sopenharmony_ci 435e41f4b71Sopenharmony_ciThis function is not thread-safe. 436e41f4b71Sopenharmony_ci 437e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeImage 438e41f4b71Sopenharmony_ci 439e41f4b71Sopenharmony_ci**Since**: 9 440e41f4b71Sopenharmony_ci 441e41f4b71Sopenharmony_ci**Parameters** 442e41f4b71Sopenharmony_ci 443e41f4b71Sopenharmony_ci| Name| Description| 444e41f4b71Sopenharmony_ci| -------- | -------- | 445e41f4b71Sopenharmony_ci| textureId | OpenGL ES texture ID.| 446e41f4b71Sopenharmony_ci| textureTarget | OpenGL ES texture target.| 447e41f4b71Sopenharmony_ci 448e41f4b71Sopenharmony_ci**Returns** 449e41f4b71Sopenharmony_ci 450e41f4b71Sopenharmony_ciReturns a pointer to the **OH_NativeImage** instance if the operation is successful; returns **NULL** otherwise. 451e41f4b71Sopenharmony_ci 452e41f4b71Sopenharmony_ci 453e41f4b71Sopenharmony_ci### OH_NativeImage_Destroy() 454e41f4b71Sopenharmony_ci 455e41f4b71Sopenharmony_ci``` 456e41f4b71Sopenharmony_civoid OH_NativeImage_Destroy (OH_NativeImage ** image) 457e41f4b71Sopenharmony_ci``` 458e41f4b71Sopenharmony_ci 459e41f4b71Sopenharmony_ci**Description** 460e41f4b71Sopenharmony_ci 461e41f4b71Sopenharmony_ciDestroys an **OH_NativeImage** instance created by calling **OH_NativeImage_Create**. After the instance is destroyed, 462e41f4b71Sopenharmony_ci 463e41f4b71Sopenharmony_cithe pointer to the **OH_NativeImage** instance is assigned **NULL**. 464e41f4b71Sopenharmony_ci 465e41f4b71Sopenharmony_ciThis function is not thread-safe. 466e41f4b71Sopenharmony_ci 467e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeImage 468e41f4b71Sopenharmony_ci 469e41f4b71Sopenharmony_ci**Since**: 9 470e41f4b71Sopenharmony_ci 471e41f4b71Sopenharmony_ci**Parameters** 472e41f4b71Sopenharmony_ci 473e41f4b71Sopenharmony_ci| Name| Description| 474e41f4b71Sopenharmony_ci| -------- | -------- | 475e41f4b71Sopenharmony_ci| image | Pointer to an **OH_NativeImage** instance.| 476e41f4b71Sopenharmony_ci 477e41f4b71Sopenharmony_ci 478e41f4b71Sopenharmony_ci### OH_NativeImage_DetachContext() 479e41f4b71Sopenharmony_ci 480e41f4b71Sopenharmony_ci``` 481e41f4b71Sopenharmony_ciint32_t OH_NativeImage_DetachContext (OH_NativeImage * image) 482e41f4b71Sopenharmony_ci``` 483e41f4b71Sopenharmony_ci 484e41f4b71Sopenharmony_ci**Description** 485e41f4b71Sopenharmony_ci 486e41f4b71Sopenharmony_ciDetaches an **OH_NativeImage** instance from the current OpenGL ES context. 487e41f4b71Sopenharmony_ci 488e41f4b71Sopenharmony_ciThis function is not thread-safe. 489e41f4b71Sopenharmony_ci 490e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeImage 491e41f4b71Sopenharmony_ci 492e41f4b71Sopenharmony_ci**Since**: 9 493e41f4b71Sopenharmony_ci 494e41f4b71Sopenharmony_ci**Parameters** 495e41f4b71Sopenharmony_ci 496e41f4b71Sopenharmony_ci| Name| Description| 497e41f4b71Sopenharmony_ci| -------- | -------- | 498e41f4b71Sopenharmony_ci| image | Pointer to an **OH_NativeImage** instance.| 499e41f4b71Sopenharmony_ci 500e41f4b71Sopenharmony_ci**Returns** 501e41f4b71Sopenharmony_ci 502e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise. 503e41f4b71Sopenharmony_ci 504e41f4b71Sopenharmony_ci 505e41f4b71Sopenharmony_ci### OH_NativeImage_GetSurfaceId() 506e41f4b71Sopenharmony_ci 507e41f4b71Sopenharmony_ci``` 508e41f4b71Sopenharmony_ciint32_t OH_NativeImage_GetSurfaceId (OH_NativeImage * image, uint64_t * surfaceId ) 509e41f4b71Sopenharmony_ci``` 510e41f4b71Sopenharmony_ci 511e41f4b71Sopenharmony_ci**Description** 512e41f4b71Sopenharmony_ci 513e41f4b71Sopenharmony_ciObtains the surface ID of an **OH_NativeImage** instance. 514e41f4b71Sopenharmony_ci 515e41f4b71Sopenharmony_ciThis function is not thread-safe. 516e41f4b71Sopenharmony_ci 517e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeImage 518e41f4b71Sopenharmony_ci 519e41f4b71Sopenharmony_ci**Since**: 11 520e41f4b71Sopenharmony_ci 521e41f4b71Sopenharmony_ci**Parameters** 522e41f4b71Sopenharmony_ci 523e41f4b71Sopenharmony_ci| Name| Description| 524e41f4b71Sopenharmony_ci| -------- | -------- | 525e41f4b71Sopenharmony_ci| image | Pointer to an **OH_NativeImage** instance.| 526e41f4b71Sopenharmony_ci| surfaceId | Pointer to the surface ID.| 527e41f4b71Sopenharmony_ci 528e41f4b71Sopenharmony_ci**Returns** 529e41f4b71Sopenharmony_ci 530e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise. 531e41f4b71Sopenharmony_ci 532e41f4b71Sopenharmony_ci 533e41f4b71Sopenharmony_ci### OH_NativeImage_GetTimestamp() 534e41f4b71Sopenharmony_ci 535e41f4b71Sopenharmony_ci``` 536e41f4b71Sopenharmony_ciint64_t OH_NativeImage_GetTimestamp (OH_NativeImage * image) 537e41f4b71Sopenharmony_ci``` 538e41f4b71Sopenharmony_ci 539e41f4b71Sopenharmony_ci**Description** 540e41f4b71Sopenharmony_ci 541e41f4b71Sopenharmony_ciObtains the timestamp of the texture image that recently called the **OH_NativeImage_UpdateSurfaceImage** function. 542e41f4b71Sopenharmony_ci 543e41f4b71Sopenharmony_ciThis function is not thread-safe. 544e41f4b71Sopenharmony_ci 545e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeImage 546e41f4b71Sopenharmony_ci 547e41f4b71Sopenharmony_ci**Since**: 9 548e41f4b71Sopenharmony_ci 549e41f4b71Sopenharmony_ci**Parameters** 550e41f4b71Sopenharmony_ci 551e41f4b71Sopenharmony_ci| Name| Description| 552e41f4b71Sopenharmony_ci| -------- | -------- | 553e41f4b71Sopenharmony_ci| image | Pointer to an **OH_NativeImage** instance.| 554e41f4b71Sopenharmony_ci 555e41f4b71Sopenharmony_ci**Returns** 556e41f4b71Sopenharmony_ci 557e41f4b71Sopenharmony_ciReturns the timestamp of the texture image. 558e41f4b71Sopenharmony_ci 559e41f4b71Sopenharmony_ci 560e41f4b71Sopenharmony_ci### OH_NativeImage_GetTransformMatrix() 561e41f4b71Sopenharmony_ci 562e41f4b71Sopenharmony_ci``` 563e41f4b71Sopenharmony_ciint32_t OH_NativeImage_GetTransformMatrix (OH_NativeImage * image, float matrix[16] ) 564e41f4b71Sopenharmony_ci``` 565e41f4b71Sopenharmony_ci 566e41f4b71Sopenharmony_ci**Description** 567e41f4b71Sopenharmony_ci 568e41f4b71Sopenharmony_ciObtains the transformation matrix of the texture image that recently called the **OH_NativeImage_UpdateSurfaceImage** function. 569e41f4b71Sopenharmony_ci 570e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeImage 571e41f4b71Sopenharmony_ci 572e41f4b71Sopenharmony_ci**Deprecated from**: 12 573e41f4b71Sopenharmony_ci 574e41f4b71Sopenharmony_ci**Substitute**: [OH_NativeImage_GetTransformMatrixV2](#oh_nativeimage_gettransformmatrixv2) 575e41f4b71Sopenharmony_ci 576e41f4b71Sopenharmony_ci**Since**: 9 577e41f4b71Sopenharmony_ci 578e41f4b71Sopenharmony_ci**Parameters** 579e41f4b71Sopenharmony_ci 580e41f4b71Sopenharmony_ci| Name| Description| 581e41f4b71Sopenharmony_ci| -------- | -------- | 582e41f4b71Sopenharmony_ci| image | Pointer to an **OH_NativeImage** instance.| 583e41f4b71Sopenharmony_ci| matrix | Buffer used to store the 4 \* 4 transform matrix obtained.| 584e41f4b71Sopenharmony_ci 585e41f4b71Sopenharmony_ci**Returns** 586e41f4b71Sopenharmony_ci 587e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise. 588e41f4b71Sopenharmony_ci 589e41f4b71Sopenharmony_ci### OH_NativeImage_GetTransformMatrixV2() 590e41f4b71Sopenharmony_ci 591e41f4b71Sopenharmony_ci``` 592e41f4b71Sopenharmony_ciint32_t OH_NativeImage_GetTransformMatrixV2 (OH_NativeImage* image, float matrix[16] ) 593e41f4b71Sopenharmony_ci``` 594e41f4b71Sopenharmony_ci**Description** 595e41f4b71Sopenharmony_ci 596e41f4b71Sopenharmony_ciObtains, based on the rotation angle set by the producer, the transform matrix of the texture image that recently called the **OH_NativeImage_UpdateSurfaceImage** function. 597e41f4b71Sopenharmony_ci 598e41f4b71Sopenharmony_ciThe matrix is updated only after **OH_NativeImage_UpdateSurfaceImage** is called. 599e41f4b71Sopenharmony_ci 600e41f4b71Sopenharmony_ciThis function is not thread-safe. 601e41f4b71Sopenharmony_ci 602e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeImage 603e41f4b71Sopenharmony_ci 604e41f4b71Sopenharmony_ci**Since**: 12 605e41f4b71Sopenharmony_ci 606e41f4b71Sopenharmony_ci**Parameters** 607e41f4b71Sopenharmony_ci 608e41f4b71Sopenharmony_ci| Name| Description| 609e41f4b71Sopenharmony_ci| -------- | -------- | 610e41f4b71Sopenharmony_ci| image | Pointer to an **OH_NativeImage** instance. | 611e41f4b71Sopenharmony_ci| matrix | Buffer used to store the 4 \* 4 transform matrix obtained. | 612e41f4b71Sopenharmony_ci 613e41f4b71Sopenharmony_ci**Returns** 614e41f4b71Sopenharmony_ci 615e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise. 616e41f4b71Sopenharmony_ci 617e41f4b71Sopenharmony_ci### OH_NativeImage_SetOnFrameAvailableListener() 618e41f4b71Sopenharmony_ci 619e41f4b71Sopenharmony_ci``` 620e41f4b71Sopenharmony_ciint32_t OH_NativeImage_SetOnFrameAvailableListener (OH_NativeImage * image, OH_OnFrameAvailableListener listener ) 621e41f4b71Sopenharmony_ci``` 622e41f4b71Sopenharmony_ci 623e41f4b71Sopenharmony_ci**Description** 624e41f4b71Sopenharmony_ci 625e41f4b71Sopenharmony_ciRegisters a listener to listen for frame availability events. 626e41f4b71Sopenharmony_ci 627e41f4b71Sopenharmony_ciDo not call other functions of this module in the callback. 628e41f4b71Sopenharmony_ci 629e41f4b71Sopenharmony_ciThis function is not thread-safe. 630e41f4b71Sopenharmony_ci 631e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeImage 632e41f4b71Sopenharmony_ci 633e41f4b71Sopenharmony_ci**Since**: 11 634e41f4b71Sopenharmony_ci 635e41f4b71Sopenharmony_ci**Parameters** 636e41f4b71Sopenharmony_ci 637e41f4b71Sopenharmony_ci| Name| Description| 638e41f4b71Sopenharmony_ci| -------- | -------- | 639e41f4b71Sopenharmony_ci| image | Pointer to an **OH_NativeImage** instance.| 640e41f4b71Sopenharmony_ci| listener | Listener to register.| 641e41f4b71Sopenharmony_ci 642e41f4b71Sopenharmony_ci**Returns** 643e41f4b71Sopenharmony_ci 644e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise. 645e41f4b71Sopenharmony_ci 646e41f4b71Sopenharmony_ci 647e41f4b71Sopenharmony_ci### OH_NativeImage_UnsetOnFrameAvailableListener() 648e41f4b71Sopenharmony_ci 649e41f4b71Sopenharmony_ci``` 650e41f4b71Sopenharmony_ciint32_t OH_NativeImage_UnsetOnFrameAvailableListener (OH_NativeImage * image) 651e41f4b71Sopenharmony_ci``` 652e41f4b71Sopenharmony_ci 653e41f4b71Sopenharmony_ci**Description** 654e41f4b71Sopenharmony_ci 655e41f4b71Sopenharmony_ciDeregisters the listener used to listen for frame availability events. 656e41f4b71Sopenharmony_ci 657e41f4b71Sopenharmony_ciThis function is not thread-safe. 658e41f4b71Sopenharmony_ci 659e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeImage 660e41f4b71Sopenharmony_ci 661e41f4b71Sopenharmony_ci**Since**: 11 662e41f4b71Sopenharmony_ci 663e41f4b71Sopenharmony_ci**Parameters** 664e41f4b71Sopenharmony_ci 665e41f4b71Sopenharmony_ci| Name| Description| 666e41f4b71Sopenharmony_ci| -------- | -------- | 667e41f4b71Sopenharmony_ci| image | Pointer to an **OH_NativeImage** instance.| 668e41f4b71Sopenharmony_ci 669e41f4b71Sopenharmony_ci**Returns** 670e41f4b71Sopenharmony_ci 671e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise. 672e41f4b71Sopenharmony_ci 673e41f4b71Sopenharmony_ci 674e41f4b71Sopenharmony_ci### OH_NativeImage_UpdateSurfaceImage() 675e41f4b71Sopenharmony_ci 676e41f4b71Sopenharmony_ci``` 677e41f4b71Sopenharmony_ciint32_t OH_NativeImage_UpdateSurfaceImage (OH_NativeImage * image) 678e41f4b71Sopenharmony_ci``` 679e41f4b71Sopenharmony_ci 680e41f4b71Sopenharmony_ci**Description** 681e41f4b71Sopenharmony_ci 682e41f4b71Sopenharmony_ciUpdates the OpenGL ES texture associated with the latest frame through an **OH_NativeImage** instance. 683e41f4b71Sopenharmony_ci 684e41f4b71Sopenharmony_ciThis function must be called in a thread of the OpenGL ES context. 685e41f4b71Sopenharmony_ci 686e41f4b71Sopenharmony_ciThis function must be called after the **OH_OnFrameAvailableListener** callback is triggered. 687e41f4b71Sopenharmony_ci 688e41f4b71Sopenharmony_ciThis function is not thread-safe. 689e41f4b71Sopenharmony_ci 690e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Graphic.Graphic2D.NativeImage 691e41f4b71Sopenharmony_ci 692e41f4b71Sopenharmony_ci**Since**: 9 693e41f4b71Sopenharmony_ci 694e41f4b71Sopenharmony_ci**Parameters** 695e41f4b71Sopenharmony_ci 696e41f4b71Sopenharmony_ci| Name| Description| 697e41f4b71Sopenharmony_ci| -------- | -------- | 698e41f4b71Sopenharmony_ci| image | Pointer to an **OH_NativeImage** instance.| 699e41f4b71Sopenharmony_ci 700e41f4b71Sopenharmony_ci**Returns** 701e41f4b71Sopenharmony_ci 702e41f4b71Sopenharmony_ciReturns **0** if the operation is successful; returns an error code defined in [OHNativeErrorCode](#ohnativeerrorcode) otherwise. 703