未验证 提交 898611b1 编写于 作者: O openharmony_ci 提交者: Gitee

!12757 翻译完成:11958+12066+12127+12142+12155 apis-image

Merge pull request !12757 from wusongqing/TR11958
# Image Processing
# @ohos.multimedia.image (Image Processing)
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);
const imageSourceApi = image.createImageSource(data);
```
## image.createIncrementalSource<sup>9+</sup>
## image.CreateIncrementalSource<sup>9+</sup>
createIncrementalSource(buf: ArrayBuffer): ImageSource
CreateIncrementalSource(buf: ArrayBuffer): ImageSource
Creates an **ImageSource** instance in incremental mode based on the buffers.
......@@ -1101,12 +1101,12 @@ Creates an **ImageSource** instance in incremental mode based on the buffers.
```js
const buf = new ArrayBuffer(96); // 96 is the size of the pixel map buffer to create. The value is calculated as follows: height x width x 4.
const imageSourceIncrementalSApi = image.createIncrementalSource(buf);
const imageSourceIncrementalSApi = image.CreateIncrementalSource(buf);
```
## image.createIncrementalSource<sup>9+</sup>
## image.CreateIncrementalSource<sup>9+</sup>
createIncrementalSource(buf: ArrayBuffer, options?: SourceOptions): ImageSource
CreateIncrementalSource(buf: ArrayBuffer, options?: SourceOptions): ImageSource
Creates an **ImageSource** instance in incremental mode based on the buffers.
......@@ -1129,7 +1129,7 @@ Creates an **ImageSource** instance in incremental mode based on the buffers.
```js
const buf = new ArrayBuffer(96); // 96 is the size of the pixel map buffer to create. The value is calculated as follows: height x width x 4.
const imageSourceIncrementalSApi = image.createIncrementalSource(buf);
const imageSourceIncrementalSApi = image.CreateIncrementalSource(buf);
```
## ImageSource
......@@ -1203,7 +1203,7 @@ Obtains information about an image with the specified index. This API uses a pro
**Parameters**
| Name | Type | Mandatory| Description |
| Name| Type | Mandatory| Description |
| ----- | ------ | ---- | ------------------------------------- |
| index | number | No | Index of the image. If this parameter is not set, the default value **0** is used.|
......@@ -1376,8 +1376,8 @@ Updates incremental data. This API uses a promise to return the result.
| ---------- | ----------- | ---- | ------------ |
| buf | ArrayBuffer | Yes | Incremental data. |
| isFinished | boolean | Yes | Whether the update is complete.|
| value | number | No | Offset for data reading. |
| length | number | No | Array length. |
| value | number | Yes | Offset for data reading. |
| length | number | Yes | Array length. |
**Return value**
......@@ -1409,8 +1409,8 @@ Updates incremental data. This API uses an asynchronous callback to return the r
| ---------- | ------------------- | ---- | -------------------- |
| buf | ArrayBuffer | Yes | Incremental data. |
| isFinished | boolean | Yes | Whether the update is complete. |
| value | number | No | Offset for data reading. |
| length | number | No | Array length. |
| value | number | Yes | Offset for data reading. |
| length | number | Yes | Array length. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
......@@ -1772,7 +1772,7 @@ Creates an **ImageReceiver** instance by specifying the image width, height, for
| -------- | ------ | ---- | ---------------------- |
| width | number | Yes | Default image width. |
| height | number | Yes | Default image height. |
| 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 => {
var bufferArr = new Uint8Array(component.byteBuffer);
for (var i = 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 => {
var bufferArr = new Uint8Array(component.byteBuffer);
for (var i = 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.
**System capability**: SystemCapability.Multimedia.Image.Core
| Name | Default Value| Description |
| Name | Value | Description |
| ---------------------- | ------ | ----------------- |
| UNKNOWN | 0 | Unknown format. |
| RGB_565 | 2 | RGB_565. |
......@@ -2416,7 +2442,7 @@ Enumerates the alpha types of images.
**System capability**: SystemCapability.Multimedia.Image.Core
| Name | Default Value| Description |
| Name | Value | Description |
| -------- | ------ | ----------------------- |
| UNKNOWN | 0 | Unknown alpha type. |
| OPAQUE | 1 | There is no alpha or the image is opaque.|
......@@ -2429,7 +2455,7 @@ Enumerates the scale modes of images.
**System capability**: SystemCapability.Multimedia.Image.Core
| Name | Default Value| Description |
| Name | Value | Description |
| --------------- | ------ | -------------------------------------------------- |
| CENTER_CROP | 1 | Scales the image so that it fills the requested bounds of the target and crops the extra.|
| FIT_TARGET_SIZE | 0 | Reduces the image size to the dimensions of the target. |
......@@ -2519,7 +2545,7 @@ Describes the exchangeable image file format (EXIF) information of an image.
**System capability**: SystemCapability.Multimedia.Image.Core
| Name | Default Value | Description |
| Name | Value | Description |
| ----------------- | ----------------------- | ------------------------ |
| BITS_PER_SAMPLE | "BitsPerSample" | Number of bits per pixel. |
| ORIENTATION | "Orientation" | Image orientation. |
......@@ -2542,7 +2568,7 @@ Enumerates the image formats.
**System capability**: SystemCapability.Multimedia.Image.Core
| Name | Default Value| Description |
| Name | Value | Description |
| ------------ | ------ | -------------------- |
| YCBCR_422_SP | 1000 | YCBCR422 semi-planar format.|
| JPEG | 2000 | JPEG encoding format. |
......@@ -2553,7 +2579,7 @@ Enumerates the color component types of images.
**System capability**: SystemCapability.Multimedia.Image.ImageReceiver
| Name | Default Value| Description |
| Name | Value | Description |
| ----- | ------ | ----------- |
| YUV_Y | 1 | Luminance component. |
| YUV_U | 2 | Chrominance component. |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册