未验证 提交 07a39938 编写于 作者: O openharmony_ci 提交者: Gitee

!5094 ImageReciver使用指导

Merge pull request !5094 from 张晓波/master
......@@ -271,3 +271,29 @@ imageSourceIncrementalSApi.updateData(array, false, 0, 10,(error,data )=> {})
```
### ImageReceiver的使用
示例场景:camera作为客户端将拍照数据传给服务端
```js
public async init(surfaceId: any) {
//服务端代码,创建ImageReceiver
var receiver = image.createImageReceiver(8 * 1024, 8, image.ImageFormat.JPEG, 1);
//获取Surface ID
var surfaceId = await receiver.getReceivingSurfaceId();
//注册Surface的监听,在suface的buffer准备好后触发
receiver.on('imageArrival', () => {
//去获取Surface中最新的buffer
receiver.readNextImage((err, img) => {
img.getComponent(4, (err, componet) => {
//消费componet.byteBuffer,例如:将buffer内容保存成图片。
})
})
})
//调用Camera方法将surfaceId传递给Camera。camera会通过surfaceId获取surface,并生产出surface buffer。
}
```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册