Introduction to Image Kit

Note:

Currently in the beta phase.

Image development in application development involves the process of parsing, processing, and constructing image pixel data to achieve the desired image effect. It primarily includes image decoding, image processing, and image encoding.

Before learning image development, it is essential to familiarize yourself with the following basic concepts:

  • Image Decoding
    Refers to decoding archived images of supported formats into a unified PixelMap for image display or processing within an application or system.

  • PixelMap
    Represents an uncompressed bitmap after image decoding, used for image display or processing.

  • Image Processing
    Involves operations on PixelMap, such as rotation, scaling, setting transparency, obtaining image information, reading/writing pixel data, etc. The coordinate system origin for these operations is the top-left corner.

  • Image Encoding
    Refers to encoding PixelMap into archived images of different formats for subsequent processing, such as saving or transmission.

The main workflow of image development is illustrated below.

Figure 1 Image Development Process Diagram

Image development process

  1. Obtain the Image: Acquire the original image through methods like the application sandbox.
  2. Create an ImageSource Instance: ImageSource is the image source class decoded from the image, used to retrieve or modify image-related information.
  3. Image Decoding: Decode the image into a PixelMap via ImageSource.
  4. Image Processing: Process the PixelMap to alter image properties, achieving effects like rotation, scaling, and cropping. Then display the image using the Image component.
  5. Image Encoding: Use the ImagePacker class to compress and encode the PixelMap or ImageSource, generating a new image.

In addition to the basic image development capabilities mentioned above, OpenHarmony also provides common image tools for developers to choose from.

Highlights/Features

Image Kit supports multiple image formats for encoding and decoding, employing efficient algorithms and optimization strategies to enhance the speed and efficiency of image processing.

Constraints and Limitations

  • Read/Write Permission Restrictions:
    During image processing, user images may be required. Applications must request corresponding read/write permissions from users to ensure normal functionality.

The image framework provides image encoding and decoding capabilities, supporting components like the Image component and gallery applications. The decoded results can be passed to the Image component for display.