Graphical interface video memory optimization method and device, electronic equipment and medium

By converting color data into low-bit-width index values ​​in embedded devices and storing them in the frame buffer, the problems of excessive video memory requirements and poor display effects are solved, achieving stable display and ensuring system performance.

CN121704939APending Publication Date: 2026-03-20SHENZHEN FCAR TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511524045.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-23
Publication Date
2026-03-20

AI Technical Summary

Technical Problem

Existing technologies in embedded devices have excessive video memory requirements, leading to increased hardware costs or poor display quality.

Method used

The color data of the target pixel is converted from a high-bit width to a low-bit width index value, and the index value is stored in the frame buffer. Multiple pixel index values ​​are stored in a single storage unit. When a display request is received, the index value is converted back to a color value for display.

Benefits of technology

Without increasing hardware costs, it significantly reduces video memory requirements, avoids prolonged MCU occupation, solves the problem of excessive video memory usage preventing the use of video memory drivers, and avoids display problems such as screen misalignment, flickering, and noise at the edges of images and text.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121704939A_ABST
    Figure CN121704939A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computers, and discloses a graphical interface video memory optimization method and device, electronic equipment and a medium, and the method comprises the steps: obtaining color data of a target pixel, the color data being a first color value in a first color space; converting the first color value into a corresponding index value; determining a target storage unit and bit offset in the frame buffer according to the coordinate of the target pixel, and writing the index value into a specified bit starting from the bit offset in the target storage unit; in response to the display request, reading a corresponding index value from the frame buffer according to the coordinate of the target pixel; and converting the read index value into a second color value in the first color space, and displaying the second color value. According to the method and the device, stable display under video memory driving can be realized on the premise of not increasing hardware cost, the problem that video memory driving cannot be adopted due to overlarge occupation of the video memory is solved, and meanwhile, the problem that the display effect is relatively poor due to a direct driving mode is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and specifically to a method, apparatus, electronic device, and medium for optimizing graphics interface video memory. Background Technology

[0002] Embedded graphical user interfaces (GUIs) are crucial software for human-computer interaction in embedded devices, requiring compatibility with embedded hardware limited by computing power, memory, and power consumption. Video memory (VRAM) is a core resource for GUI display, its size determined by display resolution, color depth, and the number of frame buffers. For example, a common RGB565 color mode, 320×240 resolution display requires 153.6KB of VRAM per frame buffer. However, low-cost embedded microcontroller units (MCUs) typically have only 128KB or less of on-chip SRAM, far from meeting this VRAM requirement.

[0003] To address these issues, existing technologies mainly fall into two categories. One involves replacing the MCU with a high-performance one or adding off-chip SDRAM, directly increasing hardware costs. The other uses a direct-drive approach without dedicated video memory, which incurs no additional cost but consumes MCU memory for extended periods, leading to reduced system performance and display problems such as image misalignment, animation flickering, and noise at image edges. Clearly, existing technologies suffer from excessive video memory usage and poor display quality.

[0004] The preceding description is intended to provide general background information and does not necessarily constitute prior art. Summary of the Invention

[0005] This application provides a method, apparatus, electronic device, and medium for optimizing graphical user interface video memory, which can achieve stable display under video memory driving without increasing hardware costs, solve the problem of excessive video memory usage preventing the use of video memory driving, and avoid the problem of poor display effect caused by direct driving.

[0006] In a first aspect, embodiments of this application provide a method for optimizing graphical user interface video memory, including: Obtain the color data of the target pixel, wherein the color data is a first color value in a first color space; The first color value is converted into a corresponding index value, wherein the bit width of the index value is smaller than the bit width of the first color value; The target storage unit and bit offset in the frame buffer are determined based on the coordinates of the target pixel, and the index value is written into the target storage unit at a specified bit starting from the bit offset; wherein, each storage unit is used to store the index values ​​of multiple different pixels; In response to a display request, the corresponding index value is read from the frame buffer based on the coordinates of the target pixel; The read index value is converted into a second color value in the first color space, and the second color value is displayed.

[0007] Furthermore, in some embodiments of this application, obtaining the color data of the target pixel includes: The coordinates of the target pixel to be updated are determined based on the application's drawing instructions or user input events. Based on the coordinate values, the corresponding first color value is obtained.

[0008] Furthermore, in some embodiments of this application, converting the first color value into a corresponding index value includes: A predefined color mapping table is used to store the mapping relationship between reference color values ​​and index values; Calculate the color difference between the first color value and each reference color value in the color mapping table, and select the reference color value with the smallest color difference from the first color value as the matching result; The index value corresponding to the reference color value with the smallest color difference from the first color value is selected as the index value of the target pixel.

[0009] Furthermore, in some embodiments of this application, the step of converting the first color value into the corresponding index value further includes: Extract the red, green, and blue color components from the first color value, respectively; Perform bit-width compression on each color component to generate compressed color components; The compressed color components are combined to form the index value.

[0010] Furthermore, in some embodiments of this application, the step of determining the target storage unit and bit offset in the frame buffer based on the coordinates of the target pixel, and writing the index value into the target storage unit at a specified bit starting from the bit offset, includes: Based on the coordinates of the target pixel, the horizontal resolution of the display device, and the bit width occupied by each pixel index value, calculate the linear address of the index value in the frame buffer; Based on the linear address, determine the byte address of the target storage unit and its internal bit offset; Using bit manipulation instructions, the index value is written into the storage unit corresponding to the byte address, starting from the bit offset, for a specified number of bits.

[0011] Furthermore, in some embodiments of this application, the step of reading the corresponding index value from the frame buffer according to the coordinates of the target pixel in response to a display request includes: The display request is generated in response to the vertical synchronization signal of the display device; Based on the coordinates of the target pixel that needs to be refreshed, locate and read the index value corresponding to the target pixel in the frame buffer.

[0012] Furthermore, in some embodiments of this application, the step of converting the read index value into a second color value in the first color space and outputting the second color value to the display driving circuit to drive the display device to display includes: When the index value is generated based on the color palette, the color mapping table is queried using the index value as the subscript to obtain the corresponding reference color value as the second color value; When the index value is generated by color component compression, the compressed color components are separated from the index value, and each color component is restored to the original bit width of the corresponding color component in the first color space through bit extension or left shift operation, so as to combine them to form the second color value. The second color value is output to the display driver circuit to drive the display device to display.

