1/* 2 * Copyright (C) 2024 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 16/** 17 * @file 18 * @kit ImageKit 19 */ 20 21import { AsyncCallback } from './@ohos.base'; 22import type colorSpaceManager from './@ohos.graphics.colorSpaceManager'; 23import type image from './@ohos.multimedia.image'; 24import type resourceManager from './@ohos.resourceManager'; 25import type rpc from './@ohos.rpc'; 26import lang from '../arkts/@arkts.lang'; 27import collections from '../arkts/@arkts.collections'; 28 /** 29 * This module provides the capability of image codec and access 30 * @namespace sendableImage 31 * @syscap SystemCapability.Multimedia.Image.Core 32 * @crossplatform 33 * @atomicservice 34 * @since 12 35 */ 36declare namespace sendableImage { 37 38 /** 39 * Describes the size of an image. 40 * 41 * @typedef Size 42 * @syscap SystemCapability.Multimedia.Image.Core 43 * @crossplatform 44 * @form 45 * @atomicservice 46 * @since 12 47 */ 48 interface Size extends lang.ISendable { 49 /** 50 * Height 51 * 52 * @type { number } 53 * @syscap SystemCapability.Multimedia.Image.Core 54 * @crossplatform 55 * @form 56 * @atomicservice 57 * @since 12 58 */ 59 height: number; 60 61 /** 62 * Width 63 * 64 * @type { number } 65 * @syscap SystemCapability.Multimedia.Image.Core 66 * @crossplatform 67 * @form 68 * @atomicservice 69 * @since 12 70 */ 71 width: number; 72} 73 74/** 75 * Describes region information. 76 * 77 * @typedef Region 78 * @syscap SystemCapability.Multimedia.Image.Core 79 * @crossplatform 80 * @form 81 * @atomicservice 82 * @since 12 83 */ 84interface Region extends lang.ISendable { 85 /** 86 * Image size. 87 * 88 * @type { Size } 89 * @syscap SystemCapability.Multimedia.Image.Core 90 * @crossplatform 91 * @form 92 * @atomicservice 93 * @since 12 94 */ 95 size: Size; 96 97 /** 98 * x-coordinate at the upper left corner of the image. 99 * 100 * @type { number } 101 * @syscap SystemCapability.Multimedia.Image.Core 102 * @crossplatform 103 * @form 104 * @atomicservice 105 * @since 12 106 */ 107 x: number; 108 109 /** 110 * y-coordinate at the upper left corner of the image. 111 * 112 * @type { number } 113 * @syscap SystemCapability.Multimedia.Image.Core 114 * @crossplatform 115 * @form 116 * @atomicservice 117 * @since 12 118 */ 119 y: number; 120} 121 122 /** 123 * Creates an ImageSource instance based on the URI. 124 * 125 * @param { string } uri Image source URI. 126 * @returns { ImageSource } returns the ImageSource instance if the operation is successful; returns undefined otherwise. 127 * @syscap SystemCapability.Multimedia.Image.ImageSource 128 * @crossplatform 129 * @atomicservice 130 * @since 12 131 */ 132 function createImageSource(uri: string): ImageSource; 133 134 /** 135 * Creates an ImageSource instance based on the file descriptor. 136 * 137 * @param { number } fd ID of a file descriptor. 138 * @returns { ImageSource } Returns the ImageSource instance if the operation is successful; returns undefined otherwise. 139 * @syscap SystemCapability.Multimedia.Image.ImageSource 140 * @crossplatform 141 * @atomicservice 142 * @since 12 143 */ 144 function createImageSource(fd: number): ImageSource; 145 146 /** 147 * Creates an ImageSource instance based on the buffer. 148 * 149 * @param { ArrayBuffer } buf The buffer of the image. 150 * @returns { ImageSource } Returns the ImageSource instance if the operation is successful; returns undefined otherwise. 151 * @syscap SystemCapability.Multimedia.Image.ImageSource 152 * @crossplatform 153 * @form 154 * @atomicservice 155 * @since 12 156 */ 157 function createImageSource(buf: ArrayBuffer): ImageSource; 158 159 /** 160 * Creates an ImageReceiver instance. 161 * 162 * @param { Size } size - The default {@link Size} in pixels of the Images that this receiver will produce. 163 * @param { ImageFormat } format - The format of the Image that this receiver will produce. This must be one of the 164 * {@link ImageFormat} constants. 165 * @param { number } capacity - The maximum number of images the user will want to access simultaneously. 166 * @returns { ImageReceiver } Returns the ImageReceiver instance if the operation is successful; returns null otherwise. 167 * @throws { BusinessError } 401 - The parameter check failed. 168 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 169 * @since 12 170 */ 171 function createImageReceiver(size: image.Size, format: image.ImageFormat, capacity: number): ImageReceiver; 172 173 /** 174 * Redefines ISendable for convenience. 175 * 176 * @typedef { lang.ISendable } ISendable 177 * @syscap SystemCapability.Multimedia.Image.Core 178 * @crossplatform 179 * @since 12 180 */ 181 type ISendable = lang.ISendable; 182 183 /** 184 * Create PixelMap by data buffer. 185 * 186 * @param { ArrayBuffer } colors The image color buffer. 187 * @param { InitializationOptions } options Initialization options for PixelMap. 188 * @returns { Promise<PixelMap> } A Promise instance used to return the PixelMap object. 189 * @syscap SystemCapability.Multimedia.Image.Core 190 * @crossplatform 191 * @since 12 192 */ 193 function createPixelMap(colors: ArrayBuffer, options: image.InitializationOptions): Promise<PixelMap>; 194 195 /** 196 * Create PixelMap by data buffer. 197 * 198 * @param { ArrayBuffer } colors The image color buffer. 199 * @param { InitializationOptions } options Initialization options for PixelMap. 200 * @returns { PixelMap } Returns the instance if the operation is successful;Otherwise, return undefined. 201 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 202 * 2.Incorrect parameter types. 3.Parameter verification failed. 203 * @syscap SystemCapability.Multimedia.Image.Core 204 * @crossplatform 205 * @since 12 206 */ 207 function createPixelMapSync(colors: ArrayBuffer, options: image.InitializationOptions): PixelMap; 208 209 /** 210 * Creates a PixelMap object based on MessageSequence parameter. 211 * 212 * @param { rpc.MessageSequence } sequence - rpc.MessageSequence parameter. 213 * @returns { PixelMap } Returns the instance if the operation is successful. 214 * Otherwise, an exception will be thrown. 215 * @throws { BusinessError } 62980096 - Operation failed. 216 * @throws { BusinessError } 62980097 - IPC error. 217 * @throws { BusinessError } 62980115 - Invalid input parameter. 218 * @throws { BusinessError } 62980105 - Failed to get the data. 219 * @throws { BusinessError } 62980177 - Abnormal API environment. 220 * @throws { BusinessError } 62980178 - Failed to create the PixelMap. 221 * @throws { BusinessError } 62980179 - Abnormal buffer size. 222 * @throws { BusinessError } 62980180 - FD mapping failed. 223 * @throws { BusinessError } 62980246 - Failed to read the PixelMap. 224 * @syscap SystemCapability.Multimedia.Image.Core 225 * @since 12 226 */ 227 function createPixelMapFromParcel(sequence: rpc.MessageSequence): PixelMap; 228 229 /** 230 * Creates a PixelMap object from surface id. 231 * 232 * @param { string } surfaceId - surface id. 233 * @param { Region } region - The region to surface. 234 * @returns { Promise<PixelMap> } Returns the instance if the operation is successful. 235 * Otherwise, an exception will be thrown. 236 * @throws { BusinessError } 62980115 - If the image parameter invalid. 237 * @throws { BusinessError } 62980105 - Failed to get the data. 238 * @throws { BusinessError } 62980178 - Failed to create the PixelMap. 239 * @syscap SystemCapability.Multimedia.Image.Core 240 * @since 12 241 */ 242 function createPixelMapFromSurface(surfaceId: string, region: image.Region): Promise<PixelMap>; 243 244 /** 245 * Creates a sendable image PixelMap from image PixelMap. 246 * 247 * @param { image.PixelMap } pixelmap - the src pixelmap. 248 * @returns { PixelMap } Returns the instance if the operation is successful. 249 * Otherwise, an exception will be thrown. 250 * @throws { BusinessError } 401 - If the image parameter invalid. Possible causes: 251 * 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed. 252 * @throws { BusinessError } 62980104 - Failed to initialize the internal object. 253 * @syscap SystemCapability.Multimedia.Image.Core 254 * @since 12 255 */ 256 function convertFromPixelMap(pixelmap: image.PixelMap): PixelMap; 257 258 /** 259 * Creates a image PixelMap from sendable image PixelMap. 260 * 261 * @param { PixelMap } pixelmap - the src pixelmap. 262 * @returns { image.PixelMap } Returns the instance if the operation is successful. 263 * Otherwise, an exception will be thrown. 264 * @throws { BusinessError } 401 - If the image parameter invalid. Possible causes: 265 * 1.Mandatory parameters are left unspecified. 2.Incorrect parameter types. 3.Parameter verification failed. 266 * @throws { BusinessError } 62980104 - Failed to initialize the internal object. 267 * @syscap SystemCapability.Multimedia.Image.Core 268 * @since 12 269 */ 270 function convertToPixelMap(pixelmap: PixelMap): image.PixelMap; 271 272 /** 273 * Sendable PixelMap instance. 274 * 275 * @typedef PixelMap 276 * @syscap SystemCapability.Multimedia.Image.Core 277 * @crossplatform 278 * @atomicservice 279 * @since 12 280 */ 281 interface PixelMap extends ISendable { 282 /** 283 * Whether the image pixelmap can be edited. 284 * 285 * @type { boolean } 286 * @syscap SystemCapability.Multimedia.Image.Core 287 * @crossplatform 288 * @atomicservice 289 * @since 12 290 */ 291 readonly isEditable: boolean; 292 293 /** 294 * Reads image pixelmap data and writes the data to an ArrayBuffer. This method uses 295 * a promise to return the result. 296 * 297 * @param { ArrayBuffer } dst A buffer to which the image pixelmap data will be written. 298 * @returns { Promise<void> } A Promise instance used to return the operation result. 299 * If the operation fails, an error message is returned. 300 * @syscap SystemCapability.Multimedia.Image.Core 301 * @crossplatform 302 * @atomicservice 303 * @since 12 304 */ 305 readPixelsToBuffer(dst: ArrayBuffer): Promise<void>; 306 307 /** 308 * Reads image pixelmap data and writes the data to an ArrayBuffer. 309 * 310 * @param { ArrayBuffer } dst A buffer to which the image pixelmap data will be written. 311 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 312 * 2.Incorrect parameter types. 3.Parameter verification failed. 313 * @throws { BusinessError } 501 - Resource Unavailable. 314 * @syscap SystemCapability.Multimedia.Image.Core 315 * @crossplatform 316 * @atomicservice 317 * @since 12 318 */ 319 readPixelsToBufferSync(dst: ArrayBuffer): void; 320 321 /** 322 * Reads image pixelmap data in an area. This method uses a promise to return the data read. 323 * 324 * @param { PositionArea } area Area from which the image pixelmap data will be read. 325 * @returns { Promise<void> } A Promise instance used to return the operation result. 326 * If the operation fails, an error message is returned. 327 * @syscap SystemCapability.Multimedia.Image.Core 328 * @crossplatform 329 * @atomicservice 330 * @since 12 331 */ 332 readPixels(area: image.PositionArea): Promise<void>; 333 334 /** 335 * Reads image pixelmap data in an area. 336 * 337 * @param { PositionArea } area Area from which the image pixelmap data will be read. 338 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 339 * 2.Incorrect parameter types. 3.Parameter verification failed. 340 * @throws { BusinessError } 501 - Resource Unavailable. 341 * @syscap SystemCapability.Multimedia.Image.Core 342 * @crossplatform 343 * @atomicservice 344 * @since 12 345 */ 346 readPixelsSync(area: image.PositionArea): void; 347 348 /** 349 * Writes image pixelmap data to the specified area. This method uses a promise to return 350 * the operation result. 351 * 352 * @param { PositionArea } area Area to which the image pixelmap data will be written. 353 * @returns { Promise<void> } A Promise instance used to return the operation result. 354 * If the operation fails, an error message is returned. 355 * @syscap SystemCapability.Multimedia.Image.Core 356 * @crossplatform 357 * @atomicservice 358 * @since 12 359 */ 360 writePixels(area: image.PositionArea): Promise<void>; 361 362 /** 363 * Writes image pixelmap data to the specified area. 364 * 365 * @param { PositionArea } area Area to which the image pixelmap data will be written. 366 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 367 * 2.Incorrect parameter types. 3.Parameter verification failed. 368 * @throws { BusinessError } 501 - Resource Unavailable. 369 * @syscap SystemCapability.Multimedia.Image.Core 370 * @crossplatform 371 * @atomicservice 372 * @since 12 373 */ 374 writePixelsSync(area: image.PositionArea): void; 375 376 /** 377 * Reads image data in an ArrayBuffer and writes the data to a PixelMap object. This method 378 * uses a promise to return the result. 379 * 380 * @param { ArrayBuffer } src A buffer from which the image data will be read. 381 * @returns { Promise<void> } A Promise instance used to return the operation result. 382 * If the operation fails, an error message is returned. 383 * @syscap SystemCapability.Multimedia.Image.Core 384 * @crossplatform 385 * @atomicservice 386 * @since 12 387 */ 388 writeBufferToPixels(src: ArrayBuffer): Promise<void>; 389 390 /** 391 * Reads image data in an ArrayBuffer and writes the data to a PixelMap object. 392 * 393 * @param { ArrayBuffer } src A buffer from which the image data will be read. 394 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 395 * 2.Incorrect parameter types. 3.Parameter verification failed. 396 * @throws { BusinessError } 501 - Resource Unavailable. 397 * @syscap SystemCapability.Multimedia.Image.Core 398 * @crossplatform 399 * @atomicservice 400 * @since 12 401 */ 402 writeBufferToPixelsSync(src: ArrayBuffer): void; 403 404 /** 405 * Obtains pixelmap information about this image. This method uses a promise to return the information. 406 * 407 * @returns { Promise<ImageInfo> } A Promise instance used to return the image pixelmap information. 408 * If the operation fails, an error message is returned. 409 * @syscap SystemCapability.Multimedia.Image.Core 410 * @crossplatform 411 * @atomicservice 412 * @since 12 413 */ 414 getImageInfo(): Promise<image.ImageInfo>; 415 416 /** 417 * Get image information from image source. 418 * 419 * @returns { ImageInfo } the image information. 420 * @throws { BusinessError } 501 - Resource Unavailable. 421 * @syscap SystemCapability.Multimedia.Image.ImageSource 422 * @crossplatform 423 * @atomicservice 424 * @since 12 425 */ 426 getImageInfoSync(): image.ImageInfo; 427 428 /** 429 * Obtains the number of bytes in each line of the image pixelmap. 430 * 431 * @returns { number } Number of bytes in each line. 432 * @syscap SystemCapability.Multimedia.Image.Core 433 * @crossplatform 434 * @atomicservice 435 * @since 12 436 */ 437 getBytesNumberPerRow(): number; 438 439 /** 440 * Obtains the total number of bytes of the image pixelmap. 441 * 442 * @returns { number } Total number of bytes. 443 * @syscap SystemCapability.Multimedia.Image.Core 444 * @crossplatform 445 * @atomicservice 446 * @since 12 447 */ 448 getPixelBytesNumber(): number; 449 450 /** 451 * Obtains the density of the image pixelmap. 452 * 453 * @returns { number } The number of density. 454 * @syscap SystemCapability.Multimedia.Image.Core 455 * @crossplatform 456 * @atomicservice 457 * @since 12 458 */ 459 getDensity(): number; 460 461 /** 462 * Set the transparent rate of pixelmap. This method uses a promise to return the result. 463 * 464 * @param { number } rate The value of transparent rate. 465 * @returns { Promise<void> } A Promise instance used to return the operation result. 466 * If the operation fails, an error message is returned. 467 * @syscap SystemCapability.Multimedia.Image.Core 468 * @crossplatform 469 * @atomicservice 470 * @since 12 471 */ 472 opacity(rate: number): Promise<void>; 473 474 /** 475 * Set the transparent rate of pixelmap. 476 * 477 * @param { number } rate The value of transparent rate. 478 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 479 * 2.Incorrect parameter types. 3.Parameter verification failed. 480 * @throws { BusinessError } 501 - Resource Unavailable. 481 * @syscap SystemCapability.Multimedia.Image.Core 482 * @crossplatform 483 * @atomicservice 484 * @since 12 485 */ 486 opacitySync(rate: number): void; 487 488 /** 489 * Obtains new pixelmap with alpha information. This method uses a promise to return the information. 490 * 491 * @returns { Promise<PixelMap> } A Promise instance used to return the new image pixelmap. 492 * If the operation fails, an error message is returned. 493 * @syscap SystemCapability.Multimedia.Image.Core 494 * @crossplatform 495 * @atomicservice 496 * @since 12 497 */ 498 createAlphaPixelmap(): Promise<PixelMap>; 499 500 /** 501 * Obtains new pixelmap with alpha information. 502 * 503 * @returns { PixelMap } return the new image pixelmap. 504 * If the operation fails, an error message is returned. 505 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Parameter verification failed. 506 * @throws { BusinessError } 501 - Resource Unavailable. 507 * @syscap SystemCapability.Multimedia.Image.Core 508 * @crossplatform 509 * @atomicservice 510 * @since 12 511 */ 512 createAlphaPixelmapSync(): PixelMap; 513 514 /** 515 * Image zoom in width and height. This method uses a promise to return the result. 516 * 517 * @param { number } x The zoom value of width. 518 * @param { number } y The zoom value of height. 519 * @returns { Promise<void> } A Promise instance used to return the operation result. 520 * If the operation fails, an error message is returned. 521 * @syscap SystemCapability.Multimedia.Image.Core 522 * @crossplatform 523 * @atomicservice 524 * @since 12 525 */ 526 scale(x: number, y: number): Promise<void>; 527 528 /** 529 * Image zoom in width and height. 530 * 531 * @param { number } x The zoom value of width. 532 * @param { number } y The zoom value of height. 533 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 534 * 2.Incorrect parameter types. 3.Parameter verification failed. 535 * @throws { BusinessError } 501 - Resource Unavailable. 536 * @syscap SystemCapability.Multimedia.Image.Core 537 * @crossplatform 538 * @atomicservice 539 * @since 12 540 */ 541 scaleSync(x: number, y: number): void; 542 543 /** 544 * Image position transformation. This method uses a promise to return the result. 545 * 546 * @param { number } x The position value of width. 547 * @param { number } y The position value of height. 548 * @returns { Promise<void> } A Promise instance used to return the operation result. 549 * If the operation fails, an error message is returned. 550 * @syscap SystemCapability.Multimedia.Image.Core 551 * @crossplatform 552 * @atomicservice 553 * @since 12 554 */ 555 translate(x: number, y: number): Promise<void>; 556 557 /** 558 * Image position transformation. 559 * 560 * @param { number } x The position value of width. 561 * @param { number } y The position value of height. 562 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 563 * 2.Incorrect parameter types. 3.Parameter verification failed. 564 * @throws { BusinessError } 501 - Resource Unavailable. 565 * @syscap SystemCapability.Multimedia.Image.Core 566 * @crossplatform 567 * @atomicservice 568 * @since 12 569 */ 570 translateSync(x: number, y: number): void; 571 572 /** 573 * Image rotation. This method uses a promise to return the result. 574 * 575 * @param { number } angle The rotation angle. 576 * @returns { Promise<void> } A Promise instance used to return the operation result. 577 * If the operation fails, an error message is returned. 578 * @syscap SystemCapability.Multimedia.Image.Core 579 * @crossplatform 580 * @atomicservice 581 * @since 12 582 */ 583 rotate(angle: number): Promise<void>; 584 585 /** 586 * Image rotation. 587 * 588 * @param { number } angle The rotation angle. 589 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 590 * 2.Incorrect parameter types. 3.Parameter verification failed. 591 * @throws { BusinessError } 501 - Resource Unavailable. 592 * @syscap SystemCapability.Multimedia.Image.Core 593 * @crossplatform 594 * @atomicservice 595 * @since 12 596 */ 597 rotateSync(angle: number): void; 598 599 /** 600 * Image flipping. This method uses a promise to return the result. 601 * 602 * @param { boolean } horizontal Is flip in horizontal. 603 * @param { boolean } vertical Is flip in vertical. 604 * @returns { Promise<void> } A Promise instance used to return the operation result. 605 * If the operation fails, an error message is returned. 606 * @syscap SystemCapability.Multimedia.Image.Core 607 * @crossplatform 608 * @atomicservice 609 * @since 12 610 */ 611 flip(horizontal: boolean, vertical: boolean): Promise<void>; 612 613 /** 614 * Image flipping. 615 * 616 * @param { boolean } horizontal Is flip in horizontal. 617 * @param { boolean } vertical Is flip in vertical. 618 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 619 * 2.Incorrect parameter types. 3.Parameter verification failed. 620 * @throws { BusinessError } 501 - Resource Unavailable. 621 * @syscap SystemCapability.Multimedia.Image.Core 622 * @crossplatform 623 * @atomicservice 624 * @since 12 625 */ 626 flipSync(horizontal: boolean, vertical: boolean): void; 627 628 /** 629 * Crop the image. This method uses a promise to return the result. 630 * 631 * @param { Region } region The region to crop. 632 * @returns { Promise<void> } A Promise instance used to return the operation result. 633 * If the operation fails, an error message is returned. 634 * @syscap SystemCapability.Multimedia.Image.Core 635 * @crossplatform 636 * @atomicservice 637 * @since 12 638 */ 639 crop(region: image.Region): Promise<void>; 640 641 /** 642 * Crop the image. 643 * 644 * @param { Region } region The region to crop. 645 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 646 * 2.Incorrect parameter types. 3.Parameter verification failed. 647 * @throws { BusinessError } 501 - Resource Unavailable. 648 * @syscap SystemCapability.Multimedia.Image.Core 649 * @crossplatform 650 * @atomicservice 651 * @since 12 652 */ 653 cropSync(region: image.Region): void; 654 655 /** 656 * Get color space of pixelmap. 657 * 658 * @returns { colorSpaceManager.ColorSpaceManager } If the operation fails, an error message is returned. 659 * @throws { BusinessError } 62980101 - If the image data abnormal. 660 * @throws { BusinessError } 62980103 - If the image data unsupport. 661 * @throws { BusinessError } 62980115 - If the image parameter invalid. 662 * @syscap SystemCapability.Multimedia.Image.Core 663 * @crossplatform 664 * @since 12 665 */ 666 getColorSpace(): colorSpaceManager.ColorSpaceManager; 667 668 /** 669 * Set color space of pixelmap. 670 * 671 * This method is only used to set the colorspace property of PixelMap, 672 * while all pixel data remains the same after calling this method. 673 * If you want to change colorspace for all pixels, use method 674 * {@Link #applyColorSpace(colorSpaceManager.ColorSpaceManager)}. 675 * 676 * @param { colorSpaceManager.ColorSpaceManager } colorSpace The color space for pixelmap. 677 * @throws { BusinessError } 62980111 - If the operation invalid. 678 * @throws { BusinessError } 62980115 - If the image parameter invalid. 679 * @syscap SystemCapability.Multimedia.Image.Core 680 * @crossplatform 681 * @since 12 682 */ 683 setColorSpace(colorSpace: colorSpaceManager.ColorSpaceManager): void; 684 685 /** 686 * Is it stride Alignment 687 * 688 * @type { boolean } 689 * @readonly 690 * @syscap SystemCapability.Multimedia.Image.Core 691 * @since 12 692 */ 693 readonly isStrideAlignment: boolean; 694 695 /** 696 * Apply color space of pixelmap, the pixels will be changed by input color space. 697 * This method uses a promise to return the result. 698 * 699 * This method is used to change color space of PixelMap. 700 * Pixel data will be changed by calling this method. 701 * If you want to set the colorspace property of PixelMap only, 702 * use method {@Link #setColorSpace(colorSpaceManager.ColorSpaceManager)}. 703 * 704 * @param { colorSpaceManager.ColorSpaceManager } targetColorSpace - The color space for pixelmap. 705 * @returns { Promise<void> } A Promise instance used to return the operation result. 706 * If the operation fails, an error message is returned. 707 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1.Mandatory parameters are left unspecified. 708 * 2.Incorrect parameter types. 3.Parameter verification failed. 709 * @throws { BusinessError } 62980104 - Failed to initialize the internal object. 710 * @throws { BusinessError } 62980108 - Failed to convert the color space. 711 * @throws { BusinessError } 62980115 - Invalid image parameter. 712 * @syscap SystemCapability.Multimedia.Image.Core 713 * @crossplatform 714 * @since 12 715 */ 716 applyColorSpace(targetColorSpace: colorSpaceManager.ColorSpaceManager): Promise<void>; 717 718 /** 719 * Releases this PixelMap object. This method uses a promise to return the result. 720 * 721 * @returns { Promise<void> } A Promise instance used to return the instance release result. 722 * If the operation fails, an error message is returned. 723 * @syscap SystemCapability.Multimedia.Image.Core 724 * @crossplatform 725 * @atomicservice 726 * @since 12 727 */ 728 release(): Promise<void>; 729 730 /** 731 * Marshalling PixelMap and write into MessageSequence. 732 * 733 * @param { rpc.MessageSequence } sequence rpc.MessageSequence parameter. 734 * @throws { BusinessError } 62980115 - Invalid image parameter. 735 * @throws { BusinessError } 62980097 - IPC error. 736 * @syscap SystemCapability.Multimedia.Image.Core 737 * @since 12 738 */ 739 marshalling(sequence: rpc.MessageSequence): void; 740 741 /** 742 * Creates a PixelMap object based on MessageSequence parameter. 743 * 744 * @param { rpc.MessageSequence } sequence rpc.MessageSequence parameter. 745 * @returns { Promise<PixelMap> } A Promise instance used to return the PixelMap object. 746 * @throws { BusinessError } 62980115 - Invalid image parameter. 747 * @throws { BusinessError } 62980097 - IPC error. 748 * @throws { BusinessError } 62980096 - The operation failed. 749 * @syscap SystemCapability.Multimedia.Image.Core 750 * @since 12 751 */ 752 unmarshalling(sequence: rpc.MessageSequence): Promise<PixelMap>; 753 } 754 755 /** 756 * ImageSource instance. 757 * 758 * @typedef ImageSource 759 * @syscap SystemCapability.Multimedia.Image.ImageSource 760 * @crossplatform 761 * @form 762 * @atomicservice 763 * @since 12 764 */ 765 interface ImageSource { 766 /** 767 * Creates a PixelMap object based on image decoding parameters. This method uses a promise to 768 * return the object. 769 * 770 * @param { DecodingOptions } options Image decoding parameters. 771 * @returns { Promise<PixelMap> } A Promise instance used to return the PixelMap object. 772 * @syscap SystemCapability.Multimedia.Image.ImageSource 773 * @crossplatform 774 * @form 775 * @atomicservice 776 * @since 12 777 */ 778 createPixelMap(options?: image.DecodingOptions): Promise<PixelMap>; 779 780 /** 781 * Releases an ImageSource instance and uses a promise to return the result. 782 * 783 * @returns { Promise<void> } A Promise instance used to return the operation result. 784 * @syscap SystemCapability.Multimedia.Image.ImageSource 785 * @crossplatform 786 * @since 12 787 */ 788 release(): Promise<void>; 789 } 790 791 /** 792 * Provides basic image operations, including obtaining image information, and reading and writing image data. 793 * 794 * @typedef Image 795 * @syscap SystemCapability.Multimedia.Image.Core 796 * @since 12 797 */ 798 interface Image extends lang.ISendable { 799 /** 800 * Sets or gets the image area to crop, default is size. 801 * 802 * @type { Region } 803 * @syscap SystemCapability.Multimedia.Image.Core 804 * @since 12 805 */ 806 clipRect: Region; 807 808 /** 809 * Image size. 810 * 811 * @type { Size } 812 * @syscap SystemCapability.Multimedia.Image.Core 813 * @since 12 814 */ 815 readonly size: Size; 816 817 /** 818 * Image format. 819 * 820 * @type { number } 821 * @syscap SystemCapability.Multimedia.Image.Core 822 * @since 12 823 */ 824 readonly format: number; 825 826 /** 827 * Image timestamp. 828 * 829 * @type { number } 830 * @syscap SystemCapability.Multimedia.Image.Core 831 * @since 12 832 */ 833 readonly timestamp: number; 834 835 /** 836 * Get component buffer from image and uses a promise to return the result. 837 * 838 * @param { ComponentType } componentType The component type of image. 839 * @returns { Promise<Component> } A Promise instance used to return the component buffer. 840 * @syscap SystemCapability.Multimedia.Image.Core 841 * @since 12 842 */ 843 getComponent(componentType: image.ComponentType): Promise<image.Component>; 844 845 /** 846 * Release current image to receive another and uses a promise to return the result. 847 * 848 * @returns { Promise<void> } A Promise instance used to return the operation result. 849 * @syscap SystemCapability.Multimedia.Image.Core 850 * @since 12 851 */ 852 release(): Promise<void>; 853 } 854 855 /** 856 * Image receiver object. 857 * 858 * @typedef ImageReceiver 859 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 860 * @since 12 861 */ 862 interface ImageReceiver { 863 /** 864 * Image size. 865 * 866 * @type { Size } 867 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 868 * @since 12 869 */ 870 readonly size: image.Size; 871 872 /** 873 * Image capacity. 874 * 875 * @type { number } 876 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 877 * @since 12 878 */ 879 readonly capacity: number; 880 881 /** 882 * Image format. 883 * 884 * @type { ImageFormat } 885 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 886 * @since 12 887 */ 888 readonly format: image.ImageFormat; 889 890 /** 891 * Get an id which indicates a surface and can be used to set to Camera or other component can receive a surface 892 * and uses a promise to return the result. 893 * 894 * @returns { Promise<string> } A Promise instance used to return the surface id. 895 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 896 * @since 12 897 */ 898 getReceivingSurfaceId(): Promise<string>; 899 900 /** 901 * Get lasted image from receiver and uses a promise to return the result. 902 * 903 * @returns { Promise<Image> } A Promise instance used to return the latest image. 904 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 905 * @since 12 906 */ 907 readLatestImage(): Promise<Image>; 908 909 /** 910 * Get next image from receiver and uses a promise to return the result. 911 * 912 * @returns { Promise<Image> } A Promise instance used to return the next image. 913 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 914 * @since 12 915 */ 916 readNextImage(): Promise<Image>; 917 918 /** 919 * Subscribe callback when receiving an image 920 * 921 * @param { 'imageArrival' } type Callback used to return the next image. 922 * @param { AsyncCallback<void> } callback Callback used to return image. 923 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 924 * @since 12 925 */ 926 on(type: 'imageArrival', callback: AsyncCallback<void>): void; 927 928 /** 929 * Release image receiver instance and uses a promise to return the result. 930 * 931 * @returns { Promise<void> } A Promise instance used to return the operation result. 932 * @syscap SystemCapability.Multimedia.Image.ImageReceiver 933 * @since 12 934 */ 935 release(): Promise<void>; 936 } 937 938} 939 940export default sendableImage;