Color mixing processing method for display

CN122888919APending Publication Date: 2026-10-09AMICRO SEMICONDUCTOR CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510352728.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-25
Publication Date
2026-10-09

AI Technical Summary

Benefits of technology

[0015]本申请通过控制背景色扩展数据和左移后的背景色数据进行按位或运算,得到背景色整体组合结果,使所述前景色整体组合结果使用扩展比特位数存储中间结果,避免浮点运算,也能保证计算精度。然后,所述背景色整体组合结果和掩码进行按位与运算时,掩码将提取颜色分量的二进制范围由所述预设比特位数扩展为所述扩展比特位数,且预先计算出来的背景色整体组合结果已经通过左移位来将不同颜色分量分配到最高所述预设比特位数的数据和最低所述预设比特位数的数据中,同时,掩码在所述背景色整体组合结果中屏蔽除了所需保留的颜色分量之外的二进制位,只保留符合特定的颜色编码格式的颜色分量占据的比特位,进而实现从所述背景色整体组合结果中提取出符合预设比特位数的颜色编码格式数据中所有颜色分量。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122888919A_ABST
    Figure CN122888919A_ABST
Patent Text Reader

Abstract

The application discloses a color mixing processing method for display, comprising the following steps: step 1, configuring foreground color data, background color data and transparency for a screen of a display; wherein, for the same foreground color data and the same background color data, the transparency is adjustable to change the difference between the foreground color data and the background color data; step 2, through a shift operation, controlling the foreground color data and the background color data to perform color mixing calculation under the transparency superposition to obtain a mixed color value, so that the color corresponding to the mixed color value is displayed on the screen of the display without color encoding format conversion, and the color corresponding to the mixed color value changes with the change of the transparency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of color display, and more particularly to a color mixing processing method for display. Background Technology

[0002] TFT-LCD (Thin-Film Transistor Liquid Crystal Display) is a type of liquid crystal display based on thin-film transistor (TFT) technology, and is an upgraded version of LCD (Liquid Crystal Display). This type of LCD basically consists of a liquid crystal layer, a TFT array, and a backlight module. The liquid crystal layer: controls the alignment of liquid crystal molecules through voltage, regulating the passage of light. The TFT array: each pixel corresponds to a thin-film transistor, achieving precise voltage control. The backlight module: provides the light source (usually LED).

[0003] Chinese invention patent application number CN202211359586.1 discloses an object recognition method. This object recognition method involves a robot converting images of several objects from an RGB color model to an HSV color model and determining the HSV value of the pixels occupied by each object. The RGB (red, green, blue) color model described therein is most commonly used in display systems. Color cathode ray tubes and color raster graphics displays all use R, G, B values ​​to drive R, G, B electron guns to emit electrons, which in turn excite the R, G, and B phosphors on the screen to emit light of different brightness. Various colors are then produced by adding and mixing them together.

[0004] Therefore, those skilled in the art can determine that the RGB color model is called a device-dependent color space because different scanners will produce image data with different colors when scanning the same image. For example, RGB565, as a 16-bit color encoding format, is used to represent the combination of three color components: red, green, and blue. The numbers "5-6-5" in its name correspond to the bit allocation of the three color channels: red (R): 5 bits (value range: 0~31), green (G): 6 bits (value range: 0~63), and blue (B): 5 bits (value range: 0~31). Therefore, the RGB565 format uses 16 bits to store colors, distributed as: R (5 bits) | G (6 bits) | B (5 bits). However, the RGB565 format cannot directly represent transparency (0%~100%), resulting in the inability to achieve native transparent blending effects. When converting the RGB565 format to RGB888 (24 bits), the number of bits for each component needs to be expanded to match 8-bit precision.

[0005] Currently, two methods are commonly used for displaying gradual brightening, gradual dimming, and mixed color displays on TFTLCD screens: (1) The screen backlight module pins are controlled by a high-frequency duty cycle generated by software or hardware. The duty cycle can be adjusted continuously within a certain period of time to raise the overall brightness of the screen (until it is fully lit) or lower it (until it is completely off). This method can only adjust the overall brightness of the screen and cannot adjust the brightness of individual pixels. Moreover, when the duty cycle is 0, the backlight is not lit, but the internal light-emitting material is still displaying data. If you observe carefully, you will find that the screen still displays data changes. This method is generally found on low-cost screens.

[0006] (2) Convert RGB565 color data to RGB888 color data, then perform transparency blending and overlay using the converted RGB888 data, and finally convert the blended color data back to RGB565 color data, which is then transmitted to the screen through the display driver chip. When performing transparency blending and overlay, first calculate the RGB weights of the foreground and background colors based on the transparency ratio, and then perform a weighted average calculation. The weighted average calculation method introduces division operations, which is extremely resource-intensive on MCUs without floating-point units (it requires integers to simulate floating-point operations). This is very costly for MCUs with limited resources and slow clock speeds because it involves floating-point operations. Using this blending and overlay calculation method on MCUs without dedicated floating-point units may take more than 50ms of calculation time (the time depends on the number of pixels being calculated and the screen size). Summary of the Invention

[0007] This application discloses a color mixing processing method for display, and the specific technical solution is as follows: A color mixing processing method for display includes the following steps: Step 1: Configure foreground color data, background color data, and transparency for the display screen; wherein, for the same foreground color data and the same background color data, the transparency is adjustable to change the difference between the foreground color data and the background color data; Step 2: Control the foreground color data and background color data to perform color mixing calculation under the superposition of transparency through a shift operation to obtain a mixed color value, so as to display the color corresponding to the mixed color value on the display screen without color encoding format conversion, and the color corresponding to the mixed color value changes with the change of transparency.

[0008] In summary, by executing steps 1 and 2, when the foreground color data, background color data, and transparency are configured, a shift operation is used to directly perform color mixing calculations on the foreground and background color data under transparency overlay. This eliminates the need for color encoding format conversion of the foreground and background color data. The calculated mixed color value can then be written to the display to generate the corresponding color. Furthermore, when the transparency is adjusted, the mixed color value is calculated and updated in real time, updating local areas of the display screen to achieve a gradual brightening or darkening effect without relying on backlight control for the entire screen. Therefore, when a local area of ​​the display screen needs to change gradually, a new mixed color value can be directly calculated using the currently configured foreground and background color data, facilitating the handling of display control issues after color mixing.

[0009] Furthermore, the color mixing calculation of foreground and background color data under transparency overlay by executing step 2 is implemented based on shift operations. Therefore, the pixels used to display colors on the display can be directly subjected to color mixing calculations through shift operations under different transparency overlays. It is not necessary to decompose the foreground and background color data into various color components for weighted mixing calculations, nor is it necessary to control the conversion between different color encoding formats of the foreground and background color data. This avoids the introduction of floating-point operations due to the participation of multiple color channels in color mixing calculations. Thus, the entire process avoids the data operation with high overhead, saves calculation speed, and makes the color mixing processing method suitable for driving the screen display color of the display on MCUs with limited resources and low clock speeds.

[0010] Furthermore, in step 2, when controlling the foreground and background color data to perform color mixing calculations under the superposition of transparency, the foreground and background color data are not decomposed into various color components. The foreground, background, and mixed color values ​​are all color-coded data of a preset bit depth. The foreground and background color data are both calculated using binary numbers of the preset bit depth, ensuring that the mixed color value is the result of mixing the foreground and background color data based on the transparency, thus calculating the mixed color value without color encoding format conversion. The preset bit depth binary number represents an unsigned integer of the preset bit depth. A color-coded data of a preset bit depth is composed of multiple color components, and the sum of the bit depths of the multiple color components equals the preset bit depth. Transparency is represented by an integer. Therefore, by executing step 2 to calculate the final mixed color value used to drive the display screen without decomposing various color components or performing color encoding format conversion, the calculation speed is improved compared to traditional methods.

