Image loading method and related device

By determining the rendering operation according to the image source format and using appropriate compression algorithms, the problems of slow image loading speed and waste of storage space in embedded systems are solved, and more efficient image loading and storage are achieved.

CN113538208BActive Publication Date: 2024-09-17HUAWEI TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202010314065.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-04-20
Publication Date
2024-09-17
Estimated Expiration
2040-04-20

AI Technical Summary

Technical Problem

In the existing technology, due to PSRAM limitations when loading images in embedded systems, it takes a long time to load image resources from Flash to memory, which affects the user experience, and the unified use of ARGB8888 format leads to a waste of storage space.

Method used

By determining the rendering operation based on the source format of the image, it supports image input in different source formats and saves storage resources without affecting the display effect. For example, the ARGB8888 format is used in transparent overlay scenes, but does not involve transparent overlay scenes. Use RGB24 or RGB16 format, and optimize image storage and loading through compression and decompression algorithms.

Benefits of technology

It reduces the size of image storage, increases image loading speed, improves user experience, and effectively utilizes storage resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113538208B
    Figure CN113538208B
Patent Text Reader

Abstract

A method for loading an image is disclosed, comprising: an electronic device acquiring a first image file, the first image file comprising a format field and a data field, the format field being used to indicate a source format of the first image file, the data field comprising pixel data of the first image file; the electronic device determining a rendering operation corresponding to the first image file according to the source format of the first image file; the electronic device rendering the first image file to a display screen according to the rendering operation corresponding to the first image file. In this way, the electronic device can support image inputs of different source formats, and then display the images on the display screen through different rendering methods, which can save image storage resources and reduce the size of image storage. This reduces the time required to load image resources from Flash to memory, and improves user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing, and in particular to a method for loading an image and related devices. Background Art

[0002] The memory of the processor in an embedded system is usually small, so the memory is generally used as stack space when the code is running. As for the resource cache related to the UI page display such as pictures and fonts, an external PSRAM (Pseudostatic random access memory) is usually used to solve it. Adding a piece of PSRAM will have a very large impact on the hardware cost, power consumption and battery life of the product. Therefore, the size of PSRAM is generally not configured to ensure the cache of image resources of all pages. Therefore, when switching pages, it is necessary to clear the image resources of the previous page and load the resources of the new page. The size of the image resources has a great impact on the response time when switching pages.

[0003] In the prior art one, the picture loading solution provided by the UI framework in the current embedded system is usually to convert the Portable Network Graphics (PNG) picture into the Bitmap (bitmap, BMP) format through a tool, and then compile the picture data into the code of the electronic device and load it directly into the memory of the processor. In order not to affect the storage and loading of the picture, the source format of all pictures in the electronic device needs to be unified. If a transparent overlay scene is involved, all pictures of the electronic device must use the ARGB8888 format. However, this method will take up code storage space when loading pictures, so the number of pictures that can be loaded is limited; and ARGB8888 is 32 bits, and most scenes do not use so many colors, so there is a problem of wasted storage space.

[0004] In the second prior art, after converting the image from PNG to ARGB8888 32-bit BMP format, it is compressed and generated into a bin file and saved in Flash, and the image resources are loaded into PSRAM as needed when the system is running. However, it takes time to load the image resources from Flash to the memory, and when the page is complex, the page response time is long, and the user experience is poor.

[0005] Therefore, reducing the size of image storage and improving image loading speed become problems that need to be solved. Summary of the invention

[0006] The embodiments of the present application provide a method for loading an image and a related device, which can reduce the size of image storage and improve the image loading speed.

[0007] In a first aspect, the present application provides a method for loading an image, which is applied to an electronic device. The method may include: the electronic device acquires a first image file, the first image file includes a format field and a data field, the format field is used to indicate the source format of the first image file, and the data field includes pixel data of the first image file; the electronic device determines a rendering operation corresponding to the first image file according to the source format of the first image file; the electronic device renders the first image file onto a display screen according to the rendering operation corresponding to the first image file.

[0008] Implementing the method of the first aspect, the electronic device determines the rendering operation of the first picture file through the source format of the first picture file, wherein different source formats correspond to different rendering operations, and displays the first picture file on the display screen. In this way, the electronic device can support the input of pictures in different source formats, and then display the pictures on the display screen through different rendering methods, which can save the storage resources of the pictures and reduce the size of the picture storage. For example, in a scene involving transparent overlay, it is not necessary for all pictures in the electronic device to use the ARGB8888 format. It is only necessary to use the ARGB8888 format for pictures in scenes involving transparent overlay, and use the RGB24 or RGB16 format for pictures in scenes not involving transparent overlay, so that the storage resources of the pictures can be saved without affecting the display effect. Thereby reducing the time required to load picture resources from Flash into memory and improving the user experience.

[0009] In conjunction with the first aspect, in some embodiments, when the source format of the first image file is the first format, the rendering operation includes: controlling the transparency of the first image file through a transparent channel, and displaying the first image file on the display screen with a transparent effect, and the first format supports the transparent channel. This method provides an exemplary rendering operation, and when the source format of the first image file supports the transparent channel, the rendering operation of the electronic device on the first image file includes transparent calculation, that is, the first image file can have a transparent effect when displayed on the display screen.

[0010] In combination with the first aspect, in some embodiments, when the source format of the first image file is the second format, the rendering operation includes: blocking other image files when displaying the first image file on the display screen. This method provides another exemplary rendering operation. When the source format of the first image file does not support a transparent channel, the electronic device's rendering operation of the first image file includes directly superimposing it on other images to block other images.

[0011] In combination with the first aspect, in some embodiments, the method further includes: the electronic device obtains a second picture file, the second picture file includes a format field and a data field, the format field is used to indicate the source format of the second picture file, and the data field includes pixel data of the second picture file; the electronic device determines the rendering operation corresponding to the first picture file according to the format field of the first picture file, specifically including: the electronic device determines the rendering operation corresponding to the first picture file according to the format field of the first picture file and the second picture file. When the second picture file is a background picture, the electronic device may have different rendering operations for the first picture file for different background pictures. Specifically, the electronic device may display the first picture file superimposed on the second picture file, or the electronic device may display the first picture file superimposed on the second picture file according to different transparencies, or the electronic device may display the first picture file superimposed on the second picture file at different positions, or the electronic device may display the first picture file superimposed on the second picture file in different sizes or proportions.

[0012] In combination with the first aspect, in some embodiments, before the electronic device obtains the first picture file, it also includes: the electronic device obtains the source file of the first picture file, and converts the format of the source file of the first picture file into the first picture file. In some embodiments, before the electronic device obtains the second picture file, it also includes: the electronic device obtains the source file of the second picture file, and converts the format of the source file of the second picture file into the second picture file. The source file of the first picture file and the source file of the second picture file can be in different formats (for example, BMP format and PNG format), and the format of the first picture file and the second picture file are the same. That is to say, the electronic device can support the input of pictures with different source formats, and then convert the formats into the same format, so as to facilitate the storage and loading of pictures by the electronic device.

[0013] In some embodiments, the format of the source file of the first picture file is converted into the first picture file, including: compressing the source file of the first picture file according to a preset compression algorithm; if the compression ratio is greater than or equal to a threshold, filling the compressed pixel data into the data field of the first picture file; if the compression ratio is less than the threshold, filling the pixel data before compression into the data field of the first picture file, and the compression ratio is the ratio of the size of the source file of the first picture file before compression to the size after compression. In some embodiments, the threshold may be related to the computing power of the electronic device and the file reading speed. The process of judging whether the compression ratio is greater than or equal to the threshold can avoid the situation where the picture file occupies more storage resources of the electronic device after compression, and optimize the processing effect of the picture.

[0014] In some embodiments, a decompression algorithm is provided for the above-mentioned compression algorithm, and the first image file is decompressed before image rendering. The electronic device renders the first image file onto the display screen according to the rendering operation corresponding to the first image file, and the electronic device also includes: the electronic device determines whether the data field of the first image file is a compressed field; if so, decompresses the data field of the first image file according to a preset decompression algorithm; fills the decompressed pixel data into the data field of the first image file; if not, does not change the data field of the first image file.

[0015] In conjunction with the first aspect, in some embodiments, the first image file further includes a transparent color field, and the transparent color field is used to indicate a color area displayed transparently in the first image file. The transparent color field provided by the present application can enable an image that does not support a transparent channel to achieve a transparent effect and be displayed on a display screen. This expands the scope of use of image formats that do not support transparent channels, and further saves storage resources of electronic devices.

[0016] In some embodiments, when the source format of the first picture file is the third format, the electronic device renders the first picture file to the display screen according to the rendering operation corresponding to the first picture file, specifically including: determining whether the transparent color field of the first picture file is valid; if so, the electronic device performs transparent processing on the first picture file according to the transparent color field, so that the color area corresponding to the transparent color field in the first picture file has a transparent effect on the display screen; if not, the electronic device blocks other pictures when displaying the first picture file on the display screen. In other words, even if the third format does not support transparent channels, if the transparent color field of the first picture file is valid, the first picture file can also have a transparent effect on the display screen. That is, the color area corresponding to the transparent color field is displayed on the display screen as transparent and does not block other pictures. In this way, when pictures in a format that supports transparent channels are originally required, the third format can also be used, which reduces the size of picture storage and thus increases the speed of picture loading.

[0017] In combination with the first aspect, in some embodiments, the method further includes: obtaining configuration information of the electronic device, wherein the configuration information includes the size of the display screen and the display configuration of the display screen; the electronic device determines the rendering operation corresponding to the first image file according to the format field of the first image file, specifically including: the electronic device determines the rendering operation corresponding to the first image file according to the first format field of the first image file and the configuration information. The electronic device determines the display ratio of the first image file by the size of the display screen; and converts the format of the first image file by the display configuration (e.g., display format) of the display screen so that the first image file can be displayed on the display screen.

[0018] In conjunction with the first aspect, in some embodiments, the rendering operation includes one or more of the following: scaling, rotation, and transparent calculation. Among them, the scaling operation is used to control the size or proportion of the image file displayed on the display screen, the rotation operation is used to control the rotation effect of the image file displayed on the display screen, and the transparent calculation is used to control the transparency of the image file displayed on the display screen. This application does not limit the operation method and steps of the rendering operation.