[0013] Secondly, embodiments of this application provide a graphical user interface (GUI) video memory optimization device, comprising: The acquisition module is used to acquire the color data of the target pixel, wherein the color data is a first color value in a first color space; A first conversion module is used to convert the first color value into a corresponding index value, wherein the bit width of the index value is smaller than the bit width of the first color value; The writing module is used to determine the target storage unit and bit offset in the frame buffer according to the coordinates of the target pixel, and write the index value into the target storage unit at a specified bit starting from the bit offset; wherein, each storage unit is used to store the index values ​​of multiple different pixels; A reading module is used to read the corresponding index value from the frame buffer according to the coordinates of the target pixel in response to a display request; The second conversion module is used to convert the read index value into a second color value in the first color space and display the second color value.

[0014] Thirdly, embodiments of this application provide an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the graphical interface video memory optimization method as described in the first aspect.

[0015] Fourthly, embodiments of this application provide a storage medium storing a computer program capable of being loaded by a processor and executing the optimization method for the graphical user interface memory as described in the first aspect.

[0016] This application provides a method, apparatus, electronic device, and medium for optimizing graphics interface video memory. The method includes: acquiring color data of a target pixel, wherein the color data is a first color value in a first color space; converting the first color value into a corresponding index value, wherein the bit width of the index value is smaller than the bit width of the first color value; determining a target storage unit and a bit offset in a frame buffer based on the coordinates of the target pixel, and writing the index value into a specified bit starting from the bit offset in the target storage unit; wherein each storage unit is used to store index values ​​of multiple different pixels; in response to a display request, reading the corresponding index value from the frame buffer based on the coordinates of the target pixel; converting the read index value into a second color value in the first color space, and displaying the second color value. In the optimized graphics interface memory scheme provided in this application, firstly, the first color value in the first color space is converted into an index value with a smaller bit width, and each storage unit stores the index values ​​of multiple pixels. This significantly reduces the storage occupation of a single pixel in the frame buffer, thereby significantly reducing the overall memory requirements. This allows the limited on-chip SRAM of the low-cost embedded MCU to be sufficient to accommodate the memory, eliminating the need to replace it with a high-performance MCU or add off-chip SDRAM to expand storage, thus avoiding increased hardware costs. Secondly, by storing the index values ​​in the frame buffer, the index values ​​are converted back to the second color value in the first color space when responding to a display request. This eliminates the need for the MCU to continuously participate in the real-time transmission and processing of pixel data, avoiding system performance degradation caused by the MCU being occupied for a long time. At the same time, the pre-storage of image data in the frame buffer reduces the real-time pressure of data transmission, thereby avoiding display problems such as image misalignment, flickering, and image edge noise that are prone to occur when directly driving. Therefore, this application can achieve stable display and effective system performance guarantee under memory-driven mode without increasing hardware costs, solving the problem of excessive memory occupation preventing the use of memory-driven mode, while avoiding the problem of poor display effect caused by direct driving. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0018] Figure 1 This is an application environment diagram of the graphical interface video memory optimization method provided in the embodiments of this application; Figure 2 This is a flowchart illustrating the method for optimizing graphical user interface video memory provided in an embodiment of this application. Figure 3 This is a schematic diagram of a conventional RGB565 memory location provided in an embodiment of this application; Figure 4 This is a schematic diagram of the 4-color compact bit field storage provided in an embodiment of this application; Figure 5 This is a schematic diagram of the 16-color compact bit-field storage provided in an embodiment of this application; Figure 6 This is a schematic diagram of a 64-color compact bit-field storage provided in an embodiment of this application; Figure 7 This is a schematic diagram of the structure of the graphical user interface memory optimization device provided in the embodiments of this application; Figure 8 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0019] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of systems and methods consistent with those detailed in the appended claims or with some aspects of this application.

[0020] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover descriptions such as non-exclusive inclusion, so that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, components, features, and elements with the same names in different embodiments of this application may have the same meaning or different meanings, the specific meaning of which must be determined by its interpretation in that specific embodiment or further in conjunction with the context of that specific embodiment.

[0021] It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit this application.

[0022] In the following description, the use of suffixes such as "module," "part," or "unit" to denote elements is solely for the purpose of illustrative purposes and has no specific meaning in itself. Therefore, "module," "part," or "unit" may be used interchangeably.

[0023] To address the aforementioned technical problems and overcome the shortcomings of existing technologies, embodiments of this application provide a method, apparatus, electronic device, and medium for optimizing graphical user interface video memory. This enables stable display under video memory driving without increasing hardware costs, solves the problem of excessive video memory usage preventing the use of video memory driving, and avoids the problem of poor display effects caused by direct driving.

[0024] Figure 1 This is an application environment diagram illustrating a graphical user interface (GUI) memory optimization method in one embodiment. (Refer to...) Figure 1This method for optimizing graphical user interface (GUI) video memory is applied to a system for optimizing GUI video memory. The system includes a terminal 110 and a server 120. The terminal 110 and server 120 are connected via a network. The terminal 110 can be a desktop terminal or a mobile terminal, specifically a mobile phone, tablet computer, laptop computer, or other similar devices. The server 120 can be a standalone server or a server cluster consisting of multiple servers. The terminal 110 is configured to execute the aforementioned method for optimizing GUI video memory, including: acquiring color data of a target pixel, where the color data is a first color value in a first color space; converting the first color value into a corresponding index value, where the bit width of the index value is less than the bit width of the first color value; determining the target storage unit and bit offset in the frame buffer based on the coordinates of the target pixel, and writing the index value into a specified bit starting from the bit offset in the target storage unit; wherein each storage unit is used to store the index values ​​of multiple different pixels; responding to a display request, reading the corresponding index value from the frame buffer based on the coordinates of the target pixel; converting the read index value into a second color value in the first color space, and displaying the second color value.

[0025] Please see Figure 2 , Figure 2 This is a flowchart illustrating a method for optimizing graphics interface video memory according to an embodiment of this application. This embodiment mainly uses the application of this method to a computer device as an example for illustration. The method for optimizing graphics interface video memory according to an embodiment of this application may specifically include the following steps: S1. Obtain the color data of the target pixel, where the color data is the first color value in the first color space; Specifically, for step S1, the target pixel refers to a single pixel that needs to be displayed or updated in the embedded graphical user interface (GUI), such as the pixels of interface text, icons, and background areas; the first color space is usually the RGB color space commonly used in embedded GUIs, and the first color value is the original color information of the target pixel in the RGB color space. Its bit width is determined by the conventional color mode. For example, in the RGB565 color mode, the first color value is 16 bits, which contains the specific data of the red, green, and blue color components and can accurately represent the original color of the pixel.