[0011] Further, in step 2, the method for controlling the color mixing calculation of foreground and background color data under the superposition of transparency through shift operations includes: Step 21, scaling the transparency by right shift to obtain the target transparency; then proceeding to step 22; Step 22, combining the foreground color data by left shift to obtain the overall foreground color combination result; then using a mask to retain all color components of the overall foreground color combination result to obtain the foreground color processing result; and combining the background color data by left shift to obtain the overall background color combination result; then using a mask to retain all color components of the overall background color combination result to obtain the background color processing result; then proceeding to step 23; Step 23, calculating the difference between the foreground color processing result and the background color processing result, and then using the target transparency... The brightness difference is amplified to obtain a color difference value; then, the color difference value is scaled by right shifting to obtain a scaled result; then, the sum of the scaled result and the background color processing result is calculated, and a mask is used to retain all color components of the sum to obtain a blending result; then, step 24 is executed; step 24: the blending result is merged by right shifting to obtain the blended color value, and the color encoding format data conforming to the preset bit number is generated by shifting and merging; wherein, the number of bits of the mask is equal to the number of extended bits; the mask is used to allocate binary bits for itself to locate various color components in the binary bits of the extended bit number according to the color encoding format data of the preset bit number; the number of extended bits is equal to twice the number of preset bits. By executing steps 21 to 24, the extraction and reorganization of foreground and background color data are optimized by using shift operations and masks. First, the bit positions occupied by various color components can be located and identified at once, without calculating three times; second, the division operation is avoided by shifting, saving time and further reducing the consumption of computing resources.

[0012] Further, in step 21, the method of scaling the transparency by right shift includes: converting the transparency into an unsigned integer with an extended number of bits to obtain extended transparency; controlling the extended transparency to add a preset compensation value to obtain corrected transparency, so as to prevent the corrected transparency from becoming a value of 0 after right shift; controlling the corrected transparency to shift right by a first right shift number to obtain the target transparency, thereby completing the scaling process of transparency; wherein, the first right shift number is less than the number of binary bits occupied by the transparency, and the number of binary bits occupied by the transparency is equal to half of the preset number of bits. This prevents the loss of too much information during the right shift process (because the right shift is rounded down).

[0013] Further, in step 22, the method of combining foreground color data by left shift includes: converting the foreground color data into an unsigned integer with an extended bit count to obtain extended foreground color data; controlling the extended foreground color data to shift left by the preset bit count to obtain left-shifted foreground color data; then controlling the extended foreground color data and the left-shifted foreground color data to perform a bitwise OR operation to obtain the overall foreground color combination result; the method of using a mask to retain all color components of the overall foreground color combination result includes: controlling the overall foreground color combination result and the mask to perform a bitwise AND operation to obtain the foreground color processing result; wherein, the number of bits in the overall foreground color combination result is equal to the extended bit count, and the number of bits in the foreground color processing result is equal to the extended bit count. This method extracts all color components from the color encoding format data conforming to the preset bit count from the overall foreground color combination result, and is suitable for embedded display drivers, graphics processing, and other scenarios.

[0014] Further, in step 22, the method of combining background color data by left shift includes: converting the background color data into an unsigned integer with an extended bit width to obtain extended background color data; controlling the extended background color data to shift left by the preset bit width to obtain left-shifted background color data; then controlling the extended background color data and the left-shifted background color data to perform a bitwise OR operation to obtain the overall background color combination result; the method of using a mask to retain all color components of the overall background color combination result includes: controlling the overall background color combination result and the mask to perform a bitwise AND operation to obtain the background color processing result; wherein, the number of bits in the overall background color combination result is equal to the number of extended bits, and the number of bits in the background color processing result is equal to the number of extended bits.

[0015] This application obtains the overall background color combination result by performing a bitwise OR operation on the extended background color data and the left-shifted background color data. This allows the overall foreground color combination result to store intermediate results using an extended bit depth, avoiding floating-point operations while ensuring calculation accuracy. Then, when the overall background color combination result and the mask are bitwise ANDed, the mask expands the binary range of extracted color components from the preset bit depth to the extended bit depth. Furthermore, the pre-calculated overall background color combination result has already been left-shifted to allocate different color components to the data with the highest and lowest preset bit depths. Simultaneously, the mask masks bits other than the desired color components in the overall background color combination result, retaining only the bits occupied by color components conforming to a specific color encoding format. This allows for the extraction of all color components from the overall background color combination result that conform to the preset bit depth color encoding format.

[0016] Further, in step 23, the method of amplifying the difference between the foreground color processing result and the background color processing result using the target transparency after calculating the difference includes: controlling the difference to be multiplied by the target transparency to obtain a color difference value; the method of scaling the color difference value by right shifting includes: controlling the color difference value to be shifted right by a second right shift number to obtain a scaled result of the color difference value, wherein the sum of the first right shift number and the second right shift number is equal to the number of binary bits occupied by the transparency; the method of using a mask to retain all color components of the sum after calculating the sum of the scaled result of the color difference value and the background color processing result includes: controlling the sum to be bitwise ANDed with the mask to obtain a mixed processing result; wherein the number of bits in the mixed processing result is equal to the number of bits in the extended bits, and the number of bits in the sum is equal to the number of bits in the extended bits. This allows for the simultaneous calculation of multiple color components by combining foreground color data, background color data, and transparency within the integer of the extended bit length, eliminating the need for three separate calculations. The mixed calculation is accomplished through multiplication, shifting, and addition operations between the integers of the extended bit length, avoiding division operations and floating-point calculations.

[0017] Furthermore, whenever a bitwise AND operation is performed between the color data and the mask for a given number of extended bits, the mask sequentially retains various color components within the color data for that extended number of bits according to the preset bit-number color encoding format. Simultaneously, the mask masks all binary bits in the color data for that extended number of bits except for the desired color components, setting the masked binary bits to binary 0. The positions occupied by each color component in the color data for that extended number of bits are unique. The color data for that extended number of bits is the overall combination result of the foreground color described in step 22, the overall combination result of the background color described in step 22, or the sum value described in step 23. This process utilizes the mask to iterate bit-by-bit through the color data for that extended number of bits to select the bits to retain, forming color data conforming to the preset bit-number color encoding format, while masking all binary bits except for the desired color components.

[0018] Furthermore, the bit order in which the mask retains bits in the highest preset bit-length data of the extended bit-length color data is equal to the bit order in which the mask masks bits in the lowest preset bit-length data of the extended bit-length color data; conversely, the bit order in which the mask retains bits in the lowest preset bit-length data of the extended bit-length color data is equal to the bit order in which the mask masks bits in the highest preset bit-length data of the extended bit-length color data. This allows for the extraction of all color components from color data of an extended bit-length color data that conforms to a preset bit-length color encoding format.

[0019] Further, in step 24, the method for merging the mixing result by right shift includes: controlling the mixing result to shift right by the preset number of bits to obtain a right-shifted mixing result; controlling the right-shifted mixing result to perform a bitwise OR operation with the mixing result to obtain a merged result; and converting the merged result into an unsigned integer of the preset number of bits to obtain the mixed color value. This realizes the restoration of color data with one extended bit length to color encoding format data conforming to the preset bit length, which can be directly written to video memory and displayed on the screen of the monitor by calling a pre-set display function.

[0020] Furthermore, when the transparency described in step 21 increases, the blended color value calculated in step 24 increases, the blending ratio between the foreground color data and the background color data increases, thereby increasing the brightness of the foreground color displayed on the screen of the display; when the transparency described in step 21 decreases, the blended color value calculated in step 24 decreases, the blending ratio between the foreground color data and the background color data decreases, thereby increasing the brightness of the background color displayed on the screen of the display. Attached Figure Description