[0019] In combination with the first aspect, in some embodiments, the first image file further includes a palette field, and the palette field is used to indicate a mapping relationship between pixel colors and index numbers of the first image file, where one index number indicates a color. The palette field provided in the present application can further compress the size of the first image file by using index numbers to represent pixel colors.

[0020] In a second aspect, the present application provides an electronic device, which may include: one or more processors, a memory, and a display screen; the memory and the display screen are coupled to the one or more processors, the memory is used to store a computer program code, the computer program code includes a computer instruction, and the one or more processors call the computer instruction to enable the electronic device to execute:

[0021] Obtain a first image file, the first image file including a format field and a data field, the format field is used to represent a source format of the first image file, and the data field includes pixel data of the first image file; determine a rendering operation corresponding to the first image file according to the source format of the first image file; and render the first image file onto the display screen according to the rendering operation corresponding to the first image file.

[0022] In combination with the second aspect, in some embodiments, when the source format of the first image file is a first format, the rendering operation includes: controlling the transparency of the first image file through a transparent channel, and displaying the first image file on the display screen with a transparent effect, and the first format supports the transparent channel.

[0023] In combination with the second aspect, in some embodiments, when the source format of the first image file is the second format, the rendering operation includes: blocking other image files when displaying the first image file on the display screen.

[0024] In combination with the second aspect, in some embodiments, the electronic device also includes: obtaining a second image file, the second image file including a format field and a data field, the format field is used to indicate a source format of the second image file, and the data field includes pixel data of the second image file; determining the rendering operation corresponding to the first image file based on the format field of the first image file, specifically including: determining the rendering operation corresponding to the first image file based on the format field of the first image file and the second image file.

[0025] In conjunction with the second aspect, in some embodiments, before obtaining the first picture file, it also includes: obtaining the source file of the first picture file, and converting the format of the source file of the first picture file into the first picture file. In some embodiments, before obtaining the second picture file, it also includes: the electronic device obtains the source file of the second picture file, and converts the format of the source file of the second picture file into the second picture file. The source file of the first picture file and the source file of the second picture file can be in different formats (for example, BMP format and PNG format), and the format of the first picture file and the second picture file is the same. In other words, the electronic device can support the input of pictures in different source formats, and then convert the formats into the same format, so as to facilitate the storage and loading of pictures by the electronic device.

[0026] In some embodiments, the format of the source file of the first picture file is converted into the first picture file, including: compressing the source file of the first picture file according to a preset compression algorithm; if the compression ratio is greater than or equal to a threshold, filling the compressed pixel data into the data field of the first picture file; if the compression ratio is less than the threshold, filling the pixel data before compression into the data field of the first picture file, and the compression ratio is the ratio of the size of the source file of the first picture file before compression to the size after compression.

[0027] In some embodiments, according to the rendering operation corresponding to the first image file, the first image file is rendered onto the display screen, and the process also includes: determining whether the data field of the first image file is a compressed field; if so, decompressing the data field of the first image file according to a preset decompression algorithm; filling the decompressed pixel data into the data field of the first image file; if not, not changing the data field of the first image file.

[0028] In combination with the second aspect, in some embodiments, the first image file also includes a transparent color field, and the transparent color field is used to represent a color area displayed transparently in the first image file.

[0029] In some embodiments, when the source format of the first image file is the third format, the first image file is rendered onto a display screen according to a rendering operation corresponding to the first image file, specifically including: determining whether the transparent color field of the first image file is valid; if so, performing transparent processing on the first image file according to the transparent color field so that the color area corresponding to the transparent color field in the first image file has a transparent effect on the display screen; if not, obstructing other images when displaying the first image file on the display screen.

[0030] In combination with the second aspect, in some embodiments, the electronic device also includes: obtaining configuration information, wherein the configuration information includes the size of the display screen and the display configuration of the display screen; and determining the rendering operation corresponding to the first image file based on the format field of the first image file, specifically including: determining the rendering operation corresponding to the first image file based on the first format field of the first image file and the configuration information.

[0031] In combination with the second aspect, in some embodiments, the rendering operation includes one or more of the following: scaling, rotation, and transparency calculation.

[0032] In combination with the second aspect, in some embodiments, the first image file further includes a palette field, which is used to represent a mapping relationship between pixel colors of the first image file and index numbers, where one index number represents a color.

[0033] In a third aspect, an embodiment of the present application provides a computer storage medium, including computer instructions, which, when executed on an electronic device, enables the electronic device to execute the method for loading an image in any possible implementation of the first aspect.

[0034] In a fourth aspect, an embodiment of the present application provides a computer program product. When the computer program product is run on a computer, it enables the computer to execute the method for loading an image in any possible implementation of the first aspect.

[0035] It can be understood that the electronic device provided in the second aspect, the computer storage medium provided in the third aspect, and the computer program product provided in the fourth aspect are all used to execute the image loading method provided in the first aspect. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the method provided in the first aspect and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 A system architecture diagram of a method for loading images provided in an embodiment of the present application;

[0037] Figure 2 A picture encoding format provided in an embodiment of the present application;

[0038] Figure 3 A format conversion method provided in an embodiment of the present application;

[0039] Figure 4 A method for loading an image provided in an embodiment of the present application;

[0040] Figure 5 Another picture encoding format provided in the embodiment of the present application;

[0041] Figure 6 Another format conversion method provided in an embodiment of the present application;

[0042] Figure 7 Another image loading method provided in the embodiment of the present application;

[0043] Figure 8 An installation data packet format provided in an embodiment of the present application;

[0044] Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;

[0045] Fig.10 A schematic diagram of a software architecture provided for an embodiment of the present application. DETAILED DESCRIPTION

[0046] The technical solutions in the embodiments of the present application will be described clearly and in detail below in conjunction with the accompanying drawings. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in the text is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.

[0047] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as suggesting or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features, and in the description of the embodiments of the present application, unless otherwise specified, "plurality" means two or more.

[0048] The electronic devices involved in the embodiments of the present application can be mobile phones, tablet computers, desktops, laptops, notebook computers, ultra-mobile personal computers (Ultra-mobile Personal Computer, UMPC), handheld computers, netbooks, personal digital assistants (Personal Digital Assistant, PDA), wearable electronic devices (such as sports watches, smart bracelets, smart watches), virtual reality devices, in-vehicle multimedia devices, smart home devices, medical equipment and other devices with display functions.

[0049] First, some relevant background information in this application is explained to facilitate understanding by those skilled in the art.

[0050] (1) For non-embedded systems, compressed image formats such as PNG are usually used and rendered by a graphics processing unit (GPU) to reduce resource overhead. However, for embedded systems, since embedded systems usually have a lower main frequency and poorer computing performance, images in formats such as PNG are generally converted to BMP format before use.

[0051] (2) BMP color format: including RGB16 format, RGB24 format and RGB16 format.

[0052] In RGB16 format, each pixel is represented by 16 bits, and one pixel occupies 2 bytes. There are usually two formats: RGB565 and RGB555. The RGB components R (red), G (green), and B (blue) of RGB565 use 5 bits, 6 bits, and 5 bits respectively, while the RGB components R, G, and B of RGB555 use 5 bits, 5 bits, and 5 bits respectively, and the highest bit is not used.

[0053] In the RGB24 format, each pixel is represented by 24 bits, and one pixel occupies 3 bytes. The RGB888 format is usually used. The RGB components R, G, and B of RGB888 use 8 bits, 8 bits, and 8 bits respectively.

[0054] In RGB32 format, each pixel is represented by 32 bits, and one pixel occupies 4 bytes. ARGB8888 format is usually used. ARGB8888 format is essentially RGB24 with Alpha channel. The RGB components R, G, and B of RGB32 use 8 bits, 8 bits, and 8 bits respectively. The reserved 8 bits are used to represent transparency, that is, Alpha value.

[0055] Because both RGB16 and RGB24 format images do not have transparent channels, there will be occlusion problems when images are superimposed on each other. If images are not superimposed on each other, RGB16 (RGB565 / 555) or RGB24 (RGB888) can generally be used as the format of the original image resource. If images are superimposed on each other, RGB32 (ARGB8888) is usually used.

[0056] (3) BMP compression method

[0057] ① Color palette

[0058] Use indexes to represent images, and the palette is a mapping table of indexes and their corresponding colors. That is, one byte is used to represent a color. When storing an image, a combination of numbers is stored, and the mapping of numbers to image colors is stored at the same time. This method can only store a limited number of colors, usually 256 colors. Corresponding to the computer system, a one-byte number is used to index a color. On the basis of using the palette, there is no need to use RGBA to describe the color, but instead use the color index to describe it. The advantage of using the palette is that a 25% compression ratio can be obtained. The disadvantage is that the palette has a small number of colors and the application scenarios are relatively limited. In addition, when the image is small, the palette itself has overhead, which will result in a low compression ratio or negative compression.

[0059] ②Merge consecutive identical pixels

[0060] For example, 13 consecutive identical red pixels can be combined and represented as "F Red 13", where F is the compression flag, Red is the color, and 13 is the number of colors. When decompressing, after encountering the compression flag F, the subsequent 13 consecutive colors are expanded. The advantage of this compression algorithm is that the execution efficiency is very high. The disadvantage is that if the image is not as fast as a large area of ​​continuous pure color, the compression ratio is very low, and even data expansion and negative compression scenarios may occur.

[0061] (4) Image Rendering

[0062] Image rendering is the process of displaying an image on a display screen. Before rendering an image on a display screen, the original pixel data of the image must be obtained first. If the image is a compressed image, it needs to be decompressed first.

[0063] The image rendering process includes: first obtain the coordinates of the image; pass the coordinates to the vertex shader (calculate the vertices of the image); rasterize the image (obtain the pixels corresponding to the image on the screen); calculate the fragment shader (calculate the final displayed color value of each pixel, if a transparent value appears, the color of each pixel needs to be * the transparency value); render from the frame buffer to the screen.

[0064] Secondly, in order to facilitate understanding of the embodiments of the present application, the system architecture in the embodiments of the present application is analyzed in detail below. Figure 1 The following is an exemplary diagram of the system architecture of a method for loading an image provided by the present application.

[0065] like Figure 1 As shown, the system architecture may include MCU (Microcontroller Unit), flash memory, PSRAM (Pseudo static random access memory) and display LCD.