[0026] For example, in the embedded GUI of a home appliance control panel, a temperature adjustment icon needs to be displayed. A certain pixel on the edge of the icon is the target pixel. If the RGB565 color mode is used, the first color value of the target pixel is 0xF800, which represents pure red. It has a 16-bit width and conforms to the color data definition under the first color space.

[0027] S2. Convert the first color value to the corresponding index value, where the bit width of the index value is smaller than the bit width of the first color value; Specifically, for step S2, the index value is a simplified representation of the first color value. The core is to reduce the storage occupation of a single pixel by reducing the bit width. Since the bit width of the first color value is relatively high (such as 16 bits in RGB565 mode), direct storage will occupy a lot of video memory. The index value, by discarding some non-critical color information or establishing a color mapping relationship, compresses the bit width to a smaller range (such as 2 bits, 4 bits, 6 bits, etc.), and regardless of the specific bit width, it is smaller than the bit width of the first color value, which provides a basis for reducing the overall video memory requirements in the future.

[0028] For example, the first color value of the target pixel is 0xF800 (16-bit, pure red) in RGB565 format. If it is adapted to a 16-color display scenario, the index value bit width is designed to be 4 bits. At this time, the pure red corresponding to 0xF800 can be mapped to the index value "0001" (4-bit bit width). This bit width (4 bits) is significantly smaller than the bit width of the first color value (16 bits).

[0029] S3. Determine the target storage unit and bit offset in the frame buffer based on the coordinates of the target pixel, and write the index value into the specified bit starting from the bit offset in the target storage unit; wherein, each storage unit is used to store the index values ​​of multiple different pixels; Specifically, in step S3, the frame buffer is a memory area used to centrally store all pixel index values, and the storage unit is usually 1 byte (8 bits). The coordinates of the target pixel, such as (x, y), where x is the horizontal coordinate and y is the vertical coordinate, are the key basis for locating the storage position. First, the linear position of the target pixel in the frame buffer is calculated by multiplying the vertical coordinate and the horizontal resolution, and then adding the horizontal coordinate. Then, the total number of bits occupied by the index value is calculated by combining the index value bit width, thereby determining the target storage unit (the specific byte address, i.e., the integer result of dividing the total number of bits by 8) and the bit offset (the remainder of dividing the total number of bits by 8, i.e., the starting bit position of the index value in the target byte). Since the index value bit width is less than 8 bits, a single 1-byte storage unit can accommodate multiple index values, such as storing 4 two-bit index values ​​and 2 four-bit index values, achieving efficient memory utilization.

[0030] Assume the embedded GUI's display resolution is 320×240 (320 horizontally, 240 vertically), the target pixel coordinates are (x=3, y=1), and the index value is "0001" (4-bit width). The first step is to calculate the linear position: 1×320+3=323, meaning that the pixel is the 323rd pixel on the screen. The second step is to calculate the total number of bits: 323 × 4 = 1292, meaning that this index value occupies the 1292nd bit in the frame buffer. The third step is to determine the target memory cell and bit offset. The memory cell address = 1292 / / 8 = 161 (i.e., the 161st byte), and the bit offset = 1292%8 = 4, which means starting from the 4th bit of the 161st byte. The fourth step is to write the index value, writing "0001" into bits 4-7 of the 161st byte (specified bits). At this point, the 161st byte has stored the index values ​​for x=2 (when y=1, the 322nd pixel, bits 0-3) and x=3 (the 323rd pixel, bits 4-7), which conforms to the design of storing multiple pixel index values ​​in a single storage unit.

[0031] S4. In response to a display request, read the corresponding index value from the frame buffer based on the coordinates of the target pixel; Specifically, for step S4, the display request refers to the screen refresh signal triggered by the embedded system or display device, such as the vertical synchronization signal of the display device, GUI interface switching instructions, etc. After receiving the display request, the reverse operation needs to be performed according to the mapping logic consistent with the previous step. The linear position is calculated through the target pixel coordinates, and the total number of bits is obtained by combining the index value bit width. Then, the storage unit address and bit offset are determined. The index value is then extracted from the specified bit of the storage unit through bit operations (such as bit mask) to ensure that the index value read is consistent with the one written before.

[0032] For example, when the display screen sends a vertical synchronization signal (display request), the pixel at coordinates (x=3, y=1) needs to be refreshed. First, determine that the index value of this pixel is stored in bits 4-7 of the 161st byte. Extract the value of this bit segment through bitmasking operations (such as AND 0b11110000), and finally read the index value "0001".

[0033] S5. Convert the read index value into a second color value in the first color space and display the second color value; Specifically, for step S5, the second color value is the color data restored from the index value, and its color space is consistent with the first color space (both are RGB space) to ensure that the displayed color matches the original design color. The conversion process needs to be based on the preset correspondence between the index value and the RGB color value, to restore the index value with a smaller bit width to the complete color data that meets the display requirements, and then transmit the second color value to the display driver circuit to drive the corresponding pixel of the display screen to display, thus completing the entire display process.

[0034] For example, if the index value read is "0001" (4 bits), and the preset correspondence is "0001" maps to 0xF800 (pure red) in RGB565 format, then "0001" is converted to the second color value 0xF800; then 0xF800 is transmitted to the display driver circuit to drive the (x=3, y=1) pixels of the display screen to display pure red.

[0035] This embodiment significantly reduces video memory usage by converting high-bit-width color values ​​in the first color space into low-bit-width index values ​​and storing the index values ​​of multiple pixels in a single memory unit. This allows the on-chip SRAM of a low-cost embedded MCU to be sufficient to accommodate the frame buffer without increasing hardware costs. At the same time, display is achieved by relying on the frame buffer, avoiding the long-term occupation of the MCU by the direct driving method, solving problems such as screen misalignment, flickering, and noise, and ultimately achieving stable video memory-driven display for a low-cost embedded GUI.

