• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# OH_NativeImage
2
3
4## Overview
5
6The **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.
7
8\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
9
10**Since**
11
129
13
14
15## Summary
16
17
18### Files
19
20| Name| Description|
21| -------- | -------- |
22| [native_image.h](native__image_8h.md) | Defines the functions for obtaining and using **NativeImage**.<br>File to include: &lt;native_image/native_image.h&gt; |
23
24
25### Types
26
27| Name| Description|
28| -------- | -------- |
29| [OH_NativeImage](#oh_nativeimage) | Provides the declaration of an **OH_NativeImage** struct.|
30| [OHNativeWindow](#ohnativewindow) | Provides the capability of accessing the **NativeWindow**.|
31
32
33### Functions
34
35| Name| Description|
36| -------- | -------- |
37| [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.|
38| [OH_NativeImage_AcquireNativeWindow](#oh_nativeimage_acquirenativewindow) (OH_NativeImage \*image) | Obtains an **OHNativeWindow** instance associated with an **OH_NativeImage** instance. You need to call **OH_NativeWindow_DestroyNativeWindow** to release the **OHNativeWindow** instance when it is no longer required. |
39| [OH_NativeImage_AttachContext](#oh_nativeimage_attachcontext) (OH_NativeImage \*image, uint32_t textureId) | Attaches an **OH_NativeImage** instance to the current OpenGL ES context.<br>The OpenGL ES texture will be bound to an **GL_TEXTURE_EXTERNAL_OES** instance and updated through the **OH_NativeImage** instance.|
40| [OH_NativeImage_DetachContext](#oh_nativeimage_detachcontext) (OH_NativeImage \*image) | Detaches an **OH_NativeImage** instance from the current OpenGL ES context.|
41| [OH_NativeImage_UpdateSurfaceImage](#oh_nativeimage_updatesurfaceimage) (OH_NativeImage \*image) | Updates the OpenGL ES texture associated with the latest frame through an **OH_NativeImage** instance.|
42| [OH_NativeImage_GetTimestamp](#oh_nativeimage_gettimestamp) (OH_NativeImage*image) | Obtains the timestamp of the texture image that recently called the **OH_NativeImage_UpdateSurfaceImage** function.|
43| [OH_NativeImage_GetTransformMatrix](#oh_nativeimage_gettransformmatrix) (OH_NativeImage \*image, float matrix[16]) | Obtains the transform matrix of the texture image that recently called the **OH_NativeImage_UpdateSurfaceImage** function.|
44| [OH_NativeImage_Destroy](#oh_nativeimage_destroy) (OH_NativeImage \*\*image) | Destroys an **OH_NativeImage** instance created by calling **OH_NativeImage_Create**. After the instance is destroyed, the pointer to the **OH_NativeImage** instance is assigned **NULL**. |
45
46
47## Type Description
48
49
50### OH_NativeImage
51
52
53```
54typedef struct OH_NativeImage OH_NativeImage
55```
56
57**Description**
58
59Provides the declaration of an **OH_NativeImage** struct.
60
61
62### OHNativeWindow
63
64
65```
66typedef struct NativeWindow OHNativeWindow
67```
68
69**Description**
70
71Provides the capability of accessing the **NativeWindow**.
72
73
74## Function Description
75
76
77### OH_NativeImage_AcquireNativeWindow()
78
79
80```
81OHNativeWindow* OH_NativeImage_AcquireNativeWindow (OH_NativeImage * image)
82```
83
84**Description**
85
86Obtains an **OHNativeWindow** instance associated with an **OH_NativeImage** instance. You need to call **OH_NativeWindow_DestroyNativeWindow** to release the **OHNativeWindow** instance when it is no longer required.
87
88\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
89
90**Parameters**
91
92| Name| Description|
93| -------- | -------- |
94| image | Pointer to an **OH_NativeImage** instance.|
95
96**Returns**
97
98Returns a pointer to the **OHNativeWindow** instance if the operation is successful; returns **NULL** otherwise.
99
100
101### OH_NativeImage_AttachContext()
102
103
104```
105int32_t OH_NativeImage_AttachContext (OH_NativeImage * image, uint32_t textureId )
106```
107
108**Description**
109
110Attaches an **OH_NativeImage** instance to the current OpenGL ES context.
111
112The OpenGL ES texture will be bound to an **GL_TEXTURE_EXTERNAL_OES** instance and updated through the **OH_NativeImage** instance.
113
114\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
115
116**Parameters**
117
118| Name| Description|
119| -------- | -------- |
120| image | Pointer to an **OH_NativeImage** instance.|
121| textureId | ID of the OpenGL ES texture to which the **OH_NativeImage** instance is to be attached.|
122
123**Returns**
124
125Returns **0** if the operation is successful.
126
127
128### OH_NativeImage_Create()
129
130
131```
132OH_NativeImage* OH_NativeImage_Create (uint32_t textureId, uint32_t textureTarget )
133```
134
135**Description**
136
137Creates an **OH_NativeImage** instance to be associated with the OpenGL ES texture ID and target.
138
139\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
140
141**Parameters**
142
143| Name| Description|
144| -------- | -------- |
145| textureId | OpenGL ES texture ID.|
146| textureTarget | OpenGL ES texture target.|
147
148**Returns**
149
150Returns a pointer to the **OH_NativeImage** instance if the operation is successful; returns **NULL** otherwise.
151
152
153### OH_NativeImage_Destroy()
154
155
156```
157void OH_NativeImage_Destroy (OH_NativeImage ** image)
158```
159
160**Description**
161
162Destroys an **OH_NativeImage** instance created by calling **OH_NativeImage_Create**. After the instance is destroyed, the pointer to the **OH_NativeImage** instance is assigned **NULL**.
163
164\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
165
166**Parameters**
167
168| Name| Description|
169| -------- | -------- |
170| image | Pointer to an **OH_NativeImage** instance.|
171
172
173### OH_NativeImage_DetachContext()
174
175
176```
177int32_t OH_NativeImage_DetachContext (OH_NativeImage * image)
178```
179
180**Description**
181
182Detaches an **OH_NativeImage** instance from the current OpenGL ES context.
183
184\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
185
186**Parameters**
187
188| Name| Description|
189| -------- | -------- |
190| image | Pointer to an **OH_NativeImage** instance.|
191
192**Returns**
193
194Returns **0** if the operation is successful.
195
196
197### OH_NativeImage_GetTimestamp()
198
199
200```
201int64_t OH_NativeImage_GetTimestamp (OH_NativeImage * image)
202```
203
204**Description**
205
206Obtains the timestamp of the texture image that recently called the **OH_NativeImage_UpdateSurfaceImage** function.
207
208\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
209
210**Parameters**
211
212| Name| Description|
213| -------- | -------- |
214| image | Pointer to an **OH_NativeImage** instance.|
215
216**Returns**
217
218Returns the timestamp of the texture image.
219
220
221### OH_NativeImage_GetTransformMatrix()
222
223
224```
225int32_t OH_NativeImage_GetTransformMatrix (OH_NativeImage * image, float matrix[16] )
226```
227
228**Description**
229
230Obtains the transform matrix of the texture image that recently called the **OH_NativeImage_UpdateSurfaceImage** function.
231
232\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
233
234**Parameters**
235
236| Name| Description|
237| -------- | -------- |
238| image | Pointer to an **OH_NativeImage** instance.|
239| matrix | Buffer used to store the 4 \* 4 transform matrix obtained.|
240
241**Returns**
242
243Returns **0** if the operation is successful.
244
245
246### OH_NativeImage_UpdateSurfaceImage()
247
248
249```
250int32_t OH_NativeImage_UpdateSurfaceImage (OH_NativeImage * image)
251```
252
253**Description**
254
255Updates the OpenGL ES texture associated with the latest frame through an **OH_NativeImage** instance.
256
257\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
258
259**Parameters**
260
261| Name| Description|
262| -------- | -------- |
263| image | Pointer to an **OH_NativeImage** instance.|
264
265**Returns**
266
267Returns **0** if the operation is successful.
268