[0066] MCU: Microcontroller Unit, also known as single chip microcomputer or single chip microcomputer. MCU is a chip-level computer that integrates CPU, memory (RAM and ROM), multiple I / O interfaces, etc. on a single chip to provide different combination controls for different applications.

[0067] In the embodiment of the present application, the on-chip SRAM of the MCU includes relevant management modules and table resources of the file system 1001; the on-chip ROM of the MCU includes a resource mapping table 1002, which is a resource mapping table generated by a picture resource packaging tool when generating a resource file 1009. Through the resource mapping table 1002, the required resource files can be easily found in the resource file 1009.

[0068] The MCU also includes a UI framework 1003, a rendering module 1004, and a picture sending module 1005. The UI framework 1003 is in the MCU's on-chip ROM and can be implemented by pure software. The rendering module 1004 and the picture sending module 1005 can be peripheral modules for image rendering and image output.

[0069] SRAM: Static Random-Access Memory. It is a type of random access memory. The so-called "static" means that as long as the memory remains powered, the data stored in it can be kept constant, without the need for refresh operations, and the speed is fast. In contrast, the data stored in the dynamic random access memory (DRAM) needs to be updated periodically. In order to speed up the transmission of data within the MCU, SRAM is usually designed inside the MCU.

[0070] However, the capacity of SRAM is small, so SRAM is generally used as stack space when the code is running. As for the resource cache related to UI page display such as pictures and fonts, external PSRAM is usually used to solve it.

[0071] PSRAM: Pseudo static random access memory, with a larger capacity than SRAM. Since PSRAM is a volatile memory, UI resources (fonts, pictures, etc.) must be stored in ROM or external Flash. Since the ROM space of the MCU is often very small and is mainly used to store code instructions, the most common usage is to save the resource file 1009 of the picture in Flash and load it to PSRAM when it is running after booting.

[0072] In the embodiment of the present application, the PSRAM may include a decompression module 1006, a resource cache module 1007, and a frame cache module 1008. The decompression module 1006 is used to decompress the acquired image resources; the resource cache module 1007 is used to cache resources related to UI page display such as images and fonts. The decompression module 1006, the resource cache module 1007, and the frame cache module 1008 are only functional divisions and do not involve hardware divisions.

[0073] Flash: It is a type of storage chip, also known as flash memory. Flash combines the advantages of ROM and RAM. It not only has erasable and programmable performance, but also can read data quickly so that data will not be lost due to power failure.

[0074] In the embodiment of the present application, the resource file 1009 of the picture is stored in Flash. When the electronic device is turned on or the display page is switched, the MCU will use the file system 1001 to read the picture resources from the resource file 1009 of Flash into the resource cache 1007 of PSRAM by searching the resource mapping table 1002 of ROM. If the picture read by the MCU from the resource file 1009 is compressed, it needs to be decompressed 1006 to get to the resource cache 1007, and the picture in the resource cache 1007 is used by the UI framework 1003. Then, the picture in the resource cache 1007 is rendered by the UI framework 1003 and the rendering module 1004, output to the frame buffer module 1008, and output through the picture sending module 1005 to be displayed on the display LCD. Complete the loading of the picture.

[0075] The default image loading solution provided by the current embedded UI framework is usually to convert PNG images into BMP format through tools, compress and generate bin files and save them in Flash, and load the image resources into PSRAM on demand when the system is running. In order to store and load images more conveniently, the source format of all images in electronic devices needs to be unified. If transparent overlay scenes are involved, all images of electronic devices must use ARGB8888 format.

[0076] However, most scenarios do not need to support transparency and such a high number of colors. All images on electronic devices use the ARGB8888 format, which will lead to a waste of resources. In addition, it takes time to load image resources from Flash to memory. When the page is complex, the image loading time is long, the page response time is long, and the experience is poor.

[0077] In view of the above technical problems, the embodiment of the present application proposes a new picture encoding format, which realizes format unification by converting different types of picture source formats, thereby minimizing resource usage and optimizing loading performance without affecting display effects.

[0078] like Figure 2 As shown, Figure 2 An exemplary picture encoding format provided by an embodiment of the present application is shown. The picture encoding format includes control bits, color format, compression algorithm, picture width, picture height, and bitmap data. Among them,

[0079] The control properties of the control bit include whether to support transparent channel alpha. For example, if the image is in ARGB8888 format, the control bit indicates that transparent channel is supported. Exemplarily, the control bit is 4 bits. If the image is in ARGB8888 format, the control bit field is 1000, indicating that transparent channel is supported; if the image is in RGB888 or RGB565 or RGB555 format, the control bit field is 0000, indicating that transparent channel is not supported.

[0080] Color format, that is, the color format of the image. It includes RGB888 format, ARGB888 format, RGB565 / 555 format, etc. For example, 0x888 can be used to represent the RGB888 color format; if the control attribute of the control bit indicates that transparent channel is supported, the ARGB888 format is used; if the control attribute of the control bit indicates that transparent channel is not supported, the RGB888 format is used. 0x565 can be used to represent the RGB565 format, and 0x555 can be used to represent the RGB555 format.

[0081] In this application, the field indicating the format of the picture may be referred to as a format field. For example, the control attribute and the color format of the control bit together indicate that the picture is in ARGB888 format, and the format field of the picture includes the control bit and the color format.

[0082] Compression algorithm, such as continuous identical pixel merging algorithm. When the compression ratio does not reach the threshold, you can also choose not to compress. The compression ratio is the size of the space occupied before compression / the size of the space occupied after compression. For example, 0x00AA can be used to represent continuous identical pixel merging, and 0x0000 can be used to represent no compression.

[0083] Image width / image height, width*height determines the number of pixels in the bitmap data.

[0084] Bitmap data is the pixel data used to display the actual image. For example, if one pixel of ARGB8888 occupies 4 bytes, the bitmap data includes image width * image height * 4; if one pixel of RGB888 occupies 3 bytes, the bitmap data includes image width * image height * 3; if one pixel of RGB565 occupies 2 bytes, the bitmap data includes image width * image height * 2. In this application, bitmap data can be referred to as data field.

[0085] The picture encoding format provided above can describe pictures of different formats by controlling the bit field and the color format field. That is, through this picture encoding format, different types of picture formats can be encoded into a unified format, thereby improving the efficiency of picture storage and loading.

[0086] Among them, this application does not limit the order, length, name and division of the fields in the image coding format.

[0087] Through this picture coding format, the present application can distinguish different pictures using different source formats according to the characteristics of the pictures, and then convert the pictures of different source formats to achieve format unification. There is no need to use the same format for the source formats of all pictures in the electronic device in order to unify the format. For example, in a scene involving transparent overlay, it is not necessary for all pictures in the electronic device to use the ARGB8888 format. It is only necessary to use the ARGB8888 format for pictures in scenes involving transparent overlay, and use the RGB24 or RGB16 format for pictures in scenes not involving transparent overlay, and then convert ARGB8888, RGB24, RGB16, etc. into a unified format. In this way, the storage resources of the electronic device for the picture can be saved without affecting the display effect. Thereby reducing the time required for the electronic device to load the picture resources from Flash to the memory, and improving the user experience.

[0088] Next, combined with the above Figure 2 The image encoding format is based on Figure 1 Schematic hardware architecture diagram, this application provides a format conversion method, which can convert image files of different source formats into the above Figure 2 Image files in the image encoding format. Figure 3 As shown, Figure 3 A schematic flow chart of a format conversion method is shown.

[0089] S101: Reading image files and configuration files.

[0090] The electronic device reads the input image file and configuration file, where the image file may include one or more images, and the format of the one or more images may be a variety of different formats, such as ARGB8888 format, RGB565 format, RGB555 format, etc. When the usage scenario of the image requires transparency or a more delicate gradient color transition, the ARGB8888 format image can be used; other scenarios can use RGB565 / RGB555 format images. The configuration file saves the rules for converting the format of the image file, which includes the above-mentioned image encoding format, and images of different formats can be encoded into a unified format through the rules.

[0091] If the image format is ARGB8888, the control attribute of the control bit in the image encoding format indicates that transparent channels are supported, and the color format is RGB888; if the image format is RGB565, the control attribute of the control bit in the image encoding format indicates that transparent channels are not supported, and the color format is RGB565.

[0092] In an embodiment of the present application, one of the images in the above-mentioned image files can be called the source file of the first image file, the format of the source file of the first image file can be called the source format of the first image file, and the field describing the source format of the first image file can be called the format field.

[0093] S102: Parse the image into BMP format.

[0094] After the electronic device reads the image file and the configuration file, it parses one or more images in the image file into BMP format, which is an uncompressed RGB bitmap. For example, if the image read by the electronic device is a PNG image, the bitmap data of the image needs to be decompressed and described in RGB format.

[0095] S103: compressing the bitmap data.

[0096] For each picture, the electronic device parses the picture into a standard data format and then compresses the bitmap data of the picture. The compression algorithm may be a continuous identical pixel merging algorithm. The compression algorithm may also include other types of algorithms, which are not limited in the embodiments of the present application.

[0097] S104: Determine whether the compression ratio is greater than a threshold.

[0098] After the electronic device compresses the bitmap data of each picture, it determines whether the compression ratio of the picture is greater than the threshold. If it is, the picture is compressed according to the algorithm of merging consecutive identical pixels. The compression algorithm field of the picture indicates that the compression is performed using the algorithm of merging consecutive identical pixels, and the compressed data is filled into the bitmap data field of the picture encoding format. If the picture uses a large number of gradient colors, resulting in a too low compression ratio or data expansion, negative compression, or the compression ratio is less than the threshold, the bitmap data of the picture is directly filled into the bitmap data field of the picture encoding format without compression, and the compression algorithm field indicates no compression.

[0099] The compression ratio of the image is the ratio of the space occupied by the image before compression to the space occupied by the image after compression. The threshold can be given by comprehensively evaluating the MCU computing power, the file system reading speed, and the PSRAM reading and writing performance. The process of judging whether the compression ratio is greater than or equal to the threshold can avoid the situation where the image file occupies more storage resources of the electronic device after compression, and optimize the processing effect of the image.

[0100] S105: Generate a mixed loading resource file.