[0036] Furthermore, in some embodiments, step S1, "acquiring the color data of the target pixel," may specifically include: S11. Determine the coordinates of the target pixel to be updated based on the application's drawing instructions or user input events; Specifically, for step S11, in an embedded GUI system, the application's drawing instructions refer to the interface drawing / update instructions actively initiated by the GUI application, such as instructions to draw text, icons, background color blocks, etc. These instructions clearly define the range of graphic elements to be generated or modified on the interface. User input events refer to interface change events triggered by the user through the interactive components of the embedded device (such as buttons, touch keys), such as pressing a button on a home appliance control panel to trigger a temperature value update, or touching the directional keys on a retro game console to trigger character position movement. These events trigger pixel updates in specific areas of the interface. Whether it is a drawing instruction or a user input event, it will ultimately locate the pixel to be updated on the interface (i.e., the target pixel) and determine the specific coordinate values ​​of these pixels. The coordinate values ​​are usually based on the resolution of the display screen and are represented by (x,y) two-dimensional coordinates. x is the horizontal coordinate, ranging from 0 to (horizontal resolution - 1); y is the vertical coordinate, ranging from 0 to (vertical resolution - 1). For example, at a resolution of 320×240, x ranges from 0 to 319, and y ranges from 0 to 239, ensuring that the color data of the pixels can be accurately located subsequently.

[0037] S12. Based on the coordinate values, obtain the corresponding first color value; Specifically, for step S12, the first color value is the original color data of the target pixel in the first color space (such as the RGB565 color space commonly used in embedded GUIs). Its bit width matches the color space, such as 16 bits in RGB565 mode, containing red, green, and blue color component information. The embedded GUI system pre-stores the color mapping relationship of interface elements (text, icons, backgrounds, etc.), that is, the preset color data of the pixel corresponding to each coordinate in a specific scene. After determining the coordinate value of the target pixel, the system will query the preset color mapping relationship according to the coordinate value, or extract the original color data corresponding to the pixel at that coordinate according to the color rules corresponding to the drawing instructions / user input events (such as the background block being preset to light blue and the temperature text being preset to red), which is the first color value.

[0038] This embodiment determines the coordinates of the target pixel to be updated based on the application's drawing instructions or user input events, and then obtains the first color value based on the coordinates. This refines the acquisition path of the target pixel color data, ensuring accurate pixel positioning and clear color value sources. It avoids errors in subsequent memory optimization steps due to ambiguous coordinates or chaotic color value acquisition, providing a precise data foundation for the entire memory optimization scheme and ensuring the operability of the scheme.

[0039] Furthermore, in some embodiments, step S2, "converting the first color value into the corresponding index value," may specifically include: S21. A predefined color mapping table is used to store the mapping relationship between reference color values ​​and index values; Specifically, in step S21, the color mapping table is a pre-configured mapping table between reference colors and indices in the embedded system. Its function is to establish the association between low-bit-width index values ​​and high-bit-width reference color values ​​in the first color space (such as the RGB565 color space commonly used in embedded GUIs). The reference color values ​​are typical colors selected from the first color space that can cover the current GUI display requirements, such as interface text colors, background colors, and icon colors. Their bit width is consistent with the first color values ​​(e.g., 16 bits in RGB565 mode). The index value is a unique identifier assigned to each reference color value, with a bit width smaller than the reference color value's bit width (e.g., 2 bits, 4 bits, etc.). Each index value corresponds to only one reference color value, ensuring a unique mapping relationship and avoiding confusion during subsequent conversions.

[0040] S22. Calculate the color difference between the first color value and each reference color value in the color mapping table, and select the reference color value with the smallest color difference from the first color value as the matching result; Specifically, for step S22, color difference is an indicator that measures the color similarity between the first color value and the reference color value. The calculation logic is based on the color components of the first color space (such as the red, green, and blue components in RGB565 mode). First, the red (R), green (G), and blue (B) components of the first color value and the reference color value are extracted respectively. Then, the color difference between the two is calculated using mathematical formulas, such as the Euclidean distance formula. After traversing all reference color values ​​in the color mapping table and calculating the color difference with the first color value one by one, the reference color value with the smallest color difference is selected. This reference color value is the color closest to the first color value, ensuring that the color after subsequent conversion can restore the original display intent to the greatest extent.

[0041] S23. Select the index value corresponding to the reference color value with the smallest color difference from the first color value as the index value of the target pixel; Specifically, in step S23, after determining the reference color value with the smallest color difference from the first color value, the unique index value bound to the reference color value is found by querying a predefined color mapping table. This index value is the index value of the target pixel. Since the bit width of the index value is smaller than the bit width of the first color value (e.g., 4 bits vs. 16 bits), the conversion from the high bit width color value to the low bit width index value has been completed at this point, laying the foundation for reducing video memory usage in the future.

[0042] This embodiment refines the conversion process of index values ​​by predefining a color mapping table, calculating the color difference between the first color value and the reference color value to match the optimal reference color, and extracting the corresponding index value. This process compresses high-bit-width color values ​​to low-bit-width index values ​​to reduce video memory usage, while ensuring that the color corresponding to the converted index value is as close as possible to the original color. This avoids color deviation from affecting the user experience and meets the dual requirements of low-cost embedded GUI for memory optimization and color reproduction.

[0043] Furthermore, in some embodiments, step S2, "converting the first color value into the corresponding index value," may further include: S24. Extract the red, green, and blue color components from the first color value respectively; Specifically, for step S24, the first color value is usually based on the RGB color space (such as the RGB565 color mode commonly used in embedded GUIs). Color data in this color space is composed of three basic color components: red (R), green (G), and blue (B), with each component occupying a fixed number of bits in the first color value. Extracting the color components involves separating the bit segments corresponding to the R, G, and B components according to the format rules of the first color value through bit operations (such as shifting and masking) to obtain the original value of each component, providing an independent processing object for subsequent compression operations.

[0044] S25. Perform bit-width compression on each color component to generate compressed color components; Specifically, in step S25, the original bit width of each component in the first color value is relatively high (e.g., R is 5 bits, G is 6 bits, and B is 5 bits in RGB565), which would occupy a lot of video memory if stored directly. Bit width compression reduces the original bit width of each component to a smaller fixed bit width using preset rules (such as retaining the high bits of the components and uniform quantization), and the compressed bit width must meet the requirement that the total bit width of the index values ​​is less than the bit width of the first color value. For example, to adapt to the 64-color display requirement, the R, G, and B components can all be compressed to 2 bits, making the total bit width of the three components 6 bits (much smaller than the 16 bits of RGB565).