[0021] Figure 1 This is a schematic diagram of a color mixing processing method for display disclosed in one embodiment of this application.

[0022] Figure 2 This is a schematic flowchart of a color mixing calculation method disclosed in another embodiment of this application. Detailed Implementation

[0023] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0024] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.

[0025] Foreground color: This typically refers to the color of the main content in the image, such as text, icons, and lines. It's the object that users directly interact with on the screen, therefore requiring high visibility and recognizability. The choice of foreground color directly impacts user experience and interface usability. Background color: This refers to the color of the area behind the content. It provides a platform for foreground elements. Background colors are generally softer, designed not to distract users from key information (such as text or graphics). A suitable background color enhances the harmony of the overall design and highlights important foreground elements.

[0026] The conversion process between RGB565 format color data and RGB888 format color data (a 24-bit color encoding format, in which the numbers "8-8-8" in its name correspond to the bit allocation of the red, green, and blue color channels, respectively) disclosed in the prior art is as follows: I. Conversion from RGB565 color data to RGB888 color data involves: RGB565 color data uses 16 bits to store color data, distributed as: R (5 bits)|G (6 bits)|B (5 bits); when converting to RGB888 color data, the number of bits for each component needs to be extended to match 8-bit precision.

[0027] Specifically, it is necessary to first separate the red component (denoted as R15 component), green component (denoted as G16 component), and blue component (B15 component) from the foreground color data in RGB565 format.

[0028] The red component is converted from 5 bits to 8 bits: R18 = (R15 << 3) | (R15 >> 2). For example, the 5-bit R15 = 31 (2^5 - 1) is converted to the 8-bit red component R18 = 255 (2^8 - 1).

[0029] The green component is converted from 6 bits to 8 bits: G18 = (G16<<2)|(G16>>4). For example, 6-bit G16=0 is converted to 8-bit green component G18=0.

[0030] The blue component is converted from 5 bits to 8 bits: B18 = (B15 << 3) | (B15 >> 2). For example, 5 bits B15 = 0 is converted to 8 bits of blue component B18 = 0.

[0031] Furthermore, the red component (denoted as R25 component), green component (denoted as G26 component), and blue component (B25 component) are separated from the background color data in RGB565 format.

[0032] The red component is converted from 5 bits to 8 bits: R28 = (R25 << 3) | (R25 >> 2). For example, the 5-bit R25 = 31 (2^5 - 1) is converted to the 8-bit red component R28 = 255 (2^8 - 1).

[0033] The green component is converted from 6 bits to 8 bits: G28 = (G26 << 2) | (G26 >> 4). For example, the 6-bit G26 = 63 is converted to the 8-bit green component G28 = 255.

[0034] The blue component is converted from 5 bits to 8 bits: B28 = (B25 << 3) | (B25 >> 2). For example, the 5-bit B25 = 31 (2^5 - 1) is converted to the 8-bit blue component B28 = 255 (2^8 - 1).

[0035] This maximizes the use of available bits, making the converted 8-bit value as close as possible to a linear extension of the original 5 / 6-bit value.

[0036] II. Transparency overlay and blending calculations result in: Transparency alpha=127; The red component blending value R_out = (R18*alpha + R28*(255-alpha)) / 255 = 255; Green component blending value G_out=(G18*alpha+G28*(255-alpha)) / 255=128; Blue component blending value B_out=(B18*alpha+B28*(255-alpha)) / 255=128; The calculated blending result is RGB888 (255, 128, 128). Some images displayed on a computer screen can show transparency, but this cannot be displayed on a monitor driven by a microcontroller.

[0037] III. Conversion from RG888 color data to RGB565 color data involves: The red component blending value R_out is converted from 8 bits to 5 bits: R5=R_out>>3. For example, the 8-bit R_out=255 is converted to R5=31 (255>>3=31).

[0038] The green component blending value G_out is converted from 8 bits to 6 bits: G6=G_out>>2. For example, 8-bit G_out=128 is converted to G6=32 (128>>2=32).

[0039] The blue component blending value B_out is converted from 8 bits to 5 bits: B5=B_out>>3. For example, the 8-bit B_out=128 is converted to B5=16 (128>>3=16).

[0040] Therefore, the mixed RGB888 format color data is compressed back into RGB565 format color data to adapt to the limitations of display devices.

[0041] After decomposing each color data into different color components, two format conversions are performed for each color component: RGB565→RGB888→RGB565, increasing the conversion overhead. Furthermore, as seen in the aforementioned transparency overlay calculation, it is essentially a weighted mixture calculation of the same color component in the foreground and background color data. Calculating the weight of each color component requires dividing by 255, which introduces a slight error. If division is performed, floating-point operations are used. On MCUs without dedicated floating-point units, this overlay calculation method may take more than 50ms of computation time (the time depends on the number of pixels being calculated and the screen size). Additionally, since the red, green, and blue components are calculated separately, data processing time is increased.

[0042] To address the aforementioned technical problems, this application discloses a color mixing processing method for display. This method is applicable to resource-constrained microcontroller units (MCUs) used to drive and control displays. It is particularly useful in resource-constrained scenarios such as embedded display drivers and low-power MCUs for performing mixing calculations of data with a certain color encoding format. It also supports mixing and calculating new color data by superimposing transparency on foreground and background color data. At least, it does not control the entire display screen through the backlight pins of the display, but instead calculates new colors through color mixing. Furthermore, it avoids performing floating-point operations on the channels of various color components by shifting the data with a certain color encoding format.

[0043] like Figure 1 As shown, the color mixing processing method includes: Step 1: Configure the foreground color data, background color data, and transparency for the monitor's screen. This can also be understood as configuring the foreground color data, background color data, and transparency for the monitor's display surface (screen display area). For the same foreground color data and the same background color data, the transparency is adjustable to change the difference between the foreground and background color data. For example, adjusting the transparency to amplify or reduce the difference between the foreground and background color data is equivalent to changing the color ratio between the foreground and background color data. Then proceed to Step 2.

[0044] In practice, to calculate the mixed color of foreground and background color data under the superposition of transparency (the result of the mixed color calculation), this application sets a color mixing function. The foreground color data, background color data, and transparency of the display screen can be used as three parameters input to the color mixing function. Among them, transparency supports real-time adjustment. Schematic, the foreground color data is configured as 0xF800 (representing red), the background color data is configured as 0xFFFF (white), and the current transparency is adjusted to 127. After the mixed color of foreground and background color data is calculated and displayed under the superposition of transparency, the main color displayed is still red, but white is mixed into the red, which reduces the brightness of the red. As the transparency is gradually decreased, the proportion of white displayed will gradually increase until it is completely displayed as white. Since the color data of the RGB565 color encoding format cannot be decomposed into a transparent color channel (no transparency bits are allocated), the color proportion defined by the real-time adjustable transparency is used to indirectly control the change of the mixed color. By adjusting the transparency in real time, the brightness of some pixels on the display screen can be controlled to achieve localized brightening or dimming effects, while avoiding residual display problems caused by global backlight adjustment.

[0045] It should be noted that transparency is often used to represent the degree of opacity of a color or object. When transparency is expressed as an integer range, it is generally between 0 and 255. The blend color is calculated by superimposing the foreground color data and the background color data with transparency. If the transparency is 0, the blend color is the background color; if the transparency is 255, the blend color is the foreground color; if the transparency is between 0 and 255, the blend color is the color generated by mixing the foreground color and the background color according to their transparency.

