_o_h___native_image.md 6.4 KB
Newer Older
Z
zengyawen 已提交
1 2 3
# OH_NativeImage


4
## 概述
Z
zengyawen 已提交
5

6
提供NativeImage功能,作为数据消费者,主要用来将数据和OpenGL纹理对接,需在OpenGL环境下使用
Z
zengyawen 已提交
7

8
\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
Z
zengyawen 已提交
9

10
**起始版本:**
Z
zengyawen 已提交
11 12 13 14 15 16 17 18 19

9


## 汇总


### 文件

20 21 22 23 24 25 26 27
| 名称 | 描述 |
| -------- | -------- |
| [native_image.h](native__image_8h.md) | 定义获取和使用NativeImage的相关函数<br/>引用文件:&lt;native_image/native_image.h&gt; |


### 类型定义

| 名称 | 描述 |
Z
zengyawen 已提交
28
| -------- | -------- |
29 30
| [OH_NativeImage](#oh_nativeimage) | 提供OH_NativeImage结构体声明 |
| [OHNativeWindow](#ohnativewindow) | 提供对NativeWindow的访问功能 |
Z
zengyawen 已提交
31 32 33 34


### 函数

35
| 名称 | 描述 |
Z
zengyawen 已提交
36
| -------- | -------- |
37 38 39 40 41 42 43 44
| [OH_NativeImage_Create](#oh_nativeimage_create) (uint32_t textureId, uint32_t textureTarget) | 创建一个**OH_NativeImage**实例,该实例与OpenGL ES的纹理ID和纹理目标相关联 |
| [OH_NativeImage_AcquireNativeWindow](#oh_nativeimage_acquirenativewindow) (OH_NativeImage \*image) | 获取与OH_NativeImage相关联的OHNativeWindow指针. 该OHNativeWindow后续不再需要时需要调用<br/>OH_NativeWindow_DestroyNativeWindow释放 |
| [OH_NativeImage_AttachContext](#oh_nativeimage_attachcontext) (OH_NativeImage \*image, uint32_t textureId) | 将OH_NativeImage实例附加到当前OpenGL ES上下文, 且该OpenGL ES纹理会绑定到<br/>GL_TEXTURE_EXTERNAL_OES, 并通过OH_NativeImage进行更新 |
| [OH_NativeImage_DetachContext](#oh_nativeimage_detachcontext) (OH_NativeImage \*image) | 将OH_NativeImage实例从当前OpenGL ES上下文分离 |
| [OH_NativeImage_UpdateSurfaceImage](#oh_nativeimage_updatesurfaceimage) (OH_NativeImage \*image) | 通过OH_NativeImage获取最新帧更新相关联的OpenGL ES纹理 |
| [OH_NativeImage_GetTimestamp](#oh_nativeimage_gettimestamp) (OH_NativeImage*image) | 获取最近调用OH_NativeImage_UpdateSurfaceImage的纹理图像的相关时间戳 |
| [OH_NativeImage_GetTransformMatrix](#oh_nativeimage_gettransformmatrix) (OH_NativeImage \*image, float matrix[16]) | 获取最近调用OH_NativeImage_UpdateSurfaceImage的纹理图像的变化矩阵 |
| [OH_NativeImage_Destroy](#oh_nativeimage_destroy) (OH_NativeImage \*\*image) | 销毁通过OH_NativeImage_Create创建的**OH_NativeImage**实例, 销毁后该<br/>**OH_NativeImage**指针会被赋值为空 |
Z
zengyawen 已提交
45 46


47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
## 类型定义说明


### OH_NativeImage


```
typedef struct OH_NativeImage OH_NativeImage
```

**描述:**

提供OH_NativeImage结构体声明


### OHNativeWindow


```
typedef struct NativeWindow OHNativeWindow
```

**描述:**

提供对NativeWindow的访问功能
Z
zengyawen 已提交
72 73 74 75 76 77 78 79 80 81 82 83


## 函数说明


### OH_NativeImage_AcquireNativeWindow()


```
OHNativeWindow* OH_NativeImage_AcquireNativeWindow (OH_NativeImage * image)
```

84 85 86
**描述:**

获取与OH_NativeImage相关联的OHNativeWindow指针. 该OHNativeWindow后续不再需要时需要调用
Z
zengyawen 已提交
87

88
OH_NativeWindow_DestroyNativeWindow释放
Z
zengyawen 已提交
89

90
\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
Z
zengyawen 已提交
91

92
**参数:**
Z
zengyawen 已提交
93

94
| 名称 | 描述 |
Z
zengyawen 已提交
95
| -------- | -------- |
Z
zengyawen 已提交
96
| image | 指向OH_NativeImage实例的指针。 |
Z
zengyawen 已提交
97

98
**返回:**
Z
zengyawen 已提交
99

100
成功则返回一个指向OHNativeWindow实例的指针,否则返回**NULL**
Z
zengyawen 已提交
101 102 103 104 105 106 107 108 109


### OH_NativeImage_AttachContext()


```
int32_t OH_NativeImage_AttachContext (OH_NativeImage * image, uint32_t textureId )
```

110
**描述:**
Z
zengyawen 已提交
111

112
将OH_NativeImage实例附加到当前OpenGL ES上下文, 且该OpenGL ES纹理会绑定到
Z
zengyawen 已提交
113

114
GL_TEXTURE_EXTERNAL_OES, 并通过OH_NativeImage进行更新
Z
zengyawen 已提交
115

116
\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
Z
zengyawen 已提交
117

118 119 120
**参数:**

| 名称 | 描述 |
Z
zengyawen 已提交
121 122 123 124
| -------- | -------- |
| image | 指向OH_NativeImage实例的指针。 |
| textureId | OH_NativeImage要附加到的OPENGL ES纹理的id。 |

125
**返回:**
Z
zengyawen 已提交
126

127
返回值为0表示执行成功
Z
zengyawen 已提交
128 129 130 131 132 133 134 135 136


### OH_NativeImage_Create()


```
OH_NativeImage* OH_NativeImage_Create (uint32_t textureId, uint32_t textureTarget )
```

137
**描述:**
Z
zengyawen 已提交
138

139
创建一个**OH_NativeImage**实例,该实例与OpenGL ES的纹理ID和纹理目标相关联
Z
zengyawen 已提交
140

141
\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
Z
zengyawen 已提交
142

143
**参数:**
Z
zengyawen 已提交
144

145
| 名称 | 描述 |
Z
zengyawen 已提交
146
| -------- | -------- |
147 148
| textureId | OpenGL ES的纹理ID,OH_NativeImage实例会与之相关联 |
| textureTarget | OpenGL ES的纹理目标 |
Z
zengyawen 已提交
149

150
**返回:**
Z
zengyawen 已提交
151

152
返回一个指向**OH_NativeImage**实例的指针 returns **NULL** otherwise
Z
zengyawen 已提交
153 154 155 156 157 158 159 160 161


### OH_NativeImage_Destroy()


```
void OH_NativeImage_Destroy (OH_NativeImage ** image)
```

162 163 164
**描述:**

销毁通过OH_NativeImage_Create创建的**OH_NativeImage**实例, 销毁后该
Z
zengyawen 已提交
165

166
**OH_NativeImage**指针会被赋值为空
Z
zengyawen 已提交
167

168
\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
Z
zengyawen 已提交
169

170
**参数:**
Z
zengyawen 已提交
171

172
| 名称 | 描述 |
Z
zengyawen 已提交
173 174 175 176 177 178 179 180 181 182 183
| -------- | -------- |
| image | 指向OH_NativeImage实例的指针。 |


### OH_NativeImage_DetachContext()


```
int32_t OH_NativeImage_DetachContext (OH_NativeImage * image)
```

184
**描述:**
Z
zengyawen 已提交
185

186
将OH_NativeImage实例从当前OpenGL ES上下文分离
Z
zengyawen 已提交
187

188
\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
Z
zengyawen 已提交
189

190
**参数:**
Z
zengyawen 已提交
191

192
| 名称 | 描述 |
Z
zengyawen 已提交
193 194 195
| -------- | -------- |
| image | 指向OH_NativeImage实例的指针。 |

196
**返回:**
Z
zengyawen 已提交
197

198
返回值为0表示执行成功
Z
zengyawen 已提交
199 200 201 202 203 204 205 206 207


### OH_NativeImage_GetTimestamp()


```
int64_t OH_NativeImage_GetTimestamp (OH_NativeImage * image)
```

208
**描述:**
Z
zengyawen 已提交
209

210
获取最近调用OH_NativeImage_UpdateSurfaceImage的纹理图像的相关时间戳
Z
zengyawen 已提交
211

212
\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
Z
zengyawen 已提交
213

214
**参数:**
Z
zengyawen 已提交
215

216
| 名称 | 描述 |
Z
zengyawen 已提交
217 218 219
| -------- | -------- |
| image | 指向OH_NativeImage实例的指针。 |

220
**返回:**
Z
zengyawen 已提交
221

222
返回纹理图像的相关时间戳
Z
zengyawen 已提交
223 224 225 226 227 228 229 230 231


### OH_NativeImage_GetTransformMatrix()


```
int32_t OH_NativeImage_GetTransformMatrix (OH_NativeImage * image, float matrix[16] )
```

232
**描述:**
Z
zengyawen 已提交
233

234
获取最近调用OH_NativeImage_UpdateSurfaceImage的纹理图像的变化矩阵
Z
zengyawen 已提交
235

236
\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
Z
zengyawen 已提交
237

238
**参数:**
Z
zengyawen 已提交
239

240
| 名称 | 描述 |
Z
zengyawen 已提交
241 242 243 244
| -------- | -------- |
| image | 指向OH_NativeImage实例的指针。 |
| matrix | 用来存储要获取的4\*4的变化矩阵。 |

245
**返回:**
Z
zengyawen 已提交
246

247
返回值为0表示执行成功
Z
zengyawen 已提交
248 249 250 251 252 253 254 255 256


### OH_NativeImage_UpdateSurfaceImage()


```
int32_t OH_NativeImage_UpdateSurfaceImage (OH_NativeImage * image)
```

257
**描述:**
Z
zengyawen 已提交
258

259
通过OH_NativeImage获取最新帧更新相关联的OpenGL ES纹理
Z
zengyawen 已提交
260

261
\@syscap SystemCapability.Graphic.Graphic2D.OH_NativeImage
Z
zengyawen 已提交
262

263
**参数:**
Z
zengyawen 已提交
264

265
| 名称 | 描述 |
Z
zengyawen 已提交
266 267 268
| -------- | -------- |
| image | 指向OH_NativeImage实例的指针。 |

269
**返回:**
Z
zengyawen 已提交
270

271
返回值为0表示执行成功