[0101] After completing the compression judgment for a single image, the electronic device converts the image according to the image encoding format according to the rules configured in the configuration file. After all images in the image file have completed the format conversion, the electronic device generates a resource mapping table for the image. In the resource mapping table, the image is encoded according to the rule of "application ID_resource ID", such as A100_001, A100_002, A100_003, etc. When the electronic device needs to use the image, it can directly index the position of the image in the resource file through the application ID and resource ID. Among them, the mixed loading resource file includes the resource file of the image and the resource mapping table of the image. The resource file of the image can be saved in the flash of the electronic device, and the resource mapping table of the image can be saved in the ROM of the electronic device.

[0102] In the present application, after the electronic device converts the source file of the first picture file according to the above-mentioned picture encoding format, it can be called the first picture file.

[0103] The above process describes the image based on Figure 2 The format conversion process completed by the picture encoding format. According to the above process, the electronic device can read pictures of different formats, convert the pictures of different formats, and achieve format unification. Without affecting the display effect, the storage resources for pictures in the electronic device are saved, the size of the picture storage is reduced, and the picture loading speed is improved.

[0104] Accordingly, for Figure 3 The format conversion method of the provided image, Figure 4 A method for loading an image is described. When an electronic device is turned on or a display page is switched, the image needs to be decompressed and loaded onto the display screen of the electronic device. Figure 4 Embodiment of the method.

[0105] S201: Reading a picture.

[0106] The electronic device reads the image into the memory. The resource file of the image is saved in the Flash of the electronic device. When the electronic device is turned on or the display page is switched, the MCU uses the file system to read the image resource from the resource file of the Flash by searching the resource mapping table of the ROM. The image is encoded according to the rule of "application ID_resource ID". When the electronic device needs to use the image, it can directly index the location of the image in the resource file through the application ID and resource ID.

[0107] For example, when an electronic device needs to use pictures coded as A100_001, A100_002 and A100_003, the positions of the pictures coded as A100_001, A100_002 and A100_003 in the resource file are searched in the resource mapping table. After obtaining the positions, the resources of the pictures corresponding to the positions are read in the resource file.

[0108] In the present application, the electronic device reads a picture into the memory, and the picture can be referred to as a first picture file.

[0109] S202: Parsing the image header data.

[0110] After the electronic device reads the image into the memory, it Figure 2 The provided image encoding format parses the file header. The information obtained by parsing the file header includes control bits (whether transparent channels are supported), color format, and compression algorithm.

[0111] In the present application, the control bit and color format of the first picture file may be referred to as the format field of the first picture file. The format field of the first picture file describes the source format of the first picture file.

[0112] S203: Determine whether the data is compressed.

[0113] After parsing the header data of the image, the electronic device determines whether the bitmap data in the image is compressed data. If the compression algorithm field in the header of the image file indicates that a compression algorithm for merging continuous pixels is used, the bitmap data in the image is compressed data, and step S204 is implemented; if the compression algorithm field in the header of the image file indicates that no compression is used, the bitmap data in the image is not compressed data, and step S205 is implemented.

[0114] In this application, the above bitmap data can be referred to as a data field.

[0115] S204: Decompression.

[0116] If the compression algorithm field in the header of the image file indicates that a compression algorithm for merging consecutive pixels is used, the bitmap data in the image is compressed data, and the electronic device performs pixel expansion on the bitmap data of the image. For example, 13 consecutive identical red pixels can be combined to represent "F Red 13", where F is the compression flag, Red is the color, and 13 is the number of colors. During decompression, after encountering the compression flag F, the subsequent 13 consecutive colors are expanded.

[0117] S205: Generate a picture object.

[0118] If the compression algorithm field in the picture file header indicates uncompressed, the bitmap data in the picture is not compressed data, and the bitmap data of the picture does not need to be decompressed, and the picture object is directly generated. If the compression algorithm field in the picture header indicates compressed, the bitmap data of the picture is decompressed to generate the picture object.

[0119] After the electronic device generates the picture object, it distinguishes the picture object according to the control bit and the color format, and renders the picture objects of different formats respectively. The embodiment of the present application exemplarily provides two different rendering methods. For a picture object with a transparent channel (for example, an ARGB8888 format picture), step S206 is executed; for a picture object without a transparent channel (for example, an RGB565 format picture), step S207 is executed.

[0120] In the present application, the format of a picture with a transparent channel may be referred to as a first format (eg, ARGB8888 format), and the format of a picture without a transparent channel may be referred to as a second format (eg, RGB565 format).

[0121] S206: Scaling, rotation, transparent calculation, etc.

[0122] The electronic device performs scaling, rotation, and transparency calculation on the ARGB8888 format image. Since the ARGB8888 format image has a transparent channel, it can support rendering operations such as rotation, scaling, and transparency calculation. The scaling operation is used to control the size or ratio of the image displayed on the display screen, the rotation operation is used to control the rotation effect of the image displayed on the display screen, and the transparency calculation is used to control the transparency of the image displayed on the display screen.

[0123] For example, the display interface of a dial may include dial background, hour hand, minute hand, second hand and other pictures. The pictures of the hour hand, minute hand and second hand require transparency and rotation, so the pictures of the hour hand, minute hand and second hand use ARGB8888 format pictures. The electronic device performs rotation and transparency calculations for the pictures of the hour hand, minute hand and second hand respectively, so that the hour hand, minute hand and second hand can rotate, and the pictures of the hour hand, minute hand and second hand will not block the dial background.

[0124] In some possible embodiments, the electronic device renders image objects of different formats respectively, and determines the rendering operation corresponding to the image according to the configuration information of the electronic device. The configuration information includes the size of the display screen and the display configuration of the display screen. The electronic device determines the display size or ratio of the image by the size of the display screen; and performs corresponding display matching on the image by the display configuration (such as the display format) of the display screen, so that the image can be displayed on the display screen through rendering.

[0125] In some possible embodiments, the electronic device renders image objects of different formats respectively, and determines the rendering operation corresponding to the first image file according to the second image file. Wherein, when the second image file is a background image, the electronic device may have different rendering operations on the first image file for different background images. Specifically, the electronic device may overlay and display the first image file on the second image file, or the electronic device may overlay and display the first image file on the second image file according to different transparencies, or the electronic device may overlay and display the first image file at different positions of the second image file, or the electronic device may overlay and display the first image file on the second image file in different sizes or proportions.

[0126] Among them, this application does not limit the operation method and steps of the rendering operation.

[0127] S207: Directly perform layer overlay.

[0128] The electronic device directly overlays layers on the RGB565 format images, that is, when the RGB565 image is used as the background, no elements are blocked; when the RGB565 image is used as the foreground, the images, texts and other elements behind it are completely blocked.

[0129] S208: Frame buffer.

[0130] After the electronic device renders the image, it displays the image on the display screen through the frame buffer module. The electronic device completes loading the image.

[0131] The above process describes the Figure 2The image loading process of the image encoding format can realize on-demand loading according to the intended purpose and support mixed loading of multiple different image display effects. Since the image encoding format provided by this application supports images of multiple different formats, the size of image storage is reduced, thereby improving the image loading speed.

[0132] In some possible embodiments, the human input for image evaluation can be reduced by reducing the supported image formats. For example, only two image formats, RGB565 and ARGB8888, are used. In scenes where transparency is required or gradient colors are obvious, ARGB8888 format images are used; in other scenes, RGB565 format images are used.

[0133] In summary, Figure 2-Figure 4 The illustrated embodiment provides a picture encoding format, and performs format conversion and picture loading according to the encoding format. By supporting mixed rendering of pictures of different formats, the electronic device optimizes the storage of pictures, the size of loaded pictures, and the loading speed of pictures. The embodiment of the present application provides a mixed rendering method for the RGB565 / ARGB8888 formats, which can cover most optimization requirements and improve the user experience. Among them, the above mixed rendering method for RGB565 / ARGB8888 is only an exemplary method, and the present application does not limit the types and quantities of picture formats supported by electronic devices.

[0134] However, RGB565 / RGB888 does not support transparency, and some scenes will have mutual occlusion. Therefore, the RGB565 / RGB888 format has some limitations in practical applications.

[0135] Based on this problem, the embodiment of the present application provides another image encoding format, which can solve the problem that the RGB565 / RGB888 format does not support transparent calculation.

[0136] like Figure 5 As shown, Figure 5 Another exemplary picture encoding format provided by the embodiment of the present application is shown. The picture encoding format includes control bits, color format, compression algorithm, picture width, picture height, transparent color, reservation, color table and bitmap data. Among them,

[0137] The control attribute of the control bit includes whether to support transparent channel alpha. For example, if the image is in ARGB8888 format, the control attribute indicates that transparent channel is supported.

[0138] The control properties of the control bit also include whether a transparent color is used. The transparent color is a preset color value representing transparency. If the image uses a color value representing transparency, the MCU will treat this color value as transparent when parsing and rendering the image. If the image is in RGB565 / RGB888 format, a certain color can be transparently processed by setting the transparent color.

[0139] The control properties of the control bit also include whether a color palette is used. Using a color palette can further compress the image by using index numbers to represent pixel colors.

[0140] Exemplarily, the control bit is 4 bits, 1 bit is used to indicate whether the transparent channel Alpha is supported, 1 indicates that the transparent channel is supported; 1 bit is used to indicate whether the transparent color is used, 1 indicates that the transparent color value is used; 1 bit is used to indicate whether the palette is used, 1 indicates that the palette is used; and 1 bit is reserved.

[0141] Color format, that is, the color format of the image. It includes RGB888 format, ARGB888 format, RGB565 / 555 format, etc. For example, 0x888 can be used to represent the RGB888 color format; if the control attribute of the control bit indicates that transparent channel is supported, the format is ARGB888; if the control attribute of the control bit indicates that transparent channel is not supported, the format is RGB888. 0x565 can be used to represent the RGB565 format, and 0x555 can be used to represent the RGB555 format.

[0142] Among them, the control bit and color format can be used to describe the image format. For example, 0x8888=(1000B<<12)+0x0888 represents an ARGB8888 32-bit image with a transparent channel; 0x4888=(0100B<<12)+0x0888 represents an RGB888 24-bit image with transparent color; 0xA888=(1010B<<12)+0x0888 represents an ARGB8888 32-bit image with a transparent channel and using palette compression; 0x6888=(0110B<<12)+0x0888 represents an RGB888 24-bit image with transparent color and using palette compression.