[0046] Step 2: Through a shift operation, the foreground and background color data are mixed and calculated under the superposition of transparency to obtain a mixed color value. This mixed color value is then displayed on the monitor screen without color encoding format conversion, and the color changes with the transparency. Specifically, Step 2 does not perform color encoding format conversion based on various color components, nor does it decompose various color components from the foreground and background color data. Instead, it directly performs a shift and magnification operation on the foreground and background color data involved in the mixing calculation. At least by replacing floating-point operations with shift operations, the impact of calculation precision caused by the decimal part is overcome, and the calculated mixed color value does not lose too much precision, including truncation errors caused by division operations or conversion between color encoding formats with different bit widths.

[0047] This application controls the color mixing calculation of foreground and background color data under the superposition of transparency. Essentially, it performs a mixing calculation by superimposing transparency on the foreground color data after a shift and magnification operation and the background color data after a shift and magnification operation, without introducing division calculations. The mixing calculation in step 2 is implemented through a predefined color mixing function. This function takes foreground color data, background color data, and transparency as input and returns the mixed color value. Transparency is used in bitwise logical operations with the color data in integer form. When transparency is adjusted, for example, by increasing transparency frame by frame (from 0 to 255), the color mixing function is called in real time to update the mixed color value. This is equivalent to adjusting the difference between the foreground and background color data in real time, and also equivalent to adjusting the mixing ratio between the foreground and background colors in real time, updating the final color displayed on the screen, and changing the brightness of local pixel areas. This allows the color corresponding to the mixed color value to be directly displayed on the screen without color encoding format conversion, and enables the adjustment of individual pixel brightness.

[0048] It should be added that displaying the color corresponding to the mixed color value on the monitor screen can be driven onto the monitor screen through a predefined display function, which is equivalent to the mixing and superposition of different colors. Each color displayed on the monitor screen corresponds to a mixed color value, and there is a mapping relationship between the two. When a mixed color value is written into the monitor system, it can excite the R, G, and B phosphors on the screen to emit light of different brightness, and these colors are then mixed to produce various colors.

[0049] Within the RGB565 color space, by executing steps 1 and 2, the foreground and background color data are directly mixed and calculated under the overlay of transparency. Then, the aforementioned display function is directly called to write the calculated mixed color value into the display's screen memory without format conversion. The mixed color value is updated in real time by adjusting the transparency, thereby updating the local area of ​​the screen to achieve a gradual brightening or darkening effect. This is suitable for adjusting the brightness of individual pixels on low-cost MCU-driven displays, avoiding the need for global screen backlight adjustment.

[0050] In summary, by executing steps 1 and 2, when the foreground color data, background color data, and transparency are configured, a shift operation is used to directly perform color mixing calculations on the foreground and background color data under transparency overlay. This eliminates the need for color encoding format conversion of the foreground and background color data. The calculated mixed color value can then be written to the display to generate the corresponding color. Furthermore, when the transparency is adjusted, the mixed color value is calculated and updated in real time, updating local areas of the display screen to achieve a gradual brightening or darkening effect without relying on backlight control for the entire screen. Therefore, when a local area of ​​the display screen needs to change gradually, a new mixed color value can be directly calculated using the currently configured foreground and background color data, facilitating the handling of display control issues after color mixing.

[0051] Furthermore, the color mixing calculation of foreground and background color data under transparency overlay by executing step 2 is implemented based on shift operations. Therefore, the pixels used to display colors on the screen can be directly subjected to color mixing calculations through shift operations under different transparency overlays. It is not necessary to decompose the foreground and background color data into various color components for weighted mixing calculations, nor is it necessary to control the conversion between different color encoding formats of the foreground and background color data. This avoids the introduction of floating-point operations due to the participation of multiple color channels in color mixing calculations. Thus, the entire process avoids the data operation with high overhead, saves calculation speed, and makes the color mixing processing method suitable for driving the screen display color on MCUs with limited resources and low clock speeds.

[0052] Specifically, in step 2, when controlling the foreground and background color data to perform color mixing calculations under the overlay of transparency, the foreground and background color data are not decomposed into various color components. Instead, the color mixing calculation is performed by subtracting, adding, and multiplying the color data as a whole according to a preset bit-level color encoding format. Furthermore, shift operations are used instead of division operations for color components, and no color encoding format conversion occurs. Preferably, a shift-amplification operation is performed on the background and foreground color data to avoid floating-point operations. By executing step 2, the final mixed color value used to drive the display screen is calculated without decomposing various color components or performing color encoding format conversion, thus improving the calculation speed compared to traditional methods.

[0053] The foreground color data, background color data, and blend color value are all color-coded data in a preset bit depth format. Both the foreground and background color data are calculated using binary numbers with a preset bit depth for color blending. The blend color value is the result of blending the foreground and background color data based on transparency; that is, the blend color is calculated based on pre-configured foreground and background colors and their transparency. The preset bit depth binary number represents an unsigned integer with a preset bit depth to avoid floating-point calculations when blending the foreground and background color data with transparency.

[0054] The color encoding format data with a preset bit depth is composed of multiple color components, and the sum of the bit depths of the multiple color components is equal to the preset bit depth. In the RGB565 color space, the preset bit depth is equal to 16 bits. The RGB565 format is a 16-bit color encoding format that uses 16 bits to store colors, distributed as: R (5 bits)|G (6 bits)|B (5 bits). That is, the color data in the RGB565 format is a combination of three color components: red, green, and blue.

[0055] This application uses integers to represent transparency, reducing floating-point calculations. Since no transparent color channel is allocated within the RGB565 color space, transparency needs to be configured beforehand. Adjusting transparency is equivalent to controlling the overlap between the foreground and background colors by adjusting the color proportions. Based on the light transmittance in the physical world, transparency is used to represent the color transparency produced by the overlap of the foreground and background colors.

[0056] When transparency is defined as an integer, its parameter range can be adjusted between 0 and 255, where 0 represents complete transparency and 255 represents complete opacity. Illustratively, with transparency = 0, foreground color data is 0xF800 (representing red), background color data is 0xFFFF (representing white), and the blend color value calculated after step 2 is 0xFFFF (ultimately displayed as white on the monitor screen); with transparency = 127, foreground color data is 0xF800 (representing red), background color data is 0xFFFF (representing white), and the blend color value calculated after step 2 is 0xFBEF (representing pink, also representing the result of an equal proportion of red and white, where a moderate amount of white is mixed into the red, reducing its brightness); as transparency gradually increases, the proportion of red gradually increases until it becomes completely red; with transparency = 255, foreground color data is 0xF800 (representing red), background color data is 0xFFFF (representing white), and the blend color value calculated after step 2 is 0xF800 (ultimately displayed as red on the monitor screen). Therefore, the final displayed color is directly output to the monitor screen through a color encoding format with a preset bit width (RGB565 format), without the need to convert it to other bit width color encoding formats (e.g., RGB888 format).

[0057] As one embodiment, in step 2, a method for calculating color blending of foreground and background color data under the superposition of transparency is used through a shift operation, such as... Figure 2 As shown, it includes: Step 21: Scale the transparency by right shifting to obtain the target transparency; then proceed to step 22. Since transparency is an integer, it can be converted to an unsigned integer with a preset extension number of bits before scaling. The scaling process in step 21 involves right-shifting the binary bits controlling transparency, discarding the low bits (including the least significant bit), and right-shifting the relatively high bits of transparency to the relatively low bits to obtain the target transparency.

[0058] Step 22: Combine the foreground color data by left shifting to obtain the overall foreground color combination result; then use a mask to retain all color components of the overall foreground color combination result to obtain the foreground color processing result; and combine the background color data by left shifting to obtain the overall background color combination result; then use a mask to retain all color components of the overall background color combination result to obtain the background color processing result; then execute step 23.