[0045] S26. Combine the compressed color components to form an index value; Specifically, in step S26, the three compressed color components are concatenated into a continuous bit sequence according to a preset order, such as R compressed component → G compressed component → B compressed component. This sequence is the index value. Since the bit width of each compressed component is fixed, the total bit width of the concatenated index value can be precisely controlled, such as 2 R bits + 2 G bits + 2 B bits = 6 bits for the index value. The total bit width is necessarily less than the bit width of the first color value (e.g., 6 bits < 16 bits), which fully meets the core requirement that the bit width of the index value is less than the bit width of the first color value.

[0046] This embodiment provides an alternative index value conversion path by extracting RGB components from the first color value, compressing the bit width of each component, and combining the compressed components to generate an index value. This eliminates the need for an additional color mapping table and simplifies the conversion process. At the same time, by accurately compressing the component bit width, it effectively reduces the storage footprint of the index value while ensuring the basic color reproduction effect, thus meeting the storage optimization and conversion efficiency requirements of low-cost embedded GUIs.

[0047] Furthermore, in some embodiments, step S3, "determining the target storage unit and bit offset in the frame buffer based on the coordinates of the target pixel, and writing the index value into the target storage unit at a specified bit starting from the bit offset," may specifically include: S31. Based on the coordinates of the target pixel, the horizontal resolution of the display device, and the bit width occupied by each pixel index value, calculate the linear address of the index value in the frame buffer; Specifically, in step S31, the coordinates of the target pixel are represented in a two-dimensional (x, y) form, where x represents the horizontal position and y represents the vertical position. The horizontal resolution of the display device refers to the total number of pixels contained in the horizontal direction of the screen. These two parameters are used together to determine the index of the target pixel in the entire screen pixel sequence. First, by multiplying y by the horizontal resolution and adding x, we calculate that the pixel is the Nth pixel on the screen (i.e., the pixel index). Then, combining the bit width of each pixel index value, we calculate the total bit position occupied by the index value in the frame buffer by multiplying the pixel index and the bit width of the index value. This total bit position is the linear address. The core function of the linear address is to convert the two-dimensional pixel coordinates into a one-dimensional storage location identifier, providing a basis for subsequent location of specific storage units.

[0048] S32. Determine the byte address of the target memory unit and its internal bit offset based on the linear address; Specifically, for step S32, the storage unit of the frame buffer is based on bytes. Therefore, the linear address (bit-level position) needs to be converted into a byte address (the location of the storage unit) and a bit offset (the starting bit position of the index value within the byte). The specific calculation logic is as follows: byte address = linear address ÷ 8 (round down to the nearest integer), indicating which byte in the frame buffer the index value is stored in; bit offset = linear address % 8 (remainder), indicating which bit in the target byte the index value starts storing in. Using these two parameters, the physical storage location of the index value in the frame buffer can be precisely located.

[0049] S33. Using bit manipulation instructions, write the index value into the memory cell corresponding to the byte address, starting from the bit offset, for a specified number of bits; Specifically, for step S33, since a single storage unit (1 byte) needs to store the index values ​​of multiple pixels (e.g., 4 can be stored with 2-bit index values), direct writing can easily overwrite other index values. Therefore, precise writing is achieved through bit manipulation instructions. The specific operation logic is as follows: First, read the original byte data corresponding to the target byte address; then, clear the specified bits starting from the bit offset in the byte using a mask operation (e.g., performing an AND operation with a specific binary number) (the number of specified bits is consistent with the width of the index value) to avoid interference from the original data; next, shift the index value left by the offset bit to align it to the bit position to be written; finally, perform an OR operation between the shifted index value and the cleared original byte data to obtain new byte data, and write it to the target byte address to complete the safe storage of the index value.

[0050] This embodiment calculates the linear address based on pixel coordinates, horizontal resolution, and index value bit width, then locates the target storage unit and bit offset, and finally accurately writes the index value through bit operations. This achieves efficient and interference-free storage of the index value in the frame buffer. It reduces video memory usage by using a single storage unit to store multiple index values, and avoids overwriting the index values ​​of other pixels during writing, which would cause display errors. This provides storage layer support for the stable operation of the video memory optimization scheme.

[0051] Furthermore, in some embodiments, step S4, "in response to a display request, reading the corresponding index value from the frame buffer based on the coordinates of the target pixel," may specifically include: S41. In response to the vertical synchronization signal of the display device, generate a display request; Specifically, in step S41, in an embedded GUI display system, the display device refreshes the screen line by line or frame by frame at a fixed refresh rate. The vertical synchronization signal is a crucial synchronization signal emitted by the display device, signifying that the display device has completed displaying one frame and is ready to refresh the next frame. To avoid screen tearing (i.e., new and old screen data being displayed simultaneously), the system needs to respond to this vertical synchronization signal by generating a display request when the signal is triggered. The core function of this display request is to initiate the process of reading pixel data from the frame buffer and updating the screen, ensuring that data reading is synchronized with the screen refresh rhythm and guaranteeing smooth display.

[0052] S42. Based on the coordinates of the target pixel that needs to be refreshed, locate and read the index value of the target pixel in the frame buffer. Specifically, for step S42, the target pixel to be refreshed may be all pixels of the entire frame (such as when switching to full-screen mode) or pixels of a local area (such as when only updating temperature values ​​or icon states). However, the core positioning logic is the same. Both require the target pixel's (x,y) coordinates to be used, following the same mapping rules between coordinates and storage locations as the index value being written. First, the index number of the target pixel in the screen pixel sequence is calculated, and then the linear address (bit-level position) of the index value in the frame buffer is calculated in combination with the index value bit width. This determines the corresponding storage unit byte address and bit offset. Subsequently, the index value is extracted from the specified bit of the storage unit through bit operations (such as bitmasking and shifting) to ensure that the read index value is completely consistent with the previously written value, providing accurate data for subsequent color restoration.

[0053] This embodiment generates a display request in response to the vertical synchronization signal of the display device, ensuring that the index value reading rhythm is synchronized with the screen refresh, thus avoiding screen tearing caused by the asynchrony between data reading and display. At the same time, it accurately locates and reads the index value according to coordinates, ensuring the accuracy of the read data and providing reliable data for the subsequent restoration of the index value to the color value and display, thus ensuring the smoothness and correctness of the embedded GUI display.