[0143] In this application, the field indicating the format of the picture may be referred to as a format field. For example, the control attribute and the color format of the control bit together indicate that the picture is in ARGB888 format, and the format field of the picture includes the control bit and the color format.

[0144] Compression algorithm, such as continuous identical pixel merging algorithm. When the compression ratio does not reach the threshold, you can also choose not to compress.

[0145] Image width / image height, width*height determines the number of pixels in the bitmap data.

[0146] Transparent color is a preset color value representing transparency. It can realize full transparent display of some areas of RGB565 / RGB888. In the decompression stage, if the control attribute of the control bit indicates that there is no transparent color, this field is not processed. In a possible implementation, the transparent color can set two or more transparent color values.

[0147] The palette is used to store the correspondence between color values ​​and color indexes. During the decompression phase, if the control attribute of the control bit indicates that the palette is used, the palette is parsed; if the control attribute of the control bit indicates that the palette is not used, the palette is not parsed.

[0148] Reserved to ensure that the image format header is aligned to the entire byte.

[0149] Bitmap data is the pixel data used to display the actual image. For example, one pixel of ARGB8888 occupies 4 bytes; one pixel of RGB888 occupies 3 bytes; one pixel of RGB565 occupies 2 bytes; one pixel of a palette format image occupies 1 byte. In this application, bitmap data can be referred to as a data field.

[0150] The picture encoding format provided above can describe pictures of different formats by controlling the bit field and the color format field, that is, through the picture encoding format, different types of picture formats can be encoded to achieve a unified format, thereby improving the efficiency of picture storage and loading. The picture encoding format in this embodiment also includes fields for transparent color and palette. The transparent color can be used for picture formats that do not support transparent channels, so that some colors have a transparent effect on the display screen, expanding the scope of use of picture formats that do not support transparent channels, and further saving storage resources of electronic devices; the palette can further compress the picture size and save storage resources of electronic devices.

[0151] Among them, this application does not limit the order, length, name and division of the fields in the image coding format.

[0152] Through this picture coding format, the present application can distinguish different source formats for different pictures according to the characteristics of the pictures, and then convert the pictures of different source formats to achieve format unification. There is no need to use the same format for the source formats of all pictures in the electronic device in order to unify the format. The present application can also set transparent colors for picture formats that do not support transparent channels, and increase the frequency of use of picture formats that do not support transparent channels. For example, a transparent color is set for the RGB565 / RGB888 picture format, without using the ARGB8888 format, saving storage resources for the picture.

[0153] Next, combined with the above Figure 5 The image encoding format is based on Figure 1 Schematic hardware architecture diagram, this application provides another format conversion method, which can convert image files of different source formats into the above Figure 5 Image files in the image encoding format. Figure 6 As shown, Figure 6 A flowchart of yet another format conversion method is shown.

[0154] S301: Read image files and configuration files.

[0155] The electronic device reads the input image file and configuration file, where the image file may include one or more images, and the format of the one or more images may be a variety of different formats, such as ARGB8888 format, RGB888 format, RGB565 / RGB555 format, etc. When the usage scenario of the image requires transparency or a more delicate gradient color transition, the ARGB8888 format image can be used; other scenarios can use RGB565 / RGB555 format images. The configuration file saves the rules for converting the format of the image file, which includes the above-mentioned image encoding format, and images of different formats can be encoded into a unified format through the rules.

[0156] The configuration file also includes the transparent color value of the image file. If the transparent color value of the image is set in the configuration file, the control attribute of the control bit in the encoding format of the image is set to use the transparent color value, and the transparent color value is directly filled into the transparent color field of the image encoding format; then when the MCU renders the image, the transparent color value is treated as transparent. If the transparent color value of the image is not set in the configuration file, the control attribute of the control bit in the encoding format of the image is set to not use the transparent color value, and the transparent color field in the encoding format of the image is invalid. When the MCU renders the image, the transparent color field is not processed.

[0157] In an embodiment of the present application, one of the images in the above-mentioned image files can be called the source file of the first image file, the format of the source file of the first image file can be called the source format of the first image file, and the field describing the source format of the first image file can be called the format field.

[0158] S302: Parse the image into BMP format.

[0159] After the electronic device reads the image file and the configuration file, it parses one or more images in the image file into BMP format, which is an uncompressed RGB bitmap. For example, if the image read by the electronic device is a PNG image, the bitmap data of the image needs to be decompressed and described in RGB format.

[0160] S303: Determine whether the number of colors in the image is less than or equal to 256.

[0161] After the electronic device parses the image into a standard image format, it determines whether the number of all different colors contained in the image is less than or equal to 256. Since the color palette can only store a limited number of colors, usually 256 colors, if you want to use the color palette to compress the image, you need to first determine the number of colors in the image. If yes, execute step S304; if no, execute step S307.

[0162] S304: Determine whether the color palette is applicable.

[0163] If the number of all different colors contained in the image is less than or equal to 256, then continue to determine whether the image is suitable for palette compression. Because the palette itself will introduce additional overhead of "number of color bits * 256 / 8 bytes", if the image is too small, the additional overhead will be larger than the compressed data, and it is not suitable for palette compression. Among them, the image size before compression is (image width * image height * number of color bits / 8), and the image size after palette compression is (image width * image height + number of color bits * 256 / 8). If the compressed image size is smaller than the image size before compression, the image is suitable for palette compression. If the compressed image size is greater than or equal to the image size before compression, the image is not suitable for palette compression.

[0164] If yes, step S305 is executed, and the palette field of the picture coding format indicates that the palette is used; if no, step S307 is executed, and the palette field of the picture coding format indicates that the palette is not used.

[0165] S305: Generate a color palette.

[0166] If the image size is suitable for palette format compression, a palette is generated, which introduces an additional overhead of "number of color bits * 256 / 8 bytes".

[0167] S306: Generate bitmap data based on the palette.

[0168] Generate bitmap data based on the palette, that is, use one byte to represent one color.

[0169] S307: Compress the bitmap data.

[0170] For each picture, after the electronic device parses the picture into a standard data format, if the number of colors of the picture is greater than 256, the bitmap data of the picture is directly compressed; if the number of colors of the picture is less than or equal to 256, but it is not suitable for the palette, the bitmap data of the picture is directly compressed; if the picture generates new bitmap data based on the palette, the new bitmap data of the picture is compressed. The compression algorithm can be a continuous identical pixel merging algorithm.

[0171] S308: Determine whether the compression ratio is greater than a threshold.

[0172] After the electronic device compresses the bitmap data of each picture, it determines whether the compression ratio of the picture is greater than the threshold. If it is, the picture is compressed according to the algorithm of merging consecutive identical pixels. The compression algorithm field of the picture indicates that the compression is performed using the algorithm of merging consecutive identical pixels, and the compressed data is filled into the bitmap data field of the picture encoding format. If the picture uses a large number of gradient colors, resulting in a too low compression ratio or data expansion, negative compression, or the compression ratio is less than the threshold, the bitmap data of the picture is directly filled into the bitmap data field of the picture encoding format without compression, and the compression algorithm field indicates no compression.

[0173] The compression ratio of the image is the ratio of the space occupied by the image before compression to the space occupied by the image after compression. The threshold can be given by comprehensively evaluating the MCU computing power, the file system reading speed, and the PSRAM reading and writing performance. The process of judging whether the compression ratio is greater than or equal to the threshold can avoid the situation where the image file occupies more storage resources of the electronic device after compression, and optimize the processing effect of the image.

[0174] S309: Generate a mixed loading resource file.

[0175] After completing the compression judgment for a single image, the electronic device converts the image according to the image encoding format according to the rules configured in the configuration file. After all images in the image file have completed the format conversion, the electronic device generates a resource mapping table for the image. In the resource mapping table, the image is encoded according to the rule of "application ID_resource ID", such as A100_001, A100_002, A100_003, etc. When the electronic device needs to use the image, it can directly index the position of the image in the resource file through the application ID and resource ID. Among them, the mixed loading resource file includes the resource file of the image and the resource mapping table of the image. The resource file of the image can be saved in the flash of the electronic device, and the resource mapping table of the image can be saved in the ROM of the electronic device.

[0176] In the present application, after the electronic device converts the source file of the first picture file according to the picture coding format, it can be called the first picture file.

[0177] The above process describes the image based on Figure 5 The format conversion process completed by the picture encoding format. According to the above process, the electronic device can read pictures of different formats, convert the formats of pictures of different formats, and achieve format unification. It can save the storage resources for pictures in electronic devices without affecting the display effect, reduce the size of picture storage, and thus improve the picture loading speed. At the same time, a transparent color field is added to the picture encoding format of the present application, and some picture formats without transparent channels can also be processed transparently. The picture encoding format of the present application also adds a palette format, which can further compress the size of the picture.

[0178] Accordingly, for Figure 6 The format conversion method of the provided image, Figure 7 Another method for loading pictures is described. When the electronic device is turned on or the display page is switched, the picture needs to be decompressed and loaded onto the display screen of the electronic device. Figure 7 Embodiment of the method.

[0179] S401: Reading a picture.

[0180] The electronic device reads the image into the memory. The resource file of the image is saved in the Flash of the electronic device. When the electronic device is turned on or the display page is switched, the MCU uses the file system to read the image resource from the resource file of the Flash by searching the resource mapping table of the ROM. The image is encoded according to the rule of "application ID_resource ID". When the electronic device needs to use the image, it can directly index the location of the image in the resource file through the application ID and resource ID.

[0181] For example, when an electronic device needs to use pictures coded as A100_001, A100_002 and A100_003, the positions of the pictures coded as A100_001, A100_002 and A100_003 in the resource file are searched in the resource mapping table. After obtaining the positions, the resources of the pictures corresponding to the positions are read in the resource file.

[0182] In the present application, the electronic device reads a picture into the memory, and the picture can be referred to as a first picture file.

[0183] S402: Parsing picture header data.

[0184] After the electronic device reads the image into the memory, it Figure 2The provided image encoding format parses the file header. The information obtained by parsing the file header includes control bits (whether transparent channels are supported, whether transparent colors are used, whether palettes are used), color formats, and compression algorithms.