[0059] In step 22, the combination of foreground and background color data can be achieved by left-shifting to expand the original bit range. This shifts the original color data to relatively higher bits, reserving relatively lower bits to combine with the original color data into new color data. This yields the overall foreground and background color combination results, preserving computational precision. Then, a mask is used to preserve all color components in the overall combination results. This involves locating and extracting all color components within the bit width occupied by the overall combination results, while masking and clearing other bits. This is equivalent to extracting various color components from the overall foreground and background color combination results separately, without needing to perform color encoding format conversion beforehand.

[0060] It should be noted that the number of bits in the mask is equal to the number of bits in the extended bit range; the mask is used to allocate binary bits for locating various color components in the binary bits of the extended bit range according to the color encoding format data of the preset number of bits; the number of bits in the extended bit range is equal to twice the number of bits in the preset bit range.

[0061] Step 23: Calculate the difference between the foreground color processing result and the background color processing result, and then use the target transparency to amplify the difference to obtain the color difference value; then scale the color difference value by right shifting to obtain the scaled result of the color difference value; then calculate the sum of the scaled result of the color difference value and the background color processing result, and then use a mask to extract all color components from the sum to obtain the blending result; then execute step 24.

[0062] The difference between the foreground color processing result and the background color processing result calculated in step 23 is used to represent the color value difference between the channels of each color component. This color value difference can be amplified by the target transparency to obtain the color difference value, thereby controlling the mixing ratio between the foreground color data and the background color data.

[0063] Step 23 scales the color difference value by right shifting. Essentially, it controls the right shift of the color difference value based on the number of bits shifted to the right of the transparency, discarding the low bits (including the lowest bit) of the color difference value, and shifting the relatively high bits of the color difference value to their relatively low bits to obtain the scaling result. At this time, the mixing calculation between the foreground color data and the background color data is realized under the superposition of transparency.

[0064] When the scaling result of the color difference value is added to the background color processing result, it is considered to complete a linear interpolation process. Then, a mask is used to extract various color components from the sum of the scaling result of the color difference value and the background color processing result, but the bits that do not store color are cleared. Without performing color encoding format conversion in advance, the mixed processing result can be obtained.

[0065] Step 24: The mixing result is merged by right shifting to obtain the mixed color value, thus generating color encoding format data conforming to the preset bit count. Since left shifting and multiplication operations are performed on the color data in steps 22 and 23, the right shift in step 24 reduces the size of the mixing result, converting it into an unsigned integer of the preset bit count. After the right shift, a bitwise OR operation is performed with the original mixing result to combine the low and high bits of the original result, preserving computational precision. Finally, the result of the bitwise OR operation is converted to an unsigned type of the preset bit count, retaining only the lowest preset bit count, generating color encoding format data conforming to the preset bit count through bit-level shifting and merging operations. This process extracts and combines specific bit patterns from the mixing result to drive the display to generate color information conforming to the preset bit count color encoding format.

[0066] By executing steps 21 to 24, the extraction and recombination of foreground and background color data are optimized using shift operations and masks. First, the bits occupied by each color component can be located and identified in one operation without having to perform the calculation three times. Second, the division operation is avoided by shifting, saving time and further reducing the consumption of computing resources.

[0067] In step 21, the method of scaling the transparency by right shift includes: converting the transparency into an unsigned integer with an extended number of bits to obtain extended transparency; then controlling the extended transparency to add a preset compensation value to obtain corrected transparency, so as to prevent the corrected transparency from becoming a value of 0 after right shift; then controlling the corrected transparency to shift right by a first right shift number to obtain the target transparency, thereby completing the scaling process of transparency and preventing the target transparency from becoming a value of 0; wherein, the first right shift number is less than the number of binary bits occupied by the transparency, and the number of binary bits occupied by the transparency is equal to half of the preset number of bits. Preferably, the preset compensation value is set to 3, 4, or 5.

[0068] In step 21, to facilitate the superposition of the foreground and background color data within the extended bit range for mixed calculations, the transparency is first expanded from half the preset bit range to an unsigned integer of the extended bit range, resulting in extended transparency. If the range of the extended transparency needs to be narrowed down to a specific bit range, it needs to be shifted to the right. For example, the transparency is an 8-bit unsigned integer, corresponding to a decimal number in the range of 0 to 255. After expanding to a 32-bit unsigned integer in step 21, if the required effective integer range for calculation is 0 to 31, the 32-bit unsigned integer is shifted 3 bits to the right, and the highest 5 bits of the transparency are shifted to the lowest 5 bits of the 32-bit unsigned integer. This ensures alignment for subsequent multiplication calculations, maintains stable calculated values, and avoids performance issues caused by direct division. However, when the expanded transparency is so small that it can be reduced to 0 by simply shifting it one bit to the right, it is necessary to control the expanded transparency by adding a preset compensation value to obtain the corrected transparency. Then, the corrected transparency is shifted to the right by the first right shift number to prevent the loss of too much information during the right shift (because the right shift is a floor function).

[0069] As an embodiment of foreground color data processing, in step 22, the following exists: The method for combining foreground color data by left shift includes: converting the foreground color data into an unsigned integer with an extended number of bits to obtain foreground color extended data; then controlling the foreground color extended data to shift left by the preset number of bits to obtain left-shifted foreground color data; then controlling the foreground color extended data and the left-shifted foreground color data to perform a bitwise OR operation to obtain the overall combination result of the foreground colors, so as to realize the recombination of data on the two preset number of bits in the foreground color extended data.

[0070] Step 22 converts the foreground color data into extended foreground color data, then shifts the extended foreground color data left by the preset number of bits. For example, the corresponding color component within the foreground color data can be shifted to a higher 6 bits, while the original higher 6 bits are discarded. Then, by performing a bitwise OR operation with the extended foreground color data, it is expanded into a higher-width integer, yielding the overall foreground color combination result. This preserves the precision of intermediate calculation results; that is, the overall foreground color combination result uses the extended number of bits to store intermediate results, avoiding floating-point operations.

[0071] Performing a bitwise OR operation on the foreground color extended data and the left-shifted foreground color data is equivalent to combining the two within the bit range of the extended bit number to form the overall foreground color combination result. For example, if the foreground color data is a color data in RGB565 format, the aforementioned bitwise OR operation may generate a color data containing two copies of RGB565 format, one combined in the lower 16 bits and the other combined in the higher 16 bits.

[0072] Therefore, step 22 uses a left shift operation instead of multiplication, and the bitwise OR operation between the extended foreground data and the left-shifted foreground data in step 22 is a bit logic operation performed within the binary bit range of the extended bit number. Compared with the prior art, it will not cause significant errors due to truncation, resulting in insufficient precision.

[0073] Based on this, the method for retaining all color components of the overall foreground color combination result using a mask includes: controlling the overall foreground color combination result and the mask to perform a bitwise AND operation to obtain the foreground color processing result; wherein, the number of bits in the overall foreground color combination result is equal to the number of extended bits, and the number of bits in the foreground color processing result is equal to the number of extended bits. It is understood that the mask is a fixed mask capable of switching the overall foreground color combination result to the number of extended bits, and its binary form can reveal which bits in the overall foreground color combination result are retained within the bit range of the extended bits. This ensures that the data with the highest preset bit length in the overall foreground color combination result retains at least one color component, and the data with the lowest preset bit length in the overall foreground color combination result retains other color components, avoiding floating-point operations and significantly improving operating efficiency on low-performance MCUs.

[0074] When performing a bitwise AND operation between the overall foreground color combination result and the mask, the mask expands the binary range of the extracted color components from the preset number of bits to the extended number of bits. Furthermore, the pre-calculated overall foreground color combination result has already been left-shifted to allocate different color components to the data with the highest and lowest preset number of bits. Simultaneously, the mask masks out all binary bits in the overall foreground color combination result except for the color components that need to be retained, only retaining the bits occupied by the color components that conform to a specific color encoding format. This allows for the extraction of all color components from the overall foreground color combination result that conform to the preset number of bits color encoding format, making it suitable for embedded display drivers, graphics processing, and other scenarios.

