js-apis-image.md 83.2 KB
Newer Older
W
wusongqing 已提交
1
# Image Processing
W
wusongqing 已提交
2

3 4
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).

W
wusongqing 已提交
5 6
> **NOTE**
>
W
wusongqing 已提交
7
> The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
W
wusongqing 已提交
8

W
wusongqing 已提交
9
## Modules to Import
W
wusongqing 已提交
10

W
wusongqing 已提交
11
```js
W
wusongqing 已提交
12 13 14 15
import image from '@ohos.multimedia.image';
```

## image.createPixelMap<sup>8+</sup>
16

W
wusongqing 已提交
17
createPixelMap(colors: ArrayBuffer, options: InitializationOptions): Promise\<PixelMap>
W
wusongqing 已提交
18

W
wusongqing 已提交
19
Creates a **PixelMap** object with the default BGRA_8888 format and pixel properties specified. This API uses a promise to return the result.
W
wusongqing 已提交
20

21
**System capability**: SystemCapability.Multimedia.Image.Core
W
wusongqing 已提交
22 23 24

**Parameters**

W
wusongqing 已提交
25 26 27
| Name   | Type                                            | Mandatory| Description                                                            |
| ------- | ------------------------------------------------ | ---- | ---------------------------------------------------------------- |
| colors  | ArrayBuffer                                      | Yes  | Color array in BGRA_8888 format.                                       |
W
wusongqing 已提交
28
| options | [InitializationOptions](#initializationoptions8) | Yes  | Pixel properties, including the alpha type, size, scale mode, pixel format, and editable.|
W
wusongqing 已提交
29 30 31

**Return value**

W
wusongqing 已提交
32 33 34 35
| Type                            | Description                                                                   |
| -------------------------------- | ----------------------------------------------------------------------- |
| Promise\<[PixelMap](#pixelmap7)> | Promise used to return the **PixelMap** object.<br>If the size of the created pixel map exceeds that of the original image, the pixel map size of the original image is returned.|

W
wusongqing 已提交
36 37 38 39

**Example**

```js
W
wusongqing 已提交
40
const color = new ArrayBuffer(96);
41
let bufferArr = new Uint8Array(color);
W
wusongqing 已提交
42 43 44 45
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts)
    .then((pixelmap) => {
        })
W
wusongqing 已提交
46 47 48 49
```

## image.createPixelMap<sup>8+</sup>

W
wusongqing 已提交
50
createPixelMap(colors: ArrayBuffer, options: InitializationOptions, callback: AsyncCallback\<PixelMap>): void
W
wusongqing 已提交
51

W
wusongqing 已提交
52
Creates a **PixelMap** object with the default BGRA_8888 format and pixel properties specified. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
53

54
**System capability**: SystemCapability.Multimedia.Image.Core
W
wusongqing 已提交
55 56 57

**Parameters**

W
wusongqing 已提交
58 59
| Name    | Type                                            | Mandatory| Description                      |
| -------- | ------------------------------------------------ | ---- | -------------------------- |
W
wusongqing 已提交
60
| colors   | ArrayBuffer                                      | Yes  | Color array in BGRA_8888 format. |
W
wusongqing 已提交
61
| options  | [InitializationOptions](#initializationoptions8) | Yes  | Pixel properties.                    |
W
wusongqing 已提交
62
| callback | AsyncCallback\<[PixelMap](#pixelmap7)>           | Yes  | Callback used to return the **PixelMap** object.|
W
wusongqing 已提交
63 64 65 66

**Example**

```js
W
wusongqing 已提交
67
const color = new ArrayBuffer(96);
68
let bufferArr = new Uint8Array(color);
W
wusongqing 已提交
69
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
70 71 72 73 74 75 76
image.createPixelMap(color, opts, (error, pixelmap) => {
    if(error) {
        console.log('Failed to create pixelmap.');
    } else {
        console.log('Succeeded in creating pixelmap.');
    }
})
W
wusongqing 已提交
77 78 79 80 81 82 83 84
```

## PixelMap<sup>7+</sup>

Provides APIs to read or write image pixel map data and obtain image pixel map information. Before calling any API in **PixelMap**, you must use **createPixelMap** to create a **PixelMap** object.

 ### Attributes

85
**System capability**: SystemCapability.Multimedia.Image.Core
W
wusongqing 已提交
86

87 88 89
| Name      | Type   | Readable| Writable| Description                      |
| ---------- | ------- | ---- | ---- | -------------------------- |
| isEditable | boolean | Yes  | No  | Whether the image pixel map is editable.|
W
wusongqing 已提交
90 91 92 93 94

### readPixelsToBuffer<sup>7+</sup>

readPixelsToBuffer(dst: ArrayBuffer): Promise\<void>

G
Gloria 已提交
95
Reads data of this pixel map and writes the data to an **ArrayBuffer**. This API uses a promise to return the result. If this pixel map is created in the BGRA_8888 format, the data read is the same as the original data.
W
wusongqing 已提交
96

97
**System capability**: SystemCapability.Multimedia.Image.Core
W
wusongqing 已提交
98 99 100

**Parameters**

101 102 103
| Name| Type       | Mandatory| Description                                                                                                 |
| ------ | ----------- | ---- | ----------------------------------------------------------------------------------------------------- |
| dst    | ArrayBuffer | Yes  | Buffer to which the image pixel map data will be written. The buffer size is obtained by calling **getPixelBytesNumber**.|
W
wusongqing 已提交
104 105 106 107

**Return value**

| Type          | Description                                           |
108 109
| -------------- | ----------------------------------------------- |
| Promise\<void> | Promise used to return the result. If the operation fails, an error message is returned.|
W
wusongqing 已提交
110 111 112 113

**Example**

```js
114
const readBuffer = new ArrayBuffer(96);
W
wusongqing 已提交
115 116
pixelmap.readPixelsToBuffer(readBuffer).then(() => {
    console.log('Succeeded in reading image pixel data.'); // Called if the condition is met.
W
wusongqing 已提交
117
}).catch(error => {
W
wusongqing 已提交
118
    ('Failed to read image pixel data.'); // Called if no condition is met.
W
wusongqing 已提交
119
})
W
wusongqing 已提交
120 121 122 123 124 125
```

### readPixelsToBuffer<sup>7+</sup>

readPixelsToBuffer(dst: ArrayBuffer, callback: AsyncCallback\<void>): void

G
Gloria 已提交
126
Reads data of this pixel map and writes the data to an **ArrayBuffer**. This API uses an asynchronous callback to return the result. If this pixel map is created in the BGRA_8888 format, the data read is the same as the original data.
W
wusongqing 已提交
127

128
**System capability**: SystemCapability.Multimedia.Image.Core
W
wusongqing 已提交
129 130 131

**Parameters**

132 133 134 135
| Name  | Type                | Mandatory| Description                                                                                                 |
| -------- | -------------------- | ---- | ----------------------------------------------------------------------------------------------------- |
| dst      | ArrayBuffer          | Yes  | Buffer to which the image pixel map data will be written. The buffer size is obtained by calling **getPixelBytesNumber**.|
| callback | AsyncCallback\<void> | Yes  | Callback used to return the result. If the operation fails, an error message is returned.                                                                       |
W
wusongqing 已提交
136 137 138 139

**Example**

```js
140
const readBuffer = new ArrayBuffer(96);
W
wusongqing 已提交
141
pixelmap.readPixelsToBuffer(readBuffer, (err, res) => {
W
wusongqing 已提交
142
    if(err) {
W
wusongqing 已提交
143
        console.log('Failed to read image pixel data.');  // Called if no condition is met.
W
wusongqing 已提交
144
    } else {
W
wusongqing 已提交
145
        console.log('Succeeded in reading image pixel data.'); // Called if the condition is met.
W
wusongqing 已提交
146 147
    }
})
W
wusongqing 已提交
148 149 150 151 152 153
```

### readPixels<sup>7+</sup>

readPixels(area: PositionArea): Promise\<void>

154
Reads image pixel map data in an area. This API uses a promise to return the data read.
W
wusongqing 已提交
155

156
**System capability**: SystemCapability.Multimedia.Image.Core
W
wusongqing 已提交
157 158 159 160 161 162 163 164 165 166 167

**Parameters**

| Name| Type                          | Mandatory| Description                    |
| ------ | ------------------------------ | ---- | ------------------------ |
| area   | [PositionArea](#positionarea7) | Yes  | Area from which the image pixel map data will be read.|

**Return value**

| Type          | Description                                               |
| :------------- | :-------------------------------------------------- |
168
| Promise\<void> | Promise used to return the result. If the operation fails, an error message is returned.|
W
wusongqing 已提交
169 170 171 172

**Example**

```js
W
wusongqing 已提交
173 174 175
const area = new ArrayBuffer(400);
pixelmap.readPixels(area).then(() => {
    console.log('Succeeded in reading the image data in the area.'); // Called if the condition is met.
W
wusongqing 已提交
176
}).catch(error => {
W
wusongqing 已提交
177
    console.log('Failed to read the image data in the area.'); // Called if no condition is met.
W
wusongqing 已提交
178
})
W
wusongqing 已提交
179 180 181 182 183 184
```

### readPixels<sup>7+</sup>

readPixels(area: PositionArea, callback: AsyncCallback\<void>): void

185
Reads image pixel map data in an area. This API uses an asynchronous callback to return the data read.
W
wusongqing 已提交
186

187
**System capability**: SystemCapability.Multimedia.Image.Core
W
wusongqing 已提交
188 189 190 191 192 193

**Parameters**

| Name  | Type                          | Mandatory| Description                          |
| -------- | ------------------------------ | ---- | ------------------------------ |
| area     | [PositionArea](#positionarea7) | Yes  | Area from which the image pixel map data will be read.      |
194
| callback | AsyncCallback\<void>           | Yes  | Callback used to return the result. If the operation fails, an error message is returned.|
W
wusongqing 已提交
195 196 197 198

**Example**

```js
W
wusongqing 已提交
199
const color = new ArrayBuffer(96);
200
let bufferArr = new Uint8Array(color);
W
wusongqing 已提交
201 202
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err, pixelmap) => {
W
wusongqing 已提交
203 204 205 206 207 208 209 210 211 212 213
    if(pixelmap == undefined){
        console.info('createPixelMap failed.');
    } 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');
        })
    }
W
wusongqing 已提交
214
})
W
wusongqing 已提交
215 216 217 218 219 220 221 222
```

### writePixels<sup>7+</sup>

writePixels(area: PositionArea): Promise\<void>

Writes image pixel map data to an area. This API uses a promise to return the operation result.

223
**System capability**: SystemCapability.Multimedia.Image.Core
W
wusongqing 已提交
224 225 226 227 228

**Parameters**

| Name| Type                          | Mandatory| Description                |
| ------ | ------------------------------ | ---- | -------------------- |
229
| area   | [PositionArea](#positionarea7) | Yes  | Area to which the image pixel map data will be written.|
W
wusongqing 已提交
230 231 232 233 234

**Return value**

| Type          | Description                                               |
| :------------- | :-------------------------------------------------- |
235
| Promise\<void> | Promise used to return the result. If the operation fails, an error message is returned.|
W
wusongqing 已提交
236 237 238 239

**Example**

```js
W
wusongqing 已提交
240
const color = new ArrayBuffer(96);
241
let bufferArr = new Uint8Array(color);
W
wusongqing 已提交
242 243 244 245
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts)
    .then( pixelmap => {
        if (pixelmap == undefined) {
W
wusongqing 已提交
246
            console.info('createPixelMap failed.');
W
wusongqing 已提交
247 248 249 250 251 252
        }
        const area = { pixels: new ArrayBuffer(8),
            offset: 0,
            stride: 8,
            region: { size: { height: 1, width: 2 }, x: 0, y: 0 }
        }
W
wusongqing 已提交
253
        let bufferArr = new Uint8Array(area.pixels);
W
wusongqing 已提交
254 255 256 257 258 259 260 261 262 263 264 265
        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 }
            }        
        })
W
wusongqing 已提交
266
    }).catch(error => {
W
wusongqing 已提交
267 268
        console.log('error: ' + error);
    })
W
wusongqing 已提交
269 270 271 272 273 274
```

### writePixels<sup>7+</sup>

writePixels(area: PositionArea, callback: AsyncCallback\<void>): void

275
Writes image pixel map data to an area. This API uses an asynchronous callback to return the operation result.
W
wusongqing 已提交
276

277
**System capability**: SystemCapability.Multimedia.Image.Core
W
wusongqing 已提交
278 279 280 281 282

**Parameters**

| Name   | Type                          | Mandatory| Description                          |
| --------- | ------------------------------ | ---- | ------------------------------ |
283
| area      | [PositionArea](#positionarea7) | Yes  | Area to which the image pixel map data will be written.          |
284
| callback  | AsyncCallback\<void>           | Yes  | Callback used to return the result. If the operation fails, an error message is returned.|
W
wusongqing 已提交
285 286 287 288

**Example**

```js
W
wusongqing 已提交
289 290
const area = new ArrayBuffer(400);
pixelmap.writePixels(area, (error) => {
291
    if (error != undefined) {
W
wusongqing 已提交
292 293 294 295 296 297 298 299 300
		console.info('Failed to write pixelmap into the specified area.');
	} else {
	    const readArea = {
            pixels: new ArrayBuffer(20),
            offset: 0,
            stride: 8,
            region: { size: { height: 1, width: 2 }, x: 0, y: 0 },
        }
	}
W
wusongqing 已提交
301
})
W
wusongqing 已提交
302 303 304 305 306 307 308 309
```

### writeBufferToPixels<sup>7+</sup>

writeBufferToPixels(src: ArrayBuffer): Promise\<void>

Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** object. This API uses a promise to return the result.

310
**System capability**: SystemCapability.Multimedia.Image.Core
W
wusongqing 已提交
311 312 313 314 315 316 317 318 319 320 321

**Parameters**

| Name| Type       | Mandatory| Description          |
| ------ | ----------- | ---- | -------------- |
| src    | ArrayBuffer | Yes  | Buffer from which the image data will be read.|

**Return value**

| Type          | Description                                           |
| -------------- | ----------------------------------------------- |
322
| Promise\<void> | Promise used to return the result. If the operation fails, an error message is returned.|
W
wusongqing 已提交
323 324 325 326

**Example**

```js
W
wusongqing 已提交
327 328
const color = new ArrayBuffer(96);
const pixelMap = new ArrayBuffer(400);
329
let bufferArr = new Uint8Array(color);
W
wusongqing 已提交
330
pixelMap.writeBufferToPixels(color).then(() => {
W
wusongqing 已提交
331 332 333
    console.log("Succeeded in writing data from a buffer to a PixelMap.");
}).catch((err) => {
    console.error("Failed to write data from a buffer to a PixelMap.");
W
wusongqing 已提交
334
})
W
wusongqing 已提交
335 336 337 338 339 340
```

### writeBufferToPixels<sup>7+</sup>

writeBufferToPixels(src: ArrayBuffer, callback: AsyncCallback\<void>): void

341
Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** object. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
342

343
**System capability**: SystemCapability.Multimedia.Image.Core
W
wusongqing 已提交
344 345 346 347 348 349

**Parameters**

| Name  | Type                | Mandatory| Description                          |
| -------- | -------------------- | ---- | ------------------------------ |
| src      | ArrayBuffer          | Yes  | Buffer from which the image data will be read.                |
350
| callback | AsyncCallback\<void> | Yes  | Callback used to return the result. If the operation fails, an error message is returned.|
W
wusongqing 已提交
351 352 353 354

**Example**

```js
355
const color = new ArrayBuffer(96);
W
wusongqing 已提交
356
const pixelMap = new ArrayBuffer(400);
357
let bufferArr = new Uint8Array(color);
W
wusongqing 已提交
358
pixelMap.writeBufferToPixels(color, function(err) {
W
wusongqing 已提交
359 360 361
    if (err) {
        console.error("Failed to write data from a buffer to a PixelMap.");
        return;
W
wusongqing 已提交
362 363 364
    } else {
		console.log("Succeeded in writing data from a buffer to a PixelMap.");
	}
W
wusongqing 已提交
365 366 367 368 369 370 371
});
```

### getImageInfo<sup>7+</sup>

getImageInfo(): Promise\<ImageInfo>

372
Obtains pixel map information of this image. This API uses a promise to return the information.
W
wusongqing 已提交
373

374
**System capability**: SystemCapability.Multimedia.Image.Core
W
wusongqing 已提交
375 376 377 378 379 380 381 382 383 384

**Return value**

| Type                             | Description                                                       |
| --------------------------------- | ----------------------------------------------------------- |
| Promise\<[ImageInfo](#imageinfo)> | Promise used to return the pixel map information. If the operation fails, an error message is returned.|

**Example**

```js
W
wusongqing 已提交
385 386
const pixelMap = new ArrayBuffer(400);
pixelMap.getImageInfo().then(function(info) {
W
wusongqing 已提交
387 388 389 390 391 392 393 394 395 396
    console.log("Succeeded in obtaining the image pixel map information.");
}).catch((err) => {
    console.error("Failed to obtain the image pixel map information.");
});
```

### getImageInfo<sup>7+</sup>

getImageInfo(callback: AsyncCallback\<ImageInfo>): void

397
Obtains pixel map information of this image. This API uses an asynchronous callback to return the information.
W
wusongqing 已提交
398

399
**System capability**: SystemCapability.Multimedia.Image.Core
W
wusongqing 已提交
400 401 402 403 404 405 406 407 408 409

**Parameters**

| Name  | Type                                   | Mandatory| Description                                                        |
| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ |
| callback | AsyncCallback\<[ImageInfo](#imageinfo)> | Yes  | Callback used to return the pixel map information. If the operation fails, an error message is returned.|

**Example**

```js
W
wusongqing 已提交
410
pixelmap.getImageInfo((imageInfo) => { 
411
    console.log("Succeeded in obtaining the image pixel map information.");
W
wusongqing 已提交
412
})
W
wusongqing 已提交
413 414 415 416 417 418
```

### getBytesNumberPerRow<sup>7+</sup>

getBytesNumberPerRow(): number

419
Obtains the number of bytes per row of this image pixel map.
W
wusongqing 已提交
420

421
**System capability**: SystemCapability.Multimedia.Image.Core
W
wusongqing 已提交
422 423 424 425 426

**Return value**

| Type  | Description                |
| ------ | -------------------- |
427
| number | Number of bytes per row.|
W
wusongqing 已提交
428 429 430 431

**Example**

```js
W
wusongqing 已提交
432
const color = new ArrayBuffer(96);
433
let bufferArr = new Uint8Array(color);
W
wusongqing 已提交
434 435
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
image.createPixelMap(color, opts, (err,pixelmap) => {
W
wusongqing 已提交
436 437
    let rowCount = pixelmap.getBytesNumberPerRow();
})
W
wusongqing 已提交
438 439 440 441 442 443
```

### getPixelBytesNumber<sup>7+</sup>

getPixelBytesNumber(): number

444
Obtains the total number of bytes of this image pixel map.
W
wusongqing 已提交
445

446
**System capability**: SystemCapability.Multimedia.Image.Core
W
wusongqing 已提交
447 448 449 450 451 452 453 454 455 456

**Return value**

| Type  | Description                |
| ------ | -------------------- |
| number | Total number of bytes.|

**Example**

```js
W
wusongqing 已提交
457
let pixelBytesNumber = pixelmap.getPixelBytesNumber();
W
wusongqing 已提交
458 459
```

460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812
### getDensity<sup>9+</sup>

getDensity():number

Obtains the density of this image pixel map.

**System capability**: SystemCapability.Multimedia.Image.Core

**Return value**

| Type  | Description           |
| ------ | --------------- |
| number | Density of the image pixel map.|

**Example**

```js
let getDensity = pixelmap.getDensity();
```

### opacity<sup>9+</sup>

opacity(rate: number, callback: AsyncCallback\<void>): void

Sets an opacity rate for this image pixel map. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Multimedia.Image.Core

**Parameters**

| Name  | Type                | Mandatory| Description                          |
| -------- | -------------------- | ---- | ------------------------------ |
| rate     | number               | Yes  | Opacity rate to set. The value ranges from 0 to 1.  |
| callback | AsyncCallback\<void> | Yes  | Callback used to return the result. If the operation fails, an error message is returned.|

**Example**

```js
async function () {
	await pixelMap.opacity(0.5);
}
```

### opacity<sup>9+</sup>

opacity(rate: number): Promise\<void>

Sets an opacity rate for this image pixel map. This API uses a promise to return the result.

**System capability**: SystemCapability.Multimedia.Image.Core

**Parameters**

| Name| Type  | Mandatory| Description                       |
| ------ | ------ | ---- | --------------------------- |
| rate   | number | Yes  | Opacity rate to set. The value ranges from 0 to 1.|

**Return value**

| Type          | Description                                           |
| -------------- | ----------------------------------------------- |
| Promise\<void> | Promise used to return the result. If the operation fails, an error message is returned.|

**Example**

```js
async function () {
	await pixelMap.opacity(0.5);
}
```

### createAlphaPixelmap<sup>9+</sup>

createAlphaPixelmap(): Promise\<PixelMap>

Creates a **PixelMap** object that contains only the alpha channel information. This object can be used for the shadow effect. This API uses a promise to return the result.

**System capability**: SystemCapability.Multimedia.Image.Core

**Return value**

| Type                            | Description                       |
| -------------------------------- | --------------------------- |
| Promise\<[PixelMap](#pixelmap7)> | Promise used to return the **PixelMap** object.|

**Example**

```js
pixelMap.createAlphaPixelmap(async (err, alphaPixelMap) => {
    if (alphaPixelMap == undefined) {
        console.info('Failed to obtain new pixel map.');
    } else {
        console.info('Succeed in obtaining new pixel map.');
    }
})
```

### createAlphaPixelmap<sup>9+</sup>

createAlphaPixelmap(callback: AsyncCallback\<PixelMap>): void

Creates a **PixelMap** object that contains only the alpha channel information. This object can be used for the shadow effect. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Multimedia.Image.Core

**Parameters**

| Name  | Type                    | Mandatory| Description                    |
| -------- | ------------------------ | ---- | ------------------------ |
| callback | AsyncCallback\<PixelMap> | Yes  | Callback used to return the **PixelMap** object.|

**Example**

```js
let pixelMap = await imageSource.createPixelMap();
if (pixelMap != undefined) {
    pixelMap.createAlphaPixelmap(async (err, alphaPixelMap) => {
        console.info('Failed to obtain new pixel map.');    
    })
} else {
    console.info('Succeed in obtaining new pixel map.');
}
```

### scale<sup>9+</sup>

scale(x: number, y: number, callback: AsyncCallback\<void>): void

Scales this image based on the input width and height. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Multimedia.Image.Core

**Parameters**

| Name  | Type                | Mandatory| Description                           |
| -------- | -------------------- | ---- | ------------------------------- |
| x        | number               | Yes  | Scaling ratio of the width.|
| y        | number               | Yes  | Scaling ratio of the height.|
| callback | AsyncCallback\<void> | Yes  | Callback used to return the result. If the operation fails, an error message is returned. |

**Example**

```js
async function () {
	await pixelMap.scale(2.0, 1.0);
}
```

### scale<sup>9+</sup>

scale(x: number, y: number): Promise\<void>

Scales this image based on the input width and height. This API uses a promise to return the result.

**System capability**: SystemCapability.Multimedia.Image.Core

**Parameters**

| Name| Type  | Mandatory| Description                           |
| ------ | ------ | ---- | ------------------------------- |
| x      | number | Yes  | Scaling ratio of the width.|
| y      | number | Yes  | Scaling ratio of the height.|

**Return value**

| Type          | Description                       |
| -------------- | --------------------------- |
| Promise\<void> | Promise used to return the result.|

**Example**

```js
async function () {
	await pixelMap.scale(2.0, 1.0);
}
```

### translate<sup>9+</sup>

translate(x: number, y: number, callback: AsyncCallback\<void>): void

Translates this image based on the input coordinates. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Multimedia.Image.Core

**Parameters**

| Name  | Type                | Mandatory| Description                         |
| -------- | -------------------- | ---- | ----------------------------- |
| x        | number               | Yes  | X coordinate to translate.                 |
| y        | number               | Yes  | Y coordinate to translate.                 |
| callback | AsyncCallback\<void> | Yes  | Callback used to return the result. If the operation fails, an error message is returned.|

**Example**

```js
async function () {
	await pixelMap.translate(3.0, 1.0);
}
```

### translate<sup>9+</sup>

translate(x: number, y: number): Promise\<void>

Translates this image based on the input coordinates. This API uses a promise to return the result.

**System capability**: SystemCapability.Multimedia.Image.Core

**Parameters**

| Name| Type  | Mandatory| Description       |
| ------ | ------ | ---- | ----------- |
| x      | number | Yes  | X coordinate to translate.|
| y      | number | Yes  | Y coordinate to translate.|

**Return value**

| Type          | Description                       |
| -------------- | --------------------------- |
| Promise\<void> | Promise used to return the result.|

**Example**

```js
async function () {
	await pixelMap.translate(3.0, 1.0);
}
```

### rotate<sup>9+</sup>

rotate(angle: number, callback: AsyncCallback\<void>): void

Rotates this image based on the input angle. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Multimedia.Image.Core

**Parameters**

| Name  | Type                | Mandatory| Description                         |
| -------- | -------------------- | ---- | ----------------------------- |
| angle    | number               | Yes  | Angle to rotate.             |
| callback | AsyncCallback\<void> | Yes  | Callback used to return the result. If the operation fails, an error message is returned.|

**Example**

```js
async function () {
	await pixelMap.rotate(90.0);
}
```

### rotate<sup>9+</sup>

rotate(angle: number): Promise\<void>

Rotates this image based on the input angle. This API uses a promise to return the result.

**System capability**: SystemCapability.Multimedia.Image.Core

**Parameters**

| Name| Type  | Mandatory| Description                         |
| ------ | ------ | ---- | ----------------------------- |
| angle  | number | Yes  | Angle to rotate.             |

**Return value**

| Type          | Description                       |
| -------------- | --------------------------- |
| Promise\<void> | Promise used to return the result.|

**Example**

```js
async function () {
	await pixelMap.rotate(90.0);
}
```

### flip<sup>9+</sup>

flip(horizontal: boolean, vertical: boolean, callback: AsyncCallback\<void>): void

Flips this image horizontally or vertically, or both. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Multimedia.Image.Core

**Parameters**

| Name    | Type                | Mandatory| Description                         |
| ---------- | -------------------- | ---- | ----------------------------- |
| horizontal | boolean              | Yes  | Whether to flip the image horizontally.                   |
| vertical   | boolean              | Yes  | Whether to flip the image vertically.                   |
| callback   | AsyncCallback\<void> | Yes  | Callback used to return the result. If the operation fails, an error message is returned.|

**Example**

```js
async function () {
	await pixelMap.flip(false, true);
}
```

### flip<sup>9+</sup>

flip(horizontal: boolean, vertical: boolean): Promise\<void>

Flips this image horizontally or vertically, or both. This API uses a promise to return the result.

**System capability**: SystemCapability.Multimedia.Image.Core

**Parameters**

| Name    | Type   | Mandatory| Description     |
| ---------- | ------- | ---- | --------- |
| horizontal | boolean | Yes  | Whether to flip the image horizontally.|
| vertical   | boolean | Yes  | Whether to flip the image vertically.|

**Return value**

| Type          | Description                       |
| -------------- | --------------------------- |
| Promise\<void> | Promise used to return the result.|

**Example**

```js
async function () {
	await pixelMap.flip(false, true);
}
```

### crop<sup>9+</sup>

crop(region: Region, callback: AsyncCallback\<void>): void

Crops this image based on the input size. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Multimedia.Image.Core

**Parameters**

| Name  | Type                | Mandatory| Description                         |
| -------- | -------------------- | ---- | ----------------------------- |
| region   | [Region](#region7)   | Yes  | Size of the image after cropping.                 |
| callback | AsyncCallback\<void> | Yes  | Callback used to return the result. If the operation fails, an error message is returned.|

**Example**

```js
async function () {
G
Gloria 已提交
813
	await pixelMap.crop({ x: 0, y: 0, size: { height: 100, width: 100 } });
814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840
}
```

### crop<sup>9+</sup>

crop(region: Region): Promise\<void>

Crops this image based on the input size. This API uses a promise to return the result.

**System capability**: SystemCapability.Multimedia.Image.Core

**Parameters**

| Name| Type              | Mandatory| Description       |
| ------ | ------------------ | ---- | ----------- |
| region | [Region](#region7) | Yes  | Size of the image after cropping.|

**Return value**

| Type          | Description                       |
| -------------- | --------------------------- |
| Promise\<void> | Promise used to return the result.|

**Example**

```js
async function () {
G
Gloria 已提交
841
	await pixelMap.crop({ x: 0, y: 0, size: { height: 100, width: 100 } });
842 843 844
}
```

W
wusongqing 已提交
845 846 847 848 849 850
### release<sup>7+</sup>

release():Promise\<void>

Releases this **PixelMap** object. This API uses a promise to return the result.

851
**System capability**: SystemCapability.Multimedia.Image.Core
W
wusongqing 已提交
852 853 854

**Return value**

855 856 857
| Type          | Description                           |
| -------------- | ------------------------------- |
| Promise\<void> | Promise used to return the result.|
W
wusongqing 已提交
858 859 860 861

**Example**

```js
W
wusongqing 已提交
862
const color = new ArrayBuffer(96);
863
let bufferArr = new Uint8Array(color);
W
wusongqing 已提交
864
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
W
wusongqing 已提交
865 866
image.createPixelMap(color, opts, (pixelmap) => {
    pixelmap.release().then(() => {
W
wusongqing 已提交
867
	    console.log('Succeeded in releasing pixelmap object.');
W
wusongqing 已提交
868
    }).catch(error => {
W
wusongqing 已提交
869
	    console.log('Failed to release pixelmap object.');
W
wusongqing 已提交
870 871
    })
})
W
wusongqing 已提交
872 873 874 875 876 877
```

### release<sup>7+</sup>

release(callback: AsyncCallback\<void>): void

878
Releases this **PixelMap** object. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
879

880
**System capability**: SystemCapability.Multimedia.Image.Core
W
wusongqing 已提交
881 882 883 884 885

**Parameters**

| Name    | Type                | Mandatory| Description              |
| -------- | -------------------- | ---- | ------------------ |
886
| callback | AsyncCallback\<void> | Yes  | Callback used to return the result.|
W
wusongqing 已提交
887 888 889 890

**Example**

```js
W
wusongqing 已提交
891
const color = new ArrayBuffer(96);
892
let bufferArr = new Uint8Array(color);
W
wusongqing 已提交
893
let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } }
W
wusongqing 已提交
894 895
image.createPixelMap(color, opts, (pixelmap) => {
    pixelmap.release().then(() => {
W
wusongqing 已提交
896
	    console.log('Succeeded in releasing pixelmap object.');
W
wusongqing 已提交
897 898
    })
})
W
wusongqing 已提交
899 900 901 902 903 904 905 906
```

## image.createImageSource

createImageSource(uri: string): ImageSource

Creates an **ImageSource** instance based on the URI.

907
**System capability**: SystemCapability.Multimedia.Image.ImageSource
W
wusongqing 已提交
908 909 910 911 912

**Parameters**

| Name| Type  | Mandatory| Description                              |
| ------ | ------ | ---- | ---------------------------------- |
G
Gloria 已提交
913
| uri    | string | Yes  | Image path. Currently, only the application sandbox path is supported.<br>Currently, the following raw formats are supported: .jpg, .png, .gif, .bmp, and .webp.|
W
wusongqing 已提交
914 915 916

**Return value**

W
wusongqing 已提交
917 918 919
| Type                       | Description                                        |
| --------------------------- | -------------------------------------------- |
| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns **undefined** otherwise.|
W
wusongqing 已提交
920 921 922 923

**Example**

```js
W
wusongqing 已提交
924 925
let path = this.context.getApplicationContext().fileDirs + "test.jpg";
const imageSourceApi = image.createImageSource(path);
W
wusongqing 已提交
926 927
```

928 929 930 931 932 933 934 935 936 937 938 939
## image.createImageSource<sup>9+</sup>

createImageSource(uri: string, options: SourceOptions): ImageSource

Creates an **ImageSource** instance based on the URI.

**System capability**: SystemCapability.Multimedia.Image.ImageSource

**Parameters**

| Name | Type                           | Mandatory| Description                               |
| ------- | ------------------------------- | ---- | ----------------------------------- |
G
Gloria 已提交
940
| uri     | string                          | Yes  | Image path. Currently, only the application sandbox path is supported.<br>Currently, the following raw formats are supported: .jpg, .png, .gif, .bmp, and .webp.|
941 942 943 944 945 946 947 948 949 950 951 952 953 954
| options | [SourceOptions](#sourceoptions9) | Yes  | Image properties, including the image index and default property value.|

**Return value**

| Type                       | Description                                        |
| --------------------------- | -------------------------------------------- |
| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns **undefined** otherwise.|

**Example**

```js
const imageSourceApi = image.createImageSource('/sdcard/test.jpg');
```

W
wusongqing 已提交
955 956 957 958 959 960
## image.createImageSource<sup>7+</sup>

createImageSource(fd: number): ImageSource

Creates an **ImageSource** instance based on the file descriptor.

961
**System capability**: SystemCapability.Multimedia.Image.ImageSource
W
wusongqing 已提交
962 963 964

**Parameters**

965 966
| Name| Type  | Mandatory| Description         |
| ------ | ------ | ---- | ------------- |
W
wusongqing 已提交
967 968 969 970
| fd     | number | Yes  | File descriptor.|

**Return value**

W
wusongqing 已提交
971 972 973
| Type                       | Description                                        |
| --------------------------- | -------------------------------------------- |
| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns **undefined** otherwise.|
W
wusongqing 已提交
974 975 976 977

**Example**

```js
W
wusongqing 已提交
978
const imageSourceApi = image.createImageSource(0);
W
wusongqing 已提交
979 980
```

981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011
## image.createImageSource<sup>9+</sup>

createImageSource(fd: number, options: SourceOptions): ImageSource

Creates an **ImageSource** instance based on the file descriptor.

**System capability**: SystemCapability.Multimedia.Image.ImageSource

**Parameters**

| Name | Type                           | Mandatory| Description                               |
| ------- | ------------------------------- | ---- | ----------------------------------- |
| fd      | number                          | Yes  | File descriptor.                     |
| options | [SourceOptions](#sourceoptions9) | Yes  | Image properties, including the image index and default property value.|

**Return value**

| Type                       | Description                                        |
| --------------------------- | -------------------------------------------- |
| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns **undefined** otherwise.|

**Example**

```js
const imageSourceApi = image.createImageSource(fd);
```

## image.createImageSource<sup>9+</sup>

createImageSource(buf: ArrayBuffer): ImageSource

W
wusongqing 已提交
1012
Creates an **ImageSource** instance based on the buffers.
1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032

**System capability**: SystemCapability.Multimedia.Image.ImageSource

**Parameters**

| Name| Type       | Mandatory| Description            |
| ------ | ----------- | ---- | ---------------- |
| buf    | ArrayBuffer | Yes  | Array of image buffers.|

**Example**

```js
const buf = new ArrayBuffer(96);
const imageSourceApi = image.createImageSource(buf);
```

## image.createImageSource<sup>9+</sup>

createImageSource(buf: ArrayBuffer, options: SourceOptions): ImageSource

W
wusongqing 已提交
1033
Creates an **ImageSource** instance based on the buffers.
1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060

**System capability**: SystemCapability.Multimedia.Image.ImageSource

**Parameters**

| Name| Type                            | Mandatory| Description                                |
| ------ | -------------------------------- | ---- | ------------------------------------ |
| buf    | ArrayBuffer                      | Yes  | Array of image buffers.                    |
| options | [SourceOptions](#sourceoptions9) | Yes  | Image properties, including the image index and default property value.|

**Return value**

| Type                       | Description                                        |
| --------------------------- | -------------------------------------------- |
| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns **undefined** otherwise.|

**Example**

```js
const data = new ArrayBuffer(112);
const imageSourceApi = image.createImageSource(data);
```

## image.CreateIncrementalSource<sup>9+</sup>

CreateIncrementalSource(buf: ArrayBuffer): ImageSource

W
wusongqing 已提交
1061
Creates an **ImageSource** instance in incremental mode based on the buffers.
1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087

**System capability**: SystemCapability.Multimedia.Image.ImageSource

**Parameters**

| Name | Type       | Mandatory| Description     |
| ------- | ------------| ---- | ----------|
| buf     | ArrayBuffer | Yes  | Incremental data.|

**Return value**

| Type                       | Description                             |
| --------------------------- | --------------------------------- |
| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns undefined otherwise.|

**Example**

```js
const buf = new ArrayBuffer(96);
const imageSourceApi = image.CreateIncrementalSource(buf);
```

## image.CreateIncrementalSource<sup>9+</sup>

CreateIncrementalSource(buf: ArrayBuffer, options?: SourceOptions): ImageSource

W
wusongqing 已提交
1088
Creates an **ImageSource** instance in incremental mode based on the buffers.
1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111

**System capability**: SystemCapability.Multimedia.Image.ImageSource

**Parameters**

| Name | Type                           | Mandatory| Description                                |
| ------- | ------------------------------- | ---- | ------------------------------------ |
| buf     | ArrayBuffer                     | Yes  | Incremental data.                          |
| options | [SourceOptions](#sourceoptions9) | No  | Image properties, including the image index and default property value.|

**Return value**

| Type                       | Description                             |
| --------------------------- | --------------------------------- |
| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns undefined otherwise.|

**Example**

```js
const buf = new ArrayBuffer(96);
const imageSourceApi = image.CreateIncrementalSource(buf);
```

W
wusongqing 已提交
1112 1113 1114 1115 1116 1117
## ImageSource

Provides APIs to obtain image information. Before calling any API in **ImageSource**, you must use **createImageSource** to create an **ImageSource** instance.

### Attributes

1118
**System capability**: SystemCapability.Multimedia.Image.ImageSource
W
wusongqing 已提交
1119

W
wusongqing 已提交
1120 1121
| Name            | Type          | Readable| Writable| Description                                                        |
| ---------------- | -------------- | ---- | ---- | ------------------------------------------------------------ |
W
wusongqing 已提交
1122
| supportedFormats | Array\<string> | Yes  | No  | Supported image formats, including png, jpeg, wbmp, bmp, gif, webp, and heif.|
W
wusongqing 已提交
1123 1124 1125 1126 1127

### getImageInfo

getImageInfo(index: number, callback: AsyncCallback\<ImageInfo>): void

1128
Obtains information about an image with the specified index. This API uses an asynchronous callback to return the information.
W
wusongqing 已提交
1129

1130
**System capability**: SystemCapability.Multimedia.Image.ImageSource
W
wusongqing 已提交
1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141

**Parameters**

| Name  | Type                                  | Mandatory| Description                                    |
| -------- | -------------------------------------- | ---- | ---------------------------------------- |
| index    | number                                 | Yes  | Index of the image.                    |
| callback | AsyncCallback<[ImageInfo](#imageinfo)> | Yes  | Callback used to return the image information.|

**Example**

```js
W
wusongqing 已提交
1142 1143 1144 1145 1146 1147 1148
imageSourceApi.getImageInfo(0,(error, imageInfo) => { 
    if(error) {
        console.log('getImageInfo failed.');
    } else {
        console.log('getImageInfo succeeded.');
    }
})
W
wusongqing 已提交
1149 1150 1151 1152 1153 1154
```

### getImageInfo

getImageInfo(callback: AsyncCallback\<ImageInfo>): void

1155
Obtains information about this image. This API uses an asynchronous callback to return the information.
W
wusongqing 已提交
1156

1157
**System capability**: SystemCapability.Multimedia.Image.ImageSource
W
wusongqing 已提交
1158 1159 1160 1161 1162 1163 1164 1165 1166 1167

**Parameters**

| Name    | Type                                  | Mandatory| Description                                    |
| -------- | -------------------------------------- | ---- | ---------------------------------------- |
| callback | AsyncCallback<[ImageInfo](#imageinfo)> | Yes  | Callback used to return the image information.|

**Example**

```js
W
wusongqing 已提交
1168
imageSourceApi.getImageInfo(imageInfo => { 
W
wusongqing 已提交
1169
    console.log('Succeeded in obtaining the image information.');
W
wusongqing 已提交
1170
})
W
wusongqing 已提交
1171 1172 1173 1174 1175 1176 1177 1178
```

### getImageInfo

getImageInfo(index?: number): Promise\<ImageInfo>

Obtains information about an image with the specified index. This API uses a promise to return the image information.

1179
**System capability**: SystemCapability.Multimedia.Image.ImageSource
W
wusongqing 已提交
1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196

**Parameters**

| Name | Type  | Mandatory| Description                                 |
| ----- | ------ | ---- | ------------------------------------- |
| index | number | No  | Index of the image. If this parameter is not set, the default value **0** is used.|

**Return value**

| Type                            | Description                  |
| -------------------------------- | ---------------------- |
| Promise<[ImageInfo](#imageinfo)> | Promise used to return the image information.|

**Example**

```js
imageSourceApi.getImageInfo(0)
W
wusongqing 已提交
1197
    .then(imageInfo => {
W
wusongqing 已提交
1198
		console.log('Succeeded in obtaining the image information.');
W
wusongqing 已提交
1199
	}).catch(error => {
W
wusongqing 已提交
1200
		console.log('Failed to obtain the image information.');
W
wusongqing 已提交
1201
	})
W
wusongqing 已提交
1202 1203 1204 1205 1206 1207 1208 1209
```

### getImageProperty<sup>7+</sup>

getImageProperty(key:string, options?: GetImagePropertyOptions): Promise\<string>

Obtains the value of a property with the specified index in this image. This API uses a promise to return the result.

1210
**System capability**: SystemCapability.Multimedia.Image.ImageSource
W
wusongqing 已提交
1211 1212 1213 1214 1215 1216 1217 1218 1219 1220

 **Parameters**

| Name   | Type                                                | Mandatory| Description                                |
| ------- | ---------------------------------------------------- | ---- | ------------------------------------ |
| key     | string                                               | Yes  | Name of the property.                        |
| options | [GetImagePropertyOptions](#getimagepropertyoptions7) | No  | Image properties, including the image index and default property value.|

**Return value**

1221 1222
| Type            | Description                                                             |
| ---------------- | ----------------------------------------------------------------- |
W
wusongqing 已提交
1223 1224 1225 1226 1227
| Promise\<string> | Promise used to return the property value. If the operation fails, the default value is returned.|

**Example**

```js
W
wusongqing 已提交
1228
imageSourceApi.getImageProperty("BitsPerSample")
W
wusongqing 已提交
1229
    .then(data => {
W
wusongqing 已提交
1230
		console.log('Succeeded in getting the value of the specified attribute key of the image.');
W
wusongqing 已提交
1231
	})
W
wusongqing 已提交
1232 1233 1234 1235 1236 1237
```

### getImageProperty<sup>7+</sup>

getImageProperty(key:string, callback: AsyncCallback\<string>): void

1238
Obtains the value of a property with the specified index in this image. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1239

1240
**System capability**: SystemCapability.Multimedia.Image.ImageSource
W
wusongqing 已提交
1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251

 **Parameters**

| Name  | Type                  | Mandatory| Description                                                        |
| -------- | ---------------------- | ---- | ------------------------------------------------------------ |
| key      | string                 | Yes  | Name of the property.                                                |
| callback | AsyncCallback\<string> | Yes  | Callback used to return the property value. If the operation fails, the default value is returned.|

**Example**

```js
W
wusongqing 已提交
1252 1253
imageSourceApi.getImageProperty("BitsPerSample",(error,data) => { 
    if(error) {
W
wusongqing 已提交
1254
        console.log('Failed to get the value of the specified attribute key of the image.');
W
wusongqing 已提交
1255
    } else {
W
wusongqing 已提交
1256
        console.log('Succeeded in getting the value of the specified attribute key of the image.');
W
wusongqing 已提交
1257 1258
    }
})
W
wusongqing 已提交
1259 1260 1261 1262 1263 1264
```

### getImageProperty<sup>7+</sup>

getImageProperty(key:string, options: GetImagePropertyOptions, callback: AsyncCallback\<string>): void

1265
Obtains the value of a property in this image. This API uses an asynchronous callback to return the property value in a string.
W
wusongqing 已提交
1266

1267
**System capability**: SystemCapability.Multimedia.Image.ImageSource
W
wusongqing 已提交
1268 1269 1270

**Parameters**

1271 1272 1273 1274
| Name  | Type                                                | Mandatory| Description                                                         |
| -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------- |
| key      | string                                               | Yes  | Name of the property.                                                 |
| options  | [GetImagePropertyOptions](#getimagepropertyoptions7) | Yes  | Image properties, including the image index and default property value.                         |
W
wusongqing 已提交
1275 1276 1277 1278 1279
| callback | AsyncCallback\<string>                               | Yes  | Callback used to return the property value. If the operation fails, the default value is returned.|

**Example**

```js
W
wusongqing 已提交
1280 1281
const property = new ArrayBuffer(400);
imageSourceApi.getImageProperty("BitsPerSample",property,(error,data) => { 
W
wusongqing 已提交
1282
    if(error) {
W
wusongqing 已提交
1283
        console.log('Failed to get the value of the specified attribute key of the image.');
W
wusongqing 已提交
1284
    } else {
W
wusongqing 已提交
1285
        console.log('Succeeded in getting the value of the specified attribute key of the image.');
W
wusongqing 已提交
1286 1287
    }
})
W
wusongqing 已提交
1288 1289
```

1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404
### modifyImageProperty<sup>9+</sup>

modifyImageProperty(key: string, value: string): Promise\<void>

Modifies the value of a property in this image. This API uses a promise to return the result.

**System capability**: SystemCapability.Multimedia.Image.ImageSource

**Parameters**

| Name | Type  | Mandatory| Description        |
| ------- | ------ | ---- | ------------ |
| key     | string | Yes  | Name of the property.|
| value   | string | Yes  | New value of the property.    |

**Return value**

| Type          | Description                       |
| -------------- | --------------------------- |
| Promise\<void> | Promise used to return the result.|

**Example**

```js
imageSourceApi.modifyImageProperty("ImageWidth", "120")
            .then(() => {
                const w = imageSourceApi.getImageProperty("ImageWidth")
                console.info('w', w);
            })
```

### modifyImageProperty<sup>9+</sup>

modifyImageProperty(key: string, value: string, callback: AsyncCallback\<void>): void

Modifies the value of a property in this image. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Multimedia.Image.ImageSource

**Parameters**

| Name  | Type               | Mandatory| Description                          |
| -------- | ------------------- | ---- | ------------------------------ |
| key      | string              | Yes  | Name of the property.                  |
| value    | string              | Yes  | New value of the property.                      |
| callback | AsyncCallback\<void> | Yes  | Callback used to return the result.|

**Example**

```js
imageSourceApi.modifyImageProperty("ImageWidth", "120",() => {})
```

### updateData<sup>9+</sup>

updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number): Promise\<void>

Updates incremental data. This API uses a promise to return the result.

**System capability**: SystemCapability.Multimedia.Image.ImageSource

**Parameters**

| Name      | Type       | Mandatory| Description        |
| ---------- | ----------- | ---- | ------------ |
| 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.    |

**Return value**

| Type          | Description                      |
| -------------- | -------------------------- |
| Promise\<void> | Promise used to return the result.|

**Example**

```js
const array = new ArrayBuffer(100);
imageSourceIncrementalSApi.updateData(array, false, 0, 10).then(data => {
            console.info('Succeeded in updating data.');
        })
```


### updateData<sup>9+</sup>

updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number, callback: AsyncCallback\<void>): void

Updates incremental data. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Multimedia.Image.ImageSource

**Parameters**

| Name      | Type               | Mandatory| Description                |
| ---------- | ------------------- | ---- | -------------------- |
| 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.            |
| callback   | AsyncCallback\<void> | Yes  | Callback used to return the result.|

**Example**

```js
const array = new ArrayBuffer(100);
imageSourceIncrementalSApi.updateData(array, false, 0, 10,(error,data )=> {
            if(data !== undefined){
                console.info('Succeeded in updating data.');     
            }
		})
```

W
wusongqing 已提交
1405 1406
### createPixelMap<sup>7+</sup>

W
wusongqing 已提交
1407
createPixelMap(options?: DecodingOptions): Promise\<PixelMap>
W
wusongqing 已提交
1408

1409
Creates a **PixelMap** object based on image decoding parameters. This API uses a promise to return the result.
W
wusongqing 已提交
1410

1411
**System capability**: SystemCapability.Multimedia.Image.ImageSource
W
wusongqing 已提交
1412 1413 1414

**Parameters**

W
wusongqing 已提交
1415 1416 1417 1418 1419 1420 1421 1422 1423
| 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.|
W
wusongqing 已提交
1424 1425 1426 1427

**Example**

```js
W
wusongqing 已提交
1428
imageSourceApi.createPixelMap().then(pixelmap => {
W
wusongqing 已提交
1429
    console.log('Succeeded in creating pixelmap object through image decoding parameters.');
W
wusongqing 已提交
1430
}).catch(error => {
W
wusongqing 已提交
1431
    console.log('Failed to create pixelmap object through image decoding parameters.');
W
wusongqing 已提交
1432
})
W
wusongqing 已提交
1433 1434 1435 1436
```

### createPixelMap<sup>7+</sup>

W
wusongqing 已提交
1437
createPixelMap(callback: AsyncCallback\<PixelMap>): void
W
wusongqing 已提交
1438

1439
Creates a **PixelMap** object based on the default parameters. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1440

1441
**System capability**: SystemCapability.Multimedia.Image.ImageSource
W
wusongqing 已提交
1442 1443 1444

**Parameters**

W
wusongqing 已提交
1445 1446 1447
| Name    | Type                                 | Mandatory| Description                      |
| -------- | ------------------------------------- | ---- | -------------------------- |
| callback | AsyncCallback<[PixelMap](#pixelmap7)> | Yes  | Callback used to return the **PixelMap** object.|
W
wusongqing 已提交
1448 1449 1450 1451

**Example**

```js
1452 1453 1454
imageSourceApi.createPixelMap((err, pixelmap) => {
                    console.info('Succeeded in creating pixelmap object.');
                })
W
wusongqing 已提交
1455 1456 1457 1458
```

### createPixelMap<sup>7+</sup>

W
wusongqing 已提交
1459
createPixelMap(options: DecodingOptions, callback: AsyncCallback\<PixelMap>): void
W
wusongqing 已提交
1460

1461
Creates a **PixelMap** object based on image decoding parameters. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1462

1463
**System capability**: SystemCapability.Multimedia.Image.ImageSource
W
wusongqing 已提交
1464 1465 1466

**Parameters**

W
wusongqing 已提交
1467 1468 1469 1470
| Name    | Type                                 | Mandatory| Description                      |
| -------- | ------------------------------------- | ---- | -------------------------- |
| options  | [DecodingOptions](#decodingoptions7)  | Yes  | Image decoding parameters.                |
| callback | AsyncCallback<[PixelMap](#pixelmap7)> | Yes  | Callback used to return the **PixelMap** object.|
W
wusongqing 已提交
1471 1472 1473 1474

**Example**

```js
W
wusongqing 已提交
1475
const decodingOptions = new ArrayBuffer(400);
W
wusongqing 已提交
1476
imageSourceApi.createPixelMap(decodingOptions, pixelmap => { 
W
wusongqing 已提交
1477 1478
    console.log('Succeeded in creating pixelmap object.');
})
W
wusongqing 已提交
1479 1480 1481 1482 1483 1484
```

### release

release(callback: AsyncCallback\<void>): void

1485
Releases this **ImageSource** instance. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1486

1487
**System capability**: SystemCapability.Multimedia.Image.ImageSource
W
wusongqing 已提交
1488 1489 1490 1491 1492 1493 1494 1495 1496 1497

**Parameters**

| Name    | Type                | Mandatory| Description                              |
| -------- | -------------------- | ---- | ---------------------------------- |
| callback | AsyncCallback\<void> | Yes  | Callback invoked for instance release. If the operation fails, an error message is returned.|

**Example**

```js
W
wusongqing 已提交
1498 1499 1500
imageSourceApi.release(() => { 
    console.log('release succeeded.');
})
W
wusongqing 已提交
1501 1502 1503 1504 1505 1506 1507 1508
```

### release

release(): Promise\<void>

Releases this **ImageSource** instance. This API uses a promise to return the result.

1509
**System capability**: SystemCapability.Multimedia.Image.ImageSource
W
wusongqing 已提交
1510 1511 1512 1513 1514

**Return value**

| Type          | Description                       |
| -------------- | --------------------------- |
1515
| Promise\<void> | Promise used to return the result.|
W
wusongqing 已提交
1516 1517 1518 1519

**Example**

```js
W
wusongqing 已提交
1520
imageSourceApi.release().then(()=>{
W
wusongqing 已提交
1521
    console.log('Succeeded in releasing the image source instance.');
W
wusongqing 已提交
1522
}).catch(error => {
W
wusongqing 已提交
1523
    console.log('Failed to release the image source instance.');
W
wusongqing 已提交
1524
})
W
wusongqing 已提交
1525 1526 1527 1528 1529 1530 1531 1532
```

## image.createImagePacker

createImagePacker(): ImagePacker

Creates an **ImagePacker** instance.

1533
**System capability**: SystemCapability.Multimedia.Image.ImagePacker
W
wusongqing 已提交
1534 1535 1536

**Return value**

W
wusongqing 已提交
1537 1538 1539
| Type                       | Description                 |
| --------------------------- | --------------------- |
| [ImagePacker](#imagepacker) | **ImagePacker** instance created.|
W
wusongqing 已提交
1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552

**Example**

```js
const imagePackerApi = image.createImagePacker();
```

## ImagePacker

Provide APIs to pack images. Before calling any API in **ImagePacker**, you must use **createImagePacker** to create an **ImagePacker** instance.

### Attributes

1553
**System capability**: SystemCapability.Multimedia.Image.ImagePacker
W
wusongqing 已提交
1554 1555 1556 1557

| Name            | Type          | Readable| Writable| Description                      |
| ---------------- | -------------- | ---- | ---- | -------------------------- |
| supportedFormats | Array\<string> | Yes  | No  | Supported image format, which can be jpeg.|
W
wusongqing 已提交
1558 1559 1560

### packing

W
wusongqing 已提交
1561
packing(source: ImageSource, option: PackingOption, callback: AsyncCallback\<ArrayBuffer>): void
W
wusongqing 已提交
1562

1563
Packs an image. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1564

1565
**System capability**: SystemCapability.Multimedia.Image.ImagePacker
W
wusongqing 已提交
1566 1567 1568 1569 1570 1571

**Parameters**

| Name  | Type                              | Mandatory| Description                              |
| -------- | ---------------------------------- | ---- | ---------------------------------- |
| source   | [ImageSource](#imagesource)        | Yes  | Image to pack.                    |
G
Gloria 已提交
1572
| option   | [PackingOption](#packingoption)    | Yes  | Option for image packing.                     |
W
wusongqing 已提交
1573
| callback | AsyncCallback\<ArrayBuffer>        | Yes  | Callback used to return the packed data.|
W
wusongqing 已提交
1574 1575 1576 1577

**Example**

```js
W
wusongqing 已提交
1578 1579 1580
let packOpts = { format:"image/jpeg", quality:98 };
const imageSourceApi = new ArrayBuffer(400);
imagePackerApi.packing(imageSourceApi, packOpts, data => {})
W
wusongqing 已提交
1581 1582 1583 1584
```

### packing

W
wusongqing 已提交
1585
packing(source: ImageSource, option: PackingOption): Promise\<ArrayBuffer>
W
wusongqing 已提交
1586 1587 1588

Packs an image. This API uses a promise to return the result.

1589
**System capability**: SystemCapability.Multimedia.Image.ImagePacker
W
wusongqing 已提交
1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600

**Parameters**

| Name| Type                           | Mandatory| Description          |
| ------ | ------------------------------- | ---- | -------------- |
| source | [ImageSource](#imagesource)     | Yes  | Image to pack.|
| option | [PackingOption](#packingoption) | Yes  | Option for image packing.|

**Return value**

| Type                        | Description                                         |
1601 1602
| ---------------------------- | --------------------------------------------- |
| Promise\<ArrayBuffer>        | Promise used to return the packed data.|
W
wusongqing 已提交
1603 1604 1605 1606

**Example**

```js
W
wusongqing 已提交
1607 1608 1609
let packOpts = { format:"image/jpeg", quality:98 }
const imageSourceApi = new ArrayBuffer(400);
imagePackerApi.packing(imageSourceApi, packOpts)
W
wusongqing 已提交
1610 1611 1612 1613 1614
    .then( data => {
        console.log('packing succeeded.');
	}).catch(error => {
	    console.log('packing failed.');
	})
W
wusongqing 已提交
1615 1616
```

W
wusongqing 已提交
1617
### packing<sup>8+</sup>
W
wusongqing 已提交
1618 1619

packing(source: PixelMap, option: PackingOption, callback: AsyncCallback\<ArrayBuffer>): void
W
wusongqing 已提交
1620

1621
Packs an image. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1622

1623
**System capability**: SystemCapability.Multimedia.Image.ImagePacker
W
wusongqing 已提交
1624 1625 1626 1627 1628

**Parameters**

| Name  | Type                           | Mandatory| Description                              |
| -------- | ------------------------------- | ---- | ---------------------------------- |
W
wusongqing 已提交
1629
| source   | [PixelMap](#pixelmap)           | Yes  | **PixelMap** object to pack.              |
W
wusongqing 已提交
1630
| option   | [PackingOption](#packingoption) | Yes  | Option for image packing.                    |
W
wusongqing 已提交
1631
| callback | AsyncCallback\<ArrayBuffer>     | Yes  | Callback used to return the packed data.|
W
wusongqing 已提交
1632 1633 1634 1635

**Example**

```js
W
wusongqing 已提交
1636 1637 1638 1639
let packOpts = { format:"image/jpeg", quality:98 }
const pixelMapApi = new ArrayBuffer(400);
imagePackerApi.packing(pixelMapApi, packOpts, data => { 
    console.log('Succeeded in packing the image.');
W
wusongqing 已提交
1640
})
W
wusongqing 已提交
1641 1642
```

W
wusongqing 已提交
1643
### packing<sup>8+</sup>
W
wusongqing 已提交
1644

W
wusongqing 已提交
1645
packing(source: PixelMap, option: PackingOption): Promise\<ArrayBuffer>
W
wusongqing 已提交
1646 1647 1648

Packs an image. This API uses a promise to return the result.

1649
**System capability**: SystemCapability.Multimedia.Image.ImagePacker
W
wusongqing 已提交
1650 1651 1652

**Parameters**

W
wusongqing 已提交
1653 1654
| Name| Type                           | Mandatory| Description              |
| ------ | ------------------------------- | ---- | ------------------ |
W
wusongqing 已提交
1655
| source | [PixelMap](#pixelmap)           | Yes  | **PixelMap** object to pack.|
W
wusongqing 已提交
1656
| option | [PackingOption](#packingoption) | Yes  | Option for image packing.    |
W
wusongqing 已提交
1657 1658 1659

**Return value**

1660 1661
| Type                 | Description                                        |
| --------------------- | -------------------------------------------- |
W
wusongqing 已提交
1662
| Promise\<ArrayBuffer> | Promise used to return the packed data.|
W
wusongqing 已提交
1663 1664 1665 1666

**Example**

```js
W
wusongqing 已提交
1667 1668 1669
let packOpts = { format:"image/jpeg", quality:98 }
const pixelMapApi = new ArrayBuffer(400);
imagePackerApi.packing(pixelMapApi, packOpts)
W
wusongqing 已提交
1670
    .then( data => {
W
wusongqing 已提交
1671
	    console.log('Succeeded in packing the image.');
W
wusongqing 已提交
1672
	}).catch(error => {
W
wusongqing 已提交
1673
	    console.log('Failed to pack the image..');
W
wusongqing 已提交
1674
	})
W
wusongqing 已提交
1675 1676 1677 1678 1679 1680
```

### release

release(callback: AsyncCallback\<void>): void

1681
Releases this **ImagePacker** instance. This API uses an asynchronous callback to return the result.
W
wusongqing 已提交
1682

1683
**System capability**: SystemCapability.Multimedia.Image.ImagePacker
W
wusongqing 已提交
1684 1685 1686 1687 1688 1689 1690 1691 1692 1693

**Parameters**

| Name  | Type                | Mandatory| Description                          |
| -------- | -------------------- | ---- | ------------------------------ |
| callback | AsyncCallback\<void> | Yes  | Callback invoked for instance release. If the operation fails, an error message is returned.|

**Example**

```js
W
wusongqing 已提交
1694
imagePackerApi.release(()=>{ 
W
wusongqing 已提交
1695
    console.log('Succeeded in releasing image packaging.');
W
wusongqing 已提交
1696
})
W
wusongqing 已提交
1697 1698 1699 1700 1701 1702 1703 1704
```

### release

release(): Promise\<void>

Releases this **ImagePacker** instance. This API uses a promise to return the result.

1705
**System capability**: SystemCapability.Multimedia.Image.ImagePacker
W
wusongqing 已提交
1706 1707 1708

**Return value**

1709 1710
| Type          | Description                                                  |
| -------------- | ------------------------------------------------------ |
W
wusongqing 已提交
1711 1712 1713 1714 1715
| Promise\<void> | Promise used to return the instance release result. If the operation fails, an error message is returned.|

**Example**

```js
W
wusongqing 已提交
1716
imagePackerApi.release().then(()=>{
W
wusongqing 已提交
1717
    console.log('Succeeded in releasing image packaging.');
W
wusongqing 已提交
1718
}).catch((error)=>{ 
W
wusongqing 已提交
1719
    console.log('Failed to release image packaging.'); 
W
wusongqing 已提交
1720
}) 
W
wusongqing 已提交
1721 1722
```

W
wusongqing 已提交
1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748
## image.createImageReceiver<sup>9+</sup>

createImageReceiver(width: number, height: number, format: number, capacity: number): ImageReceiver

Create an **ImageReceiver** instance by specifying the image width, height, format, and capacity.

**System capability**: SystemCapability.Multimedia.Image.ImageReceiver

**Parameters**

| Name    | Type  | Mandatory| Description                  |
| -------- | ------ | ---- | ---------------------- |
| width    | number | Yes  | Default image width.      |
| height   | number | Yes  | Default image height.      |
| format   | number | Yes  | Image format.            |
| capacity | number | Yes  | Maximum number of images that can be accessed at the same time.|

**Return value**

| Type                            | Description                                   |
| -------------------------------- | --------------------------------------- |
| [ImageReceiver](#imagereceiver9) | Returns an **ImageReceiver** instance if the operation is successful.|

**Example**

```js
W
wusongqing 已提交
1749
var receiver = image.createImageReceiver(8192, 8, 4, 8);
W
wusongqing 已提交
1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761
```

## ImageReceiver<sup>9+</sup>

Provides APIs to obtain the surface ID of a component, read the latest image, read the next image, and release the **ImageReceiver** instance.

Before calling any APIs in **ImageReceiver**, you must create an **ImageReceiver** instance.

### Attributes

**System capability**: SystemCapability.Multimedia.Image.ImageReceiver

1762 1763 1764 1765 1766
| Name    | Type                        | Readable| Writable| Description              |
| -------- | ---------------------------- | ---- | ---- | ------------------ |
| size     | [Size](#size)                | Yes  | No  | Image size.        |
| capacity | number                       | Yes  | No  | Maximum number of images that can be accessed at the same time.|
| format   | [ImageFormat](#imageformat9) | Yes  | No  | Image format.        |
W
wusongqing 已提交
1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784

### getReceivingSurfaceId<sup>9+</sup>

getReceivingSurfaceId(callback: AsyncCallback\<string>): void

Obtains a surface ID for the camera or other components. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Multimedia.Image.ImageReceiver

**Parameters**

| Name    | Type                  | Mandatory| Description                      |
| -------- | ---------------------- | ---- | -------------------------- |
| callback | AsyncCallback\<string> | Yes  | Callback used to return the surface ID.|

**Example**

```js
W
wusongqing 已提交
1785
receiver.getReceivingSurfaceId((err, id) => { 
W
wusongqing 已提交
1786 1787 1788 1789 1790 1791
    if(err) {
        console.log('getReceivingSurfaceId failed.');
    } else {
        console.log('getReceivingSurfaceId succeeded.');
    }
});
W
wusongqing 已提交
1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811
```

### getReceivingSurfaceId<sup>9+</sup>

getReceivingSurfaceId(): Promise\<string>

Obtains a surface ID for the camera or other components. This API uses a promise to return the result.

**System capability**: SystemCapability.Multimedia.Image.ImageReceiver

**Return value**

| Type            | Description                |
| ---------------- | -------------------- |
| Promise\<string> | Promise used to return the surface ID.|

**Example**

```js
receiver.getReceivingSurfaceId().then( id => { 
W
wusongqing 已提交
1812 1813 1814 1815
    console.log('getReceivingSurfaceId succeeded.');
}).catch(error => {
    console.log('getReceivingSurfaceId failed.');
})
W
wusongqing 已提交
1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834
```

### readLatestImage<sup>9+</sup>

readLatestImage(callback: AsyncCallback\<Image>): void

Reads the latest image from the **ImageReceiver** instance. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Multimedia.Image.ImageReceiver

**Parameters**

| Name    | Type                           | Mandatory| Description                    |
| -------- | ------------------------------- | ---- | ------------------------ |
| callback | AsyncCallback<[Image](#image9)> | Yes  | Callback used to return the latest image.|

**Example**

```js
W
wusongqing 已提交
1835 1836 1837 1838 1839 1840 1841
receiver.readLatestImage((err, img) => { 
    if(err) {
        console.log('readLatestImage failed.');
    } else {
        console.log('readLatestImage succeeded.');
    }
});
W
wusongqing 已提交
1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855
```

### readLatestImage<sup>9+</sup>

readLatestImage(): Promise\<Image>

Reads the latest image from the **ImageReceiver** instance. This API uses a promise to return the result.

**System capability**: SystemCapability.Multimedia.Image.ImageReceiver

**Return value**

| Type                     | Description              |
| ------------------------- | ------------------ |
1856
| Promise<[Image](#image9)> | Promise used to return the latest image.|
W
wusongqing 已提交
1857 1858 1859 1860

**Example**

```js
W
wusongqing 已提交
1861 1862 1863 1864 1865
receiver.readLatestImage().then(img => {
    console.log('readLatestImage succeeded.');
}).catch(error => {
    console.log('readLatestImage failed.');
})
W
wusongqing 已提交
1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884
```

### readNextImage<sup>9+</sup>

readNextImage(callback: AsyncCallback\<Image>): void

Reads the next image from the **ImageReceiver** instance. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Multimedia.Image.ImageReceiver

**Parameters**

| Name    | Type                           | Mandatory| Description                      |
| -------- | ------------------------------- | ---- | -------------------------- |
| callback | AsyncCallback<[Image](#image9)> | Yes  | Callback used to return the next image.|

**Example**

```js
W
wusongqing 已提交
1885 1886 1887 1888 1889 1890 1891
receiver.readNextImage((err, img) => { 
    if(err) {
        console.log('readNextImage failed.');
    } else {
        console.log('readNextImage succeeded.');
    }
});
W
wusongqing 已提交
1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910
```

### readNextImage<sup>9+</sup>

readNextImage(): Promise\<Image>

Reads the next image from the **ImageReceiver** instance. This API uses a promise to return the result.

**System capability**: SystemCapability.Multimedia.Image.ImageReceiver

**Return value**

| Type                     | Description                |
| ------------------------- | -------------------- |
| Promise<[Image](#image9)> | Promise used to return the next image.|

**Example**

```js
W
wusongqing 已提交
1911 1912 1913 1914 1915
receiver.readNextImage().then(img => {
    console.log('readNextImage succeeded.');
}).catch(error => {
    console.log('readNextImage failed.');
})
W
wusongqing 已提交
1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935
```

### on('imageArrival')<sup>9+</sup>

on(type: 'imageArrival', callback: AsyncCallback\<void>): void

Listens for image arrival events.

**System capability**: SystemCapability.Multimedia.Image.ImageReceiver

**Parameters**

| Name    | Type                | Mandatory| Description                                                  |
| -------- | -------------------- | ---- | ------------------------------------------------------ |
| type     | string               | Yes  | Type of event to listen for. The value is fixed at **imageArrival**, which is triggered when an image is received.|
| callback | AsyncCallback\<void> | Yes  | Callback invoked for the event.                                      |

**Example**

```js
W
wusongqing 已提交
1936
receiver.on('imageArrival', () => {})
W
wusongqing 已提交
1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955
```

### release<sup>9+</sup>

release(callback: AsyncCallback\<void>): void

Releases this **ImageReceiver** instance. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Multimedia.Image.ImageReceiver

**Parameters**

| Name    | Type                | Mandatory| Description                    |
| -------- | -------------------- | ---- | ------------------------ |
| callback | AsyncCallback\<void> | Yes  | Callback used to return the result.|

**Example**

```js
W
wusongqing 已提交
1956
receiver.release(() => {})
W
wusongqing 已提交
1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975
```

### release<sup>9+</sup>

release(): Promise\<void>

Releases this **ImageReceiver** instance. This API uses a promise to return the result.

**System capability**: SystemCapability.Multimedia.Image.ImageReceiver

**Return value**

| Type          | Description              |
| -------------- | ------------------ |
| Promise\<void> | Promise used to return the result.|

**Example**

```js
W
wusongqing 已提交
1976 1977 1978 1979 1980
receiver.release().then(() => {
    console.log('release succeeded.');
}).catch(error => {
    console.log('release failed.');
})
W
wusongqing 已提交
1981 1982 1983 1984 1985 1986 1987 1988 1989 1990
```

## Image<sup>9+</sup>

Provides APIs for basic image operations, including obtaining image information and reading and writing image data. An **Image** instance is returned when [readNextImage](#readnextimage9) and [readLatestImage](#readlatestimage9) are called.

### Attributes

**System capability**: SystemCapability.Multimedia.Image.Core

1991 1992 1993 1994 1995
| Name    | Type              | Readable| Writable| Description                                              |
| -------- | ------------------ | ---- | ---- | -------------------------------------------------- |
| clipRect | [Region](#region7) | Yes  | Yes  | Image area to be cropped.                                |
| size     | [Size](#size)      | Yes  | No  | Image size.                                        |
| format   | number             | Yes  | No  | Image format. For details, see [PixelMapFormat](#pixelmapformat7).|
W
wusongqing 已提交
1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014

### getComponent<sup>9+</sup>

getComponent(componentType: ComponentType, callback: AsyncCallback\<Component>): void

Obtains the component buffer from the **Image** instance based on the color component type. This API uses an asynchronous callback to return the result.

**System capability**: SystemCapability.Multimedia.Image.Core

**Parameters**

| Name         | Type                                   | Mandatory| Description                |
| ------------- | --------------------------------------- | ---- | -------------------- |
| componentType | [ComponentType](#componenttype9)        | Yes  | Color component type of the image.    |
| callback      | AsyncCallback<[Component](#component9)> | Yes  | Callback used to return the component buffer.|

**Example**

```js
W
wusongqing 已提交
2015 2016 2017 2018 2019 2020 2021
img.getComponent(4, (err, component) => {
    if(err) {
        console.log('getComponent failed.');
    } else {
        console.log('getComponent succeeded.');
    }
})
W
wusongqing 已提交
2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068
```

### getComponent<sup>9+</sup>

getComponent(componentType: ComponentType): Promise\<Component>

Obtains the component buffer from the **Image** instance based on the color component type. This API uses a promise to return the result.

**System capability**: SystemCapability.Multimedia.Image.Core

**Parameters**

| Name         | Type                            | Mandatory| Description            |
| ------------- | -------------------------------- | ---- | ---------------- |
| componentType | [ComponentType](#componenttype9) | Yes  | Color component type of the image.|

**Return value**

| Type                             | Description                             |
| --------------------------------- | --------------------------------- |
| Promise<[Component](#component9)> | Promise used to return the component buffer.|

**Example**

```js
img.getComponent(4).then(component => { })
```

### release<sup>9+</sup>

release(callback: AsyncCallback\<void>): void

Releases this **Image** instance. This API uses an asynchronous callback to return the result.

The corresponding resources must be released before another image arrives.

**System capability**: SystemCapability.Multimedia.Image.Core

**Parameters**

| Name    | Type                | Mandatory| Description          |
| -------- | -------------------- | ---- | -------------- |
| callback | AsyncCallback\<void> | Yes  | Callback used to return the result.|

**Example**

```js
W
wusongqing 已提交
2069 2070 2071
img.release(() =>{ 
    console.log('release succeeded.');
}) 
W
wusongqing 已提交
2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093
```

### release<sup>9+</sup>

release(): Promise\<void>

Releases this **Image** instance. This API uses a promise to return the result.

The corresponding resources must be released before another image arrives.

**System capability**: SystemCapability.Multimedia.Image.Core

**Return value**

| Type          | Description                 |
| -------------- | --------------------- |
| Promise\<void> | Promise used to return the result.|

**Example**

```js
img.release().then(() =>{
W
wusongqing 已提交
2094 2095 2096 2097
    console.log('release succeeded.');
}).catch(error => {
    console.log('release failed.');
})
W
wusongqing 已提交
2098 2099
```

W
wusongqing 已提交
2100 2101 2102 2103
## PositionArea<sup>7+</sup>

Describes area information in an image.

2104
**System capability**: SystemCapability.Multimedia.Image.Core
W
wusongqing 已提交
2105

W
wusongqing 已提交
2106 2107 2108 2109
| Name  | Type              | Readable| Writable| Description                                                        |
| ------ | ------------------ | ---- | ---- | ------------------------------------------------------------ |
| pixels | ArrayBuffer        | Yes  | No  | Pixels of the image.                                                      |
| offset | number             | Yes  | No  | Offset for data reading.                                                    |
W
wusongqing 已提交
2110 2111
| 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](#region7) | 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.|
W
wusongqing 已提交
2112

W
wusongqing 已提交
2113
## ImageInfo
W
wusongqing 已提交
2114 2115 2116

Describes image information.

2117
**System capability**: SystemCapability.Multimedia.Image.Core
W
wusongqing 已提交
2118 2119 2120 2121 2122 2123 2124 2125 2126

| Name| Type         | Readable| Writable| Description      |
| ---- | ------------- | ---- | ---- | ---------- |
| size | [Size](#size) | Yes  | Yes  | Image size.|

## Size

Describes the size of an image.

2127
**System capability**: SystemCapability.Multimedia.Image.Core
W
wusongqing 已提交
2128 2129 2130 2131 2132 2133 2134 2135

| Name  | Type  | Readable| Writable| Description          |
| ------ | ------ | ---- | ---- | -------------- |
| height | number | Yes  | Yes  | Image height.|
| width  | number | Yes  | Yes  | Image width.|

## PixelMapFormat<sup>7+</sup>

W
wusongqing 已提交
2136
Enumerates the pixel formats of images.
W
wusongqing 已提交
2137

2138
**System capability**: SystemCapability.Multimedia.Image.Core
W
wusongqing 已提交
2139

2140 2141 2142 2143 2144 2145
| Name                  | Default Value| Description             |
| ---------------------- | ------ | ----------------- |
| UNKNOWN                | 0      | Unknown format.       |
| RGB_565                | 2      | RGB_565.    |
| RGBA_8888              | 3      | RGBA_8888.|
| BGRA_8888<sup>9+</sup> | 4      | BGRA_8888.|
W
wusongqing 已提交
2146

W
wusongqing 已提交
2147
## AlphaType<sup>9+</sup>
W
wusongqing 已提交
2148

W
wusongqing 已提交
2149
Enumerates the alpha types of images.
W
wusongqing 已提交
2150

2151
**System capability**: SystemCapability.Multimedia.Image.Core
W
wusongqing 已提交
2152 2153 2154 2155

| Name    | Default Value| Description                   |
| -------- | ------ | ----------------------- |
| UNKNOWN  | 0      | Unknown alpha type.           |
2156
| OPAQUE   | 1      | There is no alpha or the image is opaque.|
W
wusongqing 已提交
2157 2158 2159
| PREMUL   | 2      | Premultiplied alpha.         |
| UNPREMUL | 3      | Unpremultiplied alpha, that is, straight alpha.       |

W
wusongqing 已提交
2160
## ScaleMode<sup>9+</sup>
W
wusongqing 已提交
2161

W
wusongqing 已提交
2162
Enumerates the scale modes of images.
W
wusongqing 已提交
2163

2164
**System capability**: SystemCapability.Multimedia.Image.Core
W
wusongqing 已提交
2165 2166 2167 2168

| Name           | Default Value| Description                                              |
| --------------- | ------ | -------------------------------------------------- |
| CENTER_CROP     | 1      | Scales the image so that it fills the requested bounds of the target and crops the extra.|
G
Gloria 已提交
2169
| FIT_TARGET_SIZE | 0      | Reduces the image size to the dimensions of the target.                          |
W
wusongqing 已提交
2170

2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183
## SourceOptions<sup>9+</sup>

Defines image source initialization options.

**System capability**: SystemCapability.Multimedia.Image.Core

| Name             | Type                              | Readable| Writable| Description              |
| ----------------- | ---------------------------------- | ---- | ---- | ------------------ |
| sourceDensity     | number                             | Yes  | Yes  | Density of the image source.|
| sourcePixelFormat | [PixelMapFormat](#pixelmapformat7) | Yes  | Yes  | Pixel format of the image source.    |
| sourceSize        | [Size](#size)                      | Yes  | Yes  | Pixel size of the image source.    |


W
wusongqing 已提交
2184 2185
## InitializationOptions<sup>8+</sup>

W
wusongqing 已提交
2186 2187
Defines pixel map initialization options.

2188
**System capability**: SystemCapability.Multimedia.Image.Core
W
wusongqing 已提交
2189

2190 2191 2192 2193 2194 2195 2196
| Name                    | Type                              | Readable| Writable| Description          |
| ------------------------ | ---------------------------------- | ---- | ---- | -------------- |
| 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<sup>9+</sup>   | [ScaleMode](#scalemode9)           | Yes  | Yes  | Scale mode.      |
| size                     | [Size](#size)                      | Yes  | Yes  | Image size.|
W
wusongqing 已提交
2197 2198 2199

## DecodingOptions<sup>7+</sup>

W
wusongqing 已提交
2200
Defines image decoding options.
W
wusongqing 已提交
2201

2202
**System capability**: SystemCapability.Multimedia.Image.ImageSource
W
wusongqing 已提交
2203 2204 2205 2206

| Name              | Type                              | Readable| Writable| Description            |
| ------------------ | ---------------------------------- | ---- | ---- | ---------------- |
| sampleSize         | number                             | Yes  | Yes  | Thumbnail sampling size.|
W
wusongqing 已提交
2207
| rotate             | number                             | Yes  | Yes  | Rotation angle.      |
W
wusongqing 已提交
2208 2209
| editable           | boolean                            | Yes  | Yes  | Whether the image is editable.    |
| desiredSize        | [Size](#size)                      | Yes  | Yes  | Expected output size.  |
W
wusongqing 已提交
2210
| desiredRegion      | [Region](#region7)                 | Yes  | Yes  | Region to decode.      |
W
wusongqing 已提交
2211
| desiredPixelFormat | [PixelMapFormat](#pixelmapformat7) | Yes  | Yes  | Pixel map format for decoding.|
W
wusongqing 已提交
2212
| index              | number                             | Yes  | Yes  | Index of the image to decode.  |
W
wusongqing 已提交
2213

W
wusongqing 已提交
2214
## Region<sup>7+</sup>
W
wusongqing 已提交
2215 2216 2217

Describes region information.

2218
**System capability**: SystemCapability.Multimedia.Image.Core
W
wusongqing 已提交
2219

W
wusongqing 已提交
2220 2221 2222
| Name| Type         | Readable| Writable| Description        |
| ---- | ------------- | ---- | ---- | ------------ |
| size | [Size](#size) | Yes  | Yes  | Region size.  |
W
wusongqing 已提交
2223 2224 2225 2226 2227
| x    | number        | Yes  | Yes  | X coordinate of the region.|
| y    | number        | Yes  | Yes  | Y coordinate of the region.|

## PackingOption

W
wusongqing 已提交
2228
Defines the option for image packing.
W
wusongqing 已提交
2229

2230
**System capability**: SystemCapability.Multimedia.Image.ImagePacker
W
wusongqing 已提交
2231

2232 2233
| Name   | Type  | Readable| Writable| Description                                               |
| ------- | ------ | ---- | ---- | --------------------------------------------------- |
G
Gloria 已提交
2234
| format  | string | Yes  | Yes  | Format of the packed image.<br>Currently, the following raw formats are supported: .jpg, .png, .gif, .bmp, and .webp. |
W
wusongqing 已提交
2235
| quality | number | Yes  | Yes  | Quality of the output image during JPEG encoding. The value ranges from 1 to 100.|
W
wusongqing 已提交
2236 2237 2238 2239 2240

## GetImagePropertyOptions<sup>7+</sup>

Describes image properties.

2241
**System capability**: SystemCapability.Multimedia.Image.ImageSource
W
wusongqing 已提交
2242 2243 2244 2245 2246 2247 2248 2249

| Name        | Type  | Readable| Writable| Description        |
| ------------ | ------ | ---- | ---- | ------------ |
| index        | number | Yes  | Yes  | Index of an image.  |
| defaultValue | string | Yes  | Yes  | Default property value.|

## PropertyKey<sup>7+</sup>

W
wusongqing 已提交
2250
Describes the exchangeable image file format (EXIF) information of an image.
W
wusongqing 已提交
2251

2252
**System capability**: SystemCapability.Multimedia.Image.Core
W
wusongqing 已提交
2253

2254 2255 2256 2257 2258 2259 2260 2261 2262 2263
| Name             | Default Value                 | Description                    |
| ----------------- | ----------------------- | ------------------------ |
| BITS_PER_SAMPLE   | "BitsPerSample"         | Number of bits per pixel.        |
| ORIENTATION       | "Orientation"           | Image orientation.              |
| IMAGE_LENGTH      | "ImageLength"           | Image length.              |
| IMAGE_WIDTH       | "ImageWidth"            | Image width.              |
| GPS_LATITUDE      | "GPSLatitude"           | Image latitude.              |
| GPS_LONGITUDE     | "GPSLongitude"          | Image longitude.              |
| GPS_LATITUDE_REF  | "GPSLatitudeRef"        | Latitude reference, for example, N or S.    |
| GPS_LONGITUDE_REF | "GPSLongitudeRef"       | Longitude reference, for example, W or E.    |
W
wusongqing 已提交
2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300

## ImageFormat<sup>9+</sup>

Enumerates the image formats.

**System capability**: SystemCapability.Multimedia.Image.Core

| Name        | Default Value| Description                |
| ------------ | ------ | -------------------- |
| YCBCR_422_SP | 1000   | YCBCR422 semi-planar format.|
| JPEG         | 2000   | JPEG encoding format.      |

## ComponentType<sup>9+</sup>

Enumerates the color component types of images.

**System capability**: SystemCapability.Multimedia.Image.ImageReceiver

| Name | Default Value| Description       |
| ----- | ------ | ----------- |
| YUV_Y | 1      | Luminance component. |
| YUV_U | 2      | Chrominance component. |
| YUV_V | 3      | Chrominance component. |
| JPEG  | 4      | JPEG type.|

## Component<sup>9+</sup>

Describes the color components of an image.

**System capability**: SystemCapability.Multimedia.Image.Core

| Name         | Type                            | Readable| Writable| Description        |
| ------------- | -------------------------------- | ---- | ---- | ------------ |
| componentType | [ComponentType](#componenttype9) | Yes  | No  | Color component type.  |
| rowStride     | number                           | Yes  | No  | Row stride.      |
| pixelStride   | number                           | Yes  | No  | Pixel stride.  |
| byteBuffer    | ArrayBuffer                      | Yes  | No  | Component buffer.|
2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325

## ResponseCode

Enumerates the response codes returned upon build errors.

| Name                               | Value      | Description                                               |
| ----------------------------------- | -------- | --------------------------------------------------- |
| ERR_MEDIA_INVALID_VALUE             | -1       | Invalid value.                                         |
| SUCCESS                             | 0        | Operation successful.                                         |
| ERROR                               | 62980096 | Operation failed.                                         |
| ERR_IPC                             | 62980097 | IPC error.                                          |
| ERR_SHAMEM_NOT_EXIST                | 62980098 | The shared memory does not exist.                                     |
| ERR_SHAMEM_DATA_ABNORMAL            | 62980099 | The shared memory is abnormal.                                     |
| ERR_IMAGE_DECODE_ABNORMAL           | 62980100 | An error occurs during image decoding.                                     |
| ERR_IMAGE_DATA_ABNORMAL             | 62980101 | The input image data is incorrect.                                 |
| ERR_IMAGE_MALLOC_ABNORMAL           | 62980102 | An error occurs during image memory allocation.                                   |
| ERR_IMAGE_DATA_UNSUPPORT            | 62980103 | Unsupported image type.                                   |
| ERR_IMAGE_INIT_ABNORMAL             | 62980104 | An error occurs during image initialization.                                   |
| ERR_IMAGE_GET_DATA_ABNORMAL         | 62980105 | An error occurs during image data retrieval.                                 |
| ERR_IMAGE_TOO_LARGE                 | 62980106 | The image data is too large.                                     |
| ERR_IMAGE_TRANSFORM                 | 62980107 | An error occurs during image transformation.                                     |
| ERR_IMAGE_COLOR_CONVERT             | 62980108 | An error occurs during image color conversion.                                 |
| ERR_IMAGE_CROP                      | 62980109 | An error occurs during image cropping.                                         |
| ERR_IMAGE_SOURCE_DATA               | 62980110 | The image source data is incorrect.                                   |
| ERR_IMAGE_SOURCE_DATA_INCOMPLETE    | 62980111 | The image source data is incomplete.                                 |
W
wusongqing 已提交
2326
| ERR_IMAGE_MISMATCHED_FORMAT         | 62980112 | The image formats do not match.                                   |
2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341
| ERR_IMAGE_UNKNOWN_FORMAT            | 62980113 | Unknown image format.                                     |
| ERR_IMAGE_SOURCE_UNRESOLVED         | 62980114 | The image source is not parsed.                                     |
| ERR_IMAGE_INVALID_PARAMETER         | 62980115 | Invalid image parameter.                                     |
| ERR_IMAGE_DECODE_FAILED             | 62980116 | Decoding failed.                                         |
| ERR_IMAGE_PLUGIN_REGISTER_FAILED    | 62980117 | Failed to register the plug-in.                                     |
| ERR_IMAGE_PLUGIN_CREATE_FAILED      | 62980118 | Failed to create the plug-in.                                     |
| ERR_IMAGE_ENCODE_FAILED             | 62980119 | Failed to encode the image.                                     |
| ERR_IMAGE_ADD_PIXEL_MAP_FAILED      | 62980120 | Failed to add the image pixel map.                             |
| ERR_IMAGE_HW_DECODE_UNSUPPORT       | 62980121 | Unsupported image hardware decoding.                               |
| ERR_IMAGE_DECODE_HEAD_ABNORMAL      | 62980122 | The image decoding header is incorrect.                                   |
| ERR_IMAGE_DECODE_EXIF_UNSUPPORT     | 62980123 | EXIF decoding is not supported.                             |
| ERR_IMAGE_PROPERTY_NOT_EXIST        | 62980124 | The image property does not exist. The error codes for the image start from 150.|
| ERR_IMAGE_READ_PIXELMAP_FAILED      | 62980246 | Failed to read the pixel map.                                 |
| ERR_IMAGE_WRITE_PIXELMAP_FAILED     | 62980247 | Failed to write the pixel map.                                 |
| ERR_IMAGE_PIXELMAP_NOT_ALLOW_MODIFY | 62980248 | Modification to the pixel map is not allowed.                               |
W
wusongqing 已提交
2342
| ERR_IMAGE_CONFIG_FAILED             | 62980259 | The configuration is incorrect.                                         |