[0185] In the present application, the control bit and color format of the first picture file may be referred to as the format field of the first picture file. The format field of the first picture file describes the source format of the first picture file.

[0186] S403: Determine whether the data is compressed.

[0187] After parsing the header data of the image, the electronic device determines whether the bitmap data in the image is compressed data. If the compression algorithm field in the header of the image file indicates that a compression algorithm for merging continuous pixels is used, the bitmap data in the image is compressed data, and step S404 is implemented; if the compression algorithm field in the header of the image file indicates that no compression is used, the bitmap data in the image is not compressed data, and step S405 is implemented.

[0188] S404: Decompression.

[0189] If the compression algorithm field in the header of the image file indicates that a compression algorithm for merging consecutive pixels is used, the bitmap data in the image is compressed data, and the electronic device performs pixel expansion on the bitmap data portion of the image. For example, 13 consecutive identical red pixels can be combined to represent "F Red 13", where F is the compression flag, Red is the color, and 13 is the number of colors. During decompression, after encountering the compression flag F, the subsequent 13 consecutive colors are expanded.

[0190] S405: Determine whether it is a palette format.

[0191] If the compression algorithm field in the picture file header indicates no compression, the electronic device determines whether the picture is in a palette format; or after the electronic device decompresses the picture, the electronic device determines whether the picture is in a palette format. If the control attribute of the control bit field in the picture file header indicates that a palette is used, step S406 is executed. If the control attribute of the control bit field in the picture file header indicates that a palette is not used, step S409 is executed.

[0192] S406: Determine whether the UI framework supports the color palette.

[0193] If the control attribute of the control bit field in the header of the picture file indicates that a palette is used, the electronic device checks whether the UI framework capability supports the palette format. That is, whether it supports direct rendering of pictures using a palette. If so, execute step S407. If not, execute step S408.

[0194] S407: Generate a picture object (palette).

[0195] If the UI framework capability of the electronic device supports the palette format, the image object is generated using the bitmap data represented by the palette and the color index, that is, the bitmap data in the image format of the image object is in the palette format.

[0196] After the electronic device generates the picture object, it distinguishes the picture objects according to the control bit and the color format, and renders the picture objects of different formats respectively, including picture objects of ARGB8888, RGB888, and RGB565 / RGB555 palette formats.

[0197] S408: Restoring the bitmap data by table lookup.

[0198] If the UI framework does not support the palette format, you need to use the palette to restore the bitmap data field in the image encoding format. That is, restore the bitmap data in the palette format to the source format according to the color index table. A pixel in the palette format occupies 1 byte, and when restored to the ARGB8888 format, it occupies 4 bytes; when restored to the RGB888 format, it occupies 3 bytes; when restored to the RGB565 / RGB555 format, it occupies 2 bytes.

[0199] S409: Generate a picture object.

[0200] After decompressing the bitmap data of the picture, if the control attribute of the control bit field in the picture file header indicates that the palette is not used, the electronic device generates a picture object according to the picture format.

[0201] If the UI framework capability does not support the palette format, the electronic device restores the bitmap data field in the image encoding format through a table lookup and generates an image object according to the image format.

[0202] After the electronic device generates the picture object (including the picture in steps S407 and S409), the picture object is distinguished according to the control bit and the color format, and the picture objects of different formats are rendered separately. The embodiment of the present application exemplarily provides three rendering methods. For a picture object with a transparent channel, steps S410 and S412 are executed; for a picture object without a transparent channel but containing a transparent color, step S414 is executed; for a picture object without a transparent channel and without a transparent color, step S415 is executed.

[0203] In this application, the format of a picture with a transparent channel can be called a first format; the format of a picture without a transparent channel can be called a second format; and the format of a picture without a transparent channel but containing transparent colors can be called a third format.

[0204] S410: Scaling, rotation calculation, etc.

[0205] After the electronic device generates the picture object, it performs scaling and rotation calculations on the ARGB8888 format picture. The ARGB8888 format picture supports rendering operations such as rotation and scaling. The scaling operation is used to control the size or ratio of the picture displayed on the display screen, and the rotation operation is used to control the rotation effect of the picture displayed on the display screen.

[0206] In some possible embodiments, the electronic device renders image objects of different formats respectively, and determines the rendering operation corresponding to the image according to the configuration information of the electronic device. The configuration information includes the size of the display screen and the display configuration of the display screen. The electronic device determines the display size or ratio of the image by the size of the display screen; and performs corresponding display matching on the image by the display configuration (such as the display format) of the display screen, so that the image can be displayed on the display screen through rendering.

[0207] For example, the display interface of a dial may include pictures such as the dial background, hour hand, minute hand, second hand, and weather icon. If the pictures of the hour hand, minute hand, and second hand need to be rotated, the pictures of the hour hand, minute hand, and second hand use ARGB8888 format pictures. The electronic device performs rotation calculations on the pictures of the hour hand, minute hand, and second hand respectively, so that the hour hand, minute hand, and second hand can rotate. Among them, this application does not limit the operation method and steps of the rendering operation.

[0208] S411: Determine whether a transparent channel is included.

[0209] After the electronic device generates the picture object, the electronic device determines whether the picture object contains a transparent channel. If the control attribute of the control bit field in the picture file header indicates that it contains a transparent channel, step S412 is executed. If the control attribute of the control bit field in the picture file header indicates that it does not contain a transparent channel, step S413 is executed.

[0210] S412: Use alpha channel to overlay foreground and background.

[0211] If the control attribute of the control bit field in the header of the picture file indicates that it contains a transparent channel, the transparent channel is used to perform foreground and background overlay calculations.

[0212] In some possible embodiments, the electronic device renders image objects of different formats respectively, and determines the rendering operation corresponding to the first image file according to the second image file. Wherein, when the second image file is a background image, the electronic device may have different rendering operations on the first image file for different background images. Specifically, the electronic device may overlay and display the first image file on the second image file, or the electronic device may overlay and display the first image file on the second image file according to different transparencies, or the electronic device may overlay and display the first image file at different positions of the second image file, or the electronic device may overlay and display the first image file on the second image file in different sizes or proportions.

[0213] S413: Determine whether it contains transparent color.

[0214] If the control attribute of the control bit field in the header of the picture file indicates that it does not contain a transparent channel, the electronic device further determines whether the picture object contains a transparent color. If so, step S414 is executed. If not, step S415 is executed.

[0215] S414: The transparent colors of the foreground image correspond to background pixels that are not blocked, and the non-transparent colors correspond to background pixels that are blocked.

[0216] If the control attribute of the control bit field in the image file header indicates that it contains a transparent color, the transparent color value in the image is treated as transparent and does not block the background image, text and other elements. The background image corresponding to the non-transparent color in the image will still be blocked.

[0217] S415: Directly perform layer overlay.

[0218] If the control attribute of the control bit field in the header of the image file indicates that it does not contain a transparent channel and does not contain a transparent color, the image is displayed on top of other images, that is, the layers are directly superimposed, and the image completely blocks the background image, text and other elements.

[0219] S416: Frame buffer.

[0220] After the electronic device renders the image, it displays the image on the display screen through the frame buffer module. The electronic device completes loading the image.

[0221] The above process describes the Figure 5The picture loading process of the picture coding format can realize on-demand loading according to the expected purpose, and support mixed loading of multiple different picture display effects. Since the picture coding format provided by this application supports pictures of multiple different formats, the size of picture storage is reduced, thereby improving the picture loading speed. Through the transparent color field, the transparent function can be realized for pictures in RGB888 and RGB565 formats, which greatly improves the frequency of use of pictures in RGB888 and RGB565 formats and saves picture storage resources. Through the palette field, the size of the picture file is further compressed to save the storage space of the electronic device.

[0222] In some possible embodiments, the human input for image evaluation can be reduced by reducing the supported image formats. For example, only two image formats, RGB565 and ARGB8888, are used. In scenes where transparency is required or gradient colors are obvious, ARGB8888 format images are used; other scenes are completed with RGB565 format images. It is also possible to expand the use scenarios of RGB565 format images by setting multiple transparent colors to save image storage resources.

[0223] In summary, Figure 5-Figure 7 The illustrated embodiment provides a picture encoding format, and performs format conversion and picture loading according to the encoding format. By supporting mixed rendering of pictures of different formats, the electronic device optimizes the storage of pictures, the size of loaded pictures, and the loading speed of pictures. By adding a transparent color field to the picture encoding format, the transparent function can be realized for RGB888 and RGB565 formats without transparent channels, which greatly improves the frequency of use of RGB888 and RGB565 format pictures in practical applications, saves picture storage resources, and optimizes flash performance.

[0224] The above-mentioned embodiments provide a method for image format conversion and image loading. The following describes the application scenarios of the embodiments of the present application in the watch dial market for sports watches.

[0225] Figure 8 The following figure shows a unified installation data package format for the dial market, taking the application on a sports watch as an example. Figure 8 As shown, Figure 8 The exemplary dial data packet format provided by the embodiment of the present application is shown. The dial data packet format includes the resource packaging tool version number, dial configuration size, image mapping table size, reserved fields, dial configuration, image resource mapping table and image resources.

[0226] Resource Packaging Tool version number, used to indicate the version of the resource packaging tool. After the dial market control capabilities are enhanced, the resource packaging tool version number needs to be upgraded. The dial market also needs to upgrade this version number when it supports mixed loading of images. Updating the resource packaging tool version number can prevent the new version of mixed loading of images from not being displayed properly on old versions of watches.

[0227] The dial configuration size is used to describe the length of the dial configuration field. Since the dial elements of different manufacturers are different, the configuration size will also be different.

[0228] The image mapping table size is used to describe the size of the image mapping table used in the watch face. Since different manufacturers use different numbers of images in their watch faces, different numbers of image resources require different mapping table entries.

[0229] The watch face resource size is used to describe the total size of the image resources used by the watch face. Since the image content and number used by watch faces of different manufacturers are different, the total size of the image resources will also be different.

[0230] The dial configuration mainly saves the dial-related control parameters, coordinates, data connection, behavior description and other information.

[0231] The image resource mapping table describes the structure of the image resources and the attributes of each image. Each mapping table entry contains two fields: offset and size. The offset can be used to find the location of a certain image in the image resource segment, and the size can be used to read a complete image into the PSRAM cache.