[0075] As one embodiment of background color data processing, in step 22, the following exists: The method for combining background color data by left shift includes: converting the background color data into an unsigned integer with an extended bit width to obtain extended background color data; then controlling the extended background color data to shift left by the preset bit width to obtain the left-shifted background color data; then controlling the extended background color data and the left-shifted background color data to perform a bitwise OR operation to obtain the overall combination result of the background colors, so as to realize the recombination of data at two preset bit widths in the extended background color data. After converting the background color data into extended background color data in step 22, the extended background color data is shifted left by the preset bit width. For example, the corresponding color component in the background color data can be shifted to a higher 6 bits, while the original higher 6 bits are discarded. Then, by performing a bitwise OR operation with the extended background color data, it is expanded into an integer with a higher bit width to obtain the overall combination result of the background colors, and the extended background color data is retained as an intermediate result of the calculation. That is, the overall combination result of the foreground colors uses an extended bit width to store the intermediate result, avoiding floating-point operations and ensuring calculation accuracy.

[0076] Performing a bitwise OR operation on the extended background color data and the left-shifted background color data is equivalent to combining the two within the bit range of the extended bit range to form a complete background color combination. For example, if the background color data is an RGB565 format color data, the aforementioned bitwise OR operation may generate a background color data containing two RGB565 format copies, one combined in the lower 16 bits and the other combined in the higher 16 bits. Therefore, step 22 uses a left shift operation instead of multiplication, and step 22 controls the bitwise OR operation on the extended background color data and the left-shifted background color data to be performed within the binary bit range of the extended bit range, thus avoiding significant errors caused by truncation and resulting in insufficient precision compared to existing technologies.

[0077] Based on this, the method for retaining all color components of the overall background color combination result using a mask includes: controlling the overall background color combination result and the mask to perform a bitwise AND operation to obtain the background color processing result; wherein, the number of bits in the overall background color combination result is equal to the number of extended bits, and the number of bits in the background color processing result is equal to the number of extended bits. It is understood that the mask is a fixed mask capable of switching the overall background color combination result to the number of extended bits, and its binary form can reveal which bits of the overall background color combination result are retained within the bit range of the extended bits. This ensures that the data with the highest preset bit length in the overall background color combination result retains at least one color component, and the data with the lowest preset bit length in the overall background color combination result retains other color components, avoiding floating-point operations and significantly improving operating efficiency on low-performance MCUs.

[0078] When performing a bitwise AND operation between the overall background color combination result and the mask, the mask expands the binary range of the extracted color components from the preset number of bits to the extended number of bits. The pre-calculated overall background color combination result has already been left-shifted to allocate different color components to the data with the highest preset number of bits and the data with the lowest preset number of bits. At the same time, the mask masks out the binary bits in the overall background color combination result except for the color components that need to be retained, and only retains the bits occupied by the color components that conform to the specific color encoding format. This allows the extraction of all color components in the color encoding format data that conforms to the preset number of bits from the overall background color combination result.

[0079] Based on the foregoing embodiments, in step 23, the following exists: After calculating the difference between the foreground color processing result and the background color processing result, the method of amplifying this difference using target transparency includes: controlling the difference to be multiplied by the target transparency to obtain a color difference value. The target transparency is used to adjust the difference between the foreground color data and the background color data; that is, the multiplication operation adjusts the difference between the foreground color processing result and the background color processing result according to the target transparency to influence the mixed color value. The difference between the foreground color processing result and the background color processing result is typically used to determine the amount of color change. Since the target transparency is obtained by converting transparency (e.g., an unsigned 8-bit integer) and adding a preset compensation value, as well as performing a right shift operation, although the target transparency is scaled by a right shift, it is still an unsigned integer that is not zero. Therefore, controlling the multiplication of the difference with the target transparency effectively amplifies the difference between the foreground color data and the background color data using the target transparency to obtain the color difference value. This color difference value can represent the color value difference between the channels of each color component. Therefore, by dynamically adjusting the transparency, the difference between the foreground color data and the background color data can be controlled, thereby changing the subsequently calculated mixed color value.

[0080] The method for scaling the color difference value by shifting includes: controlling the color difference value to shift right by a second right shift number to obtain the scaling result of the color difference value, wherein the sum of the first right shift number and the second right shift number is equal to the number of binary bits occupied by the transparency.

[0081] Step 21 has already controlled the corrected transparency to shift right by a first right shift number to obtain the target transparency, thus completing the first scaling process of transparency and preventing the target transparency from becoming a value of 0. At this time, in step 23, the scaling result of the color difference value is obtained by controlling the color difference value to shift right by a second right shift number, which is equivalent to performing a second scaling process on the transparency. In order to restore the bit width of the color difference value to be equal to the bit width of the background color processing result, the number of right shifts of the color difference value is controlled to be equal to the difference between the number of binary bits occupied by the transparency and the first right shift number. Then, within the same bit width range, the scaling result of the color difference value is added to the background color processing result to obtain the sum of the scaling result of the color difference value and the background color processing result. The process of adding the scaling result of the color difference value to the background color processing result is actually the process of controlling the blending of the foreground color and the background color.

[0082] After calculating the sum of the scaling result of the color difference value and the background color processing result, the method of using a mask to retain all color components of the sum includes: controlling the sum to perform a bitwise AND operation with the mask to obtain a mixed processing result; wherein the number of bits in the mixed processing result is equal to the number of bits in the extended bit range, and the number of bits in the sum is equal to the number of bits in the extended bit range.

[0083] When performing a bitwise AND operation between the sum and the mask, the mask retains at least one color component in the highest preset bit position of the sum, and retains other color components in the lowest preset bit position of the sum. Simultaneously, the mask masks all binary bits in the sum except for the desired color components, thus extracting all color components from the extended bit position of the sum that conform to the color encoding format data of the preset bit position. Finally, the result of the bitwise AND operation is the binary number of the extended bit position. This allows for the simultaneous calculation of multiple color components by combining foreground color data, background color data, and transparency within the integer of the extended bit position, eliminating the need for three separate calculations. The mixed calculation is completed through multiplication, shifting, and addition operations between the integers of the extended bit position, avoiding division operations and floating-point calculations.

[0084] In the embodiments related to steps 22 and 23 above, whenever a bitwise AND operation is performed between the color data and the mask with a certain number of extended bits, the mask sequentially retains various color components in the color data with a certain number of extended bits according to the preset bit-number color encoding format. This is equivalent to sequentially extracting each color component that conforms to the preset bit-number color encoding format. Each color component may occupy the same number of bits, but their positions may differ. Simultaneously, the mask masks out bits other than the desired color components in the color data with a certain number of extended bits. These masked bits become the binary bits separating two adjacent color components. In the binary form of the mask, the bits that need to be retained in the color data with a certain number of extended bits according to the preset bit-number color encoding format are aligned to binary 1s in the mask, and the masked bits are aligned to binary 0s in the color data with a certain number of extended bits. This achieves the extraction of all color components conforming to the preset bit-number color encoding format from a single color data with a certain number of extended bits.

[0085] It should be noted that the color data with an extended bit depth is the overall combination result of the foreground color described in step 22, the overall combination result of the background color described in step 22, or the sum value described in step 23.

[0086] Preferably, in order to extract all color components in color encoding format data conforming to a preset bit length from a color data of an extended bit length, the mask retains at least one color component in the highest preset bit length data of the color data of an extended bit length, and retains other color components in the lowest preset bit length data of the color data of an extended bit length. This fully utilizes the high and low preset bit length data in the overall combination result of the foreground color obtained by left shifting in step 22, as well as the high and low preset bit length data in the overall combination result of the background color obtained by left shifting in step 22, for mixed calculation, reducing bit truncation error. Since the shift amplification operation in step 22, floating-point operations are directly avoided.