[0054] Furthermore, in some embodiments, step S5, "converting the read index value into a second color value in the first color space and outputting the second color value to the display driver circuit to drive the display device to display," may specifically include: S51. When the index value is generated based on the color palette, use the index value as the subscript to query the color mapping table and obtain the corresponding reference color value as the second color value; Specifically, in step S51, the index values ​​generated based on the color palette are stored and compressed using a preset correspondence between the index and the color. Therefore, the conversion relies on a pre-configured color mapping table (i.e., the color palette). In this mapping table, each index value uniquely corresponds to a reference color value in a first color space (e.g., RGB565 color space), and the bit width of the reference color value is consistent with that of the first color value (e.g., 16 bits). During the conversion, the read index value is directly used as the index to locate the corresponding entry in the mapping table, and the reference color value within the entry is extracted. This reference color value is the second color value, and its color space is completely consistent with the first color space, ensuring the accuracy of color reproduction.

[0055] S52. When the index value is generated by color component compression, the compressed color components are separated from the index value, and each color component is restored to the original bit width of the corresponding color component in the first color space through bit extension or left shift operation, so as to combine them to form the second color value. Specifically, for step S52, the index value generated by color component compression is essentially a concatenated sequence of compressed RGB components. Therefore, the conversion requires three steps: separation, restoration, and combination. First, according to the component concatenation order when generating the index value (e.g., R→G→B), the compressed red (R), green (G), and blue (B) components are separated from the index value (e.g., a 6-bit index value is split into 2 bits of R, 2 bits of G, and 2 bits of B). Second, for each compressed component, its bit width is restored to the original bit width of the corresponding component in the first color space through bit extension (e.g., padding with 0s in the low bits) or left shift operation. For example, in RGB565, R is 5 bits, G is 6 bits, and B is 5 bits, so 2 bits of R need to be extended to 5 bits, 2 bits of G to 6 bits, and 2 bits of B to 5 bits. Finally, according to the component order of the first color space (e.g., R5G6B5 in RGB565), the restored components are concatenated into complete color data, which is the second color value.

[0056] S53. Output the second color value to the display driver circuit to drive the display device to display; Specifically, in step S53, the display driver circuit is the core component connecting the data processing and display devices. It needs to receive color data conforming to a specific format (such as RGB565) to control the pixels to light up. The converted second color value already matches the input format of the display driver circuit, so the second color value is directly transmitted to the driver circuit. After receiving the data, the driver circuit controls the pixels at the corresponding coordinates of the display device to display the corresponding color according to the color information of the second color value, thus completing the display of a single pixel. The display of all pixels in sequence forms a complete GUI interface.

[0057] This embodiment provides precise color restoration logic for two types of index values ​​generated based on a color palette and based on color component compression, respectively, to ensure that the converted second color value matches the first color space and guarantee the accuracy of the displayed color. At the same time, the second color value is output to the display driver circuit to complete the display, realizing a closed loop from index value to screen image, providing display-end support for the video memory optimization scheme, and ensuring that the embedded GUI presents a clear and accurate picture.

[0058] To better understand the graphics interface memory optimization method provided in this embodiment, the following description uses specific examples, including 4-color compact bit-domain memory design, 16-color compact bit-domain memory design, and 64-color compact bit-domain memory design. The specific process is as follows: Compact bit-domain memory design stores multiple pixel information within 1 byte of storage space. In 4-color and 16-color modes, each pixel occupies 2 bits and 4 bits of memory respectively. Because the number of bits is too small to use color depth, a palette method is used, with one value corresponding to one color. In 64-color mode, a compressed color depth method can be used, employing 2 bits to represent the color depth of a primary color, with the three primary colors (red, green, and blue) occupying a total of 6 bits.

[0059] Figures 3-6 This comparison examines the memory requirements of the original RGB565 mode and these three color modes when the screen resolution is 320*240. Compared to the 153.6KB of video memory required for RGB565 mode, the video memory required for 4-color, 16-color, and 64-color modes are 19.2KB, 38.4KB, and 57.6KB respectively. This represents a significant reduction in video memory requirements compared to the original 153.6KB for these three color modes.

[0060] The color palette method for 4-color mode is as follows: 1) Define the frame buffer: Create a uint8_t array, the size of which is equal to the screen resolution divided by 4.

[0061] 2) Define a color palette: Create a uint16_t array with a size of 4 to store the RGB565 values ​​of the four colors.

[0062] 3) Write the set_pixel interface: Write the RGB565 value of the (x,y) coordinate into the frame buffer in a compact 4-color bit field manner.

[0063] 4) Write the get_pixel interface: return the RGB565 value of the (x,y) coordinates from the framebuffer according to the palette definition.

[0064] The color palette method for 16-color mode is as follows: 1) Define the frame buffer: Create a uint8_t array with a size equal to the screen resolution divided by 2.

[0065] 2) Define a color palette: Create a uint16_t array with a size of 16 to store the RGB565 values ​​of 16 colors.

[0066] 3) Write the set_pixel interface: Write the RGB565 value of the (x,y) coordinate into the frame buffer in a 16-color compact bit field manner.

[0067] 4) Write the get_pixel interface: return the RGB565 value of the (x,y) coordinates from the framebuffer according to the palette definition.

[0068] The method for compressing color depth in 64-color mode is as follows: 1) Define the frame buffer: Create a uint8_t array with a size equal to 3 / 4 of the screen resolution.

[0069] 2) Write the set_pixel interface: convert the RGB565 value of the (x,y) coordinate to RGB222 value, and then write it into the frame buffer in a 64-color compact bit field manner.

[0070] 3) Write the get_pixel interface: find the RGB222 value of the (x,y) coordinate in the frame buffer, then convert it to an RGB565 value and return it.

[0071] The above steps ultimately yield two key interface functions: `set_pixel` obtains compact bit-domain video memory information, and `get_pixel` obtains screen information. When you need to store video information in video memory, you must call `set_pixel`. When you need to display video information on the screen, you must call `get_pixel`.

