1/* 2* Copyright (C) 2022 Huawei Device Co., Ltd. 3* Licensed under the Apache License, Version 2.0 (the "License"); 4* you may not use this file except in compliance with the License. 5* You may obtain a copy of the License at 6* 7* http://www.apache.org/licenses/LICENSE-2.0 8* 9* Unless required by applicable law or agreed to in writing, software 10* distributed under the License is distributed on an "AS IS" BASIS, 11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12* See the License for the specific language governing permissions and 13* limitations under the License. 14*/ 15 16import { AsyncCallback } from './basic'; 17 18/** 19 * @name image 20 * @since 6 21 */ 22declare namespace image { 23 24 /** 25 * Enumerates pixel map formats. 26 * @since 7 27 * @syscap SystemCapability.Multimedia.Image.Core 28 */ 29 enum PixelMapFormat { 30 /** 31 * Indicates an unknown format. 32 * @since 7 33 * @syscap SystemCapability.Multimedia.Image.Core 34 */ 35 UNKNOWN = 0, 36 37 /** 38 * Indicates that each pixel is stored on 16 bits. Only the R, G, and B components are encoded 39 * from the higher-order to the lower-order bits: red is stored with 5 bits of precision, 40 * green is stored with 6 bits of precision, and blue is stored with 5 bits of precision. 41 * @since 7 42 * @syscap SystemCapability.Multimedia.Image.Core 43 */ 44 RGB_565 = 2, 45 46 /** 47 * Indicates that each pixel is stored on 32 bits. Each pixel contains 4 components:B(8bits), G(8bits), R(8bits), A(8bits) 48 * and are stored from the higher-order to the lower-order bits. 49 * @since 7 50 * @syscap SystemCapability.Multimedia.Image.Core 51 */ 52 RGBA_8888 = 3, 53 54 /** 55 * Indicates that each pixel is stored on 32 bits. Each pixel contains 4 components:B(8bits), G(8bits), R(8bits), A(8bits) 56 * and are stored from the higher-order to the lower-order bits. 57 * @since 9 58 * @syscap SystemCapability.Multimedia.Image.Core 59 */ 60 BGRA_8888 = 4, 61 62 /** 63 * Indicates that each pixel is stored on 24 bits. Each pixel contains 3 components:R(8bits), G(8bits), B(8bits) 64 * and are stored from the higher-order to the lower-order bits. 65 * @since 9 66 * @syscap SystemCapability.Multimedia.Image.Core 67 */ 68 RGB_888 = 5, 69 70 /** 71 * Indicates that each pixel is stored on 8 bits. Each pixel contains 1 component:ALPHA(8bits) 72 * and is stored from the higher-order to the lower-order bits. 73 * @since 9 74 * @syscap SystemCapability.Multimedia.Image.Core 75 */ 76 ALPHA_8 = 6, 77 78 /** 79 * Indicates that each pixel is stored on 32 bits. Each pixel contains 4 components:B(8bits), G(8bits), R(8bits), A(8bits) 80 * and are stored from the higher-order to the lower-order bits in F16. 81 * @since 9 82 * @syscap SystemCapability.Multimedia.Image.Core 83 */ 84 RGBA_F16 = 7, 85 86 /** 87 * Indicates that the storage order is to store Y first and then V U alternately each occupies 8 bits 88 * and are stored from the higher-order to the lower-order bits. 89 * @since 9 90 * @syscap SystemCapability.Multimedia.Image.Core 91 */ 92 NV21 = 8, 93 94 /** 95 * Indicates that the storage order is to store Y first and then U V alternately each occupies 8 bits 96 * and are stored from the higher-order to the lower-order bits. 97 * @since 9 98 * @syscap SystemCapability.Multimedia.Image.Core 99 */ 100 NV12 = 9, 101 } 102 103 /** 104 * Describes the size of an image. 105 * @since 6 106 * @syscap SystemCapability.Multimedia.Image.Core 107 */ 108 interface Size { 109 /** 110 * Height 111 * @since 6 112 * @syscap SystemCapability.Multimedia.Image.Core 113 */ 114 height: number; 115 116 /** 117 * Width 118 * @since 6 119 * @syscap SystemCapability.Multimedia.Image.Core 120 */ 121 width: number; 122 } 123 124 /** 125 * Enumerates exchangeable image file format (Exif) information types of an image. 126 * @since 7 127 * @syscap SystemCapability.Multimedia.Image.Core 128 */ 129 enum PropertyKey { 130 /** 131 * Number of bits in each pixel of an image. 132 * @since 7 133 * @syscap SystemCapability.Multimedia.Image.Core 134 */ 135 BITS_PER_SAMPLE = "BitsPerSample", 136 137 /** 138 * Image rotation mode. 139 * @since 7 140 * @syscap SystemCapability.Multimedia.Image.Core 141 */ 142 ORIENTATION = "Orientation", 143 144 /** 145 * Image length. 146 * @since 7 147 * @syscap SystemCapability.Multimedia.Image.Core 148 */ 149 IMAGE_LENGTH = "ImageLength", 150 151 /** 152 * Image width. 153 * @since 7 154 * @syscap SystemCapability.Multimedia.Image.Core 155 */ 156 IMAGE_WIDTH = "ImageWidth", 157 158 /** 159 * GPS latitude. 160 * @since 7 161 * @syscap SystemCapability.Multimedia.Image.Core 162 */ 163 GPS_LATITUDE = "GPSLatitude", 164 165 /** 166 * GPS longitude. 167 * @since 7 168 * @syscap SystemCapability.Multimedia.Image.Core 169 */ 170 GPS_LONGITUDE = "GPSLongitude", 171 172 /** 173 * GPS latitude reference. For example, N indicates north latitude and S indicates south latitude. 174 * @since 7 175 * @syscap SystemCapability.Multimedia.Image.Core 176 */ 177 GPS_LATITUDE_REF = "GPSLatitudeRef", 178 179 /** 180 * GPS longitude reference. For example, E indicates east longitude and W indicates west longitude. 181 * @since 7 182 * @syscap SystemCapability.Multimedia.Image.Core 183 */ 184 GPS_LONGITUDE_REF = "GPSLongitudeRef", 185 186 /** 187 * Shooting time 188 * @since 9 189 * @syscap SystemCapability.Multimedia.Image.Core 190 */ 191 DATE_TIME_ORIGINAL = "DateTimeOriginal", 192 193 /** 194 * Exposure time 195 * @since 9 196 * @syscap SystemCapability.Multimedia.Image.Core 197 */ 198 EXPOSURE_TIME = "ExposureTime", 199 200 /** 201 * Scene type 202 * @since 9 203 * @syscap SystemCapability.Multimedia.Image.Core 204 */ 205 SCENE_TYPE = "SceneType", 206 207 /** 208 * ISO speedratings 209 * @since 9 210 * @syscap SystemCapability.Multimedia.Image.Core 211 */ 212 ISO_SPEED_RATINGS = "ISOSpeedRatings", 213 214 /** 215 * Aperture value 216 * @since 9 217 * @syscap SystemCapability.Multimedia.Image.Core 218 */ 219 F_NUMBER = "FNumber", 220 } 221 222 /** 223 * Enum for image formats. 224 * @since 9 225 * @syscap SystemCapability.Multimedia.Image.Core 226 */ 227 enum ImageFormat { 228 /** 229 * YCBCR422 semi-planar format. 230 * @since 9 231 * @syscap SystemCapability.Multimedia.Image.Core 232 */ 233 YCBCR_422_SP = 1000, 234 235 /** 236 * JPEG encoding format. 237 * @since 9 238 * @syscap SystemCapability.Multimedia.Image.Core 239 */ 240 JPEG = 2000 241 } 242 243 /** 244 * Enumerates alpha types. 245 * @since 9 246 * @syscap SystemCapability.Multimedia.Image.Core 247 */ 248 enum AlphaType { 249 /** 250 * Indicates an unknown alpha type. 251 * @since 9 252 * @syscap SystemCapability.Multimedia.Image.Core 253 */ 254 UNKNOWN = 0, 255 256 /** 257 * Indicates that the image has no alpha channel, or all pixels in the image are fully opaque. 258 * @since 9 259 * @syscap SystemCapability.Multimedia.Image.Core 260 */ 261 OPAQUE = 1, 262 263 /** 264 * Indicates that RGB components of each pixel in the image are premultiplied by alpha. 265 * @since 9 266 * @syscap SystemCapability.Multimedia.Image.Core 267 */ 268 PREMUL = 2, 269 270 /** 271 * Indicates that RGB components of each pixel in the image are independent of alpha and are not premultiplied by alpha. 272 * @since 9 273 * @syscap SystemCapability.Multimedia.Image.Core 274 */ 275 UNPREMUL = 3 276 } 277 278 /** 279 * Enum for image scale mode. 280 * @since 9 281 * @syscap SystemCapability.Multimedia.Image.Core 282 */ 283 enum ScaleMode { 284 /** 285 * Indicates the effect that fits the image into the target size. 286 * @since 9 287 * @syscap SystemCapability.Multimedia.Image.Core 288 */ 289 FIT_TARGET_SIZE = 0, 290 291 /** 292 * Indicates the effect that scales an image to fill the target image area and center-crops the part outside the area. 293 * @since 9 294 * @syscap SystemCapability.Multimedia.Image.Core 295 */ 296 CENTER_CROP = 1, 297 } 298 299 /** 300 * The component type of image. 301 * @since 9 302 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 303 */ 304 enum ComponentType { 305 /** 306 * Luma info. 307 * @since 9 308 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 309 */ 310 YUV_Y = 1, 311 312 /** 313 * Chrominance info. 314 * @since 9 315 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 316 */ 317 YUV_U = 2, 318 319 /** 320 * Chroma info. 321 * @since 9 322 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 323 */ 324 YUV_V = 3, 325 326 /** 327 * Jpeg type. 328 * @since 9 329 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 330 */ 331 JPEG = 4, 332 } 333 334 /** 335 * Describes region information. 336 * @since 8 337 * @syscap SystemCapability.Multimedia.Image.Core 338 */ 339 interface Region { 340 /** 341 * Image size. 342 * @since 7 343 * @syscap SystemCapability.Multimedia.Image.Core 344 */ 345 size: Size; 346 347 /** 348 * x-coordinate at the upper left corner of the image. 349 * @since 7 350 * @syscap SystemCapability.Multimedia.Image.Core 351 */ 352 x: number; 353 354 /** 355 * y-coordinate at the upper left corner of the image. 356 * @since 7 357 * @syscap SystemCapability.Multimedia.Image.Core 358 */ 359 y: number; 360 } 361 362 /** 363 * Describes area information in an image. 364 * @since 7 365 * @syscap SystemCapability.Multimedia.Image.Core 366 */ 367 interface PositionArea { 368 /** 369 * Image data that will be read or written. 370 * @since 7 371 * @syscap SystemCapability.Multimedia.Image.Core 372 */ 373 pixels: ArrayBuffer; 374 375 /** 376 * Offset for data reading. 377 * @since 7 378 * @syscap SystemCapability.Multimedia.Image.Core 379 */ 380 offset: number; 381 382 /** 383 * Number of bytes to read. 384 * @since 7 385 * @syscap SystemCapability.Multimedia.Image.Core 386 */ 387 stride: number; 388 389 /** 390 * Region to read. 391 * @since 7 392 * @syscap SystemCapability.Multimedia.Image.Core 393 */ 394 region: Region; 395 } 396 397 /** 398 * Describes image information. 399 * @since 6 400 * @syscap SystemCapability.Multimedia.Image.Core 401 */ 402 interface ImageInfo { 403 /** 404 * Indicates image dimensions specified by a {@link Size} interface. 405 * @since 6 406 * @syscap SystemCapability.Multimedia.Image.Core 407 */ 408 size: Size; 409 410 /** 411 * Indicates image default density. 412 * @since 9 413 * @syscap SystemCapability.Multimedia.Image.Core 414 */ 415 density: number; 416 } 417 418 /** 419 * Describes the option for image packing. 420 * @since 6 421 * @syscap SystemCapability.Multimedia.Image.ImagePacker 422 */ 423 interface PackingOption { 424 /** 425 * Multipurpose Internet Mail Extensions (MIME) format of the target image, for example, image/jpeg. 426 * @since 6 427 * @syscap SystemCapability.Multimedia.Image.ImagePacker 428 */ 429 format: string; 430 431 /** 432 * Quality of the target image. The value is an integer ranging from 0 to 100. A larger value indicates better. 433 * @since 6 434 * @syscap SystemCapability.Multimedia.Image.ImagePacker 435 */ 436 quality: number; 437 438 /** 439 * BufferSize of the target image. 440 * If this bufferSize is less than or equal to 0, it will be converted to 10MB. 441 * @since 9 442 * @syscap SystemCapability.Multimedia.Image.ImagePacker 443 */ 444 bufferSize?: number; 445 } 446 447 /** 448 * Describes image properties. 449 * @since 7 450 * @syscap SystemCapability.Multimedia.Image.ImageSource 451 */ 452 interface GetImagePropertyOptions { 453 /** 454 * Index of an image. 455 * @since 7 456 * @syscap SystemCapability.Multimedia.Image.ImageSource 457 */ 458 index?: number; 459 460 /** 461 * Default property value. 462 * @since 7 463 * @syscap SystemCapability.Multimedia.Image.ImageSource 464 */ 465 defaultValue?: string; 466 } 467 468 /** 469 * Describes image decoding parameters. 470 * @since 7 471 * @syscap SystemCapability.Multimedia.Image.ImageSource 472 */ 473 interface DecodingOptions { 474 /** 475 * Number of image frames. 476 * @since 7 477 * @syscap SystemCapability.Multimedia.Image.ImageSource 478 */ 479 index?: number; 480 481 /** 482 * Sampling ratio of the image pixel map. 483 * @since 7 484 * @syscap SystemCapability.Multimedia.Image.ImageSource 485 */ 486 sampleSize?: number; 487 488 /** 489 * Rotation angle of the image pixel map. The value ranges from 0 to 360. 490 * @since 7 491 * @syscap SystemCapability.Multimedia.Image.ImageSource 492 */ 493 rotate?: number; 494 495 /** 496 * Whether the image pixel map is editable. 497 * @since 7 498 * @syscap SystemCapability.Multimedia.Image.ImageSource 499 */ 500 editable?: boolean; 501 502 /** 503 * Width and height of the image pixel map. The value (0, 0) indicates that the pixels are decoded 504 * based on the original image size. 505 * @since 7 506 * @syscap SystemCapability.Multimedia.Image.ImageSource 507 */ 508 desiredSize?: Size; 509 510 /** 511 * Cropping region of the image pixel map. 512 * @since 7 513 * @syscap SystemCapability.Multimedia.Image.ImageSource 514 */ 515 desiredRegion?: Region; 516 517 /** 518 * Data format of the image pixel map. 519 * @since 7 520 * @syscap SystemCapability.Multimedia.Image.ImageSource 521 */ 522 desiredPixelFormat?: PixelMapFormat; 523 524 /** 525 * The density for image pixel map. 526 * @since 9 527 * @syscap SystemCapability.Multimedia.Image.ImageSource 528 */ 529 fitDensity?: number; 530 } 531 532 /** 533 * Describes image color components. 534 * @since 9 535 * @syscap SystemCapability.Multimedia.Image.Core 536 */ 537 interface Component { 538 /** 539 * Component type. 540 * @since 9 541 * @syscap SystemCapability.Multimedia.Image.Core 542 */ 543 readonly componentType: ComponentType; 544 545 /** 546 * Row stride. 547 * @since 9 548 * @syscap SystemCapability.Multimedia.Image.Core 549 */ 550 readonly rowStride: number; 551 552 /** 553 * Pixel stride. 554 * @since 9 555 * @syscap SystemCapability.Multimedia.Image.Core 556 */ 557 readonly pixelStride: number; 558 559 /** 560 * Component buffer. 561 * @since 9 562 * @syscap SystemCapability.Multimedia.Image.Core 563 */ 564 readonly byteBuffer: ArrayBuffer; 565 } 566 567 /** 568 * Initialization options for pixelmap. 569 * @since 8 570 * @syscap SystemCapability.Multimedia.Image.Core 571 */ 572 interface InitializationOptions { 573 /** 574 * PixelMap size. 575 * @since 8 576 * @syscap SystemCapability.Multimedia.Image.Core 577 */ 578 size: Size; 579 580 /** 581 * PixelMap expected format. 582 * @since 8 583 * @syscap SystemCapability.Multimedia.Image.Core 584 */ 585 pixelFormat?: PixelMapFormat; 586 587 /** 588 * Editable or not. 589 * @since 8 590 * @syscap SystemCapability.Multimedia.Image.Core 591 */ 592 editable?: boolean; 593 594 /** 595 * PixelMap expected alpha type. 596 * @since 9 597 * @syscap SystemCapability.Multimedia.Image.Core 598 */ 599 alphaType?: AlphaType; 600 601 /** 602 * PixelMap expected scaling effect. 603 * @since 9 604 * @syscap SystemCapability.Multimedia.Image.Core 605 */ 606 scaleMode?: ScaleMode; 607 } 608 609 /** 610 * Initialization options for ImageSource. 611 * @since 9 612 * @syscap SystemCapability.Multimedia.Image.Core 613 */ 614 interface SourceOptions { 615 /** 616 * The density for ImageSource. 617 * @since 9 618 * @syscap SystemCapability.Multimedia.Image.Core 619 */ 620 sourceDensity: number; 621 622 /** 623 * PixelMap expected format. 624 * @since 9 625 * @syscap SystemCapability.Multimedia.Image.Core 626 */ 627 sourcePixelFormat?: PixelMapFormat; 628 629 /** 630 * PixelMap size. 631 * @since 9 632 * @syscap SystemCapability.Multimedia.Image.Core 633 */ 634 sourceSize?: Size; 635 } 636 637 /** 638 * Create pixelmap by data buffer. 639 * @since 8 640 * @syscap SystemCapability.Multimedia.Image.Core 641 */ 642 function createPixelMap(colors: ArrayBuffer, options: InitializationOptions, callback: AsyncCallback<PixelMap>): void; 643 644 /** 645 * Create pixelmap by data buffer. 646 * @since 8 647 * @syscap SystemCapability.Multimedia.Image.Core 648 */ 649 function createPixelMap(colors: ArrayBuffer, options: InitializationOptions): Promise<PixelMap>; 650 651 /** 652 * Creates an ImageSource instance based on the URI. 653 * @since 6 654 * @syscap SystemCapability.Multimedia.Image.ImageSource 655 * @param uri Image source URI. 656 * @returns Returns the ImageSource instance if the operation is successful; returns null otherwise. 657 */ 658 function createImageSource(uri: string): ImageSource; 659 660 /** 661 * Creates an ImageSource instance based on the URI. 662 * @since 9 663 * @syscap SystemCapability.Multimedia.Image.ImageSource 664 * @param uri Image source URI. 665 * @param options The config of Image source. 666 * @returns Returns the ImageSource instance if the operation is successful; returns null otherwise. 667 */ 668 function createImageSource(uri: string, options: SourceOptions): ImageSource; 669 670 /** 671 * Creates an ImageSource instance based on the file descriptor. 672 * @since 7 673 * @syscap SystemCapability.Multimedia.Image.ImageSource 674 * @param fd ID of a file descriptor. 675 * @returns Returns the ImageSource instance if the operation is successful; returns null otherwise. 676 */ 677 function createImageSource(fd: number): ImageSource; 678 679 /** 680 * Creates an ImageSource instance based on the file descriptor. 681 * @since 9 682 * @syscap SystemCapability.Multimedia.Image.ImageSource 683 * @param fd ID of a file descriptor. 684 * @param options The config of Image source. 685 * @returns Returns the ImageSource instance if the operation is successful; returns null otherwise. 686 */ 687 function createImageSource(fd: number, options: SourceOptions): ImageSource; 688 689 /** 690 * Creates an ImageSource instance based on the buffer. 691 * @since 9 692 * @syscap SystemCapability.Multimedia.Image.ImageSource 693 * @param buf The buffer of the image. 694 * @returns Returns the ImageSource instance if the operation is successful; returns null otherwise. 695 */ 696 function createImageSource(buf: ArrayBuffer): ImageSource; 697 698 /** 699 * Creates an ImageSource instance based on the buffer. 700 * @since 9 701 * @syscap SystemCapability.Multimedia.Image.ImageSource 702 * @param buf The buffer of the image. 703 * @param options The config of Image source. 704 * @returns Returns the ImageSource instance if the operation is successful; returns null otherwise. 705 */ 706 function createImageSource(buf: ArrayBuffer, options: SourceOptions): ImageSource; 707 708 /** 709 * Creates an ImageSource instance based on the buffer in incremental. 710 * @since 9 711 * @syscap SystemCapability.Multimedia.Image.ImageSource 712 * @param buf The buffer of the image. 713 * @returns Returns the ImageSource instance if the operation is successful; returns null otherwise. 714 */ 715 function CreateIncrementalSource(buf: ArrayBuffer): ImageSource; 716 717 /** 718 * Creates an ImageSource instance based on the buffer in incremental. 719 * @since 9 720 * @syscap SystemCapability.Multimedia.Image.ImageSource 721 * @param buf The buffer of the image. 722 * @param options The config of source. 723 * @returns Returns the ImageSource instance if the operation is successful; returns null otherwise. 724 */ 725 function CreateIncrementalSource(buf: ArrayBuffer, options?: SourceOptions): ImageSource; 726 727 /** 728 * Creates an ImagePacker instance. 729 * @since 6 730 * @syscap SystemCapability.Multimedia.Image.ImagePacker 731 * @returns Returns the ImagePacker instance if the operation is successful; returns null otherwise. 732 */ 733 function createImagePacker(): ImagePacker; 734 735 /** 736 * Creates an ImageReceiver instance. 737 * @since 9 738 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 739 * @param width The default width in pixels of the Images that this receiver will produce. 740 * @param height The default height in pixels of the Images that this receiver will produce. 741 * @param format The format of the Image that this receiver will produce. This must be one of the 742 * {@link ImageFormat} constants. Note that not all formats are supported, like ImageFormat.NV21. 743 * @param capacity The maximum number of images the user will want to access simultaneously. 744 * @returns Returns the ImageReceiver instance if the operation is successful; returns null otherwise. 745 */ 746 function createImageReceiver(width: number, height: number, format: number, capacity: number): ImageReceiver; 747 748 /** 749 * Creates an ImageCreator instance. 750 * @since 9 751 * @syscap SystemCapability.Multimedia.Image.ImageCreator 752 * @param width The default width in pixels of the Images that this creator will produce. 753 * @param height The default height in pixels of the Images that this creator will produce. 754 * @param format The format of the Image that this creator will produce. This must be one of the 755 * {@link ImageFormat} constants. Note that not all formats are supported, like ImageFormat.NV21. 756 * @param capacity The maximum number of images the user will want to access simultaneously. 757 * @returns Returns the ImageCreator instance if the operation is successful; returns null otherwise. 758 */ 759 function createImageCreator(width: number, height: number, format: number, capacity: number): ImageCreator; 760 761 /** 762 * PixelMap instance. 763 * @since 7 764 * @syscap SystemCapability.Multimedia.Image.Core 765 */ 766 interface PixelMap { 767 /** 768 * Whether the image pixel map can be edited. 769 * @since 7 770 * @syscap SystemCapability.Multimedia.Image.Core 771 */ 772 readonly isEditable: boolean; 773 774 /** 775 * Reads image pixel map data and writes the data to an ArrayBuffer. This method uses 776 * a promise to return the result. 777 * @since 7 778 * @syscap SystemCapability.Multimedia.Image.Core 779 * @param dst A buffer to which the image pixel map data will be written. 780 * @returns A Promise instance used to return the operation result. If the operation fails, an error message is returned. 781 */ 782 readPixelsToBuffer(dst: ArrayBuffer): Promise<void>; 783 784 /** 785 * Reads image pixel map data and writes the data to an ArrayBuffer. This method uses 786 * a callback to return the result. 787 * @since 7 788 * @syscap SystemCapability.Multimedia.Image.Core 789 * @param dst A buffer to which the image pixel map data will be written. 790 * @param callback Callback used to return the operation result. If the operation fails, an error message is returned. 791 */ 792 readPixelsToBuffer(dst: ArrayBuffer, callback: AsyncCallback<void>): void; 793 794 /** 795 * Reads image pixel map data in an area. This method uses a promise to return the data read. 796 * @since 7 797 * @syscap SystemCapability.Multimedia.Image.Core 798 * @param area Area from which the image pixel map data will be read. 799 * @returns A Promise instance used to return the operation result. If the operation fails, an error message is returned. 800 */ 801 readPixels(area: PositionArea): Promise<void>; 802 803 /** 804 * Reads image pixel map data in an area. This method uses a callback to return the data read. 805 * @since 7 806 * @syscap SystemCapability.Multimedia.Image.Core 807 * @param area Area from which the image pixel map data will be read. 808 * @param callback Callback used to return the operation result. If the operation fails, an error message is returned. 809 */ 810 readPixels(area: PositionArea, callback: AsyncCallback<void>): void; 811 812 /** 813 * Writes image pixel map data to the specified area. This method uses a promise to return 814 * the operation result. 815 * @since 7 816 * @syscap SystemCapability.Multimedia.Image.Core 817 * @param area Area to which the image pixel map data will be written. 818 * @returns A Promise instance used to return the operation result. If the operation fails, an error message is returned. 819 */ 820 writePixels(area: PositionArea): Promise<void>; 821 822 /** 823 * Writes image pixel map data to the specified area. This method uses a callback to return 824 * the operation result. 825 * @since 7 826 * @syscap SystemCapability.Multimedia.Image.Core 827 * @param area Area to which the image pixel map data will be written. 828 * @param callback Callback used to return the operation result. If the operation fails, an error message is returned. 829 */ 830 writePixels(area: PositionArea, callback: AsyncCallback<void>): void; 831 832 /** 833 * Reads image data in an ArrayBuffer and writes the data to a PixelMap object. This method 834 * uses a promise to return the result. 835 * @since 7 836 * @syscap SystemCapability.Multimedia.Image.Core 837 * @param src A buffer from which the image data will be read. 838 * @returns A Promise instance used to return the operation result. If the operation fails, an error message is returned. 839 */ 840 writeBufferToPixels(src: ArrayBuffer): Promise<void>; 841 842 /** 843 * Reads image data in an ArrayBuffer and writes the data to a PixelMap object. This method 844 * uses a callback to return the result. 845 * @since 7 846 * @syscap SystemCapability.Multimedia.Image.Core 847 * @param src A buffer from which the image data will be read. 848 * @param callback Callback used to return the operation result. If the operation fails, an error message is returned. 849 */ 850 writeBufferToPixels(src: ArrayBuffer, callback: AsyncCallback<void>): void; 851 852 /** 853 * Obtains pixel map information about this image. This method uses a promise to return the information. 854 * @since 7 855 * @syscap SystemCapability.Multimedia.Image.Core 856 * @returns A Promise instance used to return the image pixel map information. If the operation fails, an error message is returned. 857 */ 858 getImageInfo(): Promise<ImageInfo>; 859 860 /** 861 * Obtains pixel map information about this image. This method uses a callback to return the information. 862 * @since 7 863 * @syscap SystemCapability.Multimedia.Image.Core 864 * @param callback Callback used to return the image pixel map information. If the operation fails, an error message is returned. 865 */ 866 getImageInfo(callback: AsyncCallback<ImageInfo>): void; 867 868 /** 869 * Obtains the number of bytes in each line of the image pixel map. 870 * @since 7 871 * @syscap SystemCapability.Multimedia.Image.Core 872 * @returns Number of bytes in each line. 873 */ 874 getBytesNumberPerRow(): number; 875 876 /** 877 * Obtains the total number of bytes of the image pixel map. 878 * @since 7 879 * @syscap SystemCapability.Multimedia.Image.Core 880 * @returns Total number of bytes. 881 */ 882 getPixelBytesNumber(): number; 883 884 /** 885 * Obtains the density of the image pixel map. 886 * @since 9 887 * @syscap SystemCapability.Multimedia.Image.Core 888 * @returns The number of density. 889 */ 890 getDensity():number; 891 892 /** 893 * Set the transparent rate of pixel map. This method uses a callback to return the operation result. 894 * @since 9 895 * @syscap SystemCapability.Multimedia.Image.Core 896 * @param rate The value of transparent rate. 897 * @param callback Callback used to return the operation result. If the operation fails, an error message is returned. 898 */ 899 opacity(rate: number, callback: AsyncCallback<void>): void; 900 901 /** 902 * Set the transparent rate of pixel map. This method uses a promise to return the result. 903 * @since 9 904 * @syscap SystemCapability.Multimedia.Image.Core 905 * @param rate The value of transparent rate. 906 * @returns A Promise instance used to return the operation result. If the operation fails, an error message is returned. 907 */ 908 opacity(rate: number): Promise<void>; 909 910 /** 911 * Obtains new pixel map with alpha information. This method uses a promise to return the information. 912 * @since 9 913 * @syscap SystemCapability.Multimedia.Image.Core 914 * @returns A Promise instance used to return the new image pixel map. If the operation fails, an error message is returned. 915 */ 916 createAlphaPixelmap(): Promise<PixelMap>; 917 918 /** 919 * Obtains new pixel map with alpha information. This method uses a callback to return the information. 920 * @since 9 921 * @syscap SystemCapability.Multimedia.Image.Core 922 * @param callback Callback used to return the new image pixel map. If the operation fails, an error message is returned. 923 */ 924 createAlphaPixelmap(callback: AsyncCallback<PixelMap>): void; 925 926 /** 927 * Image zoom in width and height. This method uses a callback to return the operation result. 928 * @since 9 929 * @syscap SystemCapability.Multimedia.Image.Core 930 * @param x The zoom value of width. 931 * @param y The zoom value of height. 932 * @param callback Callback used to return the operation result. If the operation fails, an error message is returned. 933 */ 934 scale(x: number, y: number, callback: AsyncCallback<void>): void; 935 936 /** 937 * Image zoom in width and height. This method uses a promise to return the result. 938 * @since 9 939 * @syscap SystemCapability.Multimedia.Image.Core 940 * @param x The zoom value of width. 941 * @param y The zoom value of height. 942 * @returns A Promise instance used to return the operation result. If the operation fails, an error message is returned. 943 */ 944 scale(x: number, y: number): Promise<void>; 945 946 /** 947 * Image position transformation. This method uses a callback to return the operation result. 948 * @since 9 949 * @syscap SystemCapability.Multimedia.Image.Core 950 * @param x The position value of width. 951 * @param y The position value of height. 952 * @param callback Callback used to return the operation result. If the operation fails, an error message is returned. 953 */ 954 translate(x: number, y: number, callback: AsyncCallback<void>): void; 955 956 /** 957 * Image position transformation. This method uses a promise to return the result. 958 * @since 9 959 * @syscap SystemCapability.Multimedia.Image.Core 960 * @param x The position value of width. 961 * @param y The position value of height. 962 * @returns A Promise instance used to return the operation result. If the operation fails, an error message is returned. 963 */ 964 translate(x: number, y: number): Promise<void>; 965 966 /** 967 * Image rotation. This method uses a callback to return the operation result. 968 * @since 9 969 * @syscap SystemCapability.Multimedia.Image.Core 970 * @param angle The rotation angle. 971 * @param callback Callback used to return the operation result. If the operation fails, an error message is returned. 972 */ 973 rotate(angle: number, callback: AsyncCallback<void>): void; 974 975 /** 976 * Image rotation. This method uses a promise to return the result. 977 * @since 9 978 * @syscap SystemCapability.Multimedia.Image.Core 979 * @param angle The rotation angle. 980 * @returns A Promise instance used to return the operation result. If the operation fails, an error message is returned. 981 */ 982 rotate(angle: number): Promise<void>; 983 984 /** 985 * Image flipping. This method uses a callback to return the operation result. 986 * @since 9 987 * @syscap SystemCapability.Multimedia.Image.Core 988 * @param horizontal Is flip in horizontal. 989 * @param vertical Is flip in vertical. 990 * @param callback Callback used to return the operation result. If the operation fails, an error message is returned. 991 */ 992 flip(horizontal: boolean, vertical: boolean, callback: AsyncCallback<void>): void; 993 994 /** 995 * Image flipping. This method uses a promise to return the result. 996 * @since 9 997 * @syscap SystemCapability.Multimedia.Image.Core 998 * @param horizontal Is flip in horizontal. 999 * @param vertical Is flip in vertical. 1000 * @returns A Promise instance used to return the operation result. If the operation fails, an error message is returned. 1001 */ 1002 flip(horizontal: boolean, vertical: boolean): Promise<void>; 1003 1004 /** 1005 * Crop the image. This method uses a callback to return the operation result. 1006 * @since 9 1007 * @syscap SystemCapability.Multimedia.Image.Core 1008 * @param region The region to crop. 1009 * @param callback Callback used to return the operation result. If the operation fails, an error message is returned. 1010 */ 1011 crop(region: Region, callback: AsyncCallback<void>): void; 1012 1013 /** 1014 * Crop the image. This method uses a promise to return the result. 1015 * @since 9 1016 * @syscap SystemCapability.Multimedia.Image.Core 1017 * @param region The region to crop. 1018 * @returns A Promise instance used to return the operation result. If the operation fails, an error message is returned. 1019 */ 1020 crop(region: Region): Promise<void>; 1021 1022 /** 1023 * Releases this PixelMap object. This method uses a callback to return the result. 1024 * @since 7 1025 * @syscap SystemCapability.Multimedia.Image.Core 1026 * @param callback Callback invoked for instance release. If the operation fails, an error message is returned. 1027 */ 1028 release(callback: AsyncCallback<void>): void; 1029 1030 /** 1031 * Releases this PixelMap object. This method uses a promise to return the result. 1032 * @since 7 1033 * @syscap SystemCapability.Multimedia.Image.Core 1034 * @returns A Promise instance used to return the instance release result. If the operation fails, an error message is returned. 1035 */ 1036 release(): Promise<void>; 1037 } 1038 1039 /** 1040 * ImageSource instance. 1041 * @since 6 1042 * @syscap SystemCapability.Multimedia.Image.ImageSource 1043 */ 1044 interface ImageSource { 1045 /** 1046 * Obtains information about an image with the specified sequence number and uses a callback 1047 * to return the result. 1048 * @since 6 1049 * @syscap SystemCapability.Multimedia.Image.ImageSource 1050 * @param index Sequence number of an image. 1051 * @param callback Callback used to return the image information. 1052 */ 1053 getImageInfo(index: number, callback: AsyncCallback<ImageInfo>): void; 1054 1055 /** 1056 * Obtains information about this image and uses a callback to return the result. 1057 * @since 6 1058 * @syscap SystemCapability.Multimedia.Image.ImageSource 1059 * @param callback Callback used to return the image information. 1060 */ 1061 getImageInfo(callback: AsyncCallback<ImageInfo>): void; 1062 1063 /** 1064 * Get image information from image source. 1065 * @since 6 1066 * @syscap SystemCapability.Multimedia.Image.ImageSource 1067 * @param index Sequence number of an image. If this parameter is not specified, the default value 0 is used. 1068 * @returns A Promise instance used to return the image information. 1069 */ 1070 getImageInfo(index?: number): Promise<ImageInfo>; 1071 1072 /** 1073 * Creates a PixelMap object based on image decoding parameters. This method uses a promise to 1074 * return the object. 1075 * @since 7 1076 * @syscap SystemCapability.Multimedia.Image.ImageSource 1077 * @param options Image decoding parameters. 1078 * @returns A Promise instance used to return the PixelMap object. 1079 */ 1080 createPixelMap(options?: DecodingOptions): Promise<PixelMap>; 1081 1082 /** 1083 * Creates a PixelMap object. This method uses a callback to return the object. 1084 * @since 7 1085 * @syscap SystemCapability.Multimedia.Image.ImageSource 1086 * @param callback Callback used to return the PixelMap object. 1087 */ 1088 createPixelMap(callback: AsyncCallback<PixelMap>): void; 1089 1090 /** 1091 * Creates a PixelMap object based on image decoding parameters. This method uses a callback to 1092 * return the object. 1093 * @since 7 1094 * @syscap SystemCapability.Multimedia.Image.ImageSource 1095 * @param options Image decoding parameters. 1096 * @param callback Callback used to return the PixelMap object. 1097 */ 1098 createPixelMap(options: DecodingOptions, callback: AsyncCallback<PixelMap>): void; 1099 1100 /** 1101 * Obtains the value of a property in an image with the specified index. This method uses a 1102 * promise to return the property value in a string. 1103 * @since 7 1104 * @syscap SystemCapability.Multimedia.Image.ImageSource 1105 * @param key Name of the property whose value is to be obtained. 1106 * @param options Index of the image. 1107 * @returns A Promise instance used to return the property value. If the operation fails, the default value is returned. 1108 */ 1109 getImageProperty(key: string, options?: GetImagePropertyOptions): Promise<string>; 1110 1111 /** 1112 * Obtains the value of a property in this image. This method uses a callback to return the 1113 * property value in a string. 1114 * @since 7 1115 * @syscap SystemCapability.Multimedia.Image.ImageSource 1116 * @param key Name of the property whose value is to be obtained. 1117 * @param callback Callback used to return the property value. If the operation fails, an error message is returned. 1118 */ 1119 getImageProperty(key: string, callback: AsyncCallback<string>): void; 1120 1121 /** 1122 * Obtains the value of a property in an image with the specified index. This method uses 1123 * a callback to return the property value in a string. 1124 * @since 7 1125 * @syscap SystemCapability.Multimedia.Image.ImageSource 1126 * @param key Name of the property whose value is to be obtained. 1127 * @param options Index of the image. 1128 * @param callback Callback used to return the property value. If the operation fails, the default value is returned. 1129 */ 1130 getImageProperty(key: string, options: GetImagePropertyOptions, callback: AsyncCallback<string>): void; 1131 1132 /** 1133 * Modify the value of a property in an image with the specified key. This method uses a 1134 * promise to return the property value in a string. 1135 * @since 9 1136 * @syscap SystemCapability.Multimedia.Image.ImageSource 1137 * @param key Name of the property whose value is to be modified. 1138 * @param value The value to be set to property. 1139 * @returns A Promise instance used to return the property value. 1140 */ 1141 modifyImageProperty(key: string, value: string): Promise<void>; 1142 1143 /** 1144 * Modify the value of a property in an image with the specified key. This method uses a callback to return the 1145 * property value in a string. 1146 * @since 9 1147 * @syscap SystemCapability.Multimedia.Image.ImageSource 1148 * @param key Name of the property whose value is to be obtained. 1149 * @param value The value to be set to property. 1150 * @param callback Callback to return the operation result. 1151 */ 1152 modifyImageProperty(key: string, value: string, callback: AsyncCallback<void>): void; 1153 1154 /** 1155 * Update the data in the incremental ImageSource. 1156 * @since 9 1157 * @syscap SystemCapability.Multimedia.Image.ImageSource 1158 * @param buf The data to be updated. 1159 * @param isFinished If is it finished. 1160 * @param value The offset of data. 1161 * @param length The length fo buf. 1162 * @returns A Promise instance used to return the property value. 1163 */ 1164 updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number): Promise<void>; 1165 1166 /** 1167 * Update the data in the incremental ImageSource. 1168 * @since 9 1169 * @syscap SystemCapability.Multimedia.Image.ImageSource 1170 * @param buf The data to be updated. 1171 * @param isFinished If is it finished. 1172 * @param value The offset of data. 1173 * @param length The length fo buf. 1174 * @param callback Callback to return the operation result. 1175 */ 1176 updateData(buf: ArrayBuffer, isFinished: boolean, value: number, length: number, callback: AsyncCallback<void>): void; 1177 1178 /** 1179 * Releases an ImageSource instance and uses a callback to return the result. 1180 * @since 6 1181 * @syscap SystemCapability.Multimedia.Image.ImageSource 1182 * @param callback Callback to return the operation result. 1183 */ 1184 release(callback: AsyncCallback<void>): void; 1185 1186 /** 1187 * Releases an ImageSource instance and uses a promise to return the result. 1188 * @since 6 1189 * @syscap SystemCapability.Multimedia.Image.ImageSource 1190 * @returns A Promise instance used to return the operation result. 1191 */ 1192 release(): Promise<void>; 1193 1194 /** 1195 * Supported image formats. 1196 * @since 6 1197 * @syscap SystemCapability.Multimedia.Image.ImageSource 1198 */ 1199 readonly supportedFormats: Array<string>; 1200 } 1201 1202 /** 1203 * ImagePacker instance. 1204 * @since 6 1205 * @syscap SystemCapability.Multimedia.Image.ImagePacker 1206 */ 1207 interface ImagePacker { 1208 /** 1209 * Compresses or packs an image and uses a callback to return the result. 1210 * @since 6 1211 * @syscap SystemCapability.Multimedia.Image.ImagePacker 1212 * @param source Image to be processed. 1213 * @param option Option for image packing. 1214 * @param callback Callback used to return the packed data. 1215 */ 1216 packing(source: ImageSource, option: PackingOption, callback: AsyncCallback<ArrayBuffer>): void; 1217 1218 /** 1219 * Compresses or packs an image and uses a promise to return the result. 1220 * @since 6 1221 * @syscap SystemCapability.Multimedia.Image.ImagePacker 1222 * @param source Image to be processed. 1223 * @param option Option for image packing. 1224 * @returns A Promise instance used to return the compressed or packed data. 1225 */ 1226 packing(source: ImageSource, option: PackingOption): Promise<ArrayBuffer>; 1227 1228 /** 1229 * Compresses or packs an image and uses a callback to return the result. 1230 * @since 8 1231 * @syscap SystemCapability.Multimedia.Image.ImagePacker 1232 * @param source PixelMap to be processed. 1233 * @param option Option for image packing. 1234 * @param callback Callback used to return the packed data. 1235 */ 1236 packing(source: PixelMap, option: PackingOption, callback: AsyncCallback<ArrayBuffer>): void; 1237 1238 /** 1239 * Compresses or packs an image and uses a promise to return the result. 1240 * @since 8 1241 * @syscap SystemCapability.Multimedia.Image.ImagePacker 1242 * @param source PixelMap to be processed. 1243 * @param option Option for image packing. 1244 * @returns A Promise instance used to return the compressed or packed data. 1245 */ 1246 packing(source: PixelMap, option: PackingOption): Promise<ArrayBuffer>; 1247 1248 /** 1249 * Releases an ImagePacker instance and uses a callback to return the result. 1250 * @since 6 1251 * @syscap SystemCapability.Multimedia.Image.ImagePacker 1252 * @param callback Callback to return the operation result. 1253 */ 1254 release(callback: AsyncCallback<void>): void; 1255 1256 /** 1257 * Releases an ImagePacker instance and uses a promise to return the result. 1258 * @since 6 1259 * @syscap SystemCapability.Multimedia.Image.ImagePacker 1260 * @returns A Promise instance used to return the operation result. 1261 */ 1262 release(): Promise<void>; 1263 1264 /** 1265 * Supported image formats. 1266 * @since 6 1267 * @syscap SystemCapability.Multimedia.Image.ImagePacker 1268 */ 1269 readonly supportedFormats: Array<string>; 1270 } 1271 1272 /** 1273 * Provides basic image operations, including obtaining image information, and reading and writing image data. 1274 * @since 9 1275 * @syscap SystemCapability.Multimedia.Image.Core 1276 */ 1277 interface Image { 1278 /** 1279 * Sets or gets the image area to crop, default is size. 1280 * @since 9 1281 * @syscap SystemCapability.Multimedia.Image.Core 1282 */ 1283 clipRect: Region; 1284 1285 /** 1286 * Image size. 1287 * @since 9 1288 * @syscap SystemCapability.Multimedia.Image.Core 1289 */ 1290 readonly size: Size; 1291 1292 /** 1293 * Image format. 1294 * @since 9 1295 * @syscap SystemCapability.Multimedia.Image.Core 1296 */ 1297 readonly format: number; 1298 1299 /** 1300 * Get component buffer from image and uses a callback to return the result. 1301 * @since 9 1302 * @syscap SystemCapability.Multimedia.Image.Core 1303 * @param componentType The component type of image. 1304 * @param callback Callback used to return the component buffer. 1305 */ 1306 getComponent(componentType: ComponentType, callback: AsyncCallback<Component>): void; 1307 1308 /** 1309 * Get component buffer from image and uses a promise to return the result. 1310 * @since 9 1311 * @syscap SystemCapability.Multimedia.Image.Core 1312 * @param componentType The component type of image. 1313 * @returns A Promise instance used to return the component buffer. 1314 */ 1315 getComponent(componentType: ComponentType): Promise<Component>; 1316 1317 /** 1318 * Release current image to receive another and uses a callback to return the result. 1319 * @since 9 1320 * @syscap SystemCapability.Multimedia.Image.Core 1321 * @param callback Callback to return the operation result. 1322 */ 1323 release(callback: AsyncCallback<void>): void; 1324 1325 /** 1326 * Release current image to receive another and uses a promise to return the result. 1327 * @since 9 1328 * @syscap SystemCapability.Multimedia.Image.Core 1329 * @returns A Promise instance used to return the operation result. 1330 */ 1331 release(): Promise<void>; 1332 } 1333 1334 /** 1335 * Image receiver object. 1336 * @since 9 1337 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 1338 */ 1339 interface ImageReceiver { 1340 /** 1341 * Image size. 1342 * @since 9 1343 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 1344 */ 1345 readonly size: Size; 1346 1347 /** 1348 * Image capacity. 1349 * @since 9 1350 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 1351 */ 1352 readonly capacity: number; 1353 1354 /** 1355 * Image format. 1356 * @since 9 1357 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 1358 */ 1359 readonly format: ImageFormat; 1360 1361 /** 1362 * Get an id which indicates a surface and can be used to set to Camera or other component can receive a surface 1363 * and uses a callback to return the result. 1364 * @since 9 1365 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 1366 * @param callback Callback used to return the surface id. 1367 */ 1368 getReceivingSurfaceId(callback: AsyncCallback<string>): void; 1369 1370 /** 1371 * Get an id which indicates a surface and can be used to set to Camera or other component can receive a surface 1372 * and uses a promise to return the result. 1373 * @since 9 1374 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 1375 * @returns A Promise instance used to return the surface id. 1376 */ 1377 getReceivingSurfaceId(): Promise<string>; 1378 1379 /** 1380 * Get lasted image from receiver and uses a callback to return the result. 1381 * @since 9 1382 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 1383 * @param callback Callback used to return the latest image. 1384 */ 1385 readLatestImage(callback: AsyncCallback<Image>): void; 1386 1387 /** 1388 * Get lasted image from receiver and uses a promise to return the result. 1389 * @since 9 1390 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 1391 * @returns A Promise instance used to return the latest image. 1392 */ 1393 readLatestImage(): Promise<Image>; 1394 1395 /** 1396 * Get next image from receiver and uses a callback to return the result. 1397 * @since 9 1398 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 1399 * @param callback Callback used to return the next image. 1400 */ 1401 readNextImage(callback: AsyncCallback<Image>): void; 1402 1403 /** 1404 * Get next image from receiver and uses a promise to return the result. 1405 * @since 9 1406 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 1407 * @returns A Promise instance used to return the next image. 1408 */ 1409 readNextImage(): Promise<Image>; 1410 1411 /** 1412 * Subscribe callback when receiving an image 1413 * @since 9 1414 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 1415 * @param type Callback used to return the next image. 1416 * @param callback Callback used to return image. 1417 */ 1418 on(type: 'imageArrival', callback: AsyncCallback<void>): void; 1419 1420 /** 1421 * Release image receiver instance and uses a callback to return the result. 1422 * @since 9 1423 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 1424 * @param callback Callback to return the operation result. 1425 */ 1426 release(callback: AsyncCallback<void>): void; 1427 1428 /** 1429 * Release image receiver instance and uses a promise to return the result. 1430 * @since 9 1431 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 1432 * @returns A Promise instance used to return the operation result. 1433 */ 1434 release(): Promise<void>; 1435 } 1436 1437 /** 1438 * Image creator object. 1439 * @since 9 1440 * @syscap SystemCapability.Multimedia.Image.ImageCreator 1441 */ 1442 interface ImageCreator { 1443 /** 1444 * Image capacity. 1445 * @since 9 1446 * @syscap SystemCapability.Multimedia.Image.ImageCreator 1447 */ 1448 readonly capacity: number; 1449 1450 /** 1451 * Image format. 1452 * @since 9 1453 * @syscap SystemCapability.Multimedia.Image.ImageCreator 1454 */ 1455 readonly format: ImageFormat; 1456 1457 /** 1458 * Apply for new graphic buffer from free queue and use a callback to return the result. 1459 * @since 9 1460 * @syscap SystemCapability.Multimedia.Image.ImageCreator 1461 * @param callback Callback to return the operation result. 1462 */ 1463 dequeueImage(callback: AsyncCallback<Image>): void; 1464 1465 /** 1466 * Apply for new graphic buffer from free queue and uses a promise to return the result. 1467 * @since 9 1468 * @syscap SystemCapability.Multimedia.Image.ImageCreator 1469 * @returns A Promise instance used to return the operation result. 1470 */ 1471 dequeueImage(): Promise<Image>; 1472 1473 /** 1474 * Queue buffer to dirty queue and uses a callback to return the result. 1475 * @since 9 1476 * @syscap SystemCapability.Multimedia.Image.ImageCreator 1477 * @param callback Callback to return the operation result. 1478 */ 1479 queueImage(interface: Image, callback: AsyncCallback<void>): void; 1480 1481 /** 1482 * Queue buffer to dirty queue and uses a promise to return the result. 1483 * @since 9 1484 * @syscap SystemCapability.Multimedia.Image.ImageCreator 1485 * @returns A Promise instance used to return the operation result. 1486 */ 1487 queueImage(interface: Image): Promise<void>; 1488 1489 /** 1490 * Subscribe callback when releasing buffer 1491 * @since 9 1492 * @syscap SystemCapability.Multimedia.Image.ImageCreator 1493 * @param type Callback used to return the operation result. 1494 * @param callback Callback used to return the operation result. 1495 */ 1496 on(type: 'imageRelease', callback: AsyncCallback<void>): void; 1497 1498 /** 1499 * Releases buffer in bufferqueue instance and uses a callback to return the result. 1500 * @since 9 1501 * @syscap SystemCapability.Multimedia.Image.ImageCreator 1502 * @param callback Callback to return the operation result. 1503 */ 1504 release(callback: AsyncCallback<void>): void; 1505 1506 /** 1507 * Releases buffer in bufferqueue instance and uses a promise to return the result. 1508 * @since 9 1509 * @syscap SystemCapability.Multimedia.Image.ImageCreator 1510 * @returns A Promise instance used to return the operation result. 1511 */ 1512 release(): Promise<void>; 1513 } 1514} 1515 1516export default image; 1517