[0087] Preferably, in order to extract all color components in color encoding format data conforming to a preset bit-number of color data from an extended bit-number of color data, the bit order in which the mask retains the highest preset bit-number of data in the extended bit-number of color data is equal to the bit order in which the mask masks the lowest preset bit-number of data in the extended bit-number of color data; the bit order in which the mask retains the lowest preset bit-number of data in the extended bit-number of color data is equal to the bit order in which the mask masks the highest preset bit-number of data in the extended bit-number of color data; and the bit length of the result of the bitwise AND operation between the extended bit-number of color data and the mask is equal to the extended bit-number of data.

[0088] Schematic, the preset bit depth is 16 bits, and the color encoding format data of the preset bit depth is RGB565 format color data. RGB565 format color data is composed of a 5-bit red component, a 6-bit green component, and a 5-bit blue component sequentially. The binary form of the mask is equal to 2'b00000111111000001111100000011111, making the mask used to sequentially identify 6 bits from the overall combination result of the foreground color, the overall combination result of the background color, or the sum value according to the RGB565 format. Specifically, the green component of 5 bits, the red component of 5 bits, and the blue component of 5 bits are considered as color data with an extended bit length, i.e., 32-bit color data. When the 32-bit color data and the mask 2'b00000111111000001111100000011111, the highest 16 bits and the lowest 16 bits of data are distinguished from the mask 2'b00000111111000001111100000011111.

[0089] The data in the mask, obtained by bitwise AND operation with the highest preset bit length of the color data of the one-extended bit length, has a binary form of 0000011111100000. Each bit is aligned with the highest preset bit length of the color data of the one-extended bit length. In the highest preset bit length of the color data of the one-extended bit length, bits aligned with binary 1s of the mask are retained (i.e., one bit of the extracted color component), while bits aligned with binary 0s of the mask are masked (i.e., considered invalid bits and cleared). Here, alignment means that the order of aligned bits in the mask within the bit width of the highest preset bit length of the color data of the one-extended bit length is equal to the order of aligned bits in the color data of the one-extended bit length. Therefore, the mask extracts a 6-bit green component from the 6th to 11th bits of the highest 16 bits of the color data of the one-bit extended color data according to the RGB565 format, which is counted and sorted from right to left starting from the value 1; at the same time, the mask masks the 12th to 16th bits of the highest 16 bits of the color data of the one-bit extended color data as invalid bits, and also masks the 1st to 5th bits of the highest 16 bits of the color data of the one-bit extended color data as invalid bits.

[0090] The data obtained by bitwise AND operation between the mask and the lowest preset bit length of the color data of the one-extended bit length, in binary form 111100000011111, is aligned bit by bit with the lowest preset bit length of the color data of the one-extended bit length. In the lowest preset bit length of the color data of the one-extended bit length, bits aligned with binary 1s of the mask are retained (i.e., one bit of the extracted color component), while bits aligned with binary 0s of the mask are masked (i.e., considered invalid bits and cleared to zero). Here, alignment means that the order of aligned bits in the mask within the bit width range of the lowest preset bit length of the color data of the one-extended bit length is equal to the order of aligned bits in the color data of the one-extended bit length. Therefore, the mask extracts 5 bits of blue component from the 1st to 5th bits of the lowest 16 bits of the color data of the one-extended bit-number color data according to the RGB565 format, and extracts 5 bits of blue component from the 12th to 16th bits of the lowest 16 bits of the color data of the one-extended bit-number color data. At this time, the counting and sorting are from right to left and start from the value 1; at the same time, the mask masks the 6th to 11th bits of the lowest 16 bits of the color data of the one-extended bit-number color data as invalid bits.

[0091] In summary, the mask, in RGB565 format, extracts the 6th to 11th bits (6-bit green component) of the highest 16 bits of the extended bit-width color data, which are then ordered in the same way as the 6th to 11th bits (data masked by the mask) of the lowest 16 bits of the extended bit-width color data. This allows for the extraction of all color components conforming to a preset bit-width color encoding format from extended bit-width color data.

[0092] The mask is configured in RGB565 format, with the bit order of the first to fifth bits (5-bit blue component) of the lowest 16 bits of the color data of the one-bit extended color data being equal to the bit order of the first to fifth bits (data masked by the mask) of the highest 16 bits of the color data of the one-bit extended color data.

[0093] The mask is configured in RGB565 format, with the bit order of the 12th to 16th bits (5-bit red component) of the lowest 16 bits of the color data of the one-bit extended color data being equal to the bit order of the 12th to 16th bits (data masked by the mask) of the highest 16 bits of the color data of the one-bit extended color data.

[0094] As one embodiment, in step 24, the method of merging the mixing result by right shifting includes: controlling the mixing result to shift right by the preset number of bits to obtain a right-shifted mixing result, which is equivalent to discarding the data with the lowest preset number of bits in the mixing result and moving the data with the highest preset number of bits to the position of the lowest preset number of bits.

[0095] Then, the right-shifted mixing result is bitwise ORed with the mixing result to obtain the merged result. The data with the highest preset bit length and the data with the lowest preset bit length of the mixing result are merged together to form the merged result, which is still a color data with an extended bit length.

[0096] The merging result is then converted into an unsigned integer with the preset number of bits to obtain the mixed color value. This means the color data, originally an extended bit-count color data, is restored to a color encoding format conforming to the preset bit-count. This data can be directly written to video memory, and the corresponding color can be displayed on the monitor screen by calling a pre-set display function. Illustratively, the merging result is converted from an unsigned 32-bit integer to an unsigned 16-bit integer, meaning only the lowest 16 bits are retained, and the rest are discarded. The retained lowest 16 bits are then used to drive the monitor to generate the mixed color on the screen according to the RGB565 format.

[0097] Based on the hybrid calculation method disclosed in the above embodiments, when the transparency in step 21 increases, the hybrid color value calculated in step 24 increases, and the mixing ratio between the foreground color data and the background color data increases, causing the color displayed on the screen to change. For example, when the transparency is increased at a time interval (from 0 to 255), step 2 is executed in real time to calculate and update the hybrid color value, which is equivalent to increasing the difference between the foreground color data and the background color data in real time, and also equivalent to increasing the mixing ratio between the foreground color and the background color in real time, updating the color finally displayed on the screen, changing the brightness of local pixel areas, increasing the brightness of the foreground color displayed on the screen, realizing the adjustment of individual pixel brightness on the screen, while the brightness of the background color displayed on the screen decreases, realizing the adjustment of individual dimming of other pixels on the screen. The color corresponding to the hybrid color value displayed on the screen (i.e., the hybrid color) also changes.

[0098] When the transparency decreases as described in step 21, the blended color value calculated in step 24 decreases, and the blending ratio between the foreground color data and the background color data decreases, causing a change in the color displayed on the monitor screen. For example, when the transparency decreases at time intervals (increasing from 255 to 0), step 2 is executed in real time to calculate and update the blended color value. This is equivalent to reducing the difference between the foreground color data and the background color data in real time, and also equivalent to reducing the blending ratio between the foreground and background colors in real time. This updates the color finally displayed on the monitor screen, changes the brightness of local pixel areas, reduces the brightness of the foreground color displayed on the monitor screen, and allows for the individual dimming of some pixels on the monitor screen. At the same time, the brightness of the background color displayed on the monitor screen increases, allowing for the individual brightening of other pixels on the monitor screen. The color corresponding to the blended color value displayed on the monitor screen (i.e., the blended color) also changes.

