提交 567053a4 编写于 作者: W wusongqing

updated docs

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 5792198c
Image Processing
==========
# Image Processing
> **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> The initial APIs of this module are supported since API 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Modules to Import
---------
## Modules to Import
```
import image from '@ohos.multimedia.image';
```
## image.createPixelMap<sup>8+</sup>
createPixelMap(colors: ArrayBuffer, opts: InitializetionOptions): Promise\<PixelMap>
createPixelMap(colors: ArrayBuffer, options: InitializetionOptions): Promise\<PixelMap>
Creates a **PixelMap** object. This API uses a promise to return the result.
......@@ -20,30 +18,28 @@ Creates a **PixelMap** object. This API uses a promise to return the result.
**Parameters**
| Name | Type | Mandatory| Description |
| ------ | ------------------------------------------------ | ---- | ------------------------------------------------------------ |
| colors | ArrayBuffer | Yes | Color array. |
| opts | [InitializetionOptions](#InitializationOptions8) | Yes | Pixel properties, including the alpha type, size, scale mode, pixel format, and editable.|
| Name | Type | Mandatory| Description |
| ------- | ------------------------------------------------ | ---- | ------------------------------------------------------------ |
| colors | ArrayBuffer | Yes | Color array. |
| options | [InitializetionOptions](#initializationoptions8) | Yes | Pixel properties, including the alpha type, size, scale mode, pixel format, and editable.|
**Return value**
| Type | Description |
| -------------------------------- | -------------- |
| Promise\<[PixelMap](#pixelmap7)> | Promise used to return the **PixelMap** object created.|
| Promise\<[PixelMap](#pixelmap7)> | Promise used to return the **PixelMap** object.|
**Example**
```js
image.createPixelMap(Color, opts)
.then((pixelmap) => {
expect(pixelmap !== null).assertTrue()
done()
})
```
## image.createPixelMap<sup>8+</sup>
createPixelMap(colors: ArrayBuffer, opts: InitializetionOptions) callback: AsyncCallback\<PixelMap>): void
createPixelMap(colors: ArrayBuffer, options: InitializetionOptions, callback: AsyncCallback\<PixelMap>): void
Creates a **PixelMap** object. This API uses an asynchronous callback to return the result.
......@@ -51,18 +47,16 @@ Creates a **PixelMap** object. This API uses an asynchronous callback to return
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | -------------------- |
| colors | ArrayBuffer | Yes | Color array. |
| opts | [InitializetionOptions](#InitializationOptions8) | Yes | Pixel properties. |
| callback | AsyncCallback\<[PixelMap](#pixelmap7)> | Yes | Callback used to return the **PixelMap** object obtained.|
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | -------------------------- |
| colors | ArrayBuffer | Yes | Color array. |
| options | [InitializetionOptions](#initializationoptions8) | Yes | Pixel properties. |
| callback | AsyncCallback\<[PixelMap](#pixelmap7)> | Yes | Callback used to return the **PixelMap** object.|
**Example**
```js
image.createPixelMap(Color, opts, (pixelmap) => {
expect(pixelmap !== null).assertTrue()
done()
})
```
......@@ -100,25 +94,10 @@ Reads image pixel map data and writes the data to an **ArrayBuffer**. This API u
```js
pixelmap.readPixelsToBuffer(readBuffer).then(() => {
var bufferArr = new Uint8Array(readBuffer)
var res = true
for (var i = 0; i < bufferArr.length; i++) {
if (res) {
if (bufferArr[i] !== 0) {
res = false
console.info('TC_020 Success')
expect(true).assertTrue()
done()
break
}
}
}
if (res) {
console.info('TC_020 buffer is all empty')
expect(false).assertTrue()
done()
}
})
// Called if the condition is met.
}).catch(error => {
// Called if no condition is met.
})
```
### readPixelsToBuffer<sup>7+</sup>
......@@ -140,24 +119,6 @@ Reads image pixel map data and writes the data to an **ArrayBuffer**. This API u
```js
pixelmap.readPixelsToBuffer(readBuffer, () => {
var bufferArr = new Uint8Array(readBuffer)
var res = true
for (var i = 0; i < bufferArr.length; i++) {
if (res) {
if (bufferArr[i] !== 0) {
res = false
console.info('TC_020-1 Success')
expect(true).assertTrue()
done()
break
}
}
}
if (res) {
console.info('TC_020-1 buffer is all empty')
expect(false).assertTrue()
done()
}
})
```
......@@ -185,28 +146,10 @@ Reads pixel map data in an area. This API uses a promise to return the data read
```js
pixelmap.readPixels(area).then((data) => {
if(data !== null){
var bufferArr = new Uint8Array(area.pixels);
var res = true;
for (var i = 0; i < bufferArr.length; i++) {
console.info('TC_021 buffer ' + bufferArr[i]);
if(res) {
if (bufferArr[i] == 0) {
res = false;
console.info('TC_021 Success');
expect(true).assertTrue();
done();
break;
}
}
}
if (res) {
console.info('TC_021 buffer is all empty');
expect(false).assertTrue()
done();
}
}
})
// Called if the condition is met.
}).catch(error => {
// Called if no condition is met.
})
```
### readPixels<sup>7+</sup>
......@@ -227,22 +170,22 @@ Reads image pixel map data in an area. This API uses a callback to return the da
**Example**
```js
pixelmap.readPixels(area,(data) => {
if(data !== null) {
var bufferArr = new Uint8Array(area.pixels);
var res = true;
for (var i = 0; i < bufferArr.length; i++) {
console.info('TC_021-1 buffer ' + bufferArr[i]);
if(res) {
if(bufferArr[i] == 0) {
res = false;
console.info('TC_021-1 Success');
expect(true).assertTrue();
done();
break;
}
}
}
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) => {
if(pixelmap == undefined){
console.info('createPixelMap failed');
expect(false).assertTrue();
done();
}else{
const area = { pixels: new ArrayBuffer(8),
offset: 0,
stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }}
pixelmap.readPixels(area, () => {
console.info('readPixels success');
})
}
})
```
### writePixels<sup>7+</sup>
......@@ -257,7 +200,7 @@ Writes image pixel map data to an area. This API uses a promise to return the op
| Name| Type | Mandatory| Description |
| ------ | ------------------------------ | ---- | -------------------- |
| area | [PositionArea](#PositionArea7) | Yes | Area to which the pixel map data will be written.|
| area | [PositionArea](#positionarea7) | Yes | Area to which the pixel map data will be written.|
**Return value**
......@@ -268,11 +211,39 @@ Writes image pixel map data to an area. This API uses a promise to return the op
**Example**
```js
pixelMap.writePixels(area).then(() => {
console.log("Succeeded in writing pixels.");
}).catch((err) => {
console.error("Failed to write pixels.");
});
const color = new ArrayBuffer(96);
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts)
.then( pixelmap => {
if (pixelmap == undefined) {
console.info('createPixelMap failed');
expect(false).assertTrue()
done();
}
const area = { pixels: new ArrayBuffer(8),
offset: 0,
stride: 8,
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
}
var bufferArr = new Uint8Array(area.pixels);
for (var i = 0; i < bufferArr.length; i++) {
bufferArr[i] = i + 1;
}
pixelmap.writePixels(area).then(() => {
const readArea = { pixels: new ArrayBuffer(8),
offset: 0,
stride: 8,
// region.size.width + x < opts.width, region.size.height + y < opts.height
region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
}
})
})
.catch(error => {
console.log('error: ' + error);
expect().assertFail();
done();
})
```
### writePixels<sup>7+</sup>
......@@ -287,7 +258,7 @@ Writes image pixel map data to an area. This API uses a callback to return the o
| Name | Type | Mandatory| Description |
| --------- | ------------------------------ | ---- | ------------------------------ |
| area | [PositionArea](#PositionArea7) | Yes | Area to which the pixel map data will be written. |
| area | [PositionArea](#positionarea7) | Yes | Area to which the pixel map data will be written. |
| callback: | AsyncCallback\<void> | Yes | Callback used to return the operation result. If the operation fails, an error message is returned.|
**Example**
......@@ -401,19 +372,7 @@ Obtains pixel map information about this image. This API uses a callback to retu
**Example**
```js
pixelmap.getImageInfo((imageInfo) => {
if (imageInfo !== null) {
console.info('TC_024-1 imageInfo is ready')
expect(imageInfo.size.height == 4).assertTrue()
expect(imageInfo.size.width == 6).assertTrue()
expect(imageInfo.pixelFormat == 1).assertTrue()
done()
} else {
console.info('TC_024-1 imageInfo is empty')
expect(false).assertTrue()
done()
}
})
pixelmap.getImageInfo((imageInfo) => {})
```
### getBytesNumberPerRow<sup>7+</sup>
......@@ -433,11 +392,7 @@ Obtains the number of bytes in each line of the image pixel map.
**Example**
```js
pixelmap.getBytesNumberPerRow().then((num) => {
console.info('TC_025 num is ' + num)
expect(num == expectNum).assertTrue()
done()
})
rowCount = pixelmap.getBytesNumberPerRow()
```
### getPixelBytesNumber<sup>7+</sup>
......@@ -457,11 +412,7 @@ Obtains the total number of bytes of the image pixel map.
**Example**
```js
pixelmap.getPixelBytesNumber().then((num) => {
console.info('TC_026 num is ' + num)
expect(num == expectNum).assertTrue()
done()
})
pixelBytesNumber = pixelmap.getPixelBytesNumber()
```
### release<sup>7+</sup>
......@@ -481,9 +432,8 @@ Releases this **PixelMap** object. This API uses a promise to return the result.
**Example**
```js
pixelmap.release()
expect(true).assertTrue()
done()
pixelmap.release().then(() => { })
.catch(error => {})
```
### release<sup>7+</sup>
......@@ -503,11 +453,7 @@ Releases this **PixelMap** object. This API uses a callback to return the result
**Example**
```js
pixelmap.release(()=>{
expect(true).assertTrue();
console.log('TC_027-1 success');
done();
})
pixelmap.release(()=>{ })
```
## image.createImageSource
......@@ -526,9 +472,9 @@ Creates an **ImageSource** instance based on the URI.
**Return value**
| Type | Description |
| --------------------------- | --------------------------------------- |
| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns **null** otherwise.|
| Type | Description |
| --------------------------- | -------------------------------------------- |
| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns **undefined** otherwise.|
**Example**
......@@ -552,9 +498,9 @@ Creates an **ImageSource** instance based on the file descriptor.
**Return value**
| Type | Description |
| --------------------------- | --------------------------------------- |
| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns **null** otherwise.|
| Type | Description |
| --------------------------- | -------------------------------------------- |
| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns **undefined** otherwise.|
**Example**
......@@ -590,20 +536,7 @@ Obtains information about an image with the specified index. This API uses a cal
**Example**
```js
it('TC_046', 0, async function (done) {
const imageSourceApi = image.createImageSource('/sdcard/test.jpg');
if (imageSourceApi == null) {
console.info('TC_046 create image source failed');
expect(false).assertTrue();
done();
} else {
imageSourceApi.getImageInfo(0,(error, imageInfo) => {
console.info('TC_046 imageInfo');
expect(imageInfo !== null).assertTrue();
done();
})
}
})
imageSourceApi.getImageInfo(0,(error, imageInfo) => {})
```
### getImageInfo
......@@ -623,11 +556,7 @@ Obtains information about this image. This API uses a callback to return the inf
**Example**
```js
imageSourceApi.getImageInfo(imageInfo => {
console.info('TC_045 imageInfo');
expect(imageInfo !== null).assertTrue();
done();
})
imageSourceApi.getImageInfo(imageInfo => {})
```
### getImageInfo
......@@ -654,11 +583,8 @@ Obtains information about an image with the specified index. This API uses a pro
```js
imageSourceApi.getImageInfo(0)
.then(imageInfo => {
console.info('TC_047 imageInfo');
expect(imageInfo !== null).assertTrue();
done();
})
.then(imageInfo => {})
.catch(error => {})
```
### getImageProperty<sup>7+</sup>
......@@ -685,7 +611,9 @@ Obtains the value of a property with the specified index in this image. This API
**Example**
```js
const w = imageSourceApi.getImageProperty("ImageWidth")
imageSourceApi.getImageProperty("BitsPerSample")
.then(data => {})
.catch(error => {})
```
### getImageProperty<sup>7+</sup>
......@@ -706,7 +634,7 @@ Obtains the value of a property with the specified index in this image. This API
**Example**
```js
const w = imageSourceApi.getImageProperty("ImageWidth",w=>{})
imageSourceApi.getImageProperty("BitsPerSample",(error,data) => {})
```
### getImageProperty<sup>7+</sup>
......@@ -728,12 +656,12 @@ Obtains the value of a property in this image. This API uses a callback to retur
**Example**
```js
imageSourceApi.getImageProperty("ImageWidth",PropertyOptions,(w)=>{})
imageSourceApi.getImageProperty("BitsPerSample",property,(error,data) => {})
```
### createPixelMap<sup>7+</sup>
createPixelMap(index: number, options: DecodingOptions, callback: AsyncCallback\<PixelMap>): void
createPixelMap(options?: DecodingOptions): Promise\<PixelMap>
Creates a **PixelMap** object based on image decoding parameters. This API uses a callback to return the result.
......@@ -741,58 +669,46 @@ Creates a **PixelMap** object based on image decoding parameters. This API uses
**Parameters**
| Name | Type | Mandatory| Description |
| ------------- | ------------------------------------- | ---- | -------------------- |
| options | [DecodingOptions](#decodingoptions7) | Yes | Image decoding parameters. |
| index | number | Yes | Image index. |
| AsyncCallback | AsyncCallback<[PixelMap](#pixelmap7)> | Yes | Callback used to return the operation result.|
| Name | Type | Mandatory| Description |
| ------- | ------------------------------------ | ---- | ---------- |
| options | [DecodingOptions](#decodingoptions7) | No | Image decoding parameters.|
**Return value**
| Type | Description |
| -------------------------------- | --------------------- |
| Promise\<[PixelMap](#pixelmap7)> | Promise used to return the **PixelMap** object.|
**Example**
```js
imageSourceApi.createPixelMap().then(pixelmap => {
console.info('TC_050-11 createPixelMap ');
expect(pixelmap !== null ).assertTrue();
done();
})
imageSourceApi.createPixelMap().then(pixelmap => {})
.catch(error => {})
```
### createPixelMap<sup>7+</sup>
createPixelMap(options: DecodingOptions, callback: AsyncCallback\<PixelMap>): void
createPixelMap(callback: AsyncCallback\<PixelMap>): void
Creates a **PixelMap** object based on image decoding parameters. This API uses a callback to return the result.
Creates a **PixelMap** object based on the default parameters. This API uses a callback to return the result.
**System capability**: SystemCapability.Multimedia.Image
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------- | ---- | -------------------- |
| options | [DecodingOptions](#decodingoptions7) | Yes | Image decoding parameters. |
| callback | AsyncCallback<[PixelMap](#pixelmap7)> | Yes | Callback used to return the operation result.|
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------- | ---- | -------------------------- |
| callback | AsyncCallback<[PixelMap](#pixelmap7)> | Yes | Callback used to return the **PixelMap** object.|
**Example**
```js
let decodingOptions = {
sampleSize:1,
editable: true,
desiredSize:{ width:1, height:2},
rotateDegrees:10,
desiredPixelFormat:1,
desiredRegion: { size: { height: 1, width: 2 }, x: 0, y: 0 },
};
imageSourceApi.createPixelMap(0,decodingOptions, pixelmap => {
console.info('TC_050-1 createPixelMap ');
expect(pixelmap !== null ).assertTrue();
done();
})
imageSourceApi.createPixelMap(pixelmap => {})
```
### createPixelMap<sup>7+</sup>
createPixelMap(opts: DecodingOptions, callback: AsyncCallback\<PixelMap>): void
createPixelMap(options: DecodingOptions, callback: AsyncCallback\<PixelMap>): void
Creates a **PixelMap** object based on image decoding parameters. This API uses a callback to return the result.
......@@ -800,28 +716,15 @@ Creates a **PixelMap** object based on image decoding parameters. This API uses
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------- | ---- | -------------------- |
| opts | [DecodingOptions](#decodingoptions7) | Yes | Image decoding parameters. |
| callback | AsyncCallback<[PixelMap](#pixelmap7)> | Yes | Callback used to return the operation result.|
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------- | ---- | -------------------------- |
| options | [DecodingOptions](#decodingoptions7) | Yes | Image decoding parameters. |
| callback | AsyncCallback<[PixelMap](#pixelmap7)> | Yes | Callback used to return the **PixelMap** object.|
**Example**
```js
let decodingOptions = {
sampleSize:1,
editable: true,
desiredSize:{ width:1, height:2},
rotateDegrees:10,
desiredPixelFormat:1,
desiredRegion: { size: { height: 1, width: 2 }, x: 0, y: 0 },
index:1
};
imageSourceApi.createPixelMap(decodingOptions, pixelmap => {
console.info('TC_050-1 createPixelMap ');
expect(pixelmap !== null ).assertTrue();
done();
})
imageSourceApi.createPixelMap(decodingOptions, pixelmap => {})
```
### release
......@@ -841,12 +744,7 @@ Releases this **ImageSource** instance. This API uses a callback to return the r
**Example**
```js
imageSourceApi.release(() => {
console.info('TC_044-1 Success');
expect(true).assertTrue();
done();
})
}
imageSourceApi.release(() => {})
```
### release
......@@ -866,11 +764,7 @@ Releases this **ImageSource** instance. This API uses a promise to return the re
**Example**
```js
imageSourceApi.release(() => {
console.info('TC_044-1 Success');
expect(true).assertTrue();
done();
})
imageSourceApi.release().then(()=>{ }).catch(error => {})
```
## image.createImagePacker
......@@ -883,9 +777,9 @@ Creates an **ImagePacker** instance.
**Return value**
| Type | Description |
| ----------- | ---------------------- |
| ImagePacker | **ImagePacker** instance created.|
| Type | Description |
| --------------------------- | --------------------- |
| [ImagePacker](#imagepacker) | **ImagePacker** instance created.|
**Example**
......@@ -905,7 +799,60 @@ Provide APIs to pack images. Before calling any API in **ImagePacker**, you must
### packing
packing(source: ImageSource, option: PackingOption, callback: AsyncCallback<Array\<number>>): void
packing(source: ImageSource, option: PackingOption, callback: AsyncCallback<Array\<ArrayBuffer>>): void
Packs an image. This API uses a callback to return the result.
**System capability**: SystemCapability.Multimedia.Image
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------- | ---- | ---------------------------------- |
| source | [ImageSource](#imagesource) | Yes | Image to pack. |
| option | [PackingOption](#packingoption) | Yes | Option for image packing. |
| callback | AsyncCallback<Array\<ArrayBuffer>> | Yes | Callback used to return the packed data.|
**Example**
```js
let packOpts = { format:["image/jpeg"], quality:98 }
imagePackerApi.packing(imageSourceApi, packOpts, data => {})
```
### packing
packing(source: ImageSource, option: PackingOption): Promise<Array\<ArrayBuffer>>
Packs an image. This API uses a promise to return the result.
**System capability**: SystemCapability.Multimedia.Image
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------------------------------- | ---- | -------------- |
| source | [ImageSource](#imagesource) | Yes | Image to pack.|
| option | [PackingOption](#packingoption) | Yes | Option for image packing.|
**Return value**
| Type | Description |
| :--------------------------- | :-------------------------------------------- |
| Promise<Array\<ArrayBuffer>> | Promise used to return the packed data.|
**Example**
```js
let packOpts = { format:["image/jpeg"], quality:98 }
imagePackerApi.packing(imageSourceApi, packOpts)
.then( data => { })
.catch(error => {})
```
### packing
packing(source: PixelMap, option: PackingOption, callback: AsyncCallback\<ArrayBuffer>): void
Packs an image. This API uses a callback to return the result.
......@@ -915,24 +862,20 @@ Packs an image. This API uses a callback to return the result.
| Name | Type | Mandatory| Description |
| -------- | ------------------------------- | ---- | ---------------------------------- |
| source | [ImageSource](#imagesource) | Yes | Image to pack. |
| source | [PixelMap](#pixelmap) | Yes | **PixelMap** object to pack. |
| option | [PackingOption](#packingoption) | Yes | Option for image packing. |
| callback | AsyncCallback<Array\<number>> | Yes | Callback used to return the packed data.|
| callback | AsyncCallback\<ArrayBuffer> | Yes | Callback used to return the packed data.|
**Example**
```js
let packOpts = { format:["image/jpeg"], quality:98 }
imagePackerApi.packing(imageSourceApi, packOpts, data => {
console.info('TC_062-1 finished');
expect(data !== null).assertTrue();
done();
})
imagePackerApi.packing(pixelMapApi, packOpts, data => {})
```
### packing
packing(source: ImageSource, option: PackingOption): Promise<Array\<number>>
packing(source: PixelMap, option: PackingOption): Promise<Array\<ArrayBuffer>>
Packs an image. This API uses a promise to return the result.
......@@ -942,25 +885,22 @@ Packs an image. This API uses a promise to return the result.
| Name| Type | Mandatory| Description |
| ------ | ------------------------------- | ---- | -------------- |
| source | [ImageSource](#imagesource) | Yes | Image to pack.|
| source | [PixelMap](#pixelmap) | Yes | **PixelMap** object to pack.|
| option | [PackingOption](#packingoption) | Yes | Option for image packing.|
**Return value**
| Type | Description |
| :---------------------- | :-------------------------------------------- |
| Promise<Array\<number>> | Promise used to return the packed data.|
| Type | Description |
| :--------------------------- | :-------------------------------------------- |
| Promise<Array\<ArrayBuffer>> | Promise used to return the packed data.|
**Example**
```js
let packOpts = { format:["image/jpeg"], quality:98 }
imagePackerApi.packing(imageSourceApi, packOpts)
.then( data => {
console.info('TC_062 finished');
expect(data !== null).assertTrue();
done();
})
imagePackerApi.packing(pixelMapApi, packOpts)
.then( data => { })
.catch(error => {})
```
### release
......@@ -980,10 +920,7 @@ Releases this **ImagePacker** instance. This API uses a callback to return the r
**Example**
```js
imagePackerApi.release(()=>{
console.info('TC_063-1 release');
expect(true).assertTrue();
done();
imagePackerApi.release(()=>{})
```
### release
......@@ -1003,10 +940,8 @@ Releases this **ImagePacker** instance. This API uses a promise to return the re
**Example**
```js
imagePackerApi.release();
console.info('TC_063 release');
expect(true).assertTrue();
done();
imagePackerApi.release().then(()=>{
}).catch((error)=>{})
```
## PositionArea<sup>7+</sup>
......@@ -1015,14 +950,14 @@ Describes area information in an image.
**System capability**: SystemCapability.Multimedia.Image
| Name | Type | Readable| Writable| Description |
| ------ | ------------------ | ---- | ---- | -------------------- |
| pixels | ArrayBuffer | Yes | No | Pixels of the image. |
| offset | number | Yes | No | Offset for data reading. |
| stride | number | Yes | No | Number of bytes to read. |
| region | [Region](#region8) | Yes | No | Region to read or write.|
| Name | Type | Readable| Writable| Description |
| ------ | ------------------ | ---- | ---- | ------------------------------------------------------------ |
| pixels | ArrayBuffer | Yes | No | Pixels of the image. |
| offset | number | Yes | No | Offset for data reading. |
| stride | number | Yes | No | Number of bytes from one row of pixels in memory to the next row of pixels in memory. The value of **stride** must be greater than or equal to the value of **region.size.width** multiplied by 4. |
| region | [Region](#region8) | Yes | No | Region to read or write. The width of the region to write plus the X coordinate cannot be greater than the width of the original image. The height of the region to write plus the Y coordinate cannot be greater than the height of the original image.|
## **ImageInfo**
## ImageInfo
Describes image information.
......@@ -1055,7 +990,7 @@ Enumerates pixel map formats.
| RGBA_8888 | 3 | RGBA_8888.|
| RGB_565 | 2 | RGB_565. |
## AlphaType<sup>8+</sup>
## AlphaType<sup>9+</sup>
Enumerates alpha types.
......@@ -1068,7 +1003,7 @@ Enumerates alpha types.
| PREMUL | 2 | Premultiplied alpha. |
| UNPREMUL | 3 | Unpremultiplied alpha, that is, straight alpha. |
## ScaleMode<sup>8+</sup>
## ScaleMode<sup>9+</sup>
Enumerates scale modes.
......@@ -1085,10 +1020,10 @@ Enumerates scale modes.
| Name | Type | Readable| Writable| Description |
| ----------- | ---------------------------------- | ---- | ---- | -------------- |
| alphaType | [AlphaType](#alphatype8) | Yes | Yes | Alpha type. |
| alphaType<sup>9+</sup> | [AlphaType](#alphatype9) | Yes | Yes | Alpha type. |
| editable | boolean | Yes | Yes | Whether the image is editable. |
| pixelFormat | [PixelMapFormat](#pixelmapformat7) | Yes | Yes | Pixel map format. |
| scaleMode | [ScaleMode](#scalemode8) | Yes | Yes | Scale mode. |
| scaleMode<sup>9+</sup> | [ScaleMode](#scalemode9) | Yes | Yes | Scale mode. |
| size | [Size](#size) | Yes | Yes | Image size.|
## DecodingOptions<sup>7+</sup>
......@@ -1100,22 +1035,22 @@ Describes the decoding options.
| Name | Type | Readable| Writable| Description |
| ------------------ | ---------------------------------- | ---- | ---- | ---------------- |
| sampleSize | number | Yes | Yes | Thumbnail sampling size.|
| rotateDegrees | number | Yes | Yes | Rotation angle. |
| rotate | number | Yes | Yes | Rotation angle. |
| editable | boolean | Yes | Yes | Whether the image is editable. |
| desiredSize | [Size](#size) | Yes | Yes | Expected output size. |
| desiredRegion | [Region](#region8) | Yes | Yes | Region to decode. |
| desiredRegion | [Region](#region7) | Yes | Yes | Region to decode. |
| desiredPixelFormat | [PixelMapFormat](#pixelmapformat7) | Yes | Yes | Pixel map format for decoding.|
| index | numer | Yes | Yes | Index of the image to decode. |
## Region<sup>8+</sup>
## Region<sup>7+</sup>
Describes region information.
**System capability**: SystemCapability.Multimedia.Image
| Name| Type | Readable| Writable| Description |
| ---- | ------------- | ---- | ---- | ---------- |
| size | [Size](#size) | Yes | Yes | Region size.|
| Name| Type | Readable| Writable| Description |
| ---- | ------------- | ---- | ---- | ------------ |
| size | [Size](#size) | Yes | Yes | Region size. |
| x | number | Yes | Yes | X coordinate of the region.|
| y | number | Yes | Yes | Y coordinate of the region.|
......@@ -1145,6 +1080,8 @@ Describes image properties.
Describes the exchangeable image file format (Exif) information of an image.
**System capability**: SystemCapability.Multimedia.Image
| Name | Default Value | Description |
| ----------------- | ----------------- | -------------------- |
| BITS_PER_SAMPLE | "BitsPerSample" | Number of bytes in each pixel. |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册