[0232] Image resources are used to store actual image data. The format of the image data can be Figure 2 or Figure 5 The image encoding format provided in .

[0233] For example, a sports watch obtains an image file, which includes a dial image required by the sports watch. Figure 3 or Figure 6 The image file is compressed using the compression method described in the description, and the compressed image file is filled into the image resource. When the sports watch is turned on, the main interface of the dial needs to be displayed on the screen. The MCU in the dial searches the resource mapping table of the ROM and uses the file system to read the image resources. The main interface of the dial includes multiple images such as the background image, the hour hand image, the minute hand image, the second hand image, the weather icon image, the temperature icon image, the heart rate\step count progress bar, etc. After the electronic device reads the required image resources, it then Figure 4 or Figure 7 The multiple image resources are decompressed and rendered respectively in the described manner, and finally displayed on the display screen of the sports watch.

[0234] The electronic device in the embodiment of the present application can also be a smart bracelet or a smart watch. The installation data packet format of the smart bracelet and the smart watch dial market can be referred to Figure 8 The format shown.

[0235] To facilitate understanding of the embodiments of the present application, Fig. 9 The electronic device 100 shown is taken as an example to introduce the electronic device to which the embodiments of the present application are applicable.

[0236] Fig. 9 A schematic structural diagram of an exemplary electronic device 100 provided in an embodiment of the present application is shown.

[0237] The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

[0238] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0239] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a memory, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, a micro control unit MCU, and / or a neural-network processing unit (neural-network processing unit, NPU), etc. Among them, different processing units can be independent devices or integrated in one or more processors. In some embodiments, the electronic device 100 may also include one or more processors 110.

[0240] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.

[0241] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or circulated. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the electronic device 100.

[0242] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0243] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple groups of I2C buses. The processor 110 may be coupled to the touch sensor 180K, the charger, the flash, the camera 193, etc. through different I2C bus interfaces. For example: the processor 110 may be coupled to the touch sensor 180K through the I2C interface, so that the processor 110 communicates with the touch sensor 180K through the I2C bus interface, thereby realizing the touch function of the electronic device 100.

[0244] The I2S interface can be used for audio communication. In some embodiments, the processor 110 can include multiple I2S buses. The processor 110 can be coupled to the audio module 170 via the I2S bus to achieve communication between the processor 110 and the audio module 170. In some embodiments, the audio module 170 can transmit an audio signal to the wireless communication module 160 via the I2S interface to achieve the function of answering a call through a Bluetooth headset.

[0245] The PCM interface can also be used for audio communication, sampling, quantizing and encoding analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 can be coupled via a PCM bus interface. In some embodiments, the audio module 170 can also transmit audio signals to the wireless communication module 160 via the PCM interface to realize the function of answering calls via a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.

[0246] The UART interface is a universal serial data bus for asynchronous communication. The bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, the UART interface is generally used to connect the processor 110 and the wireless communication module 160. For example, the processor 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to implement the Bluetooth function. In some embodiments, the audio module 170 can transmit an audio signal to the wireless communication module 160 through the UART interface to implement the function of playing music through a Bluetooth headset.

[0247] The MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193. The MIPI interface includes a camera serial interface (CSI), a display serial interface (DSI), etc. In some embodiments, the processor 110 and the camera 193 communicate via the CSI interface to implement the shooting function of the electronic device 100. The processor 110 and the display screen 194 communicate via the DSI interface to implement the display function of the electronic device 100.

[0248] The GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or as a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 with the camera 193, the display 194, the wireless communication module 160, the audio module 170, the sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.

[0249] The USB interface 130 is an interface that complies with the USB standard specification, and specifically can be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transfer data between the electronic device 100 and a peripheral device. It can also be used to connect headphones to play audio through the headphones. The interface can also be used to connect other electronic devices, such as AR devices, etc.

[0250] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0251] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.

[0252] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.

[0253] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.

[0254] The modem processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to a speaker 170A, a receiver 170B, etc.), or displays an image or video through a display screen 194. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be set in the same device as the mobile communication module 150 or other functional modules.

[0255] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering processing, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of the signal, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2. Exemplarily, the wireless communication module 160 may include a Bluetooth module, a Wi-Fi module, etc.

[0256] The electronic device 100 can realize the display function through the GPU, the display screen 194, and the application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs, which execute instructions to generate or change display information.

[0257] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.

[0258] The digital signal processor is used to process digital signals, and can process not only digital image signals but also other digital signals. For example, when the electronic device 100 is selecting a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.

[0259] Video codecs are used to compress or decompress digital videos. The electronic device 100 may support one or more video codecs. Thus, the electronic device 100 may play or record videos in a variety of coding formats, such as Moving Picture Experts Group (MPEG)-1, MPEG-2, MPEG-3, MPEG-4, etc.

[0260] NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can also continuously self-learn. Through NPU, applications such as intelligent cognition of electronic device 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.

[0261] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function. For example, data such as music, photos, and videos can be stored in the external memory card.

[0262] The internal memory 121 can be used to store one or more computer programs, which include instructions. The processor 110 can run the above instructions stored in the internal memory 121, so that the electronic device 100 executes the data sharing method provided in some embodiments of the present application, as well as various functional applications and data processing. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area can store an operating system; the program storage area can also store one or more applications (such as a gallery, contacts, etc.). The data storage area can store data (such as photos, contacts, etc.) created during the use of the electronic device 100. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.

[0263] The electronic device 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.

[0264] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be arranged in the processor 110, or some functional modules of the audio module 170 can be arranged in the processor 110.

[0265] The speaker 170A, also called a "speaker", is used to convert an audio electrical signal into a sound signal. The electronic device 100 can listen to music or listen to a hands-free call through the speaker 170A.

[0266] The receiver 170B, also called a "earpiece", is used to convert audio electrical signals into sound signals. When the electronic device 100 receives a call or voice message, the voice can be received by placing the receiver 170B close to the human ear.

[0267] Microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak by putting their mouth close to microphone 170C to input the sound signal into microphone 170C. The electronic device 100 can be provided with at least one microphone 170C. In other embodiments, the electronic device 100 can be provided with two microphones 170C, which can not only collect sound signals but also realize noise reduction function. In other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify the sound source, realize directional recording function, etc.

[0268] The pressure sensor 180A is used to sense pressure signals and convert the pressure signals into electrical signals.

[0269] The gyro sensor 180B may be used to determine the motion posture of the electronic device 100 .

[0270] The air pressure sensor 180C is used to measure air pressure. In some embodiments, the electronic device 100 calculates the altitude through the air pressure value measured by the air pressure sensor 180C to assist positioning and navigation.

[0271] The magnetic sensor 180D includes a Hall sensor.

[0272] The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in all directions (generally three axes). When the electronic device 100 is stationary, the magnitude and direction of gravity can be detected. It can also be used to identify the posture of the electronic device and is applied to applications such as horizontal and vertical screen switching and pedometers.

[0273] The distance sensor 180F is used to measure the distance. The electronic device 100 can measure the distance by infrared or laser. In some embodiments, when shooting a scene, the electronic device 100 can use the distance sensor 180F to measure the distance to achieve fast focusing.

[0274] The proximity light sensor 180G may include, for example, a light emitting diode (LED) and a light detector, such as a photodiode. The light emitting diode may be an infrared light emitting diode. The electronic device 100 emits infrared light outward through the light emitting diode. The electronic device 100 uses a photodiode to detect infrared reflected light from nearby objects. When sufficient reflected light is detected, it can be determined that there is an object near the electronic device 100. When insufficient reflected light is detected, the electronic device 100 can determine that there is no object near the electronic device 100. The electronic device 100 can use the proximity light sensor 180G to detect that the user holds the electronic device 100 close to the ear to talk, so as to automatically turn off the screen to save power. The proximity light sensor 180G can also be used in leather case mode and pocket mode to automatically unlock and lock the screen.

[0275] The ambient light sensor 180L is used to sense the ambient light brightness. The electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the perceived ambient light brightness. The ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures. The ambient light sensor 180L can also cooperate with the proximity light sensor 180G to detect whether the electronic device 100 is in a pocket to prevent accidental touches.

[0276] The fingerprint sensor 180H is used to collect fingerprints. The electronic device 100 can use the collected fingerprint characteristics to implement fingerprint unlocking, access application locks, fingerprint photography, fingerprint call answering, etc.

[0277] The temperature sensor 180J is used to detect the temperature.

[0278] The touch sensor 180K may also be referred to as a touch panel or a touch-sensitive surface. The touch sensor 180K may be disposed on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, also referred to as a "touch screen". The touch sensor 180K is used to detect touch operations acting on or near it. The touch sensor may transmit the detected touch operations to an application processor to determine the type of touch event. Visual output related to the touch operations may be provided through the display screen 194. In other embodiments, the touch sensor 180K may also be disposed on the surface of the electronic device 100, at a position different from that of the display screen 194.

[0279] Bone conduction sensor 180M can obtain vibration signals.

[0280] The key 190 includes a power key, a volume key, etc. The key 190 may be a mechanical key or a touch key. The electronic device 100 may receive key input and generate key signal input related to user settings and function control of the electronic device 100.