[0072] In summary, the graphical user interface (GUI) memory optimization method provided in this embodiment significantly reduces the memory footprint of the embedded MCU. For 4-color GUIs, the size is reduced to 1 / 8; for 16-color GUIs, it's reduced to 1 / 4; and for 64-color GUIs, it's reduced to 3 / 8. This solves the problem of low-cost embedded GUIs being unable to use a memory-driven approach without increasing hardware costs. It also indirectly addresses the drawbacks of direct-drive methods, such as prolonged MCU usage leading to poor overall performance, screen misalignment, severe animation flickering, and noise at image / text edges.

[0073] To facilitate better implementation of the graphical user interface (GUI) memory optimization method of this application embodiment, this application embodiment also provides a GUI memory optimization apparatus based on the above-described GUI memory optimization method. The meanings of the terms used are the same as in the above-described GUI memory optimization method, and specific implementation details can be found in the description of the method embodiment.

[0074] Please see Figure 7 , Figure 7 This is a schematic diagram of the structure of the graphics interface memory optimization device provided in the embodiments of this application. The graphics interface memory optimization device may specifically include an acquisition module 201, a first conversion module 202, a writing module 203, a reading module 204, and a second conversion module 205, as follows: The acquisition module 201 is used to acquire the color data of the target pixel, where the color data is the first color value in the first color space; The first conversion module 202 is used to convert the first color value into the corresponding index value, wherein the bit width of the index value is smaller than the bit width of the first color value; The write module 203 is used to determine the target storage unit and bit offset in the frame buffer according to the coordinates of the target pixel, and write the index value into the target storage unit starting from the bit offset; wherein, each storage unit is used to store the index values ​​of multiple different pixels; The reading module 204 is used to read the corresponding index value from the frame buffer according to the coordinates of the target pixel in response to the display request; The second conversion module 205 is used to convert the read index value into a second color value in the first color space and display the second color value.

[0075] Furthermore, in some embodiments, the acquisition module 201 is specifically used for: Determine the coordinates of the target pixel to be updated based on the application's drawing instructions or user input events; Based on the coordinate values, obtain the corresponding first color value.

[0076] Furthermore, in some embodiments, the first conversion module 202 is specifically used for: A predefined color map table is used to store the mapping relationship between reference color values ​​and index values; Calculate the color difference between the first color value and each reference color value in the color mapping table, and select the reference color value with the smallest color difference from the first color value as the matching result; The index value corresponding to the reference color value with the smallest color difference from the first color value is selected as the index value of the target pixel.

[0077] Furthermore, in some embodiments, the first conversion module 202 is specifically used for: Extract the red, green, and blue color components from the first color value respectively; Perform bit-width compression on each color component to generate compressed color components; The compressed color components are combined to form an index value.

[0078] Furthermore, in some embodiments, the writing module 203 is specifically used for: Calculate the linear address of the index value in the frame buffer based on the coordinates of the target pixel, the horizontal resolution of the display device, and the bit width occupied by each pixel index value; Based on the linear address, determine the byte address of the target memory unit and its internal bit offset; Using bit manipulation instructions, the index value is written to a specified number of bits starting from the bit offset in the memory cell corresponding to the byte address.

[0079] Furthermore, in some embodiments, the reading module 204 is specifically used for: In response to the vertical synchronization signal of the display device, a display request is generated; Based on the coordinates of the target pixel that needs to be refreshed, locate and read the index value of the target pixel in the frame buffer.

[0080] Furthermore, in some embodiments, the second conversion module 205 is specifically used for: When the index value is generated based on the color palette, the color mapping table is queried using the index value as the subscript to obtain the corresponding reference color value as the second color value; When the index value is generated by color component compression, the compressed color components are separated from the index value, and each color component is restored to the original bit width of the corresponding color component in the first color space through bit extension or left shift operation, so as to combine them to form the second color value. The second color value is output to the display driver circuit to drive the display device to display.

[0081] Specific limitations regarding the optimization device for graphics interface video memory can be found in the limitations of the optimization method for graphics interface video memory mentioned above, and will not be repeated here. Each module in the aforementioned optimization device for graphics interface video memory can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in hardware or independently of the processor in the computer device, or stored in software in the memory of the computer device, so that the processor can call and execute the operations corresponding to each module.

[0082] The graphical user interface memory optimization device provided in this embodiment includes an acquisition module 201 that acquires the color data of the target pixel, where the color data is a first color value in a first color space; a first conversion module 202 that converts the first color value into a corresponding index value, where the bit width of the index value is smaller than the bit width of the first color value; a writing module 203 that determines the target storage unit and bit offset in the frame buffer based on the coordinates of the target pixel, and writes the index value into a specified bit starting from the bit offset in the target storage unit; wherein each storage unit is used to store the index values ​​of multiple different pixels; a reading module 204 that, in response to a display request, reads the corresponding index value from the frame buffer based on the coordinates of the target pixel; and a second conversion module 205 that converts the read index value into a second color value in the first color space and displays the second color value. Therefore, this embodiment can achieve stable display and effective system performance assurance under memory-driven operation without increasing hardware costs, solving the problem of excessive memory usage preventing the use of memory-driven operation, while avoiding the problem of poor display effects caused by direct driving.

[0083] Furthermore, embodiments of this application also provide an electronic device, such as... Figure 8 As shown, it illustrates a structural schematic diagram of the electronic device involved in the embodiments of this application, specifically: The electronic device may include components such as a processor 301 with one or more processing cores, a memory 302 with one or more computer-readable storage media, a power supply 303, and an input unit 304. Those skilled in the art will understand that... Figure 8 The electronic device structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein: The processor 301 is the control center of the electronic device. It connects various parts of the electronic device via various interfaces and lines, and performs various functions and processes data by running or executing software programs and / or modules stored in the memory 302, and by calling data stored in the memory 302, thereby providing overall monitoring of the electronic device. Optionally, the processor 301 may include one or more processing cores; preferably, the processor 301 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 301.

[0084] The memory 302 can be used to store software programs and modules. The processor 301 executes various functional applications and graphical interface memory optimization methods by running the software programs and modules stored in the memory 302. The memory 302 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 302 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 302 may also include a memory controller to provide the processor 301 with access to the memory 302.

[0085] The electronic device also includes a power supply 303 that supplies power to various components. Preferably, the power supply 303 can be logically connected to the processor 301 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 303 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.

[0086] The electronic device may also include an input unit 304, which can be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.

