The **Image** module provides APIs for image processing. You can use the APIs to create a **PixelMap** object with specified properties or read image pixel data (even in an area).
...
...
@@ -1077,9 +1077,9 @@ const data = new ArrayBuffer(112);
| format | number | Yes | Image format, which is a constant of [ImageFormat](#imageformat9). (Currently, the value of this parameter is agreed between the user and camera. In the future, there may be other application scenarios. The receiver is used only for transfer. Currently, only **ImageFormat:JPEG** is supported.) |
| format | number | Yes | Image format, which is a constant of [ImageFormat](#imageformat9). (Only ImageFormat:JPEG and 4 are supported.) |
| capacity | number | Yes | Maximum number of images that can be accessed at the same time.|
**Return value**
...
...
@@ -2080,9 +2080,9 @@ Obtains an image buffer from the idle queue and writes image data into it. This
```js
creator.dequeueImage((err,img)=>{
if(err){
console.info('dequeueImage succeeded.');
}
console.info('dequeueImage failed.');
}
console.info('dequeueImage succeeded.');
});
```
...
...
@@ -2128,12 +2128,25 @@ Places the drawn image in the dirty queue. This API uses an asynchronous callbac
**Example**
```js
creator.queueImage(img,(err)=>{
creator.dequeueImage().then(img=>{
// Draw the image.
img.getComponent(4).then(component=>{
varbufferArr=newUint8Array(component.byteBuffer);
for(vari=0;i<bufferArr.length;i+=4){
bufferArr[i]=0;//B
bufferArr[i+1]=0;//G
bufferArr[i+2]=255;//R
bufferArr[i+3]=255;//A
}
})
creator.queueImage(img,(err)=>{
if(err){
console.info('dequeueImage failed: '+err);
console.info('queueImage failed: '+err);
}
console.info('dequeueImage succeeded');
console.info('queueImage succeeded');
})
})
```
### queueImage<sup>9+</sup>
...
...
@@ -2159,11 +2172,24 @@ Places the drawn image in the dirty queue. This API uses a promise to return the
**Example**
```js
creator.queueImage(img).then(()=>{
console.info('dequeueImage succeeded.');
}).catch(error=>{
console.info('dequeueImage failed: '+error);
creator.dequeueImage().then(img=>{
// Draw the image.
img.getComponent(4).then(component=>{
varbufferArr=newUint8Array(component.byteBuffer);
for(vari=0;i<bufferArr.length;i+=4){
bufferArr[i]=0;//B
bufferArr[i+1]=0;//G
bufferArr[i+2]=255;//R
bufferArr[i+3]=255;//A
}
})
creator.queueImage(img).then(()=>{
console.info('queueImage succeeded.');
}).catch(error=>{
console.info('queueImage failed: '+error);
})
})
```
### on<sup>9+</sup>
...
...
@@ -2398,7 +2424,7 @@ Enumerates the pixel formats of images.