1/* 2 * Copyright (C) 2025 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@!namespace("@ohos.multimedia.image", "image") 17 18@!sts_inject(""" 19static { loadLibrary("image_taihe_core.z"); } 20""") 21 22enum PixelMapFormat: i32 { 23 UNKNOWN = 0, 24 ARGB_8888 = 1, 25 RGB_565 = 2, 26 RGBA_8888 = 3, 27 BGRA_8888 = 4, 28 RGB_888 = 5, 29 ALPHA_8 = 6, 30 RGBA_F16 = 7, 31 NV21 = 8, 32 NV12 = 9, 33 RGBA_1010102 = 10, 34 YCBCR_P010 = 11, 35 YCRCB_P010 = 12, 36 ASTC_4x4 = 102 37} 38 39enum ResolutionQuality: i32 { 40 LOW = 1, 41 MEDIUM = 2, 42 HIGH = 3 43} 44 45struct Size { 46 width: i32; 47 height: i32; 48} 49 50enum PropertyKey: String { 51 BITS_PER_SAMPLE = "BitsPerSample", 52 ORIENTATION = "Orientation", 53 IMAGE_LENGTH = "ImageLength", 54 IMAGE_WIDTH = "ImageWidth", 55 GPS_LATITUDE = "GPSLatitude", 56 GPS_LONGITUDE = "GPSLongitude", 57 GPS_LATITUDE_REF = "GPSLatitudeRef", 58 GPS_LONGITUDE_REF = "GPSLongitudeRef", 59 DATE_TIME_ORIGINAL = "DateTimeOriginal", 60 EXPOSURE_TIME = "ExposureTime", 61 SCENE_TYPE = "SceneType", 62 ISO_SPEED_RATINGS = "ISOSpeedRatings", 63 F_NUMBER = "FNumber", 64 DATE_TIME = "DateTime", 65 GPS_TIME_STAMP = "GPSTimeStamp", 66 GPS_DATE_STAMP = "GPSDateStamp", 67 IMAGE_DESCRIPTION = "ImageDescription", 68 MAKE = "Make", 69 MODEL = "Model", 70 PHOTO_MODE = "PhotoMode", 71 SENSITIVITY_TYPE = "SensitivityType", 72 STANDARD_OUTPUT_SENSITIVITY = "StandardOutputSensitivity", 73 RECOMMENDED_EXPOSURE_INDEX = "RecommendedExposureIndex", 74 ISO_SPEED = "ISOSpeedRatings", 75 APERTURE_VALUE = "ApertureValue", 76 EXPOSURE_BIAS_VALUE = "ExposureBiasValue", 77 METERING_MODE = "MeteringMode", 78 LIGHT_SOURCE = "LightSource", 79 FLASH = "Flash", 80 FOCAL_LENGTH = "FocalLength", 81 USER_COMMENT = "UserComment", 82 PIXEL_X_DIMENSION = "PixelXDimension", 83 PIXEL_Y_DIMENSION = "PixelYDimension", 84 WHITE_BALANCE = "WhiteBalance", 85 FOCAL_LENGTH_IN_35_MM_FILM = "FocalLengthIn35mmFilm", 86 CAPTURE_MODE = "HwMnoteCaptureMode", 87 PHYSICAL_APERTURE = "HwMnotePhysicalAperture", 88 ROLL_ANGLE = "HwMnoteRollAngle", 89 PITCH_ANGLE = "HwMnotePitchAngle", 90 SCENE_FOOD_CONF = "HwMnoteSceneFoodConf", 91 SCENE_STAGE_CONF = "HwMnoteSceneStageConf", 92 SCENE_BLUE_SKY_CONF = "HwMnoteSceneBlueSkyConf", 93 SCENE_GREEN_PLANT_CONF = "HwMnoteSceneGreenPlantConf", 94 SCENE_BEACH_CONF = "HwMnoteSceneBeachConf", 95 SCENE_SNOW_CONF = "HwMnoteSceneSnowConf", 96 SCENE_SUNSET_CONF = "HwMnoteSceneSunsetConf", 97 SCENE_FLOWERS_CONF = "HwMnoteSceneFlowersConf", 98 SCENE_NIGHT_CONF = "HwMnoteSceneNightConf", 99 SCENE_TEXT_CONF = "HwMnoteSceneTextConf", 100 FACE_COUNT = "HwMnoteFaceCount", 101 FOCUS_MODE = "HwMnoteFocusMode", 102 COMPRESSION = "Compression", 103 PHOTOMETRIC_INTERPRETATION = "PhotometricInterpretation", 104 STRIP_OFFSETS = "StripOffsets", 105 SAMPLES_PER_PIXEL = "SamplesPerPixel", 106 ROWS_PER_STRIP = "RowsPerStrip", 107 STRIP_BYTE_COUNTS = "StripByteCounts", 108 X_RESOLUTION = "XResolution", 109 Y_RESOLUTION = "YResolution", 110 PLANAR_CONFIGURATION = "PlanarConfiguration", 111 RESOLUTION_UNIT = "ResolutionUnit", 112 TRANSFER_FUNCTION = "TransferFunction", 113 SOFTWARE = "Software", 114 ARTIST = "Artist", 115 WHITE_POINT = "WhitePoint", 116 PRIMARY_CHROMATICITIES = "PrimaryChromaticities", 117 YCBCR_COEFFICIENTS = "YCbCrCoefficients", 118 YCBCR_SUB_SAMPLING = "YCbCrSubSampling", 119 YCBCR_POSITIONING = "YCbCrPositioning", 120 REFERENCE_BLACK_WHITE = "ReferenceBlackWhite", 121 COPYRIGHT = "Copyright", 122 JPEG_INTERCHANGE_FORMAT = "JPEGInterchangeFormat", 123 JPEG_INTERCHANGE_FORMAT_LENGTH = "JPEGInterchangeFormatLength", 124 EXPOSURE_PROGRAM = "ExposureProgram", 125 SPECTRAL_SENSITIVITY = "SpectralSensitivity", 126 OECF = "OECF", 127 EXIF_VERSION = "ExifVersion", 128 DATE_TIME_DIGITIZED = "DateTimeDigitized", 129 COMPONENTS_CONFIGURATION = "ComponentsConfiguration", 130 SHUTTER_SPEED = "ShutterSpeedValue", 131 BRIGHTNESS_VALUE = "BrightnessValue", 132 MAX_APERTURE_VALUE = "MaxApertureValue", 133 SUBJECT_DISTANCE = "SubjectDistance", 134 SUBJECT_AREA = "SubjectArea", 135 MAKER_NOTE = "MakerNote", 136 SUBSEC_TIME = "SubsecTime", 137 SUBSEC_TIME_ORIGINAL = "SubsecTimeOriginal", 138 SUBSEC_TIME_DIGITIZED = "SubsecTimeDigitized", 139 FLASHPIX_VERSION = "FlashpixVersion", 140 COLOR_SPACE = "ColorSpace", 141 RELATED_SOUND_FILE = "RelatedSoundFile", 142 FLASH_ENERGY = "FlashEnergy", 143 SPATIAL_FREQUENCY_RESPONSE = "SpatialFrequencyResponse", 144 FOCAL_PLANE_X_RESOLUTION = "FocalPlaneXResolution", 145 FOCAL_PLANE_Y_RESOLUTION = "FocalPlaneYResolution", 146 FOCAL_PLANE_RESOLUTION_UNIT = "FocalPlaneResolutionUnit", 147 SUBJECT_LOCATION = "SubjectLocation", 148 EXPOSURE_INDEX = "ExposureIndex", 149 SENSING_METHOD = "SensingMethod", 150 FILE_SOURCE = "FileSource", 151 CFA_PATTERN = "CFAPattern", 152 CUSTOM_RENDERED = "CustomRendered", 153 EXPOSURE_MODE = "ExposureMode", 154 DIGITAL_ZOOM_RATIO = "DigitalZoomRatio", 155 SCENE_CAPTURE_TYPE = "SceneCaptureType", 156 GAIN_CONTROL = "GainControl", 157 CONTRAST = "Contrast", 158 SATURATION = "Saturation", 159 SHARPNESS = "Sharpness", 160 DEVICE_SETTING_DESCRIPTION = "DeviceSettingDescription", 161 SUBJECT_DISTANCE_RANGE = "SubjectDistanceRange", 162 IMAGE_UNIQUE_ID = "ImageUniqueID", 163 GPS_VERSION_ID = "GPSVersionID", 164 GPS_ALTITUDE_REF = "GPSAltitudeRef", 165 GPS_ALTITUDE = "GPSAltitude", 166 GPS_SATELLITES = "GPSSatellites", 167 GPS_STATUS = "GPSStatus", 168 GPS_MEASURE_MODE = "GPSMeasureMode", 169 GPS_DOP = "GPSDOP", 170 GPS_SPEED_REF = "GPSSpeedRef", 171 GPS_SPEED = "GPSSpeed", 172 GPS_TRACK_REF = "GPSTrackRef", 173 GPS_TRACK = "GPSTrack", 174 GPS_IMG_DIRECTION_REF = "GPSImgDirectionRef", 175 GPS_IMG_DIRECTION = "GPSImgDirection", 176 GPS_MAP_DATUM = "GPSMapDatum", 177 GPS_DEST_LATITUDE_REF = "GPSDestLatitudeRef", 178 GPS_DEST_LATITUDE = "GPSDestLatitude", 179 GPS_DEST_LONGITUDE_REF = "GPSDestLongitudeRef", 180 GPS_DEST_LONGITUDE = "GPSDestLongitude", 181 GPS_DEST_BEARING_REF = "GPSDestBearingRef", 182 GPS_DEST_BEARING = "GPSDestBearing", 183 GPS_DEST_DISTANCE_REF = "GPSDestDistanceRef", 184 GPS_DEST_DISTANCE = "GPSDestDistance", 185 GPS_PROCESSING_METHOD = "GPSProcessingMethod", 186 GPS_AREA_INFORMATION = "GPSAreaInformation", 187 GPS_DIFFERENTIAL = "GPSDifferential", 188 BODY_SERIAL_NUMBER = "BodySerialNumber", 189 CAMERA_OWNER_NAME = "CameraOwnerName", 190 COMPOSITE_IMAGE = "CompositeImage", 191 COMPRESSED_BITS_PER_PIXEL = "CompressedBitsPerPixel", 192 DNG_VERSION = "DNGVersion", 193 DEFAULT_CROP_SIZE = "DefaultCropSize", 194 GAMMA = "Gamma", 195 ISO_SPEED_LATITUDE_YYY = "ISOSpeedLatitudeyyy", 196 ISO_SPEED_LATITUDE_ZZZ = "ISOSpeedLatitudezzz", 197 LENS_MAKE = "LensMake", 198 LENS_MODEL = "LensModel", 199 LENS_SERIAL_NUMBER = "LensSerialNumber", 200 LENS_SPECIFICATION = "LensSpecification", 201 NEW_SUBFILE_TYPE = "NewSubfileType", 202 OFFSET_TIME = "OffsetTime", 203 OFFSET_TIME_DIGITIZED = "OffsetTimeDigitized", 204 OFFSET_TIME_ORIGINAL = "OffsetTimeOriginal", 205 SOURCE_EXPOSURE_TIMES_OF_COMPOSITE_IMAGE = "SourceExposureTimesOfCompositeImage", 206 SOURCE_IMAGE_NUMBER_OF_COMPOSITE_IMAGE = "SourceImageNumberOfCompositeImage", 207 SUBFILE_TYPE = "SubfileType", 208 GPS_H_POSITIONING_ERROR = "GPSHPositioningError", 209 PHOTOGRAPHIC_SENSITIVITY = "PhotographicSensitivity", 210 BURST_NUMBER = "HwMnoteBurstNumber", 211 FACE_CONF = "HwMnoteFaceConf", 212 FACE_LEYE_CENTER = "HwMnoteFaceLeyeCenter", 213 FACE_MOUTH_CENTER = "HwMnoteFaceMouthCenter", 214 FACE_POINTER = "HwMnoteFacePointer", 215 FACE_RECT = "HwMnoteFaceRect", 216 FACE_REYE_CENTER = "HwMnoteFaceReyeCenter", 217 FACE_SMILE_SCORE = "HwMnoteFaceSmileScore", 218 FACE_VERSION = "HwMnoteFaceVersion", 219 FRONT_CAMERA = "HwMnoteFrontCamera", 220 SCENE_POINTER = "HwMnoteScenePointer", 221 SCENE_VERSION = "HwMnoteSceneVersion", 222 IS_XMAGE_SUPPORTED = "HwMnoteIsXmageSupported", 223 XMAGE_MODE = "HwMnoteXmageMode", 224 XMAGE_LEFT = "HwMnoteXmageLeft", 225 XMAGE_TOP = "HwMnoteXmageTop", 226 XMAGE_RIGHT = "HwMnoteXmageRight", 227 XMAGE_BOTTOM = "HwMnoteXmageBottom", 228 CLOUD_ENHANCEMENT_MODE = "HwMnoteCloudEnhancementMode", 229 WIND_SNAPSHOT_MODE = "HwMnoteWindSnapshotMode", 230 GIF_LOOP_COUNT = "GIFLoopCount" 231} 232 233enum ImageFormat: i32 { 234 YCBCR_422_SP = 1000, 235 JPEG = 2000 236} 237 238enum AlphaType: i32 { 239 UNKNOWN = 0, 240 OPAQUE = 1, 241 PREMUL = 2, 242 UNPREMUL = 3 243} 244 245enum DecodingDynamicRange: i32 { 246 AUTO = 0, 247 SDR = 1, 248 HDR = 2 249} 250 251enum PackingDynamicRange: i32 { 252 AUTO = 0, 253 SDR = 1, 254} 255 256enum AntiAliasingLevel: i32 { 257 NONE = 0, 258 LOW = 1, 259 MEDIUM = 2, 260 HIGH = 3 261} 262 263enum ScaleMode: i32 { 264 FIT_TARGET_SIZE = 0, 265 CENTER_CROP = 1 266} 267 268enum ComponentType: i32 { 269 YUV_Y = 1, 270 YUV_U = 2, 271 YUV_V = 3, 272 JPEG = 4 273} 274 275enum AllocatorType: i32 { 276 AUTO = 0, 277 DMA = 1, 278 SHARE_MEMORY = 2, 279} 280 281struct Region { 282 size: Size; 283 x: i32; 284 y: i32; 285} 286 287// Can't use struct because struct is copied instead of referenced, so data changes to "pixels" in C++ will not be reflected in ArkTS 288interface PositionArea { 289 @get GetPixels(): @arraybuffer Array<u8>; 290 @set SetPixels(pixels: @arraybuffer Array<u8>): void; 291 @get GetOffset(): i32; 292 @set SetOffset(offset: i32): void; 293 @get GetStride(): i32; 294 @set SetStride(stride: i32): void; 295 @get GetRegion(): Region; 296 @set SetRegion(region: Region): void; 297} 298 299struct ImageInfo { 300 size: Size; 301 density: i32; 302 stride: i32; 303 pixelFormat: PixelMapFormat; 304 alphaType: AlphaType; 305 mimeType: String; 306 isHdr: bool; 307} 308 309enum CropAndScaleStrategy: i32 { 310 SCALE_FIRST = 1, 311 CROP_FIRST = 2 312} 313 314struct PackingOption { 315 format: String; 316 quality: i32; 317 bufferSize: Optional<i32>; 318 desiredDynamicRange: Optional<PackingDynamicRange>; 319 needsPackProperties: Optional<bool>; 320} 321 322struct ImagePropertyOptions { 323 index: Optional<i32>; 324 defaultValue: Optional<String>; 325} 326 327struct DecodingOptions { 328 index: Optional<i32>; 329 sampleSize: Optional<i32>; 330 rotate: Optional<i32>; 331 editable: Optional<bool>; 332 desiredSize: Optional<Size>; 333 desiredRegion: Optional<Region>; 334 desiredPixelFormat: Optional<PixelMapFormat>; 335 photoDesiredPixelFormat: Optional<PixelMapFormat>; // not exposed to the user 336 fitDensity: Optional<i32>; 337 fillColor: Optional<i32>; // not exposed to the user 338 SVGResize: Optional<i32>; // not exposed to the user 339 desiredColorSpace: Optional<@sts_type("colorSpaceManager.ColorSpaceManager") Opaque>; 340 desiredDynamicRange: Optional<DecodingDynamicRange>; 341 resolutionQuality: Optional<ResolutionQuality>; 342 cropAndScaleStrategy: Optional<CropAndScaleStrategy>; 343 reusePixelmap: Optional<PixelMap>; // not exposed to the user 344} 345 346struct Component { 347 @readonly componentType: ComponentType; 348 @readonly rowStride: i32; 349 @readonly pixelStride: i32; 350 @readonly byteBuffer: @arraybuffer Array<u8>; 351} 352 353struct InitializationOptions { 354 size: Size; 355 srcPixelFormat: Optional<PixelMapFormat>; 356 pixelFormat: Optional<PixelMapFormat>; 357 editable: Optional<bool>; 358 alphaType: Optional<AlphaType>; 359 scaleMode: Optional<ScaleMode>; 360} 361 362struct SourceOptions { 363 sourceDensity: i32; 364 sourcePixelFormat: Optional<PixelMapFormat>; 365 sourceSize: Optional<Size>; 366} 367 368enum AuxiliaryPictureType: i32 { 369 GAINMAP = 1, 370 DEPTH_MAP = 2, 371 UNREFOCUS_MAP = 3, 372 LINEAR_MAP = 4, 373 FRAGMENT_MAP = 5, 374} 375 376struct AuxiliaryPictureInfo { 377 auxiliaryPictureType: AuxiliaryPictureType; 378 size: Size; 379 rowStride: i32; 380 pixelFormat: PixelMapFormat; 381 colorSpace: @sts_type("colorSpaceManager.ColorSpaceManager") Opaque; 382} 383 384union PropertyValue { 385 type_string: String; 386 @null type_null; 387} 388 389interface PixelMap { 390 GetImplPtr(): i64; 391 392 @gen_async("getImageInfo") 393 @gen_promise("getImageInfo") 394 GetImageInfoSync(): ImageInfo; 395 396 @gen_async("readPixelsToBuffer") 397 @gen_promise("readPixelsToBuffer") 398 ReadPixelsToBufferSync(dst: @arraybuffer Array<u8>): void; 399 400 ReadPixelsSync(area: PositionArea): void; 401 402 WriteBufferToPixelsSync(src: @arraybuffer Array<u8>): void; 403 404 @gen_async("createAlphaPixelmap") 405 @gen_promise("createAlphaPixelmap") 406 CreateAlphaPixelmapSync(): PixelMap; 407 408 GetBytesNumberPerRow(): i32; 409 410 GetPixelBytesNumber(): i32; 411 412 @gen_async("scale") 413 @gen_promise("scale") 414 @overload("scaleSync") 415 ScaleSync(x: f64, y: f64): void; 416 417 @gen_promise("scale") 418 @overload("scaleSync") 419 ScaleWithAntiAliasingSync(x: f64, y: f64, level: AntiAliasingLevel): void; 420 421 @gen_async("crop") 422 @gen_promise("crop") 423 CropSync(region: Region): void; 424 425 @gen_async("rotate") 426 @gen_promise("rotate") 427 RotateSync(angle: f64): void; 428 429 @gen_async("flip") 430 @gen_promise("flip") 431 FlipSync(horizontal: bool, vertical: bool): void; 432 433 @gen_async("opacity") 434 @gen_promise("opacity") 435 OpacitySync(rate: f64): void; 436 437 SetMemoryNameSync(name: String): void; 438 439 @gen_async("release") 440 @gen_promise("release") 441 ReleaseSync(): void; 442 443 @get GetIsStrideAlignment(): bool; 444 445 @set SetCaptureId(captureId: i32): void; 446 @get GetCaptureId(): i32; 447 448 @set SetTimestamp(timestamp: i64): void; 449 @get GetTimestamp(): i64; 450} 451 452interface Picture { 453 GetImplPtr(): i64; 454 455 GetMainPixelmap(): PixelMap; 456 457 Marshalling(sequence: @sts_type("rpc.MessageSequence") Opaque): void; 458 459 Release(): void; 460} 461 462interface AuxiliaryPicture { 463 @gen_promise("readPixelsToBuffer") 464 ReadPixelsToBufferSync(): @arraybuffer Array<u8>; 465 466 GetAuxiliaryPictureInfo(): AuxiliaryPictureInfo; 467 468 SetAuxiliaryPictureInfo(info: AuxiliaryPictureInfo): void; 469 470 Release(): void; 471} 472 473interface ImageSource { 474 GetImplPtr(): i64; 475 @gen_async("getImageInfo") 476 @gen_promise("getImageInfoPromiseWithIndex") 477 GetImageInfoSyncWithIndex(index: u32): ImageInfo; 478 479 @gen_async("getImageInfo") 480 @gen_promise("getImageInfoPromise") 481 GetImageInfoSync(): ImageInfo; 482 483 @!sts_inject_into_interface("getImageInfoSync(index: int | undefined): ImageInfo;") 484 @!sts_inject_into_class("""getImageInfoSync(index: int | undefined): ImageInfo { 485 if (index === undefined) { 486 return this.getImageInfoSync(); 487 } else { 488 return this.getImageInfoSyncWithIndex(index); 489 } 490 } 491 """) 492 493 @!sts_inject_into_interface("getImageInfo(index: int | undefined): Promise<ImageInfo>;") 494 @!sts_inject_into_class("""getImageInfo(index: int | undefined): Promise<ImageInfo> { 495 if (index === undefined) { 496 return this.getImageInfoPromise(); 497 } else { 498 return this.getImageInfoPromiseWithIndex(index); 499 } 500 } 501 """) 502 503 @gen_async("createPixelMap") 504 @gen_promise("createPixelMapPromiseWithOptions") 505 CreatePixelMapSyncWithOptions(options: DecodingOptions): PixelMap; 506 507 @gen_async("createPixelMap") 508 @gen_promise("createPixelMapPromise") 509 CreatePixelMapSync(): PixelMap; 510 511 @!sts_inject_into_interface("createPixelMapSync(options: DecodingOptions | undefined): PixelMap;") 512 @!sts_inject_into_class("""createPixelMapSync(options: DecodingOptions | undefined): PixelMap { 513 if (options === undefined) { 514 return this.createPixelMapSync(); 515 } else { 516 return this.createPixelMapSyncWithOptions(options); 517 } 518 } 519 """) 520 521 @!sts_inject_into_interface("createPixelMap(options: DecodingOptions | undefined): Promise<PixelMap>;") 522 @!sts_inject_into_class("""createPixelMap(options: DecodingOptions | undefined): Promise<PixelMap> { 523 if (options === undefined) { 524 return this.createPixelMapPromise(); 525 } else { 526 return this.createPixelMapPromiseWithOptions(options); 527 } 528 } 529 """) 530 531 @gen_promise("createPixelMapUsingAllocator") 532 CreatePixelMapUsingAllocatorSync(options: Optional<DecodingOptions>, allocatorType: Optional<AllocatorType>): PixelMap; 533 534 @gen_async("createPixelMapList") 535 CreatePixelMapListSync(): Array<PixelMap>; 536 537 @gen_async("createPixelMapList") 538 CreatePixelMapListSyncWithOptions(options: DecodingOptions): Array<PixelMap>; 539 540 @gen_promise("createPixelMapList") 541 CreatePixelMapListSyncWithOptionalOptions(options: Optional<DecodingOptions>): Array<PixelMap>; 542 543 @gen_async("getDelayTimeList") 544 @gen_promise("getDelayTimeList") 545 GetDelayTimeListSync(): Array<i32>; 546 547 @gen_promise("getImageProperty") 548 GetImagePropertySync(key: PropertyKey, options: Optional<ImagePropertyOptions>): String; 549 550 @gen_promise("getImageProperties") 551 GetImagePropertiesSync(key: Array<PropertyKey>): @record Map<PropertyKey, PropertyValue>; 552 553 @gen_promise("modifyImageProperty") 554 ModifyImagePropertySync(key: PropertyKey, value: String): void; 555 556 @gen_promise("modifyImageProperties") 557 ModifyImagePropertiesSync(records: @record Map<PropertyKey, PropertyValue>): void; 558 559 @gen_async("release") 560 @gen_promise("release") 561 ReleaseSync(): void; 562 563 @get GetSupportedFormats(): Array<String>; 564} 565 566interface ImagePacker { 567 @gen_async("packing") 568 @gen_promise("packing") 569 PackingPixelMapSync(source: PixelMap, option: PackingOption): @arraybuffer Array<u8>; 570 571 @gen_async("packToFile") 572 @gen_promise("packToFile") 573 PackImageSourceToFileSync(source: ImageSource, fd: i32, options: PackingOption): void; 574 575 @gen_async("packToFile") 576 @gen_promise("packToFile") 577 PackPixelMapToFileSync(source: PixelMap, fd: i32, options: PackingOption): void; 578 579 @gen_promise("packToFile") 580 PackPictureToFileSync(picture: Picture, fd: i32, options: PackingOption): void; 581 582 @gen_promise("packing") 583 PackingPictureSync(picture: Picture, options: PackingOption): @arraybuffer Array<u8>; 584 585 @gen_async("release") 586 @gen_promise("release") 587 ReleaseSync(): void; 588 589 @get GetSupportedFormats(): Array<String>; 590} 591 592interface Image { 593 @get("size") GetSize(): Size; 594 @get("format") GetFormat(): i32; 595 596 @gen_async("release") 597 @gen_promise("release") 598 ReleaseSync(): void; 599} 600 601interface ImageReceiver { 602 @get GetSize(): Size; 603 @get GetCapacity(): i32; 604 @get GetFormat(): ImageFormat; 605 606 @gen_async("getReceivingSurfaceId") 607 @gen_promise("getReceivingSurfaceId") 608 GetReceivingSurfaceIdSync(): String; 609 610 @gen_async("readLatestImage") 611 @gen_promise("readLatestImage") 612 ReadLatestImageSync(): Image; 613 614 @!sts_inject_into_interface("on(type: string, callback: (err: BusinessError<void>, data: undefined)=> void): void;") 615 @!sts_inject_into_class("""on(type: string, callback: (err: BusinessError<void>, data: undefined)=> void): void { 616 if (type === 'imageArrival') { 617 this.onImageArrival(callback); 618 } else { 619 throw new Error(`Unknown type: ${type}`); 620 } 621 } 622 """) 623 624 @!sts_inject_into_interface("off(type: string, callback?: (err: BusinessError<void>, data: undefined)=> void): void;") 625 @!sts_inject_into_class("""off(type: string, callback?: (err: BusinessError<void>, data: undefined)=> void): void { 626 if (type === 'imageArrival') { 627 this.offImageArrival(callback); 628 } else { 629 throw new Error(`Unknown type: ${type}`); 630 } 631 } 632 """) 633 634 OnImageArrival(callback: (err: @sts_type("BusinessError<void>") Opaque, data: @sts_type("undefined") Opaque)=> void): void; 635 OffImageArrival(callback: Optional<(err: @sts_type("BusinessError<void>") Opaque, data: @sts_type("undefined") Opaque)=> void>): void; 636 637 @gen_async("release") 638 @gen_promise("release") 639 ReleaseSync(): void; 640} 641 642interface ImageCreator { 643 @get("capacity") GetCapacity(): i32; 644 @get("format") GetFormat(): ImageFormat; 645 646 @gen_async("release") 647 @gen_promise("release") 648 ReleaseSync(): void; 649} 650 651function MakeEmptySize(): Size; 652function MakeEmptyImageInfo(): ImageInfo; 653 654@overload("createPixelMapSync") 655function CreatePixelMapByBufferAndOptionsSync(colors: @arraybuffer Array<u8>, options: InitializationOptions): PixelMap; 656 657@overload("createPixelMapSync") 658function CreatePixelMapByOptionsSync(options: InitializationOptions): PixelMap; 659 660// For legacy ANI backward compatibility 661function CreatePixelMapByPtr(ptr: i64): PixelMap; 662 663@overload("createPixelMapFromSurfaceSync") 664function CreatePixelMapFromSurfaceByIdSync(surfaceId: String): PixelMap; 665 666@overload("createPixelMapFromSurfaceSync") 667function CreatePixelMapFromSurfaceByIdAndRegionSync(surfaceId: String, region: Region): PixelMap; 668 669@overload("createImageSource") 670function CreateImageSourceByUri(uri: String): ImageSource; 671 672@overload("createImageSource") 673function CreateImageSourceByUriOption(uri: String, options: SourceOptions): ImageSource; 674 675@overload("createImageSource") 676function CreateImageSourceByFd(fd: i32): ImageSource; 677 678@overload("createImageSource") 679function CreateImageSourceByFdOption(fd: i32, options: SourceOptions): ImageSource; 680 681@overload("createImageSource") 682function CreateImageSourceByArrayBuffer(buf: @arraybuffer Array<u8>): ImageSource; 683 684@overload("createImageSource") 685function CreateImageSourceByArrayBufferOption(buf: @arraybuffer Array<u8>, options: SourceOptions): ImageSource; 686 687@overload("createImageSource") 688function CreateImageSourceByRawFileDescriptorOption(rawfile: @sts_type("resourceManager.RawFileDescriptor") Opaque, options: Optional<SourceOptions>): ImageSource; 689 690function CreateImagePacker(): ImagePacker; 691 692@overload("createImageCreator") 693function CreateImageCreator(width: i32, height: i32, format: i32, capacity: i32): ImageCreator; 694 695@overload("createImageCreator") 696function CreateImageCreatorBySize(size: Size, format: ImageFormat, capacity: i32): ImageCreator; 697 698@overload("createImageReceiver") 699function CreateImageReceiver(width: i32, height: i32, format: i32, capacity: i32): ImageReceiver; 700 701@overload("createImageReceiver") 702function CreateImageReceiverBySize(size: Size, format: ImageFormat, capacity: i32): ImageReceiver; 703 704@overload("createPicture") 705function CreatePictureByPixelMap(mainPixelmap : PixelMap): Picture; 706 707function CreateAuxiliaryPicture(buffer: @arraybuffer Array<u8>, size: Size, type: AuxiliaryPictureType): AuxiliaryPicture;