[0281] Motor 191 can generate vibration prompts. Motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, audio playback, etc.) can correspond to different vibration feedback effects. For touch operations acting on different areas of the display screen 194, motor 191 can also correspond to different vibration feedback effects. Different application scenarios (for example: time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.

[0282] The indicator 192 may be an indicator light, which may be used to indicate the charging status, power changes, messages, missed calls, notifications, etc.

[0283] The SIM card interface 195 is used to connect a SIM card. The SIM card can be connected to and separated from the electronic device 100 by inserting it into the SIM card interface 195 or pulling it out from the SIM card interface 195. The electronic device 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, and the like. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the multiple cards can be the same or different. The SIM card interface 195 can also be compatible with different types of SIM cards. The SIM card interface 195 can also be compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to implement functions such as calls and data communications. In some embodiments, the electronic device 100 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.

[0284] Fig. 9The electronic device 100 shown in the exemplary embodiment can display various user interfaces through the display screen 194. The electronic device 100 can detect touch operations in various user interfaces through the touch sensor 180K, such as click operations in various user interfaces (such as touch operations on icons, double-click operations), and for example, upward or downward sliding operations in various user interfaces, or operations of performing circle gestures, etc. In some embodiments, the electronic device 100 can detect motion gestures performed by the user holding the electronic device 100, such as shaking the electronic device, through the gyroscope sensor 180B, the acceleration sensor 180E, etc. In some embodiments, the electronic device 100 can detect non-touch gesture operations through the camera 193 (such as a 3D camera, a depth camera).

[0285] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system of the layered architecture as an example to exemplify the software structure of the electronic device 100.

[0286] Fig.10 It is a software structure block diagram of the electronic device 100 according to an embodiment of the present application.

[0287] The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework layer, the Android runtime and system library, and the kernel layer.

[0288] The application layer can include a series of application packages.

[0289] like Fig.10 As shown, the application package may include camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message and other applications.

[0290] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.

[0291] like Fig.10 As shown, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.

[0292] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.

[0293] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.

[0294] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.

[0295] The phone manager is used to provide communication functions of the electronic device 100, such as management of call status (including connecting, hanging up, etc.).

[0296] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.

[0297] The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.

[0298] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.

[0299] The core library consists of two parts: one is the function that needs to be called by the Java language, and the other is the Android core library.

[0300] The application layer and the application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.

[0301] The system library may include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.

[0302] The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.

[0303] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.

[0304] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.

[0305] A 2D graphics engine is a drawing engine for 2D drawings.

[0306] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.

[0307] The present application also provides a computer-readable storage medium. All or part of the processes in the above method embodiments can be completed by a computer program to instruct the relevant hardware, and the program can be stored in the above computer storage medium. When the program is executed, it can include the processes of the above method embodiments. The computer-readable storage medium includes: a read-only memory (ROM) or a random access memory (RAM), a disk or an optical disk, and other media that can store program codes.

[0308] As an optional design, the computer-readable storage medium may include RAM, ROM, EEPROM, CD-ROM or other optical disk storage, disk storage or other magnetic storage devices, or any other medium that can be used to carry or store the required program code in the form of instructions or data structures, and can be accessed by the computer. Moreover, any connection is appropriately referred to as a computer-readable medium. For example, if the software is transmitted from a website, server or other remote source using a coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL) or wireless technology (such as infrared, radio and microwave), the coaxial cable, fiber optic cable, twisted pair, DSL or wireless technologies such as infrared, radio and microwave are included in the definition of the medium. Disks and optical disks as used herein include compact disks (CDs), laser disks, optical disks, digital versatile disks (DVDs), floppy disks and blue-ray disks, where disks usually reproduce data magnetically, while optical disks reproduce data optically using lasers. The combination of the above should also be included in the scope of computer-readable media.

[0309] The present application embodiment also provides a computer program product. The method described in the above method embodiment can be implemented in whole or in part by software, hardware, firmware or any combination thereof. If implemented in software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the above computer instructions are loaded and executed on a computer, the process or function described in the above method embodiment is generated in whole or in part. The above computer can be a general-purpose computer, a special-purpose computer, a computer network, a network device, a user device or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted through the computer-readable storage medium. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or a data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state disk (SSD)), etc.

[0310] The steps in the method of the embodiment of the present application can be adjusted in order, combined and deleted according to actual needs.

[0311] The modules in the device of the embodiment of the present application can be merged, divided and deleted according to actual needs.

[0312] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for loading pictures. It is characterized in that include: The electronic device obtains a source file of a first picture file, and converts the format of the source file of the first picture file into a first picture file, wherein the first picture file includes a format field and a data field, wherein the format field is used to indicate the source format of the first picture file, and the format field includes a control bit field and a color format field, wherein the control attributes of the control bit field include whether a transparent channel is supported, whether a transparent color is used, and whether a color palette is used, wherein the color format field is used to indicate the color format of the first picture file, and the data field includes pixel data of the first picture file; The electronic device determines a rendering operation corresponding to the first picture file according to a source format of the first picture file, where the source format of the first picture file includes a bitmap BMP format and / or a portable network graphic PNG format; The electronic device renders the first image file onto a display screen according to a rendering operation corresponding to the first image file.

2. The method according to claim 1, It is characterized in that When the source format of the first image file is a first format, the rendering operation includes: controlling the transparency of the first image file through a transparent channel, and displaying the first image file on the display screen with a transparent effect, and the first format supports the transparent channel.

3. The method according to claim 1, It is characterized in that When the source format of the first picture file is the second format, the rendering operation includes: shielding other picture files when displaying the first picture file on the display screen.

4. The method according to claim 1, It is characterized in that The converting the format of the source file of the first picture file into the first picture file comprises: Compressing the source file of the first picture file according to a preset compression algorithm; If the compression ratio is greater than or equal to the threshold, the compressed pixel data is filled into the data field of the first picture file; if the compression ratio is less than the threshold, the pixel data before compression is filled into the data field of the first picture file, and the compression ratio is the ratio of the size of the source file of the first picture file before compression to the size after compression.

5. The method according to claim 1, It is characterized in that The electronic device renders the first image file onto a display screen according to a rendering operation corresponding to the first image file, and the process also includes: The electronic device determines whether the data field of the first picture file is a compressed field; If yes, decompress the data field of the first picture file according to a preset decompression algorithm; fill the decompressed pixel data into the data field of the first picture file; If not, the data field of the first picture file is not changed.

6. The method according to any one of claims 1 to 5, It is characterized in that The first picture file also includes a transparent color field, and the transparent color field is used to represent a color area displayed transparently in the first picture file.

7. The method according to claim 6, It is characterized in that When the source format of the first image file is the third format, the electronic device renders the first image file onto a display screen according to a rendering operation corresponding to the first image file, specifically including: Determine whether the transparent color field of the first picture file is valid; If yes, the electronic device performs transparent processing on the first picture file according to the transparent color field, so that the color area corresponding to the transparent color field in the first picture file has a transparent effect on the display screen; If not, the electronic device blocks other pictures when displaying the first picture file on the display screen.

8. The method according to claim 1, It is characterized in that The method further comprises: acquiring configuration information of the electronic device, wherein the configuration information comprises the size of the display screen and the display configuration of the display screen; The electronic device determines, according to the format field of the first picture file, a rendering operation corresponding to the first picture file, specifically including: The electronic device determines a rendering operation corresponding to the first image file according to the first format field of the first image file and the configuration information.

9. The method according to claim 8, It is characterized in that The rendering operation includes one or more of the following: scaling, rotation, and transparent calculation.

10. The method according to claim 1, It is characterized in that The first image file also includes a palette field, which is used to represent a mapping relationship between pixel colors and index numbers in the first image file, where one index number represents one color.

11. An electronic device, It is characterized in that include: one or more processors, memory, and display screens; The memory and the display screen are coupled to the one or more processors, the memory is used to store computer program codes, the computer program codes include computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute: Acquire a source file of a first picture file, and convert the format of the source file of the first picture file into the first picture file, wherein the first picture file includes a format field and a data field, wherein the format field is used to indicate the source format of the first picture file, and the format field includes a control bit field and a color format field, wherein the control attributes of the control bit field include whether a transparent channel is supported, whether a transparent color is used, and whether a color palette is used, wherein the color format field is used to indicate the color format of the first picture file, and the data field includes pixel data of the first picture file; Determining a rendering operation corresponding to the first picture file according to a source format of the first picture file, wherein the source format of the first picture file includes a bitmap BMP format and / or a portable network graphic PNG format; According to the rendering operation corresponding to the first image file, the first image file is rendered onto the display screen.

12. The electronic device according to claim 11, It is characterized in that When the source format of the first image file is a first format, the rendering operation includes: controlling the transparency of the first image file through a transparent channel, and displaying the first image file on the display screen with a transparent effect, and the first format supports the transparent channel.

13. The electronic device according to claim 11, It is characterized in that When the source format of the first picture file is the second format, the rendering operation includes: shielding other picture files when displaying the first picture file on the display screen.

14. The electronic device according to claim 11, It is characterized in that The converting the format of the source file of the first picture file into the first picture file comprises: Compressing the source file of the first picture file according to a preset compression algorithm; If the compression ratio is greater than or equal to the threshold, the compressed pixel data is filled into the data field of the first picture file; if the compression ratio is less than the threshold, the pixel data before compression is filled into the data field of the first picture file, and the compression ratio is the ratio of the size of the source file of the first picture file before compression to the size after compression.

15. The electronic device according to claim 14, It is characterized in that The step of rendering the first image file onto a display screen according to a rendering operation corresponding to the first image file further includes: Determine whether the data field of the first picture file is a compressed field; If yes, decompress the data field of the first picture file according to a preset decompression algorithm; fill the decompressed pixel data into the data field of the first picture file; If not, the data field of the first picture file is not changed.

16. The electronic device according to any one of claims 11 to 15, It is characterized in that The first picture file also includes a transparent color field, and the transparent color field is used to represent a color area displayed transparently in the first picture file.

17. The electronic device according to claim 16, It is characterized in that When the source format of the first image file is the third format, rendering the first image file onto a display screen according to a rendering operation corresponding to the first image file specifically includes: Determine whether the transparent color field of the first picture file is valid; If yes, performing transparent processing on the first picture file according to the transparent color field, so that the color area corresponding to the transparent color field in the first picture file has a transparent effect on the display screen; If not, the first picture file is displayed on the display screen to block other pictures.

18. The electronic device according to claim 11, It is characterized in that The electronic device further comprises: acquiring configuration information, wherein the configuration information includes the size of the display screen and the display configuration of the display screen; The determining, according to the format field of the first picture file, a rendering operation corresponding to the first picture file specifically includes: A rendering operation corresponding to the first image file is determined according to the first format field of the first image file and the configuration information.

19. The electronic device according to claim 18, It is characterized in that The rendering operation includes one or more of the following: scaling, rotation, and transparent calculation.

20. The electronic device according to claim 11, It is characterized in that The first image file also includes a palette field, which is used to represent a mapping relationship between pixel colors and index numbers in the first image file, where one index number represents one color.

21. A computer storage medium, It is characterized in that The method comprises computer instructions, and when the computer instructions are executed on an electronic device, the electronic device executes the method according to any one of claims 1 to 10.

Citation Information

Cited By

  • Picture loading method and related apparatus

    WO2021213351A1