[0099] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them; although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications can still be made to the specific implementation of the present invention or equivalent substitutions can be made to some technical features without departing from the spirit of the technical solutions of the present invention, and all such modifications and substitutions should be covered within the scope of the technical solutions claimed in the present invention.

Claims

1. A color mixing processing method for display, characterized in that, Includes the following steps: Step 1: Configure the foreground color data, background color data, and transparency for the monitor screen; where the transparency is adjustable for the same foreground color data and the same background color data to change the difference between the foreground color data and the background color data. Step 2: Through shifting operations, control the foreground color data and background color data to perform color mixing calculations under the overlay of transparency to obtain a mixed color value. This mixed color value is then displayed on the monitor screen without color encoding format conversion, and the color corresponding to the mixed color value changes with the change of transparency.

2. The color mixing processing method according to claim 1, characterized in that, Step 2 controls the foreground and background color data to be mixed and calculated under the overlay of transparency, without decomposing the foreground and background color data into various color components. Among them, the foreground color data, background color data, and blend color value are all color-coded data of a preset bit length. The foreground color data and background color data are both calculated for color blending using binary numbers of a preset bit length, so that the blend color value is the result of blending the foreground color data and background color data according to the transparency. The binary number of the preset bit length is used to represent an unsigned integer of the preset bit length. In one of the color encoding formats with a preset number of bits, the data is composed of multiple color components, and the sum of the number of bits of the multiple color components is equal to the preset number of bits. Transparency is represented by integers.

3. The color mixing processing method according to claim 2, characterized in that, In step 2, the method for controlling the color blending calculation of foreground and background color data under the superposition of transparency through shift operations includes: Step 21: Scale the transparency by right shifting to obtain the target transparency; then proceed to step 22. Step 22: Combine the foreground color data by left shifting to obtain the overall foreground color combination result; then use a mask to retain all color components of the overall foreground color combination result to obtain the foreground color processing result; and combine the background color data by left shifting to obtain the overall background color combination result; then use a mask to retain all color components of the overall background color combination result to obtain the background color processing result; then proceed to step 23. Step 23: Calculate the difference between the foreground color processing result and the background color processing result, and then use the target transparency to amplify the difference to obtain the color difference value; then scale the color difference value by right shifting to obtain the scaled result of the color difference value; then calculate the sum of the scaled result of the color difference value and the background color processing result, and then use a mask to retain all color components of the sum to obtain the blending result; then execute step 24. Step 24: Merge the mixing results by right shifting to obtain the mixed color value, and merge the data to produce a color encoding format that conforms to the preset number of bits. Wherein, the number of bits in the mask is equal to the number of bits in the extended bit array; the mask is used to allocate binary bits for locating various color components in the binary bits of the extended bit array according to the color encoding format data of the preset number of bits; the number of bits in the extended bit array is equal to twice the number of bits in the preset bit array.

4. The color mixing processing method according to claim 3, characterized in that, In step 21, the method of scaling the transparency by right shift includes: Convert the transparency to an unsigned integer with an extended number of bits to obtain the extended transparency; By controlling the expanded transparency and adding a preset compensation value, a corrected transparency is obtained to prevent the corrected transparency from becoming a value of 0 after shifting to the right. The control adjusts the transparency by shifting it to the right by a first right shift number to obtain the target transparency, thereby completing the scaling process of the transparency; wherein, the first right shift number is less than the number of binary bits occupied by the transparency, and the number of binary bits occupied by the transparency is equal to half of the preset number of bits.

5. The color mixing processing method according to claim 4, characterized in that, In step 22, the following exists: The method for combining foreground color data by left shifting includes: converting the foreground color data into an unsigned integer with an extended number of bits to obtain extended foreground color data; controlling the extended foreground color data to shift left by the preset number of bits to obtain left-shifted foreground color data; and then controlling the extended foreground color data and the left-shifted foreground color data to perform a bitwise OR operation to obtain the overall combination result of the foreground colors. The method for preserving all color components of the overall foreground color combination result using a mask includes: controlling the overall foreground color combination result and the mask to perform a bitwise AND operation to obtain the foreground color processing result; wherein the number of bits in the overall foreground color combination result is equal to the number of bits in the extended bit range, and the number of bits in the foreground color processing result is equal to the number of bits in the extended bit range.

6. The color mixing processing method according to claim 4, characterized in that, In step 22, the following exists: The method for combining background color data by left shift includes: converting the background color data into an unsigned integer with an extended number of bits to obtain extended background color data; controlling the extended background color data to shift left by the preset number of bits to obtain the left-shifted background color data; and then controlling the extended background color data and the left-shifted background color data to perform a bitwise OR operation to obtain the overall combination result of the background colors. The method for preserving all color components of the overall background color combination result using a mask includes: controlling the overall background color combination result and the mask to perform a bitwise AND operation to obtain the background color processing result; wherein, the number of bits in the overall background color combination result is equal to the number of bits in the extended bit, and the number of bits in the background color processing result is equal to the number of bits in the extended bit.

7. The color mixing processing method according to claim 4, characterized in that, In step 23, the following exists: After calculating the difference between the foreground color processing result and the background color processing result, the method of amplifying the difference using the target transparency includes: controlling the difference to be multiplied by the target transparency to obtain the color difference value; The method for scaling the color difference value by right shifting includes: controlling the color difference value to shift right by a second right shift number to obtain the scaling result of the color difference value, wherein the sum of the first right shift number and the second right shift number is equal to the number of binary bits occupied by the transparency; After calculating the sum of the scaling result of the color difference value and the background color processing result, the method of using a mask to retain all color components of the sum includes: controlling the sum to perform a bitwise AND operation with the mask to obtain a mixed processing result; wherein the number of bits in the mixed processing result is equal to the number of bits in the extended bit range, and the number of bits in the sum is equal to the number of bits in the extended bit range.

8. The color mixing processing method according to any one of claims 5 to 7, characterized in that, Whenever a bitwise AND operation is performed between color data and a mask with an extended bit length, the mask sequentially retains various color components in the color data with an extended bit length according to the preset bit length color encoding format. At the same time, the mask masks out binary bits other than the color components to be retained in the color data with an extended bit length so that the masked binary bits are set to binary 0. In this context, the positions occupied by each color component in the color data of one extended bit depth are distinct; Among them, the color data with one extended bit depth is the overall combination result of the foreground color described in step 22, the overall combination result of the background color described in step 22, or the sum value described in step 23.

9. The color mixing processing method according to claim 8, characterized in that, The bit order in which the mask retains bits in the highest preset bit-number data of the color data of an extended bit-number range is equal to the bit order in which the mask masks bits in the lowest preset bit-number data of the color data of an extended bit-number range; the bit order in which the mask retains bits in the lowest preset bit-number data of the color data of an extended bit-number range is equal to the bit order in which the mask masks bits in the highest preset bit-number data of the color data of an extended bit-number range.

10. The color mixing processing method according to claim 7, characterized in that, In step 24, the method for merging the mixing results by right shift includes: The mixing result is shifted to the right by the preset number of bits to obtain a right-shifted mixing result. The right-shifted mixing result is bitwise ORed with the mixing result to obtain the merged result; The merging result is converted into an unsigned integer with the preset number of bits to obtain the mixed color value.

11. The color mixing processing method according to claim 10, characterized in that, When the transparency described in step 21 increases, the mixed color value calculated in step 24 increases, the mixing ratio between the foreground color data and the background color data increases, and the brightness of the foreground color displayed on the screen of the display increases. When the transparency described in step 21 decreases, the blended color value calculated in step 24 decreases, the blending ratio between the foreground color data and the background color data decreases, and the brightness of the background color displayed on the screen of the display increases.

Citation Information

Patent Citations

  • Object identification method and robot debugging method

    CN118038071A