[0087] Although not shown, the electronic device may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 301 in the electronic device loads the executable files corresponding to the processes of one or more applications into the memory 302 according to the following instructions, and the processor 301 runs the applications stored in the memory 302 to realize various functions, as follows: The process involves: acquiring the color data of the target pixel, where the color data is a first color value in a first color space; converting the first color value into a corresponding index value, where the bit width of the index value is smaller than that of the first color value; determining the target storage unit and bit offset in the frame buffer based on the coordinates of the target pixel, and writing the index value into the target storage unit at a specified bit starting from the bit offset; wherein each storage unit is used to store the index values ​​of multiple different pixels; responding to a display request, reading the corresponding index value from the frame buffer based on the coordinates of the target pixel; converting the read index value into a second color value in the first color space, and displaying the second color value.

[0088] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.

[0089] The embodiments of this application can achieve stable display and effective system performance guarantee under the video memory driver without increasing hardware costs, solve the problem of excessive video memory usage that prevents the use of the video memory driver, and avoid the problem of poor display effect caused by the direct driving method.

[0090] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.

[0091] Therefore, embodiments of this application provide a storage medium storing a plurality of instructions that can be loaded by a processor to execute steps in any of the graphical user interface video memory optimization methods provided in embodiments of this application. For example, the instructions can execute the following steps: The process involves: acquiring the color data of the target pixel, where the color data is a first color value in a first color space; converting the first color value into a corresponding index value, where the bit width of the index value is smaller than that of the first color value; determining the target storage unit and bit offset in the frame buffer based on the coordinates of the target pixel, and writing the index value into the target storage unit at a specified bit starting from the bit offset; wherein each storage unit is used to store the index values ​​of multiple different pixels; responding to a display request, reading the corresponding index value from the frame buffer based on the coordinates of the target pixel; converting the read index value into a second color value in the first color space, and displaying the second color value.

[0092] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.

[0093] The storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.

[0094] Since the instructions stored in the storage medium can execute the steps in any of the graphical interface memory optimization methods provided in the embodiments of this application, the beneficial effects that any of the graphical interface memory optimization methods provided in the embodiments of this application can achieve can be realized. For details, please refer to the previous embodiments, which will not be repeated here.

[0095] The above provides a detailed description of a graphical user interface memory optimization method, apparatus, electronic device, and medium provided in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A method for optimizing video memory in a graphical user interface, characterized in that, include: Obtain the color data of the target pixel, wherein the color data is a first color value in a first color space; The first color value is converted into a corresponding index value, wherein the bit width of the index value is smaller than the bit width of the first color value; The target storage unit and bit offset in the frame buffer are determined based on the coordinates of the target pixel, and the index value is written into the target storage unit at a specified bit starting from the bit offset; wherein, each storage unit is used to store the index values ​​of multiple different pixels; In response to a display request, the corresponding index value is read from the frame buffer based on the coordinates of the target pixel; The read index value is converted into a second color value in the first color space, and the second color value is displayed.

2. The method for optimizing graphical user interface video memory according to claim 1, characterized in that, The acquisition of the color data of the target pixel includes: The coordinates of the target pixel to be updated are determined based on the application's drawing instructions or user input events. Based on the coordinate values, the corresponding first color value is obtained.

3. The method for optimizing graphical user interface video memory according to claim 1, characterized in that, The step of converting the first color value into the corresponding index value includes: A predefined color mapping table is used to store the mapping relationship between reference color values ​​and index values; Calculate the color difference between the first color value and each reference color value in the color mapping table, and select the reference color value with the smallest color difference from the first color value as the matching result; The index value corresponding to the reference color value with the smallest color difference from the first color value is selected as the index value of the target pixel.

4. The method for optimizing graphical user interface video memory according to claim 3, characterized in that, The step of converting the first color value into the corresponding index value further includes: Extract the red, green, and blue color components from the first color value, respectively; Perform bit-width compression on each color component to generate compressed color components; The compressed color components are combined to form the index value.

5. The method for optimizing graphical user interface video memory according to claim 1, characterized in that, The step of determining the target storage unit and bit offset in the frame buffer based on the coordinates of the target pixel, and writing the index value into a specified bit starting from the bit offset in the target storage unit, includes: Based on the coordinates of the target pixel, the horizontal resolution of the display device, and the bit width occupied by each pixel index value, calculate the linear address of the index value in the frame buffer; Based on the linear address, determine the byte address of the target storage unit and its internal bit offset; Using bit manipulation instructions, the index value is written into the storage unit corresponding to the byte address, starting from the bit offset, for a specified number of bits.

6. The method for optimizing graphical user interface video memory according to claim 1, characterized in that, The step of responding to a display request by reading the corresponding index value from the frame buffer based on the coordinates of the target pixel includes: The display request is generated in response to the vertical synchronization signal of the display device; Based on the coordinates of the target pixel that needs to be refreshed, locate and read the index value corresponding to the target pixel in the frame buffer.

7. The method for optimizing graphical user interface video memory according to claim 1, characterized in that, The step of converting the read index value into a second color value in the first color space and outputting the second color value to the display driver circuit to drive the display device to display includes: When the index value is generated based on the color palette, the color mapping table is queried using the index value as the subscript to obtain the corresponding reference color value as the second color value; When the index value is generated by color component compression, the compressed color components are separated from the index value, and each color component is restored to the original bit width of the corresponding color component in the first color space through bit extension or left shift operation, so as to combine them to form the second color value. The second color value is output to the display driver circuit to drive the display device to display.

8. A device for optimizing graphics interface video memory, characterized in that, include: The acquisition module is used to acquire the color data of the target pixel, wherein the color data is a first color value in a first color space; A first conversion module is used to convert the first color value into a corresponding index value, wherein the bit width of the index value is smaller than the bit width of the first color value; The writing module is used to determine the target storage unit and bit offset in the frame buffer according to the coordinates of the target pixel, and write the index value into the target storage unit at a specified bit starting from the bit offset; wherein, each storage unit is used to store the index values ​​of multiple different pixels; A reading module is used to read the corresponding index value from the frame buffer according to the coordinates of the target pixel in response to a display request; The second conversion module is used to convert the read index value into a second color value in the first color space and display the second color value.

9. An electronic device, characterized in that, include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the steps of the method for optimizing the graphics interface video memory as described in any one of claims 1-7.

10. A storage medium, characterized in that, A computer program is stored that can be loaded by a processor and execute the optimization method for the graphics interface video memory as described in any one of claims 1-7.