1# @ohos.multimedia.image (Image Processing) 2 3The **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). 4 5> **NOTE** 6> 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. 8 9## Modules to Import 10 11```js 12import image from '@ohos.multimedia.image'; 13``` 14 15## image.createPixelMap<sup>8+</sup> 16 17createPixelMap(colors: ArrayBuffer, options: InitializationOptions): Promise\<PixelMap> 18 19Creates a **PixelMap** object with the default BGRA_8888 format and pixel properties specified. This API uses a promise to return the result. 20 21**System capability**: SystemCapability.Multimedia.Image.Core 22 23**Parameters** 24 25| Name | Type | Mandatory| Description | 26| ------- | ------------------------------------------------ | ---- | ---------------------------------------------------------------- | 27| colors | ArrayBuffer | Yes | Color array in BGRA_8888 format. | 28| options | [InitializationOptions](#initializationoptions8) | Yes | Pixel properties, including the alpha type, size, scale mode, pixel format, and editable.| 29 30**Return value** 31 32| Type | Description | 33| -------------------------------- | ----------------------------------------------------------------------- | 34| 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.| 35 36 37**Example** 38 39```js 40const color = new ArrayBuffer(96); // 96 is the size of the pixel map buffer to create. The value is calculated as follows: height x width x 4. 41let bufferArr = new Uint8Array(color); 42let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } 43image.createPixelMap(color, opts).then((pixelmap) => { 44 console.log('Succeeded in creating pixelmap.'); 45}).catch(error => { 46 console.log('Failed to create pixelmap.'); 47}) 48``` 49 50## image.createPixelMap<sup>8+</sup> 51 52createPixelMap(colors: ArrayBuffer, options: InitializationOptions, callback: AsyncCallback\<PixelMap>): void 53 54Creates a **PixelMap** object with the default BGRA_8888 format and pixel properties specified. This API uses an asynchronous callback to return the result. 55 56**System capability**: SystemCapability.Multimedia.Image.Core 57 58**Parameters** 59 60| Name | Type | Mandatory| Description | 61| -------- | ------------------------------------------------ | ---- | -------------------------- | 62| colors | ArrayBuffer | Yes | Color array in BGRA_8888 format. | 63| options | [InitializationOptions](#initializationoptions8) | Yes | Pixel properties. | 64| callback | AsyncCallback\<[PixelMap](#pixelmap7)> | Yes | Callback used to return the **PixelMap** object.| 65 66**Example** 67 68```js 69const color = new ArrayBuffer(96); // 96 is the size of the pixel map buffer to create. The value is calculated as follows: height x width x 4. 70let bufferArr = new Uint8Array(color); 71let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } 72image.createPixelMap(color, opts, (error, pixelmap) => { 73 if(error) { 74 console.log('Failed to create pixelmap.'); 75 } else { 76 console.log('Succeeded in creating pixelmap.'); 77 } 78}) 79``` 80 81## PixelMap<sup>7+</sup> 82 83Provides 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. Currently, the maximum size of a serialized pixel map is 128 MB. A larger size will cause a display failure. The size is calculated as follows: Width * Height * Number of bytes occupied by each pixel. 84 85### Attributes 86 87**System capability**: SystemCapability.Multimedia.Image.Core 88 89| Name | Type | Readable| Writable| Description | 90| ---------- | ------- | ---- | ---- | -------------------------- | 91| isEditable | boolean | Yes | No | Whether the image pixel map is editable.| 92 93### readPixelsToBuffer<sup>7+</sup> 94 95readPixelsToBuffer(dst: ArrayBuffer): Promise\<void> 96 97Reads 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. 98 99**System capability**: SystemCapability.Multimedia.Image.Core 100 101**Parameters** 102 103| Name| Type | Mandatory| Description | 104| ------ | ----------- | ---- | ----------------------------------------------------------------------------------------------------- | 105| dst | ArrayBuffer | Yes | Buffer to which the image pixel map data will be written. The buffer size is obtained by calling **getPixelBytesNumber**.| 106 107**Return value** 108 109| Type | Description | 110| -------------- | ----------------------------------------------- | 111| Promise\<void> | Promise used to return the result. If the operation fails, an error message is returned.| 112 113**Example** 114 115```js 116const readBuffer = new ArrayBuffer(96); // 96 is the size of the pixel map buffer to create. The value is calculated as follows: height x width x 4. 117pixelmap.readPixelsToBuffer(readBuffer).then(() => { 118 console.log('Succeeded in reading image pixel data.'); // Called if the condition is met. 119}).catch(error => { 120 console.log('Failed to read image pixel data.'); // Called if no condition is met. 121}) 122``` 123 124### readPixelsToBuffer<sup>7+</sup> 125 126readPixelsToBuffer(dst: ArrayBuffer, callback: AsyncCallback\<void>): void 127 128Reads 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. 129 130**System capability**: SystemCapability.Multimedia.Image.Core 131 132**Parameters** 133 134| Name | Type | Mandatory| Description | 135| -------- | -------------------- | ---- | ----------------------------------------------------------------------------------------------------- | 136| dst | ArrayBuffer | Yes | Buffer to which the image pixel map data will be written. The buffer size is obtained by calling **getPixelBytesNumber**.| 137| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned. | 138 139**Example** 140 141```js 142const readBuffer = new ArrayBuffer(96); // 96 is the size of the pixel map buffer to create. The value is calculated as follows: height x width x 4. 143pixelmap.readPixelsToBuffer(readBuffer, (err, res) => { 144 if(err) { 145 console.log('Failed to read image pixel data.'); // Called if no condition is met. 146 } else { 147 console.log('Succeeded in reading image pixel data.'); // Called if the condition is met. 148 } 149}) 150``` 151 152### readPixels<sup>7+</sup> 153 154readPixels(area: PositionArea): Promise\<void> 155 156Reads image pixel map data in an area. This API uses a promise to return the data read. 157 158**System capability**: SystemCapability.Multimedia.Image.Core 159 160**Parameters** 161 162| Name| Type | Mandatory| Description | 163| ------ | ------------------------------ | ---- | ------------------------ | 164| area | [PositionArea](#positionarea7) | Yes | Area from which the image pixel map data will be read.| 165 166**Return value** 167 168| Type | Description | 169| :------------- | :-------------------------------------------------- | 170| Promise\<void> | Promise used to return the result. If the operation fails, an error message is returned.| 171 172**Example** 173 174```js 175const area = { 176 pixels: new ArrayBuffer(8), 177 offset: 0, 178 stride: 8, 179 region: { size: { height: 1, width: 2 }, x: 0, y: 0 } 180} 181pixelmap.readPixels(area).then(() => { 182 console.log('Succeeded in reading the image data in the area.'); // Called if the condition is met. 183}).catch(error => { 184 console.log('Failed to read the image data in the area.'); // Called if no condition is met. 185}) 186``` 187 188### readPixels<sup>7+</sup> 189 190readPixels(area: PositionArea, callback: AsyncCallback\<void>): void 191 192Reads image pixel map data in an area. This API uses an asynchronous callback to return the data read. 193 194**System capability**: SystemCapability.Multimedia.Image.Core 195 196**Parameters** 197 198| Name | Type | Mandatory| Description | 199| -------- | ------------------------------ | ---- | ------------------------------ | 200| area | [PositionArea](#positionarea7) | Yes | Area from which the image pixel map data will be read. | 201| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned.| 202 203**Example** 204 205```js 206const color = new ArrayBuffer(96); // 96 is the size of the pixel map buffer to create. The value is calculated as follows: height x width x 4. 207let bufferArr = new Uint8Array(color); 208let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } 209image.createPixelMap(color, opts, (err, pixelmap) => { 210 if(pixelmap == undefined){ 211 console.info('createPixelMap failed.'); 212 } else { 213 const area = { pixels: new ArrayBuffer(8), 214 offset: 0, 215 stride: 8, 216 region: { size: { height: 1, width: 2 }, x: 0, y: 0 }}; 217 pixelmap.readPixels(area, () => { 218 console.info('readPixels success'); 219 }) 220 } 221}) 222``` 223 224### writePixels<sup>7+</sup> 225 226writePixels(area: PositionArea): Promise\<void> 227 228Writes image pixel map data to an area. This API uses a promise to return the operation result. 229 230**System capability**: SystemCapability.Multimedia.Image.Core 231 232**Parameters** 233 234| Name| Type | Mandatory| Description | 235| ------ | ------------------------------ | ---- | -------------------- | 236| area | [PositionArea](#positionarea7) | Yes | Area to which the image pixel map data will be written.| 237 238**Return value** 239 240| Type | Description | 241| :------------- | :-------------------------------------------------- | 242| Promise\<void> | Promise used to return the result. If the operation fails, an error message is returned.| 243 244**Example** 245 246```js 247const color = new ArrayBuffer(96); // 96 is the size of the pixel map buffer to create. The value is calculated as follows: height x width x 4. 248let bufferArr = new Uint8Array(color); 249let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } 250image.createPixelMap(color, opts) 251 .then( pixelmap => { 252 if (pixelmap == undefined) { 253 console.info('createPixelMap failed.'); 254 } 255 const area = { pixels: new ArrayBuffer(8), 256 offset: 0, 257 stride: 8, 258 region: { size: { height: 1, width: 2 }, x: 0, y: 0 } 259 } 260 let bufferArr = new Uint8Array(area.pixels); 261 for (var i = 0; i < bufferArr.length; i++) { 262 bufferArr[i] = i + 1; 263 } 264 265 pixelmap.writePixels(area).then(() => { 266 console.info('Succeeded to write pixelmap into the specified area.'); 267 }) 268 }).catch(error => { 269 console.log('error: ' + error); 270 }) 271``` 272 273### writePixels<sup>7+</sup> 274 275writePixels(area: PositionArea, callback: AsyncCallback\<void>): void 276 277Writes image pixel map data to an area. This API uses an asynchronous callback to return the operation result. 278 279**System capability**: SystemCapability.Multimedia.Image.Core 280 281**Parameters** 282 283| Name | Type | Mandatory| Description | 284| --------- | ------------------------------ | ---- | ------------------------------ | 285| area | [PositionArea](#positionarea7) | Yes | Area to which the image pixel map data will be written. | 286| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned.| 287 288**Example** 289 290```js 291const area = { pixels: new ArrayBuffer(8), 292 offset: 0, 293 stride: 8, 294 region: { size: { height: 1, width: 2 }, x: 0, y: 0 } 295} 296let bufferArr = new Uint8Array(area.pixels); 297for (var i = 0; i < bufferArr.length; i++) { 298 bufferArr[i] = i + 1; 299} 300pixelmap.writePixels(area, (error) => { 301 if (error != undefined) { 302 console.info('Failed to write pixelmap into the specified area.'); 303 } else { 304 console.info('Succeeded to write pixelmap into the specified area.'); 305 } 306}) 307``` 308 309### writeBufferToPixels<sup>7+</sup> 310 311writeBufferToPixels(src: ArrayBuffer): Promise\<void> 312 313Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** object. This API uses a promise to return the result. 314 315**System capability**: SystemCapability.Multimedia.Image.Core 316 317**Parameters** 318 319| Name| Type | Mandatory| Description | 320| ------ | ----------- | ---- | -------------- | 321| src | ArrayBuffer | Yes | Buffer from which the image data will be read.| 322 323**Return value** 324 325| Type | Description | 326| -------------- | ----------------------------------------------- | 327| Promise\<void> | Promise used to return the result. If the operation fails, an error message is returned.| 328 329**Example** 330 331```js 332const color = new ArrayBuffer(96); // 96 is the size of the pixel map buffer to create. The value is calculated as follows: height x width x 4. 333let bufferArr = new Uint8Array(color); 334for (var i = 0; i < bufferArr.length; i++) { 335 bufferArr[i] = i + 1; 336} 337pixelmap.writeBufferToPixels(color).then(() => { 338 console.log("Succeeded in writing data from a buffer to a PixelMap."); 339}).catch((err) => { 340 console.error("Failed to write data from a buffer to a PixelMap."); 341}) 342``` 343 344### writeBufferToPixels<sup>7+</sup> 345 346writeBufferToPixels(src: ArrayBuffer, callback: AsyncCallback\<void>): void 347 348Reads image data in an **ArrayBuffer** and writes the data to a **PixelMap** object. This API uses an asynchronous callback to return the result. 349 350**System capability**: SystemCapability.Multimedia.Image.Core 351 352**Parameters** 353 354| Name | Type | Mandatory| Description | 355| -------- | -------------------- | ---- | ------------------------------ | 356| src | ArrayBuffer | Yes | Buffer from which the image data will be read. | 357| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned.| 358 359**Example** 360 361```js 362const color = new ArrayBuffer(96); // 96 is the size of the pixel map buffer to create. The value is calculated as follows: height x width x 4. 363let bufferArr = new Uint8Array(color); 364for (var i = 0; i < bufferArr.length; i++) { 365 bufferArr[i] = i + 1; 366} 367pixelmap.writeBufferToPixels(color, function(err) { 368 if (err) { 369 console.error("Failed to write data from a buffer to a PixelMap."); 370 return; 371 } else { 372 console.log("Succeeded in writing data from a buffer to a PixelMap."); 373 } 374}); 375``` 376 377### getImageInfo<sup>7+</sup> 378 379getImageInfo(): Promise\<ImageInfo> 380 381Obtains pixel map information of this image. This API uses a promise to return the information. 382 383**System capability**: SystemCapability.Multimedia.Image.Core 384 385**Return value** 386 387| Type | Description | 388| --------------------------------- | ----------------------------------------------------------- | 389| Promise\<[ImageInfo](#imageinfo)> | Promise used to return the pixel map information. If the operation fails, an error message is returned.| 390 391**Example** 392 393```js 394const color = new ArrayBuffer(96); // 96 is the size of the pixel map buffer to create. The value is calculated as follows: height x width x 4. 395let opts = { editable: true, pixelFormat: 2, size: { height: 6, width: 8 } } 396image.createPixelMap(color, opts).then(pixelmap => { 397 if (pixelmap == undefined) { 398 console.error("Failed to obtain the image pixel map information."); 399 } 400 pixelmap.getImageInfo().then(imageInfo => { 401 if (imageInfo == undefined) { 402 console.error("Failed to obtain the image pixel map information."); 403 } 404 if (imageInfo.size.height == 4 && imageInfo.size.width == 6) { 405 console.log("Succeeded in obtaining the image pixel map information."); 406 } 407 }) 408}) 409``` 410 411### getImageInfo<sup>7+</sup> 412 413getImageInfo(callback: AsyncCallback\<ImageInfo>): void 414 415Obtains pixel map information of this image. This API uses an asynchronous callback to return the information. 416 417**System capability**: SystemCapability.Multimedia.Image.Core 418 419**Parameters** 420 421| Name | Type | Mandatory| Description | 422| -------- | --------------------------------------- | ---- | ------------------------------------------------------------ | 423| callback | AsyncCallback\<[ImageInfo](#imageinfo)> | Yes | Callback used to return the pixel map information. If the operation fails, an error message is returned.| 424 425**Example** 426 427```js 428const color = new ArrayBuffer(96); // 96 is the size of the pixel map buffer to create. The value is calculated as follows: height x width x 4. 429let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } 430image.createPixelMap(color, opts, (err, pixelmap) => { 431 if (pixelmap == undefined) { 432 console.error("Failed to obtain the image pixel map information."); 433 } 434 pixelmap.getImageInfo((err, imageInfo) => { 435 if (imageInfo == undefined) { 436 console.error("Failed to obtain the image pixel map information."); 437 } 438 if (imageInfo.size.height == 4 && imageInfo.size.width == 6) { 439 console.log("Succeeded in obtaining the image pixel map information."); 440 } 441 }) 442}) 443``` 444 445### getBytesNumberPerRow<sup>7+</sup> 446 447getBytesNumberPerRow(): number 448 449Obtains the number of bytes per row of this image pixel map. 450 451**System capability**: SystemCapability.Multimedia.Image.Core 452 453**Return value** 454 455| Type | Description | 456| ------ | -------------------- | 457| number | Number of bytes per row.| 458 459**Example** 460 461```js 462const color = new ArrayBuffer(96); // 96 is the size of the pixel map buffer to create. The value is calculated as follows: height x width x 4. 463let bufferArr = new Uint8Array(color); 464let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } 465image.createPixelMap(color, opts, (err,pixelmap) => { 466 let rowCount = pixelmap.getBytesNumberPerRow(); 467}) 468``` 469 470### getPixelBytesNumber<sup>7+</sup> 471 472getPixelBytesNumber(): number 473 474Obtains the total number of bytes of this image pixel map. 475 476**System capability**: SystemCapability.Multimedia.Image.Core 477 478**Return value** 479 480| Type | Description | 481| ------ | -------------------- | 482| number | Total number of bytes.| 483 484**Example** 485 486```js 487let pixelBytesNumber = pixelmap.getPixelBytesNumber(); 488``` 489 490### getDensity<sup>9+</sup> 491 492getDensity():number 493 494Obtains the density of this image pixel map. 495 496**System capability**: SystemCapability.Multimedia.Image.Core 497 498**Return value** 499 500| Type | Description | 501| ------ | --------------- | 502| number | Density of the image pixel map.| 503 504**Example** 505 506```js 507let getDensity = pixelmap.getDensity(); 508``` 509 510### opacity<sup>9+</sup> 511 512opacity(rate: number, callback: AsyncCallback\<void>): void 513 514Sets an opacity rate for this image pixel map. This API uses an asynchronous callback to return the result. 515 516**System capability**: SystemCapability.Multimedia.Image.Core 517 518**Parameters** 519 520| Name | Type | Mandatory| Description | 521| -------- | -------------------- | ---- | ------------------------------ | 522| rate | number | Yes | Opacity rate to set. The value ranges from 0 to 1. | 523| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned.| 524 525**Example** 526 527```js 528var rate = 0.5; 529pixelmap.opacity(rate, (err) => { 530 if (err) { 531 console.error("Failed to set opacity."); 532 return; 533 } else { 534 console.log("Succeeded in setting opacity."); 535 } 536}) 537``` 538 539### opacity<sup>9+</sup> 540 541opacity(rate: number): Promise\<void> 542 543Sets an opacity rate for this image pixel map. This API uses a promise to return the result. 544 545**System capability**: SystemCapability.Multimedia.Image.Core 546 547**Parameters** 548 549| Name| Type | Mandatory| Description | 550| ------ | ------ | ---- | --------------------------- | 551| rate | number | Yes | Opacity rate to set. The value ranges from 0 to 1.| 552 553**Return value** 554 555| Type | Description | 556| -------------- | ----------------------------------------------- | 557| Promise\<void> | Promise used to return the result. If the operation fails, an error message is returned.| 558 559**Example** 560 561```js 562async function Demo() { 563 await pixelmap.opacity(0.5); 564} 565``` 566 567### createAlphaPixelmap<sup>9+</sup> 568 569createAlphaPixelmap(): Promise\<PixelMap> 570 571Creates 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. 572 573**System capability**: SystemCapability.Multimedia.Image.Core 574 575**Return value** 576 577| Type | Description | 578| -------------------------------- | --------------------------- | 579| Promise\<[PixelMap](#pixelmap7)> | Promise used to return the **PixelMap** object.| 580 581**Example** 582 583```js 584async function Demo() { 585 await pixelmap.createAlphaPixelmap(); 586} 587``` 588 589### createAlphaPixelmap<sup>9+</sup> 590 591createAlphaPixelmap(callback: AsyncCallback\<PixelMap>): void 592 593Creates 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. 594 595**System capability**: SystemCapability.Multimedia.Image.Core 596 597**Parameters** 598 599| Name | Type | Mandatory| Description | 600| -------- | ------------------------ | ---- | ------------------------ | 601| callback | AsyncCallback\<PixelMap> | Yes | Callback used to return the **PixelMap** object.| 602 603**Example** 604 605```js 606pixelmap.createAlphaPixelmap((err, alphaPixelMap) => { 607 if (alphaPixelMap == undefined) { 608 console.info('Failed to obtain new pixel map.'); 609 } else { 610 console.info('Succeed in obtaining new pixel map.'); 611 } 612}) 613``` 614 615### scale<sup>9+</sup> 616 617scale(x: number, y: number, callback: AsyncCallback\<void>): void 618 619Scales this image based on the input width and height. This API uses an asynchronous callback to return the result. 620 621**System capability**: SystemCapability.Multimedia.Image.Core 622 623**Parameters** 624 625| Name | Type | Mandatory| Description | 626| -------- | -------------------- | ---- | ------------------------------- | 627| x | number | Yes | Scaling ratio of the width.| 628| y | number | Yes | Scaling ratio of the height.| 629| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned. | 630 631**Example** 632 633```js 634async function Demo() { 635 await pixelmap.scale(2.0, 1.0); 636} 637``` 638 639### scale<sup>9+</sup> 640 641scale(x: number, y: number): Promise\<void> 642 643Scales this image based on the input width and height. This API uses a promise to return the result. 644 645**System capability**: SystemCapability.Multimedia.Image.Core 646 647**Parameters** 648 649| Name| Type | Mandatory| Description | 650| ------ | ------ | ---- | ------------------------------- | 651| x | number | Yes | Scaling ratio of the width.| 652| y | number | Yes | Scaling ratio of the height.| 653 654**Return value** 655 656| Type | Description | 657| -------------- | --------------------------- | 658| Promise\<void> | Promise used to return the result.| 659 660**Example** 661 662```js 663async function Demo() { 664 await pixelmap.scale(2.0, 1.0); 665} 666``` 667 668### translate<sup>9+</sup> 669 670translate(x: number, y: number, callback: AsyncCallback\<void>): void 671 672Translates this image based on the input coordinates. This API uses an asynchronous callback to return the result. 673 674**System capability**: SystemCapability.Multimedia.Image.Core 675 676**Parameters** 677 678| Name | Type | Mandatory| Description | 679| -------- | -------------------- | ---- | ----------------------------- | 680| x | number | Yes | X coordinate to translate. | 681| y | number | Yes | Y coordinate to translate. | 682| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned.| 683 684**Example** 685 686```js 687async function Demo() { 688 await pixelmap.translate(3.0, 1.0); 689} 690``` 691 692### translate<sup>9+</sup> 693 694translate(x: number, y: number): Promise\<void> 695 696Translates this image based on the input coordinates. This API uses a promise to return the result. 697 698**System capability**: SystemCapability.Multimedia.Image.Core 699 700**Parameters** 701 702| Name| Type | Mandatory| Description | 703| ------ | ------ | ---- | ----------- | 704| x | number | Yes | X coordinate to translate.| 705| y | number | Yes | Y coordinate to translate.| 706 707**Return value** 708 709| Type | Description | 710| -------------- | --------------------------- | 711| Promise\<void> | Promise used to return the result.| 712 713**Example** 714 715```js 716async function Demo() { 717 await pixelmap.translate(3.0, 1.0); 718} 719``` 720 721### rotate<sup>9+</sup> 722 723rotate(angle: number, callback: AsyncCallback\<void>): void 724 725Rotates this image based on the input angle. This API uses an asynchronous callback to return the result. 726 727**System capability**: SystemCapability.Multimedia.Image.Core 728 729**Parameters** 730 731| Name | Type | Mandatory| Description | 732| -------- | -------------------- | ---- | ----------------------------- | 733| angle | number | Yes | Angle to rotate. | 734| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned.| 735 736**Example** 737 738```js 739var angle = 90.0; 740pixelmap.rotate(angle, (err) => { 741 if (err) { 742 console.error("Failed to set rotation."); 743 return; 744 } else { 745 console.log("Succeeded in setting rotation."); 746 } 747}) 748``` 749 750### rotate<sup>9+</sup> 751 752rotate(angle: number): Promise\<void> 753 754Rotates this image based on the input angle. This API uses a promise to return the result. 755 756**System capability**: SystemCapability.Multimedia.Image.Core 757 758**Parameters** 759 760| Name| Type | Mandatory| Description | 761| ------ | ------ | ---- | ----------------------------- | 762| angle | number | Yes | Angle to rotate. | 763 764**Return value** 765 766| Type | Description | 767| -------------- | --------------------------- | 768| Promise\<void> | Promise used to return the result.| 769 770**Example** 771 772```js 773async function Demo() { 774 await pixelmap.rotate(90.0); 775} 776``` 777 778### flip<sup>9+</sup> 779 780flip(horizontal: boolean, vertical: boolean, callback: AsyncCallback\<void>): void 781 782Flips this image horizontally or vertically, or both. This API uses an asynchronous callback to return the result. 783 784**System capability**: SystemCapability.Multimedia.Image.Core 785 786**Parameters** 787 788| Name | Type | Mandatory| Description | 789| ---------- | -------------------- | ---- | ----------------------------- | 790| horizontal | boolean | Yes | Whether to flip the image horizontally. | 791| vertical | boolean | Yes | Whether to flip the image vertically. | 792| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned.| 793 794**Example** 795 796```js 797async function Demo() { 798 await pixelmap.flip(false, true); 799} 800``` 801 802### flip<sup>9+</sup> 803 804flip(horizontal: boolean, vertical: boolean): Promise\<void> 805 806Flips this image horizontally or vertically, or both. This API uses a promise to return the result. 807 808**System capability**: SystemCapability.Multimedia.Image.Core 809 810**Parameters** 811 812| Name | Type | Mandatory| Description | 813| ---------- | ------- | ---- | --------- | 814| horizontal | boolean | Yes | Whether to flip the image horizontally.| 815| vertical | boolean | Yes | Whether to flip the image vertically.| 816 817**Return value** 818 819| Type | Description | 820| -------------- | --------------------------- | 821| Promise\<void> | Promise used to return the result.| 822 823**Example** 824 825```js 826async function Demo() { 827 await pixelmap.flip(false, true); 828} 829``` 830 831### crop<sup>9+</sup> 832 833crop(region: Region, callback: AsyncCallback\<void>): void 834 835Crops this image based on the input size. This API uses an asynchronous callback to return the result. 836 837**System capability**: SystemCapability.Multimedia.Image.Core 838 839**Parameters** 840 841| Name | Type | Mandatory| Description | 842| -------- | -------------------- | ---- | ----------------------------- | 843| region | [Region](#region7) | Yes | Size of the image after cropping. | 844| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned.| 845 846**Example** 847 848```js 849async function Demo() { 850 await pixelmap.crop({ x: 0, y: 0, size: { height: 100, width: 100 } }); 851} 852``` 853 854### crop<sup>9+</sup> 855 856crop(region: Region): Promise\<void> 857 858Crops this image based on the input size. This API uses a promise to return the result. 859 860**System capability**: SystemCapability.Multimedia.Image.Core 861 862**Parameters** 863 864| Name| Type | Mandatory| Description | 865| ------ | ------------------ | ---- | ----------- | 866| region | [Region](#region7) | Yes | Size of the image after cropping.| 867 868**Return value** 869 870| Type | Description | 871| -------------- | --------------------------- | 872| Promise\<void> | Promise used to return the result.| 873 874**Example** 875 876```js 877async function Demo() { 878 await pixelmap.crop({ x: 0, y: 0, size: { height: 100, width: 100 } }); 879} 880``` 881 882### getColorSpace<sup>10+</sup> 883 884getColorSpace(): colorSpaceManager.ColorSpaceManager 885 886Obtains the color space of this image 887 888**System capability**: SystemCapability.Multimedia.Image.Core 889 890**Return value** 891 892| Type | Description | 893| ----------------------------------- | ---------------- | 894| [colorSpaceManager.ColorSpaceManager](js-apis-colorSpaceManager.md#colorspacemanager) | Color space obtained.| 895 896**Example** 897 898```js 899import colorSpaceManager from '@ohos.graphics.colorSpaceManager'; 900async function Demo() { 901 let csm = pixelmap.getColorSpace(); 902} 903``` 904 905### setColorSpace<sup>10+</sup> 906 907setColorSpace(colorSpace: colorSpaceManager.ColorSpaceManager): void 908 909Sets the color space for this image. 910 911**System capability**: SystemCapability.Multimedia.Image.Core 912 913**Parameters** 914 915| Name | Type | Mandatory| Description | 916| ---------- | ----------------------------------- | ---- | --------------- | 917| colorSpace | [colorSpaceManager.ColorSpaceManager](js-apis-colorSpaceManager.md#colorspacemanager) | Yes | Color space to set.| 918 919**Example** 920 921```js 922import colorSpaceManager from '@ohos.graphics.colorSpaceManager'; 923async function Demo() { 924 var csm = colorSpaceManager.create(colorSpaceName); 925 pixelmap.setColorSpace(csm); 926} 927``` 928 929### release<sup>7+</sup> 930 931release():Promise\<void> 932 933Releases this **PixelMap** object. This API uses a promise to return the result. 934 935**System capability**: SystemCapability.Multimedia.Image.Core 936 937**Return value** 938 939| Type | Description | 940| -------------- | ------------------------------- | 941| Promise\<void> | Promise used to return the result.| 942 943**Example** 944 945```js 946pixelmap.release().then(() => { 947 console.log('Succeeded in releasing pixelmap object.'); 948}).catch(error => { 949 console.log('Failed to release pixelmap object.'); 950}) 951``` 952 953### release<sup>7+</sup> 954 955release(callback: AsyncCallback\<void>): void 956 957Releases this **PixelMap** object. This API uses an asynchronous callback to return the result. 958 959**System capability**: SystemCapability.Multimedia.Image.Core 960 961**Parameters** 962 963| Name | Type | Mandatory| Description | 964| -------- | -------------------- | ---- | ------------------ | 965| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| 966 967**Example** 968 969```js 970pixelmap.release(() => { 971 console.log('Succeeded in releasing pixelmap object.'); 972}) 973``` 974 975## image.createImageSource 976 977createImageSource(uri: string): ImageSource 978 979Creates an **ImageSource** instance based on the URI. 980 981**System capability**: SystemCapability.Multimedia.Image.ImageSource 982 983**Parameters** 984 985| Name| Type | Mandatory| Description | 986| ------ | ------ | ---- | ---------------------------------- | 987| uri | string | Yes | Image path. Currently, only the application sandbox path is supported.<br>Currently, the following formats are supported: .jpg, .png, .gif, .bmp, .webp, and raw. For details, see [SVG Tags<sup>10+</sup>](#svg-tags). | 988 989**Return value** 990 991| Type | Description | 992| --------------------------- | -------------------------------------------- | 993| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns **undefined** otherwise.| 994 995**Example** 996 997```js 998// Stage model 999const context = getContext(this); 1000const path = context.cacheDir() + "/test.jpg"; 1001const imageSourceApi = image.createImageSource(path); 1002``` 1003 1004```js 1005// FA model 1006import featureAbility from '@ohos.ability.featureAbility'; 1007 1008const context = featureAbility.getContext(); 1009const path = context.getCacheDir() + "/test.jpg"; 1010const imageSourceApi = image.createImageSource(path); 1011``` 1012 1013## image.createImageSource<sup>9+</sup> 1014 1015createImageSource(uri: string, options: SourceOptions): ImageSource 1016 1017Creates an **ImageSource** instance based on the URI. 1018 1019**System capability**: SystemCapability.Multimedia.Image.ImageSource 1020 1021**Parameters** 1022 1023| Name | Type | Mandatory| Description | 1024| ------- | ------------------------------- | ---- | ----------------------------------- | 1025| uri | string | Yes | Image path. Currently, only the application sandbox path is supported.<br>Currently, the following formats are supported: .jpg, .png, .gif, .bmp, .webp, and raw. For details, see [SVG Tags<sup>10+</sup>](#svg-tags). | 1026| options | [SourceOptions](#sourceoptions9) | Yes | Image properties, including the image index and default property value.| 1027 1028**Return value** 1029 1030| Type | Description | 1031| --------------------------- | -------------------------------------------- | 1032| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns **undefined** otherwise.| 1033 1034**Example** 1035 1036```js 1037var sourceOptions = { sourceDensity: 120 }; 1038let imageSource = image.createImageSource('test.png', sourceOptions); 1039``` 1040 1041## image.createImageSource<sup>7+</sup> 1042 1043createImageSource(fd: number): ImageSource 1044 1045Creates an **ImageSource** instance based on the file descriptor. 1046 1047**System capability**: SystemCapability.Multimedia.Image.ImageSource 1048 1049**Parameters** 1050 1051| Name| Type | Mandatory| Description | 1052| ------ | ------ | ---- | ------------- | 1053| fd | number | Yes | File descriptor.| 1054 1055**Return value** 1056 1057| Type | Description | 1058| --------------------------- | -------------------------------------------- | 1059| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns **undefined** otherwise.| 1060 1061**Example** 1062 1063```js 1064const imageSourceApi = image.createImageSource(0); 1065``` 1066 1067## image.createImageSource<sup>9+</sup> 1068 1069createImageSource(fd: number, options: SourceOptions): ImageSource 1070 1071Creates an **ImageSource** instance based on the file descriptor. 1072 1073**System capability**: SystemCapability.Multimedia.Image.ImageSource 1074 1075**Parameters** 1076 1077| Name | Type | Mandatory| Description | 1078| ------- | ------------------------------- | ---- | ----------------------------------- | 1079| fd | number | Yes | File descriptor. | 1080| options | [SourceOptions](#sourceoptions9) | Yes | Image properties, including the image index and default property value.| 1081 1082**Return value** 1083 1084| Type | Description | 1085| --------------------------- | -------------------------------------------- | 1086| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns **undefined** otherwise.| 1087 1088**Example** 1089 1090```js 1091var sourceOptions = { sourceDensity: 120 }; 1092const imageSourceApi = image.createImageSource(0, sourceOptions); 1093``` 1094 1095## image.createImageSource<sup>9+</sup> 1096 1097createImageSource(buf: ArrayBuffer): ImageSource 1098 1099Creates an **ImageSource** instance based on the buffers. 1100 1101**System capability**: SystemCapability.Multimedia.Image.ImageSource 1102 1103**Parameters** 1104 1105| Name| Type | Mandatory| Description | 1106| ------ | ----------- | ---- | ---------------- | 1107| buf | ArrayBuffer | Yes | Array of image buffers.| 1108 1109**Example** 1110 1111```js 1112const buf = new ArrayBuffer(96); // 96 is the size of the pixel map buffer to create. The value is calculated as follows: height x width x 4. 1113const imageSourceApi = image.createImageSource(buf); 1114``` 1115 1116## image.createImageSource<sup>9+</sup> 1117 1118createImageSource(buf: ArrayBuffer, options: SourceOptions): ImageSource 1119 1120Creates an **ImageSource** instance based on the buffers. 1121 1122**System capability**: SystemCapability.Multimedia.Image.ImageSource 1123 1124**Parameters** 1125 1126| Name| Type | Mandatory| Description | 1127| ------ | -------------------------------- | ---- | ------------------------------------ | 1128| buf | ArrayBuffer | Yes | Array of image buffers. | 1129| options | [SourceOptions](#sourceoptions9) | Yes | Image properties, including the image index and default property value.| 1130 1131**Return value** 1132 1133| Type | Description | 1134| --------------------------- | -------------------------------------------- | 1135| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns **undefined** otherwise.| 1136 1137**Example** 1138 1139```js 1140const data = new ArrayBuffer(112); 1141const imageSourceApi = image.createImageSource(data); 1142``` 1143 1144## image.CreateIncrementalSource<sup>9+</sup> 1145 1146CreateIncrementalSource(buf: ArrayBuffer): ImageSource 1147 1148Creates an **ImageSource** instance in incremental mode based on the buffers. 1149 1150**System capability**: SystemCapability.Multimedia.Image.ImageSource 1151 1152**Parameters** 1153 1154| Name | Type | Mandatory| Description | 1155| ------- | ------------| ---- | ----------| 1156| buf | ArrayBuffer | Yes | Incremental data.| 1157 1158**Return value** 1159 1160| Type | Description | 1161| --------------------------- | --------------------------------- | 1162| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns undefined otherwise.| 1163 1164**Example** 1165 1166```js 1167const buf = new ArrayBuffer(96); // 96 is the size of the pixel map buffer to create. The value is calculated as follows: height x width x 4. 1168const imageSourceIncrementalSApi = image.CreateIncrementalSource(buf); 1169``` 1170 1171## image.CreateIncrementalSource<sup>9+</sup> 1172 1173CreateIncrementalSource(buf: ArrayBuffer, options?: SourceOptions): ImageSource 1174 1175Creates an **ImageSource** instance in incremental mode based on the buffers. 1176 1177**System capability**: SystemCapability.Multimedia.Image.ImageSource 1178 1179**Parameters** 1180 1181| Name | Type | Mandatory| Description | 1182| ------- | ------------------------------- | ---- | ------------------------------------ | 1183| buf | ArrayBuffer | Yes | Incremental data. | 1184| options | [SourceOptions](#sourceoptions9) | No | Image properties, including the image index and default property value.| 1185 1186**Return value** 1187 1188| Type | Description | 1189| --------------------------- | --------------------------------- | 1190| [ImageSource](#imagesource) | Returns the **ImageSource** instance if the operation is successful; returns undefined otherwise.| 1191 1192**Example** 1193 1194```js 1195const buf = new ArrayBuffer(96); // 96 is the size of the pixel map buffer to create. The value is calculated as follows: height x width x 4. 1196const imageSourceIncrementalSApi = image.CreateIncrementalSource(buf); 1197``` 1198 1199## ImageSource 1200 1201Provides APIs to obtain image information. Before calling any API in **ImageSource**, you must use **createImageSource** to create an **ImageSource** instance. 1202 1203### Attributes 1204 1205**System capability**: SystemCapability.Multimedia.Image.ImageSource 1206 1207| Name | Type | Readable| Writable| Description | 1208| ---------------- | -------------- | ---- | ---- | ------------------------------------------------------------ | 1209| supportedFormats | Array\<string> | Yes | No | Supported image formats, including PNG, JPEG, BMP, GIF, WebP, and RAW.| 1210 1211### getImageInfo 1212 1213getImageInfo(index: number, callback: AsyncCallback\<ImageInfo>): void 1214 1215Obtains information about an image with the specified index. This API uses an asynchronous callback to return the information. 1216 1217**System capability**: SystemCapability.Multimedia.Image.ImageSource 1218 1219**Parameters** 1220 1221| Name | Type | Mandatory| Description | 1222| -------- | -------------------------------------- | ---- | ---------------------------------------- | 1223| index | number | Yes | Index of the image. | 1224| callback | AsyncCallback<[ImageInfo](#imageinfo)> | Yes | Callback used to return the image information.| 1225 1226**Example** 1227 1228```js 1229imageSourceApi.getImageInfo(0,(error, imageInfo) => { 1230 if(error) { 1231 console.log('getImageInfo failed.'); 1232 } else { 1233 console.log('getImageInfo succeeded.'); 1234 } 1235}) 1236``` 1237 1238### getImageInfo 1239 1240getImageInfo(callback: AsyncCallback\<ImageInfo>): void 1241 1242Obtains information about this image. This API uses an asynchronous callback to return the information. 1243 1244**System capability**: SystemCapability.Multimedia.Image.ImageSource 1245 1246**Parameters** 1247 1248| Name | Type | Mandatory| Description | 1249| -------- | -------------------------------------- | ---- | ---------------------------------------- | 1250| callback | AsyncCallback<[ImageInfo](#imageinfo)> | Yes | Callback used to return the image information.| 1251 1252**Example** 1253 1254```js 1255imageSourceApi.getImageInfo(imageInfo => { 1256 console.log('Succeeded in obtaining the image information.'); 1257}) 1258``` 1259 1260### getImageInfo 1261 1262getImageInfo(index?: number): Promise\<ImageInfo> 1263 1264Obtains information about an image with the specified index. This API uses a promise to return the image information. 1265 1266**System capability**: SystemCapability.Multimedia.Image.ImageSource 1267 1268**Parameters** 1269 1270| Name| Type | Mandatory| Description | 1271| ----- | ------ | ---- | ------------------------------------- | 1272| index | number | No | Index of the image. If this parameter is not set, the default value **0** is used.| 1273 1274**Return value** 1275 1276| Type | Description | 1277| -------------------------------- | ---------------------- | 1278| Promise<[ImageInfo](#imageinfo)> | Promise used to return the image information.| 1279 1280**Example** 1281 1282```js 1283imageSourceApi.getImageInfo(0) 1284 .then(imageInfo => { 1285 console.log('Succeeded in obtaining the image information.'); 1286 }).catch(error => { 1287 console.log('Failed to obtain the image information.'); 1288 }) 1289``` 1290 1291### getImageProperty<sup>7+</sup> 1292 1293getImageProperty(key:string, options?: GetImagePropertyOptions): Promise\<string> 1294 1295Obtains the value of a property with the specified index in this image. This API uses a promise to return the result. 1296 1297**System capability**: SystemCapability.Multimedia.Image.ImageSource 1298 1299 **Parameters** 1300 1301| Name | Type | Mandatory| Description | 1302| ------- | ---------------------------------------------------- | ---- | ------------------------------------ | 1303| key | string | Yes | Name of the property. | 1304| options | [GetImagePropertyOptions](#getimagepropertyoptions7) | No | Image properties, including the image index and default property value.| 1305 1306**Return value** 1307 1308| Type | Description | 1309| ---------------- | ----------------------------------------------------------------- | 1310| Promise\<string> | Promise used to return the property value. If the operation fails, the default value is returned.| 1311 1312**Example** 1313 1314```js 1315imageSourceApi.getImageProperty("BitsPerSample") 1316 .then(data => { 1317 console.log('Succeeded in getting the value of the specified attribute key of the image.'); 1318 }) 1319``` 1320 1321### getImageProperty<sup>7+</sup> 1322 1323getImageProperty(key:string, callback: AsyncCallback\<string>): void 1324 1325Obtains the value of a property with the specified index in this image. This API uses an asynchronous callback to return the result. 1326 1327**System capability**: SystemCapability.Multimedia.Image.ImageSource 1328 1329 **Parameters** 1330 1331| Name | Type | Mandatory| Description | 1332| -------- | ---------------------- | ---- | ------------------------------------------------------------ | 1333| key | string | Yes | Name of the property. | 1334| callback | AsyncCallback\<string> | Yes | Callback used to return the property value. If the operation fails, the default value is returned.| 1335 1336**Example** 1337 1338```js 1339imageSourceApi.getImageProperty("BitsPerSample",(error,data) => { 1340 if(error) { 1341 console.log('Failed to get the value of the specified attribute key of the image.'); 1342 } else { 1343 console.log('Succeeded in getting the value of the specified attribute key of the image.'); 1344 } 1345}) 1346``` 1347 1348### getImageProperty<sup>7+</sup> 1349 1350getImageProperty(key:string, options: GetImagePropertyOptions, callback: AsyncCallback\<string>): void 1351 1352Obtains the value of a property in this image. This API uses an asynchronous callback to return the property value in a string. 1353 1354**System capability**: SystemCapability.Multimedia.Image.ImageSource 1355 1356**Parameters** 1357 1358| Name | Type | Mandatory| Description | 1359| -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------- | 1360| key | string | Yes | Name of the property. | 1361| options | [GetImagePropertyOptions](#getimagepropertyoptions7) | Yes | Image properties, including the image index and default property value. | 1362| callback | AsyncCallback\<string> | Yes | Callback used to return the property value. If the operation fails, the default value is returned.| 1363 1364**Example** 1365 1366```js 1367let property = { index: 0, defaultValue: '9999' } 1368imageSourceApi.getImageProperty("BitsPerSample",property,(error,data) => { 1369 if(error) { 1370 console.log('Failed to get the value of the specified attribute key of the image.'); 1371 } else { 1372 console.log('Succeeded in getting the value of the specified attribute key of the image.'); 1373 } 1374}) 1375``` 1376 1377### modifyImageProperty<sup>9+</sup> 1378 1379modifyImageProperty(key: string, value: string): Promise\<void> 1380 1381Modifies the value of a property in this image. This API uses a promise to return the result. 1382 1383**System capability**: SystemCapability.Multimedia.Image.ImageSource 1384 1385**Parameters** 1386 1387| Name | Type | Mandatory| Description | 1388| ------- | ------ | ---- | ------------ | 1389| key | string | Yes | Name of the property.| 1390| value | string | Yes | New value of the property. | 1391 1392**Return value** 1393 1394| Type | Description | 1395| -------------- | --------------------------- | 1396| Promise\<void> | Promise used to return the result.| 1397 1398**Example** 1399 1400```js 1401imageSourceApi.modifyImageProperty("ImageWidth", "120").then(() => { 1402 const w = imageSourceApi.getImageProperty("ImageWidth") 1403 console.info('w', w); 1404}) 1405``` 1406 1407### modifyImageProperty<sup>9+</sup> 1408 1409modifyImageProperty(key: string, value: string, callback: AsyncCallback\<void>): void 1410 1411Modifies the value of a property in this image. This API uses an asynchronous callback to return the result. 1412 1413**System capability**: SystemCapability.Multimedia.Image.ImageSource 1414 1415**Parameters** 1416 1417| Name | Type | Mandatory| Description | 1418| -------- | ------------------- | ---- | ------------------------------ | 1419| key | string | Yes | Name of the property. | 1420| value | string | Yes | New value of the property. | 1421| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| 1422 1423**Example** 1424 1425```js 1426imageSourceApi.modifyImageProperty("ImageWidth", "120",() => {}) 1427``` 1428 1429### updateData<sup>9+</sup> 1430 1431updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number): Promise\<void> 1432 1433Updates incremental data. This API uses a promise to return the result. 1434 1435**System capability**: SystemCapability.Multimedia.Image.ImageSource 1436 1437**Parameters** 1438 1439| Name | Type | Mandatory| Description | 1440| ---------- | ----------- | ---- | ------------ | 1441| buf | ArrayBuffer | Yes | Incremental data. | 1442| isFinished | boolean | Yes | Whether the update is complete.| 1443| value | number | Yes | Offset for data reading. | 1444| length | number | Yes | Array length. | 1445 1446**Return value** 1447 1448| Type | Description | 1449| -------------- | -------------------------- | 1450| Promise\<void> | Promise used to return the result.| 1451 1452**Example** 1453 1454```js 1455const array = new ArrayBuffer(100); 1456imageSourceApi.updateData(array, false, 0, 10).then(data => { 1457 console.info('Succeeded in updating data.'); 1458}) 1459``` 1460 1461 1462### updateData<sup>9+</sup> 1463 1464updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number, callback: AsyncCallback\<void>): void 1465 1466Updates incremental data. This API uses an asynchronous callback to return the result. 1467 1468**System capability**: SystemCapability.Multimedia.Image.ImageSource 1469 1470**Parameters** 1471 1472| Name | Type | Mandatory| Description | 1473| ---------- | ------------------- | ---- | -------------------- | 1474| buf | ArrayBuffer | Yes | Incremental data. | 1475| isFinished | boolean | Yes | Whether the update is complete. | 1476| value | number | Yes | Offset for data reading. | 1477| length | number | Yes | Array length. | 1478| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| 1479 1480**Example** 1481 1482```js 1483const array = new ArrayBuffer(100); 1484imageSourceApi.updateData(array, false, 0, 10,(error,data )=> { 1485 if(data !== undefined){ 1486 console.info('Succeeded in updating data.'); 1487 } 1488}) 1489``` 1490 1491### createPixelMap<sup>7+</sup> 1492 1493createPixelMap(options?: DecodingOptions): Promise\<PixelMap> 1494 1495Creates a **PixelMap** object based on image decoding parameters. This API uses a promise to return the result. 1496 1497**System capability**: SystemCapability.Multimedia.Image.ImageSource 1498 1499**Parameters** 1500 1501| Name | Type | Mandatory| Description | 1502| ------- | ------------------------------------ | ---- | ---------- | 1503| options | [DecodingOptions](#decodingoptions7) | No | Image decoding parameters.| 1504 1505**Return value** 1506 1507| Type | Description | 1508| -------------------------------- | --------------------- | 1509| Promise\<[PixelMap](#pixelmap7)> | Promise used to return the **PixelMap** object.| 1510 1511**Example** 1512 1513```js 1514imageSourceApi.createPixelMap().then(pixelmap => { 1515 console.log('Succeeded in creating pixelmap object through image decoding parameters.'); 1516}).catch(error => { 1517 console.log('Failed to create pixelmap object through image decoding parameters.'); 1518}) 1519``` 1520 1521### createPixelMap<sup>7+</sup> 1522 1523createPixelMap(callback: AsyncCallback\<PixelMap>): void 1524 1525Creates a **PixelMap** object based on the default parameters. This API uses an asynchronous callback to return the result. 1526 1527**System capability**: SystemCapability.Multimedia.Image.ImageSource 1528 1529**Parameters** 1530 1531| Name | Type | Mandatory| Description | 1532| -------- | ------------------------------------- | ---- | -------------------------- | 1533| callback | AsyncCallback<[PixelMap](#pixelmap7)> | Yes | Callback used to return the **PixelMap** object.| 1534 1535**Example** 1536 1537```js 1538imageSourceApi.createPixelMap((err, pixelmap) => { 1539 console.info('Succeeded in creating pixelmap object.'); 1540}) 1541``` 1542 1543### createPixelMap<sup>7+</sup> 1544 1545createPixelMap(options: DecodingOptions, callback: AsyncCallback\<PixelMap>): void 1546 1547Creates a **PixelMap** object based on image decoding parameters. This API uses an asynchronous callback to return the result. 1548 1549**System capability**: SystemCapability.Multimedia.Image.ImageSource 1550 1551**Parameters** 1552 1553| Name | Type | Mandatory| Description | 1554| -------- | ------------------------------------- | ---- | -------------------------- | 1555| options | [DecodingOptions](#decodingoptions7) | Yes | Image decoding parameters. | 1556| callback | AsyncCallback<[PixelMap](#pixelmap7)> | Yes | Callback used to return the **PixelMap** object.| 1557 1558**Example** 1559 1560```js 1561let decodingOptions = { 1562 sampleSize: 1, 1563 editable: true, 1564 desiredSize: { width: 1, height: 2 }, 1565 rotate: 10, 1566 desiredPixelFormat: 3, 1567 desiredRegion: { size: { height: 1, width: 2 }, x: 0, y: 0 }, 1568 index: 0 1569}; 1570imageSourceApi.createPixelMap(decodingOptions, pixelmap => { 1571 console.log('Succeeded in creating pixelmap object.'); 1572}) 1573``` 1574 1575### createPixelMapList<sup>10+</sup> 1576 1577createPixelMapList(options?: DecodingOptions): Promise<Array\<PixelMap>>; 1578 1579Creates an array of **PixelMap** objects based on image decoding parameters. This API uses a promise to return the result. 1580 1581**System capability**: SystemCapability.Multimedia.Image.ImageSource 1582 1583**Parameters** 1584 1585| Name | Type | Mandatory| Description | 1586| -------- | ------------------------------------- | ---- | -------------------------- | 1587| options | [DecodingOptions](#decodingoptions7) | No | Image decoding parameters. | 1588 1589**Return value** 1590 1591| Type | Description | 1592| -------------------------------- | --------------------- | 1593| Promise<Array<[PixelMap](#pixelmap7)>> | Promise used to return an array of **PixeMap** objects.| 1594 1595**Example** 1596 1597```js 1598let decodeOpts = { 1599 sampleSize: 1, 1600 editable: true, 1601 desiredSize: { width: 198, height: 202 }, 1602 rotate: 0, 1603 desiredPixelFormat: 3, 1604 index: 0, 1605}; 1606let pixelmaplist = imageSourceApi.createPixelMapList(decodeOpts); 1607``` 1608 1609### createPixelMapList<sup>10+</sup> 1610 1611createPixelMapList(callback: AsyncCallback<Array\<PixelMap>>): void 1612 1613Creates an array of **PixelMap** objects based on the default parameters. This API uses an asynchronous callback to return the result. 1614 1615**System capability**: SystemCapability.Multimedia.Image.ImageSource 1616 1617**Parameters** 1618 1619| Name | Type | Mandatory| Description | 1620| -------- | ------------------------------------- | ---- | -------------------------- | 1621| callback | AsyncCallback<Array<[PixelMap](#pixelmap7)>> | Yes | Callback used to return an array of **PixeMap** objects.| 1622 1623**Example** 1624 1625```js 1626imageSourceApi.createPixelMap( pixelmaplist => { 1627 console.info('Succeeded in creating pixelmaplist object.'); 1628}) 1629``` 1630 1631### createPixelMapList<sup>10+</sup> 1632 1633createPixelMapList(options: DecodingOptions, callback: AsyncCallback<Array\<PixelMap>>): void; 1634 1635Creates an array of **PixelMap** objects based on image decoding parameters. This API uses an asynchronous callback to return the result. 1636 1637**System capability**: SystemCapability.Multimedia.Image.ImageSource 1638 1639**Parameters** 1640 1641| Name | Type | Mandatory| Description | 1642| -------- | -------------------- | ---- | ---------------------------------- | 1643| options | [DecodingOptions](#decodingoptions7) | Yes| Image decoding parameters.| 1644| callback | AsyncCallback<Array<[PixelMap](#pixelmap7)>> | Yes | Callback used to return an array of **PixeMap** objects.| 1645 1646**Example** 1647 1648```js 1649let decodeOpts = { 1650 sampleSize: 1, 1651 editable: true, 1652 desiredSize: { width: 198, height: 202 }, 1653 rotate: 0, 1654 desiredPixelFormat: 3, 1655 index: 0, 1656}; 1657imageSourceApi.createPixelMap(decodeOpts, pixelmaplist => { 1658 console.log('Succeeded in creating pixelmaplist object.'); 1659}) 1660``` 1661 1662### getDelayTime<sup>10+</sup> 1663 1664getDelayTime(callback: AsyncCallback<Array\<number>>): void; 1665 1666Obtains an array of delay times. This API uses an asynchronous callback to return the result. 1667 1668**System capability**: SystemCapability.Multimedia.Image.ImageSource 1669 1670**Parameters** 1671 1672| Name | Type | Mandatory| Description | 1673| -------- | -------------------- | ---- | ---------------------------------- | 1674| callback | AsyncCallback<Array\<number>> | Yes | Callback used to return an array of delay times.| 1675 1676**Example** 1677 1678```js 1679imageSourceApi.getDelayTime( delayTimes => { 1680 console.log('Succeeded in getting delay time.'); 1681}); 1682``` 1683 1684### getDelayTime<sup>10+</sup> 1685 1686getDelayTime(): Promise<Array\<number>>; 1687 1688Obtains an array of delay times. This API uses a promise to return the result. 1689 1690**System capability**: SystemCapability.Multimedia.Image.ImageSource 1691 1692**Return value** 1693 1694| Type | Description | 1695| -------------- | --------------------------- | 1696| Promise<Array\<number>> | Promise used to return an array of delay times.| 1697 1698**Example** 1699 1700```js 1701let delayTimes = imageSourceApi.getDelayTime(); 1702``` 1703 1704### getFrameCount<sup>10+</sup> 1705 1706getFrameCount(callback: AsyncCallback\<number>): void; 1707 1708Obtains the number of frames. This API uses an asynchronous callback to return the result. 1709 1710**System capability**: SystemCapability.Multimedia.Image.ImageSource 1711 1712**Parameters** 1713 1714| Name | Type | Mandatory| Description | 1715| -------- | -------------------- | ---- | ---------------------------------- | 1716| callback | AsyncCallback\<number> | Yes | Callback used to return the number of frames.| 1717 1718**Example** 1719 1720```js 1721imageSourceApi.getFrameCount( frameCount => { 1722 console.log('Succeeded in getting frame count.'); 1723}); 1724``` 1725 1726### getFrameCount<sup>10+</sup> 1727 1728getFrameCount(): Promise\<number>; 1729 1730Obtains the number of frames. This API uses a promise to return the result. 1731 1732**System capability**: SystemCapability.Multimedia.Image.ImageSource 1733 1734**Return value** 1735 1736| Type | Description | 1737| -------------- | --------------------------- | 1738| Promise\<number> | Promise used to return the number of frames.| 1739 1740**Example** 1741 1742```js 1743let frameCount = imageSourceApi.getFrameCount(); 1744``` 1745 1746### release 1747 1748release(callback: AsyncCallback\<void>): void 1749 1750Releases this **ImageSource** instance. This API uses an asynchronous callback to return the result. 1751 1752**System capability**: SystemCapability.Multimedia.Image.ImageSource 1753 1754**Parameters** 1755 1756| Name | Type | Mandatory| Description | 1757| -------- | -------------------- | ---- | ---------------------------------- | 1758| callback | AsyncCallback\<void> | Yes | Callback invoked for instance release. If the operation fails, an error message is returned.| 1759 1760**Example** 1761 1762```js 1763imageSourceApi.release(() => { 1764 console.log('release succeeded.'); 1765}) 1766``` 1767 1768### release 1769 1770release(): Promise\<void> 1771 1772Releases this **ImageSource** instance. This API uses a promise to return the result. 1773 1774**System capability**: SystemCapability.Multimedia.Image.ImageSource 1775 1776**Return value** 1777 1778| Type | Description | 1779| -------------- | --------------------------- | 1780| Promise\<void> | Promise used to return the result.| 1781 1782**Example** 1783 1784```js 1785imageSourceApi.release().then(()=>{ 1786 console.log('Succeeded in releasing the image source instance.'); 1787}).catch(error => { 1788 console.log('Failed to release the image source instance.'); 1789}) 1790``` 1791 1792## image.createImagePacker 1793 1794createImagePacker(): ImagePacker 1795 1796Creates an **ImagePacker** instance. 1797 1798**System capability**: SystemCapability.Multimedia.Image.ImagePacker 1799 1800**Return value** 1801 1802| Type | Description | 1803| --------------------------- | --------------------- | 1804| [ImagePacker](#imagepacker) | **ImagePacker** instance created.| 1805 1806**Example** 1807 1808```js 1809const imagePackerApi = image.createImagePacker(); 1810``` 1811 1812## ImagePacker 1813 1814Provides APIs to pack images. Before calling any API in **ImagePacker**, you must use **createImagePacker** to create an **ImagePacker** instance. The image formats JPEG and WebP are supported. 1815 1816### Attributes 1817 1818**System capability**: SystemCapability.Multimedia.Image.ImagePacker 1819 1820| Name | Type | Readable| Writable| Description | 1821| ---------------- | -------------- | ---- | ---- | -------------------------- | 1822| supportedFormats | Array\<string> | Yes | No | Supported image format, which can be jpeg.| 1823 1824### packing 1825 1826packing(source: ImageSource, option: PackingOption, callback: AsyncCallback\<ArrayBuffer>): void 1827 1828Packs an image. This API uses an asynchronous callback to return the result. 1829 1830**System capability**: SystemCapability.Multimedia.Image.ImagePacker 1831 1832**Parameters** 1833 1834| Name | Type | Mandatory| Description | 1835| -------- | ---------------------------------- | ---- | ---------------------------------- | 1836| source | [ImageSource](#imagesource) | Yes | Image to pack. | 1837| option | [PackingOption](#packingoption) | Yes | Option for image packing. | 1838| callback | AsyncCallback\<ArrayBuffer> | Yes | Callback used to return the packed data.| 1839 1840**Example** 1841 1842```js 1843const imageSourceApi = image.createImageSource(0); 1844let packOpts = { format:"image/jpeg", quality:98 }; 1845imagePackerApi.packing(imageSourceApi, packOpts, data => {}) 1846``` 1847 1848### packing 1849 1850packing(source: ImageSource, option: PackingOption): Promise\<ArrayBuffer> 1851 1852Packs an image. This API uses a promise to return the result. 1853 1854**System capability**: SystemCapability.Multimedia.Image.ImagePacker 1855 1856**Parameters** 1857 1858| Name| Type | Mandatory| Description | 1859| ------ | ------------------------------- | ---- | -------------- | 1860| source | [ImageSource](#imagesource) | Yes | Image to pack.| 1861| option | [PackingOption](#packingoption) | Yes | Option for image packing.| 1862 1863**Return value** 1864 1865| Type | Description | 1866| ---------------------------- | --------------------------------------------- | 1867| Promise\<ArrayBuffer> | Promise used to return the packed data.| 1868 1869**Example** 1870 1871```js 1872const imageSourceApi = image.createImageSource(0); 1873let packOpts = { format:"image/jpeg", quality:98 } 1874imagePackerApi.packing(imageSourceApi, packOpts) 1875 .then( data => { 1876 console.log('packing succeeded.'); 1877 }).catch(error => { 1878 console.log('packing failed.'); 1879 }) 1880``` 1881 1882### packing<sup>8+</sup> 1883 1884packing(source: PixelMap, option: PackingOption, callback: AsyncCallback\<ArrayBuffer>): void 1885 1886Packs an image. This API uses an asynchronous callback to return the result. 1887 1888**System capability**: SystemCapability.Multimedia.Image.ImagePacker 1889 1890**Parameters** 1891 1892| Name | Type | Mandatory| Description | 1893| -------- | ------------------------------- | ---- | ---------------------------------- | 1894| source | [PixelMap](#pixelmap) | Yes | **PixelMap** object to pack. | 1895| option | [PackingOption](#packingoption) | Yes | Option for image packing. | 1896| callback | AsyncCallback\<ArrayBuffer> | Yes | Callback used to return the packed data.| 1897 1898**Example** 1899 1900```js 1901const color = new ArrayBuffer(96); // 96 is the size of the pixel map buffer to create. The value is calculated as follows: height x width x 4. 1902let bufferArr = new Uint8Array(color); 1903let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } 1904image.createPixelMap(color, opts).then((pixelmap) => { 1905 let packOpts = { format:"image/jpeg", quality:98 } 1906 imagePackerApi.packing(pixelmap, packOpts, data => { 1907 console.log('Succeeded in packing the image.'); 1908 }) 1909}) 1910``` 1911 1912### packing<sup>8+</sup> 1913 1914packing(source: PixelMap, option: PackingOption): Promise\<ArrayBuffer> 1915 1916Packs an image. This API uses a promise to return the result. 1917 1918**System capability**: SystemCapability.Multimedia.Image.ImagePacker 1919 1920**Parameters** 1921 1922| Name| Type | Mandatory| Description | 1923| ------ | ------------------------------- | ---- | ------------------ | 1924| source | [PixelMap](#pixelmap) | Yes | **PixelMap** object to pack.| 1925| option | [PackingOption](#packingoption) | Yes | Option for image packing. | 1926 1927**Return value** 1928 1929| Type | Description | 1930| --------------------- | -------------------------------------------- | 1931| Promise\<ArrayBuffer> | Promise used to return the packed data.| 1932 1933**Example** 1934 1935```js 1936const color = new ArrayBuffer(96); // 96 is the size of the pixel map buffer to create. The value is calculated as follows: height x width x 4. 1937let bufferArr = new Uint8Array(color); 1938let opts = { editable: true, pixelFormat: 3, size: { height: 4, width: 6 } } 1939image.createPixelMap(color, opts).then((pixelmap) => { 1940 let packOpts = { format:"image/jpeg", quality:98 } 1941 imagePackerApi.packing(pixelmap, packOpts) 1942 .then( data => { 1943 console.log('Succeeded in packing the image.'); 1944 }).catch(error => { 1945 console.log('Failed to pack the image..'); 1946 }) 1947}) 1948``` 1949 1950### release 1951 1952release(callback: AsyncCallback\<void>): void 1953 1954Releases this **ImagePacker** instance. This API uses an asynchronous callback to return the result. 1955 1956**System capability**: SystemCapability.Multimedia.Image.ImagePacker 1957 1958**Parameters** 1959 1960| Name | Type | Mandatory| Description | 1961| -------- | -------------------- | ---- | ------------------------------ | 1962| callback | AsyncCallback\<void> | Yes | Callback invoked for instance release. If the operation fails, an error message is returned.| 1963 1964**Example** 1965 1966```js 1967imagePackerApi.release(()=>{ 1968 console.log('Succeeded in releasing image packaging.'); 1969}) 1970``` 1971 1972### release 1973 1974release(): Promise\<void> 1975 1976Releases this **ImagePacker** instance. This API uses a promise to return the result. 1977 1978**System capability**: SystemCapability.Multimedia.Image.ImagePacker 1979 1980**Return value** 1981 1982| Type | Description | 1983| -------------- | ------------------------------------------------------ | 1984| Promise\<void> | Promise used to return the instance release result. If the operation fails, an error message is returned.| 1985 1986**Example** 1987 1988```js 1989imagePackerApi.release().then(()=>{ 1990 console.log('Succeeded in releasing image packaging.'); 1991}).catch((error)=>{ 1992 console.log('Failed to release image packaging.'); 1993}) 1994``` 1995 1996## image.createImageReceiver<sup>9+</sup> 1997 1998createImageReceiver(width: number, height: number, format: number, capacity: number): ImageReceiver 1999 2000Creates an **ImageReceiver** instance by specifying the image width, height, format, and capacity. 2001 2002**System capability**: SystemCapability.Multimedia.Image.ImageReceiver 2003 2004**Parameters** 2005 2006| Name | Type | Mandatory| Description | 2007| -------- | ------ | ---- | ---------------------- | 2008| width | number | Yes | Default image width. | 2009| height | number | Yes | Default image height. | 2010| format | number | Yes | Image format, which is a constant of [ImageFormat](#imageformat9). (Only ImageFormat:JPEG and 4 are supported.) | 2011| capacity | number | Yes | Maximum number of images that can be accessed at the same time.| 2012 2013**Return value** 2014 2015| Type | Description | 2016| -------------------------------- | --------------------------------------- | 2017| [ImageReceiver](#imagereceiver9) | Returns an **ImageReceiver** instance if the operation is successful.| 2018 2019**Example** 2020 2021```js 2022var receiver = image.createImageReceiver(8192, 8, 2000, 8); 2023``` 2024 2025## ImageReceiver<sup>9+</sup> 2026 2027Provides APIs to obtain the surface ID of a component, read the latest image, read the next image, and release the **ImageReceiver** instance. 2028 2029Before calling any APIs in **ImageReceiver**, you must create an **ImageReceiver** instance. 2030 2031### Attributes 2032 2033**System capability**: SystemCapability.Multimedia.Image.ImageReceiver 2034 2035| Name | Type | Readable| Writable| Description | 2036| -------- | ---------------------------- | ---- | ---- | ------------------ | 2037| size | [Size](#size) | Yes | No | Image size. | 2038| capacity | number | Yes | No | Maximum number of images that can be accessed at the same time.| 2039| format | [ImageFormat](#imageformat9) | Yes | No | Image format. | 2040 2041### getReceivingSurfaceId<sup>9+</sup> 2042 2043getReceivingSurfaceId(callback: AsyncCallback\<string>): void 2044 2045Obtains a surface ID for the camera or other components. This API uses an asynchronous callback to return the result. 2046 2047**System capability**: SystemCapability.Multimedia.Image.ImageReceiver 2048 2049**Parameters** 2050 2051| Name | Type | Mandatory| Description | 2052| -------- | ---------------------- | ---- | -------------------------- | 2053| callback | AsyncCallback\<string> | Yes | Callback used to return the surface ID.| 2054 2055**Example** 2056 2057```js 2058receiver.getReceivingSurfaceId((err, id) => { 2059 if(err) { 2060 console.log('getReceivingSurfaceId failed.'); 2061 } else { 2062 console.log('getReceivingSurfaceId succeeded.'); 2063 } 2064}); 2065``` 2066 2067### getReceivingSurfaceId<sup>9+</sup> 2068 2069getReceivingSurfaceId(): Promise\<string> 2070 2071Obtains a surface ID for the camera or other components. This API uses a promise to return the result. 2072 2073**System capability**: SystemCapability.Multimedia.Image.ImageReceiver 2074 2075**Return value** 2076 2077| Type | Description | 2078| ---------------- | -------------------- | 2079| Promise\<string> | Promise used to return the surface ID.| 2080 2081**Example** 2082 2083```js 2084receiver.getReceivingSurfaceId().then( id => { 2085 console.log('getReceivingSurfaceId succeeded.'); 2086}).catch(error => { 2087 console.log('getReceivingSurfaceId failed.'); 2088}) 2089``` 2090 2091### readLatestImage<sup>9+</sup> 2092 2093readLatestImage(callback: AsyncCallback\<Image>): void 2094 2095Reads the latest image from the **ImageReceiver** instance. This API uses an asynchronous callback to return the result. 2096 2097**System capability**: SystemCapability.Multimedia.Image.ImageReceiver 2098 2099**Parameters** 2100 2101| Name | Type | Mandatory| Description | 2102| -------- | ------------------------------- | ---- | ------------------------ | 2103| callback | AsyncCallback<[Image](#image9)> | Yes | Callback used to return the latest image.| 2104 2105**Example** 2106 2107```js 2108receiver.readLatestImage((err, img) => { 2109 if(err) { 2110 console.log('readLatestImage failed.'); 2111 } else { 2112 console.log('readLatestImage succeeded.'); 2113 } 2114}); 2115``` 2116 2117### readLatestImage<sup>9+</sup> 2118 2119readLatestImage(): Promise\<Image> 2120 2121Reads the latest image from the **ImageReceiver** instance. This API uses a promise to return the result. 2122 2123**System capability**: SystemCapability.Multimedia.Image.ImageReceiver 2124 2125**Return value** 2126 2127| Type | Description | 2128| ------------------------- | ------------------ | 2129| Promise<[Image](#image9)> | Promise used to return the latest image.| 2130 2131**Example** 2132 2133```js 2134receiver.readLatestImage().then(img => { 2135 console.log('readLatestImage succeeded.'); 2136}).catch(error => { 2137 console.log('readLatestImage failed.'); 2138}) 2139``` 2140 2141### readNextImage<sup>9+</sup> 2142 2143readNextImage(callback: AsyncCallback\<Image>): void 2144 2145Reads the next image from the **ImageReceiver** instance. This API uses an asynchronous callback to return the result. 2146 2147**System capability**: SystemCapability.Multimedia.Image.ImageReceiver 2148 2149**Parameters** 2150 2151| Name | Type | Mandatory| Description | 2152| -------- | ------------------------------- | ---- | -------------------------- | 2153| callback | AsyncCallback<[Image](#image9)> | Yes | Callback used to return the next image.| 2154 2155**Example** 2156 2157```js 2158receiver.readNextImage((err, img) => { 2159 if(err) { 2160 console.log('readNextImage failed.'); 2161 } else { 2162 console.log('readNextImage succeeded.'); 2163 } 2164}); 2165``` 2166 2167### readNextImage<sup>9+</sup> 2168 2169readNextImage(): Promise\<Image> 2170 2171Reads the next image from the **ImageReceiver** instance. This API uses a promise to return the result. 2172 2173**System capability**: SystemCapability.Multimedia.Image.ImageReceiver 2174 2175**Return value** 2176 2177| Type | Description | 2178| ------------------------- | -------------------- | 2179| Promise<[Image](#image9)> | Promise used to return the next image.| 2180 2181**Example** 2182 2183```js 2184receiver.readNextImage().then(img => { 2185 console.log('readNextImage succeeded.'); 2186}).catch(error => { 2187 console.log('readNextImage failed.'); 2188}) 2189``` 2190 2191### on<sup>9+</sup> 2192 2193on(type: 'imageArrival', callback: AsyncCallback\<void>): void 2194 2195Listens for image arrival events. 2196 2197**System capability**: SystemCapability.Multimedia.Image.ImageReceiver 2198 2199**Parameters** 2200 2201| Name | Type | Mandatory| Description | 2202| -------- | -------------------- | ---- | ------------------------------------------------------ | 2203| type | string | Yes | Type of event to listen for. The value is fixed at **imageArrival**, which is triggered when an image is received.| 2204| callback | AsyncCallback\<void> | Yes | Callback invoked for the event. | 2205 2206**Example** 2207 2208```js 2209receiver.on('imageArrival', () => {}) 2210``` 2211 2212### release<sup>9+</sup> 2213 2214release(callback: AsyncCallback\<void>): void 2215 2216Releases this **ImageReceiver** instance. This API uses an asynchronous callback to return the result. 2217 2218**System capability**: SystemCapability.Multimedia.Image.ImageReceiver 2219 2220**Parameters** 2221 2222| Name | Type | Mandatory| Description | 2223| -------- | -------------------- | ---- | ------------------------ | 2224| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| 2225 2226**Example** 2227 2228```js 2229receiver.release(() => {}) 2230``` 2231 2232### release<sup>9+</sup> 2233 2234release(): Promise\<void> 2235 2236Releases this **ImageReceiver** instance. This API uses a promise to return the result. 2237 2238**System capability**: SystemCapability.Multimedia.Image.ImageReceiver 2239 2240**Return value** 2241 2242| Type | Description | 2243| -------------- | ------------------ | 2244| Promise\<void> | Promise used to return the result.| 2245 2246**Example** 2247 2248```js 2249receiver.release().then(() => { 2250 console.log('release succeeded.'); 2251}).catch(error => { 2252 console.log('release failed.'); 2253}) 2254``` 2255 2256## image.createImageCreator<sup>9+</sup> 2257 2258createImageCreator(width: number, height: number, format: number, capacity: number): ImageCreator 2259 2260Creates an **ImageCreator** instance by specifying the image width, height, format, and capacity. 2261 2262**System capability**: SystemCapability.Multimedia.Image.ImageCreator 2263 2264**Parameters** 2265 2266| Name | Type | Mandatory| Description | 2267| -------- | ------ | ---- | ---------------------- | 2268| width | number | Yes | Default image width. | 2269| height | number | Yes | Default image height. | 2270| format | number | Yes | Image format, for example, YCBCR_422_SP or JPEG. | 2271| capacity | number | Yes | Maximum number of images that can be accessed at the same time.| 2272 2273**Return value** 2274 2275| Type | Description | 2276| ------------------------------ | --------------------------------------- | 2277| [ImageCreator](#imagecreator9) | Returns an **ImageCreator** instance if the operation is successful.| 2278 2279**Example** 2280 2281```js 2282var creator = image.createImageCreator(8192, 8, 4, 8); 2283``` 2284 2285## ImageCreator<sup>9+</sup> 2286 2287Provides APIs for applications to request an image native data area and compile native image data. 2288Before calling any APIs in **ImageCreator**, you must create an **ImageCreator** instance. 2289 2290### Attributes 2291 2292**System capability**: SystemCapability.Multimedia.Image.ImageCreator 2293 2294| Name | Type | Readable| Writable| Description | 2295| -------- | ---------------------------- | ---- | ---- | ------------------ | 2296| capacity | number | Yes | No | Maximum number of images that can be accessed at the same time.| 2297| format | [ImageFormat](#imageformat9) | Yes | No | Image format. | 2298 2299### dequeueImage<sup>9+</sup> 2300 2301dequeueImage(callback: AsyncCallback\<Image>): void 2302 2303Obtains an image buffer from the idle queue and writes image data into it. This API uses an asynchronous callback to return the result. 2304 2305**System capability**: SystemCapability.Multimedia.Image.ImageCreator 2306 2307**Parameters** 2308 2309| Name | Type | Mandatory| Description | 2310| ------------- | ---------------------------------------| ---- | -------------------- | 2311| callback | AsyncCallback\<Image> | Yes | Callback used to return the drawn image.| 2312 2313**Example** 2314 2315```js 2316creator.dequeueImage((err, img) => { 2317 if (err) { 2318 console.info('dequeueImage failed.'); 2319 } 2320 console.info('dequeueImage succeeded.'); 2321}); 2322``` 2323 2324### dequeueImage<sup>9+</sup> 2325 2326dequeueImage(): Promise\<Image> 2327 2328Obtains an image buffer from the idle queue and writes image data into it. This API uses a promise to return the result. 2329 2330**System capability**: SystemCapability.Multimedia.Image.ImageCreator 2331 2332**Return value** 2333 2334| Type | Description | 2335| --------------- | ------------- | 2336| Promise\<Image> | Promise used to return the drawn image.| 2337 2338**Example** 2339 2340```js 2341creator.dequeueImage().then(img => { 2342 console.info('dequeueImage succeeded.'); 2343}).catch(error => { 2344 console.log('dequeueImage failed: ' + error); 2345}) 2346``` 2347 2348### queueImage<sup>9+</sup> 2349 2350queueImage(interface: Image, callback: AsyncCallback\<void>): void 2351 2352Places the drawn image in the dirty queue. This API uses an asynchronous callback to return the result. 2353 2354**System capability**: SystemCapability.Multimedia.Image.ImageCreator 2355 2356**Parameters** 2357 2358| Name | Type | Mandatory| Description | 2359| ------------- | -------------------------| ---- | -------------------- | 2360| interface | Image | Yes | Drawn image.| 2361| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned.| 2362 2363**Example** 2364 2365```js 2366creator.dequeueImage().then(img => { 2367 // Draw the image. 2368 img.getComponent(4).then(component => { 2369 var bufferArr = new Uint8Array(component.byteBuffer); 2370 for (var i = 0; i < bufferArr.length; i += 4) { 2371 bufferArr[i] = 0; //B 2372 bufferArr[i + 1] = 0; //G 2373 bufferArr[i + 2] = 255; //R 2374 bufferArr[i + 3] = 255; //A 2375 } 2376 }) 2377 creator.queueImage(img, (err) => { 2378 if (err) { 2379 console.info('queueImage failed: ' + err); 2380 } 2381 console.info('queueImage succeeded'); 2382 }) 2383}) 2384 2385``` 2386 2387### queueImage<sup>9+</sup> 2388 2389queueImage(interface: Image): Promise\<void> 2390 2391Places the drawn image in the dirty queue. This API uses a promise to return the result. 2392 2393**System capability**: SystemCapability.Multimedia.Image.ImageCreator 2394 2395**Parameters** 2396 2397| Name | Type | Mandatory| Description | 2398| ------------- | --------| ---- | ------------------- | 2399| interface | Image | Yes | Drawn image.| 2400 2401**Return value** 2402 2403| Type | Description | 2404| -------------- | ------------- | 2405| Promise\<void> | Promise used to return the result. If the operation fails, an error message is returned.| 2406 2407**Example** 2408 2409```js 2410creator.dequeueImage().then(img => { 2411 // Draw the image. 2412 img.getComponent(4).then(component => { 2413 var bufferArr = new Uint8Array(component.byteBuffer); 2414 for (var i = 0; i < bufferArr.length; i += 4) { 2415 bufferArr[i] = 0; //B 2416 bufferArr[i + 1] = 0; //G 2417 bufferArr[i + 2] = 255; //R 2418 bufferArr[i + 3] = 255; //A 2419 } 2420 }) 2421 creator.queueImage(img).then(() => { 2422 console.info('queueImage succeeded.'); 2423 }).catch(error => { 2424 console.info('queueImage failed: ' + error); 2425 }) 2426}) 2427 2428``` 2429 2430### on<sup>9+</sup> 2431 2432on(type: 'imageRelease', callback: AsyncCallback\<void>): void 2433 2434Listens for image release events. This API uses an asynchronous callback to return the result. 2435 2436**System capability**: SystemCapability.Multimedia.Image.ImageCreator 2437 2438**Parameters** 2439 2440| Name | Type | Mandatory| Description | 2441| ------------- | -------------------------| ---- | -------------------- | 2442| type | string | Yes | Type of event, which is **'imageRelease'**.| 2443| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned.| 2444 2445**Example** 2446 2447```js 2448creator.on('imageRelease', (err) => { 2449 if (err) { 2450 console.info('on faild' + err); 2451 } 2452 console.info('on succeeded'); 2453}) 2454``` 2455 2456### release<sup>9+</sup> 2457 2458release(callback: AsyncCallback\<void>): void 2459 2460Releases this **ImageCreator** instance. This API uses an asynchronous callback to return the result. 2461 2462**System capability**: SystemCapability.Multimedia.Image.ImageCreator 2463 2464**Parameters** 2465 2466| Name | Type | Mandatory| Description | 2467| ------------- | -------------------------| ---- | -------------------- | 2468| callback | AsyncCallback\<void> | Yes | Callback used to return the result. If the operation fails, an error message is returned.| 2469 2470**Example** 2471 2472```js 2473creator.release((err) => { 2474 if (err) { 2475 console.info('release failed: ' + err); 2476 } 2477 console.info('release succeeded'); 2478}); 2479``` 2480### release<sup>9+</sup> 2481 2482release(): Promise\<void> 2483 2484Releases this **ImageCreator** instance. This API uses a promise to return the result. 2485 2486**System capability**: SystemCapability.Multimedia.Image.ImageCreator 2487 2488**Return value** 2489 2490| Type | Description | 2491| -------------- | ------------- | 2492| Promise\<void> | Promise used to return the result. If the operation fails, an error message is returned.| 2493 2494**Example** 2495 2496```js 2497creator.release().then(() => { 2498 console.info('release succeeded'); 2499}).catch(error => { 2500 console.info('release failed'); 2501}) 2502``` 2503 2504## Image<sup>9+</sup> 2505 2506Provides 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. 2507 2508### Attributes 2509 2510**System capability**: SystemCapability.Multimedia.Image.Core 2511 2512| Name | Type | Readable| Writable| Description | 2513| -------- | ------------------ | ---- | ---- | -------------------------------------------------- | 2514| clipRect | [Region](#region7) | Yes | Yes | Image area to be cropped. | 2515| size | [Size](#size) | Yes | No | Image size. | 2516| format | number | Yes | No | Image format. For details, see [PixelMapFormat](#pixelmapformat7).| 2517 2518### getComponent<sup>9+</sup> 2519 2520getComponent(componentType: ComponentType, callback: AsyncCallback\<Component>): void 2521 2522Obtains the component buffer from the **Image** instance based on the color component type. This API uses an asynchronous callback to return the result. 2523 2524**System capability**: SystemCapability.Multimedia.Image.Core 2525 2526**Parameters** 2527 2528| Name | Type | Mandatory| Description | 2529| ------------- | --------------------------------------- | ---- | -------------------- | 2530| componentType | [ComponentType](#componenttype9) | Yes | Color component type of the image. | 2531| callback | AsyncCallback<[Component](#component9)> | Yes | Callback used to return the component buffer.| 2532 2533**Example** 2534 2535```js 2536img.getComponent(4, (err, component) => { 2537 if(err) { 2538 console.log('getComponent failed.'); 2539 } else { 2540 console.log('getComponent succeeded.'); 2541 } 2542}) 2543``` 2544 2545### getComponent<sup>9+</sup> 2546 2547getComponent(componentType: ComponentType): Promise\<Component> 2548 2549Obtains the component buffer from the **Image** instance based on the color component type. This API uses a promise to return the result. 2550 2551**System capability**: SystemCapability.Multimedia.Image.Core 2552 2553**Parameters** 2554 2555| Name | Type | Mandatory| Description | 2556| ------------- | -------------------------------- | ---- | ---------------- | 2557| componentType | [ComponentType](#componenttype9) | Yes | Color component type of the image.| 2558 2559**Return value** 2560 2561| Type | Description | 2562| --------------------------------- | --------------------------------- | 2563| Promise<[Component](#component9)> | Promise used to return the component buffer.| 2564 2565**Example** 2566 2567```js 2568img.getComponent(4).then(component => { }) 2569``` 2570 2571### release<sup>9+</sup> 2572 2573release(callback: AsyncCallback\<void>): void 2574 2575Releases this **Image** instance. This API uses an asynchronous callback to return the result. 2576 2577The corresponding resources must be released before another image arrives. 2578 2579**System capability**: SystemCapability.Multimedia.Image.Core 2580 2581**Parameters** 2582 2583| Name | Type | Mandatory| Description | 2584| -------- | -------------------- | ---- | -------------- | 2585| callback | AsyncCallback\<void> | Yes | Callback used to return the result.| 2586 2587**Example** 2588 2589```js 2590img.release(() =>{ 2591 console.log('release succeeded.'); 2592}) 2593``` 2594 2595### release<sup>9+</sup> 2596 2597release(): Promise\<void> 2598 2599Releases this **Image** instance. This API uses a promise to return the result. 2600 2601The corresponding resources must be released before another image arrives. 2602 2603**System capability**: SystemCapability.Multimedia.Image.Core 2604 2605**Return value** 2606 2607| Type | Description | 2608| -------------- | --------------------- | 2609| Promise\<void> | Promise used to return the result.| 2610 2611**Example** 2612 2613```js 2614img.release().then(() =>{ 2615 console.log('release succeeded.'); 2616}).catch(error => { 2617 console.log('release failed.'); 2618}) 2619``` 2620 2621## PositionArea<sup>7+</sup> 2622 2623Describes area information in an image. 2624 2625**System capability**: SystemCapability.Multimedia.Image.Core 2626 2627| Name | Type | Readable| Writable| Description | 2628| ------ | ------------------ | ---- | ---- | ------------------------------------------------------------ | 2629| pixels | ArrayBuffer | Yes | No | Pixels of the image. | 2630| offset | number | Yes | No | Offset for data reading. | 2631| 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. | 2632| 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.| 2633 2634## ImageInfo 2635 2636Describes image information. 2637 2638**System capability**: SystemCapability.Multimedia.Image.Core 2639 2640| Name| Type | Readable| Writable| Description | 2641| ---- | ------------- | ---- | ---- | ---------- | 2642| size | [Size](#size) | Yes | Yes | Image size.| 2643| density<sup>9+</sup> | number | Yes | Yes | Pixel density, in ppi.| 2644 2645## Size 2646 2647Describes the size of an image. 2648 2649**System capability**: SystemCapability.Multimedia.Image.Core 2650 2651| Name | Type | Readable| Writable| Description | 2652| ------ | ------ | ---- | ---- | -------------- | 2653| height | number | Yes | Yes | Image height.| 2654| width | number | Yes | Yes | Image width.| 2655 2656## PixelMapFormat<sup>7+</sup> 2657 2658Enumerates the pixel formats of images. 2659 2660**System capability**: SystemCapability.Multimedia.Image.Core 2661 2662| Name | Value | Description | 2663| ---------------------- | ------ | ----------------- | 2664| UNKNOWN | 0 | Unknown format. | 2665| RGB_565 | 2 | RGB_565. | 2666| RGBA_8888 | 3 | RGBA_8888.| 2667| BGRA_8888<sup>9+</sup> | 4 | BGRA_8888.| 2668| RGB_888<sup>9+</sup> | 5 | RGB_888. | 2669| ALPHA_8<sup>9+</sup> | 6 | ALPHA_8. | 2670| RGBA_F16<sup>9+</sup> | 7 | RGBA_F16. | 2671| NV21<sup>9+</sup> | 8 | NV21. | 2672| NV12<sup>9+</sup> | 9 | NV12. | 2673 2674## AlphaType<sup>9+</sup> 2675 2676Enumerates the alpha types of images. 2677 2678**System capability**: SystemCapability.Multimedia.Image.Core 2679 2680| Name | Value | Description | 2681| -------- | ------ | ----------------------- | 2682| UNKNOWN | 0 | Unknown alpha type. | 2683| OPAQUE | 1 | There is no alpha or the image is opaque.| 2684| PREMUL | 2 | Premultiplied alpha. | 2685| UNPREMUL | 3 | Unpremultiplied alpha, that is, straight alpha. | 2686 2687## ScaleMode<sup>9+</sup> 2688 2689Enumerates the scale modes of images. 2690 2691**System capability**: SystemCapability.Multimedia.Image.Core 2692 2693| Name | Value | Description | 2694| --------------- | ------ | -------------------------------------------------- | 2695| CENTER_CROP | 1 | Scales the image so that it fills the requested bounds of the target and crops the extra.| 2696| FIT_TARGET_SIZE | 0 | Reduces the image size to the dimensions of the target. | 2697 2698## SourceOptions<sup>9+</sup> 2699 2700Defines image source initialization options. 2701 2702**System capability**: SystemCapability.Multimedia.Image.Core 2703 2704| Name | Type | Readable| Writable| Description | 2705| ----------------- | ---------------------------------- | ---- | ---- | ------------------ | 2706| sourceDensity | number | Yes | Yes | Density of the image source.| 2707| sourcePixelFormat | [PixelMapFormat](#pixelmapformat7) | Yes | Yes | Pixel format of the image source. | 2708| sourceSize | [Size](#size) | Yes | Yes | Pixel size of the image source. | 2709 2710 2711## InitializationOptions<sup>8+</sup> 2712 2713Defines pixel map initialization options. 2714 2715**System capability**: SystemCapability.Multimedia.Image.Core 2716 2717| Name | Type | Readable| Writable| Description | 2718| ------------------------ | ---------------------------------- | ---- | ---- | -------------- | 2719| alphaType<sup>9+</sup> | [AlphaType](#alphatype9) | Yes | Yes | Alpha type. | 2720| editable | boolean | Yes | Yes | Whether the image is editable. | 2721| pixelFormat | [PixelMapFormat](#pixelmapformat7) | Yes | Yes | Pixel map format. | 2722| scaleMode<sup>9+</sup> | [ScaleMode](#scalemode9) | Yes | Yes | Scale mode. | 2723| size | [Size](#size) | Yes | Yes | Image size.| 2724 2725## DecodingOptions<sup>7+</sup> 2726 2727Defines image decoding options. 2728 2729**System capability**: SystemCapability.Multimedia.Image.ImageSource 2730 2731| Name | Type | Readable| Writable| Description | 2732| ------------------ | ---------------------------------- | ---- | ---- | ---------------- | 2733| sampleSize | number | Yes | Yes | Thumbnail sampling size.| 2734| rotate | number | Yes | Yes | Rotation angle. | 2735| editable | boolean | Yes | Yes | Whether the image is editable. | 2736| desiredSize | [Size](#size) | Yes | Yes | Expected output size. | 2737| desiredRegion | [Region](#region7) | Yes | Yes | Region to decode. | 2738| desiredPixelFormat | [PixelMapFormat](#pixelmapformat7) | Yes | Yes | Pixel map format for decoding.| 2739| index | number | Yes | Yes | Index of the image to decode. | 2740| fitDensity<sup>9+</sup> | number | Yes | Yes | Image pixel density, in ppi. | 2741 2742## Region<sup>7+</sup> 2743 2744Describes region information. 2745 2746**System capability**: SystemCapability.Multimedia.Image.Core 2747 2748| Name| Type | Readable| Writable| Description | 2749| ---- | ------------- | ---- | ---- | ------------ | 2750| size | [Size](#size) | Yes | Yes | Region size. | 2751| x | number | Yes | Yes | X coordinate to translate.| 2752| y | number | Yes | Yes | Y coordinate of the region.| 2753 2754## PackingOption 2755 2756Defines the option for image packing. 2757 2758**System capability**: SystemCapability.Multimedia.Image.ImagePacker 2759 2760| Name | Type | Readable| Writable| Description | 2761| ------- | ------ | ---- | ---- | --------------------------------------------------- | 2762| format | string | Yes | Yes | Format of the packed image.<br>Only the JPG and WebP formats are supported.| 2763| quality | number | Yes | Yes | Quality of the output image in JPEG encoding. The value ranges from 1 to 100.| 2764| bufferSize<sup>9+</sup> | number | Yes | Yes | Buffer size, which is used to set the image size. The default value is 10 MB.| 2765 2766## GetImagePropertyOptions<sup>7+</sup> 2767 2768Describes image properties. 2769 2770**System capability**: SystemCapability.Multimedia.Image.ImageSource 2771 2772| Name | Type | Readable| Writable| Description | 2773| ------------ | ------ | ---- | ---- | ------------ | 2774| index | number | Yes | Yes | Index of an image. | 2775| defaultValue | string | Yes | Yes | Default property value.| 2776 2777## PropertyKey<sup>7+</sup> 2778 2779Describes the exchangeable image file format (EXIF) data of an image. 2780 2781**System capability**: SystemCapability.Multimedia.Image.Core 2782 2783| Name | Value | Description | 2784| ----------------- | ----------------------- | ------------------------ | 2785| BITS_PER_SAMPLE | "BitsPerSample" | Number of bits per pixel. | 2786| ORIENTATION | "Orientation" | Image orientation. | 2787| IMAGE_LENGTH | "ImageLength" | Image length. | 2788| IMAGE_WIDTH | "ImageWidth" | Image width. | 2789| GPS_LATITUDE | "GPSLatitude" | Image latitude. | 2790| GPS_LONGITUDE | "GPSLongitude" | Image longitude. | 2791| GPS_LATITUDE_REF | "GPSLatitudeRef" | Latitude reference, for example, N or S. | 2792| GPS_LONGITUDE_REF | "GPSLongitudeRef" | Longitude reference, for example, W or E. | 2793| DATE_TIME_ORIGINAL<sup>9+</sup> | "DateTimeOriginal" | Shooting time, for example, 2022:09:06 15:48:00. | 2794| EXPOSURE_TIME<sup>9+</sup> | "ExposureTime" | Exposure time, for example, 1/33 sec.| 2795| SCENE_TYPE<sup>9+</sup> | "SceneType" | Shooting scene type, for example, portrait, scenery, motion, and night. | 2796| ISO_SPEED_RATINGS<sup>9+</sup> | "ISOSpeedRatings" | ISO sensitivity or ISO speed, for example, 400. | 2797| F_NUMBER<sup>9+</sup> | "FNumber" | Aperture, for example, f/1.8. | 2798 2799 2800## ImageFormat<sup>9+</sup> 2801 2802Enumerates the image formats. 2803 2804**System capability**: SystemCapability.Multimedia.Image.Core 2805 2806| Name | Value | Description | 2807| ------------ | ------ | -------------------- | 2808| YCBCR_422_SP | 1000 | YCBCR422 semi-planar format.| 2809| JPEG | 2000 | JPEG encoding format. | 2810 2811## ComponentType<sup>9+</sup> 2812 2813Enumerates the color component types of images. 2814 2815**System capability**: SystemCapability.Multimedia.Image.ImageReceiver 2816 2817| Name | Value | Description | 2818| ----- | ------ | ----------- | 2819| YUV_Y | 1 | Luminance component. | 2820| YUV_U | 2 | Chrominance component. | 2821| YUV_V | 3 | Chrominance component. | 2822| JPEG | 4 | JPEG type.| 2823 2824## Component<sup>9+</sup> 2825 2826Describes the color components of an image. 2827 2828**System capability**: SystemCapability.Multimedia.Image.Core 2829 2830| Name | Type | Readable| Writable| Description | 2831| ------------- | -------------------------------- | ---- | ---- | ------------ | 2832| componentType | [ComponentType](#componenttype9) | Yes | No | Color component type. | 2833| rowStride | number | Yes | No | Row stride. | 2834| pixelStride | number | Yes | No | Pixel stride. | 2835| byteBuffer | ArrayBuffer | Yes | No | Component buffer.| 2836 2837## Supplementary Information 2838### SVG Tags 2839 2840The SVG tags are supported since API verison 10. The used version is (SVG) 1.1. Currently, the following tags are supported: 2841- a 2842- circla 2843- clipPath 2844- defs 2845- ellipse 2846- feBlend 2847- feColorMatrix 2848- feComposite 2849- feDiffuseLighting 2850- feDisplacementMap 2851- feDistantLight 2852- feFlood 2853- feGaussianBlur 2854- feImage 2855- feMorphology 2856- feOffset 2857- fePointLight 2858- feSpecularLighting 2859- feSpotLight 2860- feTurbulence 2861- filter 2862- g 2863- image 2864- line 2865- linearGradient 2866- mask 2867- path 2868- pattern 2869- polygon 2870- polyline 2871- radialGradient 2872- rect 2873- stop 2874- svg 2875- text 2876- textPath 2877- tspan 2878- use 2879 2880### ResponseCode 2881 2882Enumerates the response codes returned upon build errors. 2883 2884| Name | Value | Description | 2885| ----------------------------------- | -------- | --------------------------------------------------- | 2886| ERR_MEDIA_INVALID_VALUE | -1 | Invalid value. | 2887| SUCCESS | 0 | Operation successful. | 2888| ERROR | 62980096 | Operation failed. | 2889| ERR_IPC | 62980097 | IPC error. | 2890| ERR_SHAMEM_NOT_EXIST | 62980098 | The shared memory does not exist. | 2891| ERR_SHAMEM_DATA_ABNORMAL | 62980099 | The shared memory is abnormal. | 2892| ERR_IMAGE_DECODE_ABNORMAL | 62980100 | An error occurs during image decoding. | 2893| ERR_IMAGE_DATA_ABNORMAL | 62980101 | The input image data is incorrect. | 2894| ERR_IMAGE_MALLOC_ABNORMAL | 62980102 | An error occurs during image memory allocation. | 2895| ERR_IMAGE_DATA_UNSUPPORT | 62980103 | Unsupported image type. | 2896| ERR_IMAGE_INIT_ABNORMAL | 62980104 | An error occurs during image initialization. | 2897| ERR_IMAGE_GET_DATA_ABNORMAL | 62980105 | An error occurs during image data retrieval. | 2898| ERR_IMAGE_TOO_LARGE | 62980106 | The image data is too large. | 2899| ERR_IMAGE_TRANSFORM | 62980107 | An error occurs during image transformation. | 2900| ERR_IMAGE_COLOR_CONVERT | 62980108 | An error occurs during image color conversion. | 2901| ERR_IMAGE_CROP | 62980109 | An error occurs during image cropping. | 2902| ERR_IMAGE_SOURCE_DATA | 62980110 | The image source data is incorrect. | 2903| ERR_IMAGE_SOURCE_DATA_INCOMPLETE | 62980111 | The image source data is incomplete. | 2904| ERR_IMAGE_MISMATCHED_FORMAT | 62980112 | The image formats do not match. | 2905| ERR_IMAGE_UNKNOWN_FORMAT | 62980113 | Unknown image format. | 2906| ERR_IMAGE_SOURCE_UNRESOLVED | 62980114 | The image source is not parsed. | 2907| ERR_IMAGE_INVALID_PARAMETER | 62980115 | Invalid image parameter. | 2908| ERR_IMAGE_DECODE_FAILED | 62980116 | Decoding failed. | 2909| ERR_IMAGE_PLUGIN_REGISTER_FAILED | 62980117 | Failed to register the plug-in. | 2910| ERR_IMAGE_PLUGIN_CREATE_FAILED | 62980118 | Failed to create the plug-in. | 2911| ERR_IMAGE_ENCODE_FAILED | 62980119 | Failed to encode the image. | 2912| ERR_IMAGE_ADD_PIXEL_MAP_FAILED | 62980120 | Failed to add the image pixel map. | 2913| ERR_IMAGE_HW_DECODE_UNSUPPORT | 62980121 | Unsupported image hardware decoding. | 2914| ERR_IMAGE_DECODE_HEAD_ABNORMAL | 62980122 | The image decoding header is incorrect. | 2915| ERR_IMAGE_DECODE_EXIF_UNSUPPORT | 62980123 | EXIF decoding is not supported. | 2916| ERR_IMAGE_PROPERTY_NOT_EXIST | 62980124 | The image property does not exist. The error codes for the image start from 150.| 2917| ERR_IMAGE_READ_PIXELMAP_FAILED | 62980246 | Failed to read the pixel map. | 2918| ERR_IMAGE_WRITE_PIXELMAP_FAILED | 62980247 | Failed to write the pixel map. | 2919| ERR_IMAGE_PIXELMAP_NOT_ALLOW_MODIFY | 62980248 | Modification to the pixel map is not allowed. | 2920| ERR_IMAGE_CONFIG_FAILED | 62980259 | The configuration is incorrect. | 2921