提交 883cac07 编写于 作者: Z zhang-xiaobo1997

Modify for async

Signed-off-by: Nzhang-xiaobo1997 <tony.zhangxiaobo@huawei.com>
上级 c2c9a61f
...@@ -276,21 +276,24 @@ imageSourceIncrementalSApi.updateData(array, false, 0, 10,(error,data )=> {}) ...@@ -276,21 +276,24 @@ imageSourceIncrementalSApi.updateData(array, false, 0, 10,(error,data )=> {})
示例场景:camera作为客户端将拍照数据传给服务端 示例场景:camera作为客户端将拍照数据传给服务端
```js ```js
//服务端代码,创建ImageReceiver public async init(surfaceId: any) {
var receiver = image.createImageReceiver(8 * 1024, 8, image.ImageFormat.JPEG, 1);
//获取Surface ID //服务端代码,创建ImageReceiver
var surfaceId = await receiver.getReceivingSurfaceId(); var receiver = image.createImageReceiver(8 * 1024, 8, image.ImageFormat.JPEG, 1);
//注册Surface的监听,在suface的buffer准备好后触发 //获取Surface ID
receiver.on('imageArrival', () => { var surfaceId = await receiver.getReceivingSurfaceId();
//注册Surface的监听,在suface的buffer准备好后触发
receiver.on('imageArrival', () => {
//去获取Surface中最新的buffer //去获取Surface中最新的buffer
receiver.readNextImage((err, img) => { receiver.readNextImage((err, img) => {
img.getComponent(4, (err, componet) => { img.getComponent(4, (err, componet) => {
//消费componet.byteBuffer,例如:将buffer内容保存成图片。 //消费componet.byteBuffer,例如:将buffer内容保存成图片。
}) })
}) })
}) })
//调用Camera方法将surfaceId传递给Camera。camera会通过surfaceId获取surface,并生产出surface 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.
先完成此消息的编辑!
想要评论请 注册