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 16/** 17 * @file 18 * @kit ArkGraphics2D 19 */ 20 21import { AsyncCallback } from './@ohos.base'; 22import image from './@ohos.multimedia.image'; 23 24/** 25 * @namespace effectKit 26 * @since 9 27 */ 28/** 29 * @namespace effectKit 30 * @form 31 * @atomicservice 32 * @since 12 33 */ 34/** 35 * @namespace effectKit 36 * @crossplatform 37 * @form 38 * @atomicservice 39 * @since 14 40 */ 41 42declare namespace effectKit { 43 44 /** 45 * The Filter of FilterChain. 46 * @typedef Filter 47 * @syscap SystemCapability.Multimedia.Image.Core 48 * @since 9 49 */ 50 /** 51 * The Filter of FilterChain. 52 * @typedef Filter 53 * @syscap SystemCapability.Multimedia.Image.Core 54 * @form 55 * @atomicservice 56 * @since 12 57 */ 58 /** 59 * The Filter of FilterChain. 60 * @typedef Filter 61 * @syscap SystemCapability.Multimedia.Image.Core 62 * @crossplatform 63 * @form 64 * @atomicservice 65 * @since 14 66 */ 67 interface Filter { 68 69 /** 70 * A blur effect is added to the image. 71 * @param { number } radius - The degree of blur, the value is measured in pixels. 72 * @returns { Filter } Filters for the current effect have been added. 73 * @syscap SystemCapability.Multimedia.Image.Core 74 * @since 9 75 */ 76 /** 77 * A blur effect is added to the image. 78 * @param { number } radius - The degree of blur, the value is measured in pixels. 79 * @returns { Filter } Filters for the current effect have been added. 80 * @syscap SystemCapability.Multimedia.Image.Core 81 * @form 82 * @atomicservice 83 * @since 12 84 */ 85 /** 86 * A blur effect is added to the image. 87 * @param { number } radius - The degree of blur, the value is measured in pixels. 88 * @returns { Filter } Filters for the current effect have been added. 89 * @syscap SystemCapability.Multimedia.Image.Core 90 * @crossplatform 91 * @form 92 * @atomicservice 93 * @since 14 94 */ 95 blur(radius: number): Filter; 96 97 /** 98 * A blur effect is added to the image. 99 * @param { number } radius - The degree of blur, the value is measured in pixels. 100 * @param { TileMode } tileMode - The tile mode of blur. 101 * @returns { Filter } Filters for the current effect have been added. 102 * @syscap SystemCapability.Multimedia.Image.Core 103 * @since 14 104 */ 105 blur(radius: number, tileMode: TileMode): Filter; 106 107 /** 108 * A Brightness effect is added to the image. 109 * @param { number } bright - The degree of light and darkness,the value range is 0 to 1. 110 * @returns { Filter } Filters for the current effect have been added. 111 * @syscap SystemCapability.Multimedia.Image.Core 112 * @since 9 113 */ 114 /** 115 * A Brightness effect is added to the image. 116 * @param { number } bright - The degree of light and darkness,the value range is 0 to 1. 117 * @returns { Filter } Filters for the current effect have been added. 118 * @syscap SystemCapability.Multimedia.Image.Core 119 * @form 120 * @atomicservice 121 * @since 12 122 */ 123 /** 124 * A Brightness effect is added to the image. 125 * @param { number } bright - The degree of light and darkness,the value range is 0 to 1. 126 * @returns { Filter } Filters for the current effect have been added. 127 * @syscap SystemCapability.Multimedia.Image.Core 128 * @crossplatform 129 * @form 130 * @atomicservice 131 * @since 14 132 */ 133 brightness(bright: number): Filter; 134 135 /** 136 * A Grayscale effect is added to the image. 137 * @returns { Filter } Filters for the current effect have been added. 138 * @syscap SystemCapability.Multimedia.Image.Core 139 * @since 9 140 */ 141 /** 142 * A Grayscale effect is added to the image. 143 * @returns { Filter } Filters for the current effect have been added. 144 * @syscap SystemCapability.Multimedia.Image.Core 145 * @form 146 * @atomicservice 147 * @since 12 148 */ 149 /** 150 * A Grayscale effect is added to the image. 151 * @returns { Filter } Filters for the current effect have been added. 152 * @syscap SystemCapability.Multimedia.Image.Core 153 * @crossplatform 154 * @form 155 * @atomicservice 156 * @since 14 157 */ 158 grayscale(): Filter; 159 160 /** 161 * A invert effect is added to the image. 162 * @returns { Filter } Filters for the current effect have been added. 163 * @syscap SystemCapability.Multimedia.Image.Core 164 * @since 12 165 */ 166 /** 167 * A invert effect is added to the image. 168 * @returns { Filter } Filters for the current effect have been added. 169 * @syscap SystemCapability.Multimedia.Image.Core 170 * @crossplatform 171 * @since 14 172 */ 173 invert(): Filter; 174 175 /** 176 * A custom effect is added to the image. 177 * 178 * @param { Array<number> } colorMatrix - A matrix of 5x4 size for create effect filter. 179 * @returns { Filter } Filters for the current effect have been added. 180 * @throws { BusinessError } 401 - Input parameter error. 181 * @syscap SystemCapability.Multimedia.Image.Core 182 * @since 12 183 */ 184 /** 185 * A custom effect is added to the image. 186 * 187 * @param { Array<number> } colorMatrix - A matrix of 5x4 size for create effect filter. 188 * @returns { Filter } Filters for the current effect have been added. 189 * @throws { BusinessError } 401 - Input parameter error. 190 * @syscap SystemCapability.Multimedia.Image.Core 191 * @crossplatform 192 * @since 14 193 */ 194 setColorMatrix(colorMatrix: Array<number>): Filter; 195 196 /** 197 * Gets the PixelMap where all filter effects have been added to the image. 198 * @returns { image.PixelMap } image.PixelMap. 199 * @syscap SystemCapability.Multimedia.Image.Core 200 * @since 9 201 * @deprecated since 11 202 * @useinstead effectKit.Filter#getEffectPixelMap 203 */ 204 getPixelMap(): image.PixelMap; 205 206 /** 207 * Gets the PixelMap where all filter effects have been added to the image. 208 * @returns { Promise<image.PixelMap> } - returns the PixelMap generated. 209 * @syscap SystemCapability.Multimedia.Image.Core 210 * @since 11 211 */ 212 /** 213 * Gets the PixelMap where all filter effects have been added to the image. 214 * @returns { Promise<image.PixelMap> } - returns the PixelMap generated. 215 * @syscap SystemCapability.Multimedia.Image.Core 216 * @form 217 * @atomicservice 218 * @since 12 219 */ 220 /** 221 * Gets the PixelMap where all filter effects have been added to the image. 222 * @returns { Promise<image.PixelMap> } - returns the PixelMap generated. 223 * @syscap SystemCapability.Multimedia.Image.Core 224 * @crossplatform 225 * @form 226 * @atomicservice 227 * @since 14 228 */ 229 getEffectPixelMap(): Promise<image.PixelMap>; 230 } 231 232 /** 233 * The color picker of an image. 234 * @typedef ColorPicker 235 * @syscap SystemCapability.Multimedia.Image.Core 236 * @since 9 237 */ 238 /** 239 * The color picker of an image. 240 * @typedef ColorPicker 241 * @syscap SystemCapability.Multimedia.Image.Core 242 * @form 243 * @atomicservice 244 * @since 12 245 */ 246 /** 247 * The color picker of an image. 248 * @typedef ColorPicker 249 * @syscap SystemCapability.Multimedia.Image.Core 250 * @crossplatform 251 * @form 252 * @atomicservice 253 * @since 14 254 */ 255 interface ColorPicker { 256 257 /** 258 * get main color of an image 259 * @returns { Promise<Color> } returns the MainColor generated. 260 * @syscap SystemCapability.Multimedia.Image.Core 261 * @since 9 262 */ 263 /** 264 * get main color of an image 265 * @returns { Promise<Color> } returns the MainColor generated. 266 * @syscap SystemCapability.Multimedia.Image.Core 267 * @form 268 * @atomicservice 269 * @since 12 270 */ 271 /** 272 * get main color of an image 273 * @returns { Promise<Color> } returns the MainColor generated. 274 * @syscap SystemCapability.Multimedia.Image.Core 275 * @crossplatform 276 * @form 277 * @atomicservice 278 * @since 14 279 */ 280 getMainColor(): Promise<Color>; 281 282 /** 283 * get main color of an image 284 * @returns { Color } Main color picked in the image. 285 * @syscap SystemCapability.Multimedia.Image.Core 286 * @since 9 287 */ 288 /** 289 * get main color of an image 290 * @returns { Color } Main color picked in the image. 291 * @syscap SystemCapability.Multimedia.Image.Core 292 * @form 293 * @atomicservice 294 * @since 12 295 */ 296 /** 297 * get main color of an image 298 * @returns { Color } Main color picked in the image. 299 * @syscap SystemCapability.Multimedia.Image.Core 300 * @crossplatform 301 * @form 302 * @atomicservice 303 * @since 14 304 */ 305 getMainColorSync(): Color; 306 307 /** 308 * Get largest proportion color of an image 309 * @returns { Color } Largest proportion color picked in the image. 310 * @syscap SystemCapability.Multimedia.Image.Core 311 * @since 10 312 */ 313 /** 314 * Get largest proportion color of an image 315 * @returns { Color } Largest proportion color picked in the image. 316 * @syscap SystemCapability.Multimedia.Image.Core 317 * @form 318 * @atomicservice 319 * @since 12 320 */ 321 /** 322 * Get largest proportion color of an image 323 * @returns { Color } Largest proportion color picked in the image. 324 * @syscap SystemCapability.Multimedia.Image.Core 325 * @crossplatform 326 * @form 327 * @atomicservice 328 * @since 14 329 */ 330 getLargestProportionColor(): Color; 331 332 /** 333 * Get top proportion color of an image 334 * @param { number } colorCount - The number of colors to require, the value is 1 to 10. 335 * @returns { Array<Color | null> } An array of feature colors sorted by proportion, with a size equal to 336 * the minimum of colorCount and the actual number of extracted feature colors. 337 * @syscap SystemCapability.Multimedia.Image.Core 338 * @form 339 * @atomicservice 340 * @since 12 341 */ 342 /** 343 * Get top proportion color of an image 344 * @param { number } colorCount - The number of colors to require, the value is 1 to 10. 345 * @returns { Array<Color | null> } An array of feature colors sorted by proportion, with a size equal to 346 * the minimum of colorCount and the actual number of extracted feature colors. 347 * @syscap SystemCapability.Multimedia.Image.Core 348 * @crossplatform 349 * @form 350 * @atomicservice 351 * @since 14 352 */ 353 getTopProportionColors(colorCount: number): Array<Color | null>; 354 355 /** 356 * Get highest saturation color of an image 357 * @returns { Color } Highest saturation color picked in the image. 358 * @syscap SystemCapability.Multimedia.Image.Core 359 * @since 10 360 */ 361 /** 362 * Get highest saturation color of an image 363 * @returns { Color } Highest saturation color picked in the image. 364 * @syscap SystemCapability.Multimedia.Image.Core 365 * @form 366 * @atomicservice 367 * @since 12 368 */ 369 /** 370 * Get highest saturation color of an image 371 * @returns { Color } Highest saturation color picked in the image. 372 * @syscap SystemCapability.Multimedia.Image.Core 373 * @crossplatform 374 * @form 375 * @atomicservice 376 * @since 14 377 */ 378 getHighestSaturationColor(): Color; 379 380 /** 381 * Get average color of an image 382 * @returns { Color } Average color calculated in the image. 383 * @syscap SystemCapability.Multimedia.Image.Core 384 * @since 10 385 */ 386 /** 387 * Get average color of an image 388 * @returns { Color } Average color calculated in the image. 389 * @syscap SystemCapability.Multimedia.Image.Core 390 * @form 391 * @atomicservice 392 * @since 12 393 */ 394 /** 395 * Get average color of an image 396 * @returns { Color } Average color calculated in the image. 397 * @syscap SystemCapability.Multimedia.Image.Core 398 * @crossplatform 399 * @form 400 * @atomicservice 401 * @since 14 402 */ 403 getAverageColor(): Color; 404 405 /** 406 * Determine whether the color is black or white or gray 407 * @param { number } color - The 32 bit ARGB color to discriminate. 408 * @returns { boolean } Result of judging black, white and gray. 409 * @syscap SystemCapability.Multimedia.Image.Core 410 * @since 10 411 */ 412 /** 413 * Determine whether the color is black or white or gray 414 * @param { number } color - The 32 bit ARGB color to discriminate. 415 * @returns { boolean } Result of judging black, white and gray. 416 * @syscap SystemCapability.Multimedia.Image.Core 417 * @form 418 * @atomicservice 419 * @since 12 420 */ 421 /** 422 * Determine whether the color is black or white or gray 423 * @param { number } color - The 32 bit ARGB color to discriminate. 424 * @returns { boolean } Result of judging black, white and gray. 425 * @syscap SystemCapability.Multimedia.Image.Core 426 * @crossplatform 427 * @form 428 * @atomicservice 429 * @since 14 430 */ 431 isBlackOrWhiteOrGrayColor(color: number): boolean; 432 } 433 434 /** 435 * The color param. 436 * @typedef Color 437 * @syscap SystemCapability.Multimedia.Image.Core 438 * @since 9 439 */ 440 /** 441 * The color param. 442 * @typedef Color 443 * @syscap SystemCapability.Multimedia.Image.Core 444 * @form 445 * @atomicservice 446 * @since 12 447 */ 448 /** 449 * The color param. 450 * @typedef Color 451 * @syscap SystemCapability.Multimedia.Image.Core 452 * @crossplatform 453 * @form 454 * @atomicservice 455 * @since 14 456 */ 457 interface Color { 458 459 /** 460 * Red 461 * @type { number } 462 * @syscap SystemCapability.Multimedia.Image.Core 463 * @since 9 464 */ 465 /** 466 * Red 467 * @type { number } 468 * @syscap SystemCapability.Multimedia.Image.Core 469 * @form 470 * @atomicservice 471 * @since 12 472 */ 473 /** 474 * Red 475 * @type { number } 476 * @syscap SystemCapability.Multimedia.Image.Core 477 * @crossplatform 478 * @form 479 * @atomicservice 480 * @since 14 481 */ 482 red: number; 483 484 /** 485 * Green 486 * @type { number } 487 * @syscap SystemCapability.Multimedia.Image.Core 488 * @since 9 489 */ 490 /** 491 * Green 492 * @type { number } 493 * @syscap SystemCapability.Multimedia.Image.Core 494 * @form 495 * @atomicservice 496 * @since 12 497 */ 498 /** 499 * Green 500 * @type { number } 501 * @syscap SystemCapability.Multimedia.Image.Core 502 * @crossplatform 503 * @form 504 * @atomicservice 505 * @since 14 506 */ 507 green: number; 508 509 /** 510 * Blue 511 * @type { number } 512 * @syscap SystemCapability.Multimedia.Image.Core 513 * @since 9 514 */ 515 /** 516 * Blue 517 * @type { number } 518 * @syscap SystemCapability.Multimedia.Image.Core 519 * @form 520 * @atomicservice 521 * @since 12 522 */ 523 /** 524 * Blue 525 * @type { number } 526 * @syscap SystemCapability.Multimedia.Image.Core 527 * @crossplatform 528 * @form 529 * @atomicservice 530 * @since 14 531 */ 532 blue: number; 533 534 /** 535 * Alpha 536 * @type { number } 537 * @syscap SystemCapability.Multimedia.Image.Core 538 * @since 9 539 */ 540 /** 541 * Alpha 542 * @type { number } 543 * @syscap SystemCapability.Multimedia.Image.Core 544 * @form 545 * @atomicservice 546 * @since 12 547 */ 548 /** 549 * Alpha 550 * @type { number } 551 * @syscap SystemCapability.Multimedia.Image.Core 552 * @crossplatform 553 * @form 554 * @atomicservice 555 * @since 14 556 */ 557 alpha: number; 558 } 559 560 /** 561 * Create a FilterChain to add multiple effects to an image. 562 * @param { image.PixelMap } source - the source pixelmap. 563 * @returns { Filter } Returns the head node of FilterChain. 564 * @syscap SystemCapability.Multimedia.Image.Core 565 * @since 9 566 */ 567 /** 568 * Create a FilterChain to add multiple effects to an image. 569 * @param { image.PixelMap } source - the source pixelmap. 570 * @returns { Filter } Returns the head node of FilterChain. 571 * @syscap SystemCapability.Multimedia.Image.Core 572 * @form 573 * @atomicservice 574 * @since 12 575 */ 576 /** 577 * Create a FilterChain to add multiple effects to an image. 578 * @param { image.PixelMap } source - the source pixelmap. 579 * @returns { Filter } Returns the head node of FilterChain. 580 * @syscap SystemCapability.Multimedia.Image.Core 581 * @crossplatform 582 * @form 583 * @atomicservice 584 * @since 14 585 */ 586 function createEffect(source: image.PixelMap): Filter; 587 588 /** 589 * Create a color picker to get color of an image. 590 * @param { image.PixelMap } source - the source pixelmap. 591 * @returns { Promise<ColorPicker> } - returns the ColorPicker generated. 592 * @throws { BusinessError } 401 - Input parameter error. 593 * @syscap SystemCapability.Multimedia.Image.Core 594 * @since 9 595 */ 596 /** 597 * Create a color picker to get color of an image. 598 * @param { image.PixelMap } source - the source pixelmap. 599 * @returns { Promise<ColorPicker> } - returns the ColorPicker generated. 600 * @throws { BusinessError } 401 - Input parameter error. 601 * @syscap SystemCapability.Multimedia.Image.Core 602 * @form 603 * @atomicservice 604 * @since 12 605 */ 606 /** 607 * Create a color picker to get color of an image. 608 * @param { image.PixelMap } source - the source pixelmap. 609 * @returns { Promise<ColorPicker> } - returns the ColorPicker generated. 610 * @throws { BusinessError } 401 - Input parameter error. 611 * @syscap SystemCapability.Multimedia.Image.Core 612 * @crossplatform 613 * @form 614 * @atomicservice 615 * @since 14 616 */ 617 function createColorPicker(source: image.PixelMap): Promise<ColorPicker>; 618 619 /** 620 * Create a color picker to get color of an image. 621 * @param { image.PixelMap } source - the source pixelmap. 622 * @param { Array<number> } region - contains 4 elements, represents the region's left, top, right, bottom coordinates, 623 * default is [0, 0, 1, 1], represents the region of color picker is the whole pixelMap. 624 * @returns { Promise<ColorPicker> } - returns the ColorPicker generated. 625 * @throws { BusinessError } 401 - Input parameter error. 626 * @syscap SystemCapability.Multimedia.Image.Core 627 * @since 10 628 */ 629 /** 630 * Create a color picker to get color of an image. 631 * @param { image.PixelMap } source - the source pixelmap. 632 * @param { Array<number> } region - contains 4 elements, represents the region's left, top, right, bottom coordinates, 633 * default is [0, 0, 1, 1], represents the region of color picker is the whole pixelMap. 634 * @returns { Promise<ColorPicker> } - returns the ColorPicker generated. 635 * @throws { BusinessError } 401 - Input parameter error. 636 * @syscap SystemCapability.Multimedia.Image.Core 637 * @form 638 * @atomicservice 639 * @since 12 640 */ 641 /** 642 * Create a color picker to get color of an image. 643 * @param { image.PixelMap } source - the source pixelmap. 644 * @param { Array<number> } region - contains 4 elements, represents the region's left, top, right, bottom coordinates, 645 * default is [0, 0, 1, 1], represents the region of color picker is the whole pixelMap. 646 * @returns { Promise<ColorPicker> } - returns the ColorPicker generated. 647 * @throws { BusinessError } 401 - Input parameter error. 648 * @syscap SystemCapability.Multimedia.Image.Core 649 * @crossplatform 650 * @form 651 * @atomicservice 652 * @since 14 653 */ 654 function createColorPicker(source: image.PixelMap, region: Array<number>): Promise<ColorPicker>; 655 656 /** 657 * Create a color picker to get color of an image. 658 * @param { image.PixelMap } source - the source pixelmap. 659 * @param { AsyncCallback<ColorPicker> } callback - the callback of createColorPicker. 660 * @throws { BusinessError } 401 - Input parameter error. 661 * @syscap SystemCapability.Multimedia.Image.Core 662 * @since 9 663 */ 664 /** 665 * Create a color picker to get color of an image. 666 * @param { image.PixelMap } source - the source pixelmap. 667 * @param { AsyncCallback<ColorPicker> } callback - the callback of createColorPicker. 668 * @throws { BusinessError } 401 - Input parameter error. 669 * @syscap SystemCapability.Multimedia.Image.Core 670 * @form 671 * @atomicservice 672 * @since 12 673 */ 674 /** 675 * Create a color picker to get color of an image. 676 * @param { image.PixelMap } source - the source pixelmap. 677 * @param { AsyncCallback<ColorPicker> } callback - the callback of createColorPicker. 678 * @throws { BusinessError } 401 - Input parameter error. 679 * @syscap SystemCapability.Multimedia.Image.Core 680 * @crossplatform 681 * @form 682 * @atomicservice 683 * @since 14 684 */ 685 function createColorPicker(source: image.PixelMap, callback: AsyncCallback<ColorPicker>): void; 686 687 /** 688 * Create a color picker to get color of an image. 689 * @param { image.PixelMap } source - the source pixelmap. 690 * @param { Array<number> } region - contains 4 elements, represents the region's left, top, right, bottom coordinates, 691 * default is [0, 0, 1, 1], represents the region of color picker is the whole pixelMap. 692 * @param { AsyncCallback<ColorPicker> } callback - the callback of createColorPicker. 693 * @throws { BusinessError } 401 - Input parameter error. 694 * @syscap SystemCapability.Multimedia.Image.Core 695 * @since 10 696 */ 697 /** 698 * Create a color picker to get color of an image. 699 * @param { image.PixelMap } source - the source pixelmap. 700 * @param { Array<number> } region - contains 4 elements, represents the region's left, top, right, bottom coordinates, 701 * default is [0, 0, 1, 1], represents the region of color picker is the whole pixelMap. 702 * @param { AsyncCallback<ColorPicker> } callback - the callback of createColorPicker. 703 * @throws { BusinessError } 401 - Input parameter error. 704 * @syscap SystemCapability.Multimedia.Image.Core 705 * @form 706 * @atomicservice 707 * @since 12 708 */ 709 /** 710 * Create a color picker to get color of an image. 711 * @param { image.PixelMap } source - the source pixelmap. 712 * @param { Array<number> } region - contains 4 elements, represents the region's left, top, right, bottom coordinates, 713 * default is [0, 0, 1, 1], represents the region of color picker is the whole pixelMap. 714 * @param { AsyncCallback<ColorPicker> } callback - the callback of createColorPicker. 715 * @throws { BusinessError } 401 - Input parameter error. 716 * @syscap SystemCapability.Multimedia.Image.Core 717 * @crossplatform 718 * @form 719 * @atomicservice 720 * @since 14 721 */ 722 function createColorPicker(source: image.PixelMap, region: Array<number>, callback: AsyncCallback<ColorPicker>): void; 723 724 /** 725 * TileMode enumeration description 726 * 727 * @enum { number } 728 * @syscap SystemCapability.Multimedia.Image.Core 729 * @since 14 730 */ 731 enum TileMode { 732 /** 733 * Clamp mode. 734 * 735 * @syscap SystemCapability.Multimedia.Image.Core 736 * @since 14 737 */ 738 CLAMP = 0, 739 740 /** 741 * Repeat mode. 742 * 743 * @syscap SystemCapability.Multimedia.Image.Core 744 * @since 14 745 */ 746 REPEAT = 1, 747 748 /** 749 * Mirror mode. 750 * 751 * @syscap SystemCapability.Multimedia.Image.Core 752 * @since 14 753 */ 754 MIRROR = 2, 755 756 /** 757 * Decal mode. 758 * 759 * @syscap SystemCapability.Multimedia.Image.Core 760 * @since 14 761 */ 762 DECAL = 3, 763 } 764} 765 766export default effectKit; 767