CN114143542B - Color coding and decoding method, terminal and computer readable storage medium - Google Patents

Color coding and decoding method, terminal and computer readable storage medium Download PDF

Info

Publication number
CN114143542B
CN114143542B CN202111399304.6A CN202111399304A CN114143542B CN 114143542 B CN114143542 B CN 114143542B CN 202111399304 A CN202111399304 A CN 202111399304A CN 114143542 B CN114143542 B CN 114143542B
Authority
CN
China
Prior art keywords
color
value
color code
code
element values
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111399304.6A
Other languages
Chinese (zh)
Other versions
CN114143542A (en
Inventor
高孝敏
董国明
孙宇佳
王美玉
于立民
垢元培
王福超
崔伟
李伟
尤帅
李如山
王宇
常素彩
曹瑞明
刘佳
田志强
张金欢
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Second Geological Brigade Of Hebei Bureau Of Geology And Mineral Resources
Original Assignee
Second Geological Brigade Of Hebei Bureau Of Geology And Mineral Resources
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Second Geological Brigade Of Hebei Bureau Of Geology And Mineral Resources filed Critical Second Geological Brigade Of Hebei Bureau Of Geology And Mineral Resources
Priority to CN202111399304.6A priority Critical patent/CN114143542B/en
Publication of CN114143542A publication Critical patent/CN114143542A/en
Application granted granted Critical
Publication of CN114143542B publication Critical patent/CN114143542B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/124Quantisation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/44Decoders specially adapted therefor, e.g. video decoders which are asymmetric with respect to the encoder

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Color Image Communication Systems (AREA)

Abstract

The application relates to a color coding and decoding method, a terminal and a computer readable storage medium, and the application relates to the technical field of color display, wherein the coding method comprises the following steps: responding to a color selection operation of a user, acquiring corresponding color values, and extracting a plurality of color element values in the color values, wherein the plurality of color element values comprise a red value R, a green value G and a blue value B; integrating and converting the plurality of color element values into a first color code X; and outputting the first color code X. The application solves the problems that the code quantity for calling the color value is large, a large amount of computer memory is occupied and the running speed of the computer is influenced.

Description

Color coding and decoding method, terminal and computer readable storage medium
Technical Field
The present application relates to the technical field of color display, and in particular, to a color coding and decoding method, a terminal, and a computer readable storage medium.
Background
The colors presented on the computer display are composed of a transparency, R red, G green, B blue, and the colors on the computer display are early divided into 256 colors. 256 colors are colors that control the display with 1 byte, i.e., 8 bits; wherein 2 bits control the amount of red, 2 bits control the amount of green, 2 bits control the amount of blue, 2 bits control the brightness.
Along with the development of technology, the variety of colors displayed on computer displays is gradually increased, and the computer displays experience 16-bit colors and 24-bit colors, and currently adopt 32-bit colors. Among them, 24-bit color has been called true color, which can reach the limit of resolution of human eyes, and the number of colors is 16777215. The 32-bit color is added with 8-bit transparency (255 transparency), so that a plurality of colors with transparency are derived from the basic color capable of displaying 16777215 different parameters. Generally, the higher the number of digits in a computer display, the more colors will be displayed and the better the color display will be.
At present, the color coding method of the mainstream computer display does not achieve the effect of compatibility and combination of 8-bit display colors and 32-bit display colors, and the coding method of the 32-bit display colors adopts a (A, R, G and B) four-bit digital form for storage, so that the form is complex, and a large amount of computer memory is consumed when the color value is called.
Disclosure of Invention
In order to save memory consumption in invoking color values, the application provides a color coding and decoding method, a terminal and a computer readable storage medium.
In a first aspect, the present application provides a color coding method, which adopts the following technical scheme:
a color coding method, comprising:
Responding to a color selection operation of a user, acquiring corresponding color values, and extracting a plurality of color element values in the color values, wherein the plurality of color element values comprise a red value R, a green value G and a blue value B;
Integrating and converting the plurality of color element values into a first color code X;
And outputting the first color code X.
Optionally, the integrally converting the plurality of color element values into the first color code X includes:
If the color value is a brief color, determining a color code corresponding to a plurality of color element values corresponding to the color value in a color corresponding relation as the first color code X;
And if the color value is a combined color, encoding the plurality of color element values based on a preset encoding algorithm to obtain the first color code X.
Optionally, the encoding the plurality of color element values based on a preset encoding algorithm, and obtaining the first color code X includes:
judging whether the plurality of color element values contain a transparency value A or not;
If yes, converting the transparency value A into a transparency value T;
Substituting the transparency value T, the red value R, the green value G and the blue value B into a formula x=c+b+g 256+r 256+t 256 to obtain a first color code X, wherein C is a conversion coefficient;
if not, the red value R, the green value G and the blue value B are directly substituted into the formula x=c+b+g×256+r×256×256, and the first color code X is calculated.
Optionally, the converting the transparency value a into the transparency value T includes:
If a > 252, t=0;
if a is less than or equal to 2, then t=100;
If 2 < A.ltoreq.252, T=100- (A/2.525), where (A/2.525) is of the int type.
In a second aspect, the present application provides a color decoding method, which adopts the following technical scheme:
A color decoding method, comprising:
Acquiring a first color code X;
Converting the first color code X into a plurality of color element values;
And displaying the color corresponding to the first color code X based on the color element values.
Optionally, judging whether the color corresponding to the first color code X is a brief color;
If yes, determining the color element value corresponding to the first color code X in the color corresponding relation as the plurality of color element values;
if not, the plurality of color element values are calculated based on a decoding algorithm.
Optionally, the calculating based on the decoding algorithm obtains a plurality of color element values includes:
calculating a second color code Y based on the first color code X, wherein y=x-C;
judging the second color code Y whether or not to be not smaller than 256×256×256 the method comprises the steps of carrying out a first treatment on the surface of the;
If so, a transparency value T is calculated based on the second color code Y, wherein t=y/("a") 256×256×256 a) is provided;
A third color code Z is calculated based on the second color code Y, wherein, z=y% (256 x 256), and Z is int;
performing bit and operation on the binary corresponding to the third color code Z and the binary corresponding to 0xFF, taking the lower eight bits to obtain a blue value B, performing bit and operation on the binary corresponding to the third color code Z and the binary corresponding to 0xFF00, taking the middle eight bits to obtain a green value G, performing bit and operation on the binary corresponding to the third color code Z and the binary corresponding to 0xFF0000, and taking the upper eight bits to obtain a red value R;
Converting the transparency value T into a transparency value A;
determining the transparency value a, the red value R, the green value G, and the blue value B as the plurality of color element values;
If not, performing bit and operation on the binary corresponding to the second color code Y and the binary corresponding to 0xFF, taking the lower eight bits to obtain a blue value B, performing bit and operation on the binary corresponding to the second color code Y and the binary corresponding to 0xFF00, taking the middle eight bits to obtain a green value G, performing bit and operation on the binary corresponding to the second color code Y and the binary corresponding to 0xFF0000, and taking the upper eight bits to obtain a red value R;
the red value R, the green value G, and the blue value B are determined as the plurality of color element values.
Optionally, the converting the transparency value T into the transparency value a includes:
if T < 1, a=255;
If T > 99, a=0;
If 1.ltoreq.T.ltoreq.99, A=254- (T.2.54), where T.2.54 is of the int type.
In a third aspect, the present application provides an intelligent terminal, which adopts the following technical scheme:
An intelligent terminal comprising a memory and a processor, the memory having stored thereon a computer program capable of being loaded by the processor and performing any one of the methods of the first or second aspects.
In a fourth aspect, the present application provides a computer readable storage medium, which adopts the following technical scheme:
A computer readable storage medium storing a computer program capable of being loaded by a processor and performing any one of the methods of the first or second aspects.
In summary, when a specific color is called by the color value, a plurality of color element values (a, R, G, B) or (R, G, B) need to be input, each color element value is at least composed of one byte, each color value is at least composed of 5 bytes, and when a specific color is called by the first color code X, at least one byte is input, compared with the specific color called by the color value, the first color code X reduces a part of code amount, thereby saving memory consumption in the process of calling the color value.
Drawings
Fig. 1 is a flowchart of a color coding method according to an embodiment of the application.
Fig. 2 is a flow chart of a method for encoding a base color according to an embodiment of the present application.
Fig. 3 is a flowchart illustrating a sub-step of step S200 in an embodiment of the present application.
Fig. 4 is a flowchart of a color decoding method according to an embodiment of the application.
Fig. 5 is a flowchart of step S600 in the embodiment of the application.
Fig. 6 is a block diagram of a smart terminal 800 in an embodiment of the present application.
Detailed Description
The present application will be described in further detail with reference to the accompanying drawings.
In order to make the objects, technical solutions and advantages of the embodiments of the present application more clear, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application.
The embodiment provides a color coding method, which can be executed by an intelligent terminal, wherein the intelligent terminal can be a server or a terminal device, and the server can be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server for providing cloud computing service. The terminal device may be, but is not limited to, a smart phone, a tablet computer, a desktop computer, a notebook computer, etc.
As shown in fig. 1, an embodiment of the present application provides a color coding method, and the main flow of the method is described as follows (steps S100 to S300):
step S100, responding to a color selection operation of a user, obtaining corresponding color values, and extracting a plurality of color element values in the color values, wherein the plurality of color element values comprise a red value R, a green value G and a blue value B;
In this embodiment, a user selects a color on a color board of a system through a mouse, a keyboard, a touch screen, and the like of an intelligent terminal, the intelligent terminal responds to a color selection operation of the user to obtain a color value corresponding to the color, the color value includes three primary colors including red, green, and blue, wherein hue values of the three primary colors are respectively referred to as a red value R, a green value G, and a blue value B.
Step S200, integrating and converting a plurality of color element values into a first color code X;
In this embodiment, the colors corresponding to the color values include a brief color and a combined color, wherein the brief color refers to a color corresponding to the 8-bit display color, and the combined color refers to a color corresponding to the 32-bit display color.
If the color value is a brief color, determining a color code corresponding to a plurality of color element values corresponding to the color value in a color corresponding relation as a first color code X; before the color values are obtained, the brief colors need to be encoded to generate color correspondence, so as to call the brief colors through an integer value. Therefore, as shown in fig. 2, before step S100, the following steps are further included:
step S401, obtaining basic colors in the brief colors;
step S402, color codes are allocated for the basic colors;
The color of the computer is formed by mixing three primary colors of red, green and blue, in the embodiment, the numerical values of the three primary colors of red, green and blue are reasonably selected to construct a mathematical model, and the primary color and the secondary color are determined to determine the basic color. In this embodiment, the main hues include pure red (255, 0), pure orange (255,147,0), pure yellow (255,255,0), pure green (0,255,0), pure cyan (0,255,255), pure blue (0,0,255), pure violet (255,0,255), pure black (0, 0), pure white (255, 255, 255); secondary hues include pure orange (255,83,0), pure orange (255,204,0), pure yellow-green (166,255,0), pure cyan (0, 255, 166), pure cyan (0,166,255), pure blue-violet (153,0,255), pure violet (255,0,153). In this embodiment, a light green (122,255, 122) is exemplified, in which 255 is a main tone of the colors, 122 is a secondary tone of the colors, and colors of different shades are presented by inserting the secondary tone into the main tone; for example, (0,255,0) (122,255,122) (184,255,184) exhibit green colors that are sequentially from deep to light.
In the present embodiment, the brief colors include a base color, a transparency superimposed color, and an extended color. The intelligent terminal acquires basic colors and distributes color codes for each basic color, wherein the basic colors comprise 256 basic colors. When assigning color codes to the base colors, first, the black-and-white gray system in 256 base colors is extracted, and the black-and-white gray system is uniformly segmented according to 256/8.256 to form 32 base colors. Wherein, divide the black to gray system and gray to white system each 16 color segments, and black and white gray system is ordered according to the shade of the color sequentially; and sequentially assigning the integer values from 0 to 15 to each color segment in the black-to-gray color system, sequentially assigning the integer values from 16 to 31 to each color segment in the gray-to-white color system, and taking from 0 to 31 as the color codes of the black-to-white gray color system.
Since human eyes differ in sensitivity to colors, colors are divided into narrower-viewing-range colors and wider-viewing-range colors; colors that are more sensitive to the human eye are narrower-looking colors, e.g., yellow, cyan, purple; the colors insensitive to human eyes are wide-field colors, e.g., red, green, blue.
In this embodiment, when color codes are allocated to the color systems of 256 basic colors except for black and white gray systems, fewer color systems are divided on both sides of the narrower color of the viewing area, and more color systems are divided on both sides of the wider color of the viewing area; dividing the residual color into 14 color systems based on the tone value, and dividing each color system into 16 color segments according to the color depth; and (3) distributing a color code to each color segment in the 14 color systems, wherein the value range of the color code is an integer value in the range of 32-255.
Step S403, extracting reference colors in the basic colors, adding a plurality of transparencies for each reference color to obtain a transparency superposition color, and distributing color codes for each transparency superposition color.
In this embodiment, the reference color refers to 17 pure colors of the 256 base colors, the 17 pure colors are respectively pure black, pure white, pure ash, pure purple red, pure orange yellow pure yellow, pure yellow-green, pure cyan, pure blue-blue, pure blue-violet; nine transparencies are added for each solid color, respectively, and in this example, an increase in transparence for pure red is illustrated.
The color value of the pure red is (255, 0), the first color code corresponding to the pure red is 40, the transparency of the pure red is increased to obtain a transparent superimposed color, and the color code is allocated to the transparent superimposed color.
284-Pure red a=10% (26,255,0,0);
285-pure red a=20% (51,255,0,0);
286-pure red a=30% (77,255,0,0);
287—pure red a=40% (102,255,0,0);
288-pure red a=50% (128,255,0,0);
289— pure red a=60% (153,255,0,0);
290-pure red a=70% (179,255,0,0);
291-pure red a=80% (204,255,0,0);
292-pure red a=90% (230,255,0,0).
In this embodiment, 285—pure red a=20% (51,20%, 0) is taken as an example, where 258 is a color code, 20% is an opacity coefficient, 51 is an opacity value, and the opacity value is obtained by 20% by 255, and it should be noted that the opacity value is a transparency value in this embodiment.
The arrangement sequence of the transparent superimposed colors is full transparent, white, gray, black, red, orange, yellow-green, cyan, blue-violet, violet and purple red, wherein only one of the full transparent colors and the other colors have 9 kinds of transparency, and in the embodiment, the value range of the color codes of the transparent superimposed colors is 256-409. In the embodiment, color codes are reserved for the extended colors, and the extended colors are used for increasing the color system in the basic colors, wherein the value range of the color codes of the extended colors is 410-999.
If the color values are combined colors, encoding a plurality of color element values based on a preset encoding algorithm to obtain a first color code X.
Specifically, as shown in fig. 3, the encoding of the plurality of color element values based on the preset encoding algorithm includes the following steps:
Step S201, judging whether the transparency value A is contained in the plurality of color element values; if yes, executing step S202, otherwise executing step S204;
in this embodiment, the intelligent terminal acquires a plurality of color element values and determines whether a transparency value a exists in the plurality of color element values; when the color value is (a, R, G, B), it indicates that the transparency value a exists, and step S202 is performed at this time, otherwise step S204 is performed.
Step S202, converting the transparency value A into a transparency value T;
in this embodiment, the intelligent terminal may drag the slider on the color board through a mouse, a keyboard, or the like to select the transparency value a of the color value, and convert the acquired transparency value a into the transparency value T, and display the transparency value T on the display. Wherein, the value range of the transparency value A is 0-255; the transparency value T is 100-0, wherein 100 is completely transparent, and 0 is opaque, so that the transparency is easy to understand by a user.
In the present embodiment, the transparency values a are 1, 100, 253, respectively, and when the transparency value a is 253, the converted transparency value T is 0; when the transparency value A is 1, the converted transparency value T is 100; when the transparency value a is 100, the converted transparency value T is 100- (100/5.525), wherein 100/5.525 = 18.099, and since (a/2.525) is of the int type, 100/5.525 takes the integer value 18, and the converted transparency value T is 82.
Step S203, substituting the transparency value T, the red value R, the green value G, and the blue value B into the formula x=c+b+g256+r256+r256+t256+t256 to calculate and obtain a first color code X, wherein C is a conversion coefficient;
In this embodiment, a color value (90, 100, 0) is taken as an example, wherein the transparency value a is 90, the red value is 100, the green value is 0, and the blue value is 0. In this embodiment, since the maximum value of the first color code X in the color correspondence is 999, in order to organically combine the first color codes X of the respective colors, in this embodiment, the value of C is 1000, i.e. the formula of x=1000+b+g256+r256+t256×256, the transparency value a is first converted into the transparency value T, t=100- (90/5.525) =84, and then the transparency value T, the red value R, the green value G, and the blue value B are brought into and calculated as x=1000+100×256+256×256+256×256= 175899624.
In step S204, the red value R, the green value G and the blue value B are directly substituted into the formula x=c+b+g×256+r×256+r×256+t×256×256, and the first color code X is calculated and obtained, wherein the value of T is 0.
In this embodiment, a color value (100,50,0) is taken as an example, wherein the red value is 100, the green value is 50, the blue value is 0, and the red value R, the green value G, and the blue value B are taken into account and x=0+50×256+100×256+256+0= 6566400 is calculated.
Step S300, outputting the first color code X.
In this embodiment, the intelligent terminal will obtain the output of the first color code X, so that the corresponding color is conveniently invoked by the first color code X.
Aiming at the color coding method, the embodiment of the application also provides a color decoding method. The decoding method is also executed by the intelligent terminal, and the foregoing description of the intelligent terminal is omitted herein.
As shown in FIG. 4, the main flow of the decoding method is described as follows (steps S500 to S700)
Step S500, a first color code X is obtained;
In this embodiment, the intelligent terminal acquires the first color code X by a user through a mouse, a keyboard, a touch screen, and the like.
If the first color code X acquired by the intelligent terminal is smaller than 0, judging whether the first color code X is smaller than a preset minimum integer value, if so, converting the first color code X into-X, otherwise, assigning the preset maximum integer value to the first color code X.
In this embodiment, the preset minimum integer value is-2147483748, and the preset maximum integer value is 2147483647, for example, when the obtained first color code X is-21474836, the converted first color code X is 21474836; when the acquired first color code X is-21474839, the converted first color code X is 2147483647; when the acquired first color code 409 is more than X and less than or equal to 999, calling an unknown color, wherein in the embodiment, the unknown color is an expanded color, one unknown color is preset in the basic color, and when the first color code 409 input by a user is more than or equal to 999, the unknown color is displayed on the display of the intelligent terminal.
Searching whether the first color code X exists in the color corresponding relation or not; if yes, determining the color element value corresponding to the first color code X in the color corresponding relation as a plurality of color element values; if not, a plurality of color element values are calculated and obtained based on a decoding algorithm.
In this embodiment, the intelligent terminal acquires the first color code X and determines whether the first color code X is within a value range of the first color code X in the color correspondence, where the value range of the first color code X in the color correspondence is 0-999; if the first color code X acquired by the intelligent terminal is in the range of 0-999, the intelligent terminal inquires the color corresponding to the first color code X in the color corresponding relation, calls a background color brush, displays the color corresponding to the first color code X on a display of the intelligent terminal, and if the acquired first color code X does not belong to the color corresponding relation, enters step S600 to process the first color value X.
Step S600, converting the first color code X into a plurality of color element values;
in this implementation, as shown in fig. 5, step S600 includes the following sub-steps:
Step S601, calculating a second color code Y based on the first color code X, wherein y=x-C;
In step S602, judging the second color code Y whether or not to be not smaller than 256×256×256; if yes, go to step S603, otherwise go to step S608.
The calculation formula of the color coding part is x=c+b+g+256+r 256+t 256, and in the embodiment of the color coding part, the value of C is 1000, in order to keep the encoding part and decoding part identical, the value of C is also 1000 in this embodiment.
In this embodiment, the first color code X is taken as 1023345640 for illustration, the second color code Y is calculated as 1023344640 based on y=x-C, where 256×256=16777216, in the present embodiment, the second color code Y is greater than 256×256, so step S603 is performed.
Step S603, calculating a transparency value T based on the second color code Y, wherein t=y/("a") 256×256×256 a) is provided;
In this embodiment, the data in steps S601 and S602 are used for illustration, and the transparency value T is calculated based on t=y/256×256, wherein the second color code Y is 1023344640, so the transparency value T is 60.
Step S604, calculating a third color code Z based on the second color code Y, wherein, z=y% (256 x 256), and Z is int;
In the present embodiment, the data of step S603 is used for illustration, the third signature Z is calculated based on z=y% 256 x 256, where% represents the remainder of Y and 256 x 256, in this embodiment the second color code Y is 1023344640, so the third color code Z is 16711680.
Step S605, performing bit AND operation on the binary corresponding to the third color code Z and the binary corresponding to 0xFF, taking the lower eight bits to obtain a blue value B, performing bit AND operation on the binary corresponding to the third color code Z and the binary corresponding to 0xFF00, taking the middle eight bits to obtain a green value G, performing bit AND operation on the binary corresponding to the third color code Z and the binary corresponding to 0xFF0000, and taking the upper eight bits to obtain a red value R;
In this embodiment, the data in step S604 is exemplified by the data in step S604, wherein Z is 16711680, the binary corresponding to Z is 111111110000000000000000, the binary corresponding to 0xff is 11111111, the 11111111 is shifted to the right by 16 bits to obtain 000000000000000011111111, and the bits and operations are performed on 111111110000000000000000 and 000000000000000011111111, and the operation rules are: 0&0 =0, 0&1 =0, 1&0 =0, 1& 1=1, so that 000000000000000000000000 is obtained, the lower eight bits are taken to obtain a blue value B, and in this embodiment, the blue value B is 0; binary corresponding to 0xFF00 is 1111111111111, 11111111 is shifted to the right by 8 bits to obtain 000000001111111111111111, 000000001111111111111111 and 111111110000000000000000 are subjected to bit and operation to 000000000000000000000000, and the middle eight bits are taken to obtain a green value G of 0; binary corresponding to 0xFF0000 is 111111111111111111111111, bits and operation is carried out on 11111111111111111111111 and 111111110000000000000000 to obtain 111111110000000000000000, the upper eight bits are taken to obtain a red value 1111111111, and 11111111 is converted into decimal to obtain 255.
Step S606, converting the transparency value T into a transparency value A;
In this embodiment, the transparency value T needs to be converted into the transparency value a, and the specific conversion algorithm is as follows: if the transparency value T is less than or equal to 1, the transparency value a=255; if the transparency value T is more than or equal to 99, the transparency value A=0; if transparency 1 < T < 99, then a transparency value a is calculated based on a=254- (t×2.54), where t×2.54 is type int.
In this embodiment, the data in step S603 is used for illustration, wherein the transparency value T is 60, and the transparency value a is 100 based on a=254- (t×2.54).
Step S607, determining the transparency value a, the red value R, the green value G, and the blue value B as a plurality of color element values;
in the present embodiment, the data in steps S601 to S606 are exemplified, so that the obtained color value is (100,255,0,0)
Step S608, performing bit AND operation on the binary corresponding to the second color code Y and the binary corresponding to 0xFF, taking the lower eight bits to obtain a blue value B, performing bit AND operation on the binary corresponding to the second color code Y and the binary corresponding to 0xFF00, taking the middle eight bits to obtain a green value G, performing bit AND operation on the binary corresponding to the second color code Y and the binary corresponding to 0xFF0000, and taking the upper eight bits to obtain a red value R;
Step S609, determining a red value R, a green value G, and a blue value B as a plurality of color element values;
in this embodiment, the steps of calculating the red value R, the green value G and the blue value B are identical to the step S605, and will not be described herein.
In step S700, a color corresponding to the first color code X is displayed based on the plurality of color element values.
In this embodiment, the intelligent terminal converts the first color code X into a plurality of color element values, where the color element values include a red value R, a green value G, and a blue value B, or a red value R, a green value G, a blue value B, and a transparency value a, and invokes a color brush in the background of the intelligent terminal based on the plurality of color element values, to display the corresponding color.
Fig. 6 is a block diagram of an intelligent terminal 800 according to an embodiment of the present application. The intelligent terminal 800 may be a mobile phone, a tablet computer, a PC, a server, etc. As shown in fig. 6, the smart terminal 800 includes a memory 801, a processor 802, and a communication bus 803; the memory 801 and the processor 802 are connected by a communication bus 803. The memory 801 has stored thereon a computer program that can be loaded by the processor 802 and that performs the color encoding method and/or the color decoding method as provided by the above-described embodiments.
The memory 801 may be used to store instructions, programs, code sets, or instruction sets. The memory 801 may include a storage program area and a storage data area, wherein the storage program area may store instructions for implementing an operating system, instructions for at least one function, instructions for implementing the color coding and decoding methods provided by the above embodiments, and the like; the storage data area may store data and the like involved in the color encoding and decoding methods provided in the above embodiments.
The processor 802 may include one or more processing cores. The processor 802 performs various functions of the present application and processes data by executing or executing instructions, programs, code sets, or instruction sets stored in the memory 801, invoking data stored in the memory 801. The Processor 802 may be at least one of an Application SPECIFIC INTEGRATED Circuit (ASIC), a digital signal Processor (DIGITAL SIGNAL Processor, DSP), a digital signal processing device (DIGITAL SIGNAL Processing Device, DSPD), a programmable logic device (Programmable Logic Device, PLD), a field programmable gate array (Field Programmable GATE ARRAY, FPGA), a central processing unit (Central Processing Unit, CPU), a controller, a microcontroller, and a microprocessor. It will be appreciated that the electronics for implementing the functions of the processor 802 described above may be other for different devices, and embodiments of the present application are not particularly limited.
Communication bus 803 may include a pathway to transfer information between the aforementioned components. The communication bus 803 may be a PCI (PERIPHERAL COMPONENT INTERCONNECT, peripheral component interconnect standard) bus or an EISA (Extended Industry Standard Architecture ) bus, or the like. The communication bus 803 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one double arrow is shown in FIG. 6, but not only one bus or one type of bus.
An embodiment of the present application provides a computer-readable storage medium storing a computer program capable of being loaded by a processor and performing the color encoding and/or color decoding method as provided in the above embodiment.
In this embodiment, the computer-readable storage medium may be a tangible device that holds and stores instructions for use by the instruction execution device. The computer readable storage medium may be, but is not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any combination of the preceding. In particular, the computer readable storage medium may be a portable computer disk, hard disk, USB flash disk, random Access Memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), podium random access memory (SRAM), portable compact disc read-only memory (CD-ROM), digital Versatile Disk (DVD), memory stick, floppy disk, optical disk, magnetic disk, mechanical coding device, and any combination of the foregoing.
In addition, it is to be understood that relational terms such as first and second are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions.
The terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus.
The above description is only illustrative of the preferred embodiments of the present application and of the principles of the technology employed. It will be appreciated by persons skilled in the art that the scope of the application is not limited to the specific combinations of the features described above, but also covers other embodiments which may be formed by any combination of the features described above or their equivalents without departing from the spirit of the application. Such as the above-mentioned features and the technical features having similar functions (but not limited to) applied for in the present application are replaced with each other.

Claims (6)

1. A color coding method, comprising:
Responding to a color selection operation of a user, acquiring corresponding color values, and extracting a plurality of color element values in the color values, wherein the plurality of color element values comprise a red value R, a green value G and a blue value B;
Integrating and converting the plurality of color element values into a first color code X;
Outputting the first color code X;
The integrating the plurality of color element values into a first color code X includes:
If the color value is a brief color, determining a color code corresponding to a plurality of color element values corresponding to the color value in a color corresponding relation as the first color code X;
if the color value is a combined color, encoding the plurality of color element values based on a preset encoding algorithm to obtain the first color code X;
The encoding the plurality of color element values based on a preset encoding algorithm to obtain the first color code X includes:
judging whether the plurality of color element values contain a transparency value A or not;
If yes, converting the transparency value A into a transparency value T;
Substituting the transparency value T, the red value R, the green value G and the blue value B into a formula x=c+b+g 256+r 256+t 256 to obtain a first color code X, wherein C is a conversion coefficient;
if not, the red value R, the green value G and the blue value B are directly substituted into the formula x=c+b+g×256+r×256×256, and the first color code X is calculated.
2. The method according to claim 1, wherein said converting said transparency value a into a transparency value T comprises:
If a > 252, t=0;
if a is less than or equal to 2, then t=100;
If 2 < A.ltoreq.252, T=100 (A/2.525), where (A/2.525) is of the int type.
3. A color decoding method, comprising:
Acquiring a first color code X;
Converting the first color code X into a plurality of color element values;
displaying the color corresponding to the first color code X based on the color element values;
Before the first color code X is converted into the plurality of color element values, the method further includes:
judging whether the color corresponding to the first color code X is a brief color or not;
if yes, determining the color element value corresponding to the first color code X in the color corresponding relation as the plurality of color element values;
if not, calculating to obtain the color element values based on a decoding algorithm;
The calculating to obtain a plurality of color element values based on the decoding algorithm comprises the following steps:
calculating a second color code Y based on the first color code X, wherein y=xc;
judging the second color code Y whether or not to be not smaller than 256×256×256 the method comprises the steps of carrying out a first treatment on the surface of the;
If so, a transparency value T is calculated based on the second color code Y, wherein t=y/("a") 256×256×256 a) is provided;
A third color code Z is calculated based on the second color code Y, wherein, z=y% (256 x 256), and Z is int;
performing bit and operation on the binary corresponding to the third color code Z and the binary corresponding to 0xFF, taking the lower eight bits to obtain a blue value B, performing bit and operation on the binary corresponding to the third color code Z and the binary corresponding to 0xFF00, taking the middle eight bits to obtain a green value G, performing bit and operation on the binary corresponding to the third color code Z and the binary corresponding to 0xFF0000, and taking the upper eight bits to obtain a red value R;
Converting the transparency value T into a transparency value A;
determining the transparency value a, the red value R, the green value G, and the blue value B as the plurality of color element values;
If not, performing bit and operation on the binary corresponding to the second color code Y and the binary corresponding to 0xFF, taking the lower eight bits to obtain a blue value B, performing bit and operation on the binary corresponding to the second color code Y and the binary corresponding to 0xFF00, taking the middle eight bits to obtain a green value G, performing bit and operation on the binary corresponding to the second color code Y and the binary corresponding to 0xFF0000, and taking the upper eight bits to obtain a red value R;
the red value R, the green value G, and the blue value B are determined as the plurality of color element values.
4. A method according to claim 3, wherein said converting said transparency value T into a transparency value a comprises:
if T < 1, a=255;
If T > 99, a=0;
If 1.ltoreq.T.ltoreq.99, A=254 (T.2.54), where T.2.54 is of the int type.
5. An intelligent terminal comprising a memory and a processor, the memory having stored thereon a computer program capable of being loaded by the processor and executing the method according to claim 1 or 2.
6. A computer readable storage medium, characterized in that a computer program is stored which can be loaded by a processor and which performs the method according to claim 1 or 2.
CN202111399304.6A 2021-11-19 2021-11-19 Color coding and decoding method, terminal and computer readable storage medium Active CN114143542B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111399304.6A CN114143542B (en) 2021-11-19 2021-11-19 Color coding and decoding method, terminal and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111399304.6A CN114143542B (en) 2021-11-19 2021-11-19 Color coding and decoding method, terminal and computer readable storage medium

Publications (2)

Publication Number Publication Date
CN114143542A CN114143542A (en) 2022-03-04
CN114143542B true CN114143542B (en) 2024-08-09

Family

ID=80391147

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111399304.6A Active CN114143542B (en) 2021-11-19 2021-11-19 Color coding and decoding method, terminal and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN114143542B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102231208A (en) * 2011-06-28 2011-11-02 北京新媒传信科技有限公司 Method for compressing types of image colors
CN102282854A (en) * 2008-12-31 2011-12-14 意法爱立信有限公司 Process and apparatus for blending images

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI424425B (en) * 2009-07-22 2014-01-21 Chunghwa Picture Tubes Ltd Device and method for converting three color values to four color values, lcd and driving method thereof
CN102333223A (en) * 2011-10-25 2012-01-25 北京华兴宏视技术发展有限公司 Video data coding method, decoding method, coding system and decoding system
WO2016134785A1 (en) * 2015-02-27 2016-09-01 Hewlett-Packard Development Company, L.P. Color mapping
WO2016183154A1 (en) * 2015-05-11 2016-11-17 Google Inc. Improved color space compression

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102282854A (en) * 2008-12-31 2011-12-14 意法爱立信有限公司 Process and apparatus for blending images
CN102231208A (en) * 2011-06-28 2011-11-02 北京新媒传信科技有限公司 Method for compressing types of image colors

Also Published As

Publication number Publication date
CN114143542A (en) 2022-03-04

Similar Documents

Publication Publication Date Title
CN105957125B (en) A kind of processing method and mobile terminal of icon text
CN105005461A (en) Icon display method and terminal
CN108701351B (en) Image display enhancement method and device
CN104076928B (en) A kind of method for adjusting text importing image
CN110865856A (en) Interface element color display method and device
CN111080806B (en) Mapping processing method and device, electronic equipment and storage medium
CN111147857B (en) Image processing method, image processing device, electronic equipment and storage medium
CN103065338A (en) Method and device providing shadow for foreground image in background image
CN114143542B (en) Color coding and decoding method, terminal and computer readable storage medium
CN108471536A (en) Alpha channel transmission methods and device, terminal installation and storage medium
AU2010257408B2 (en) Colour encoding clustering
JP7274180B2 (en) Program, Neural Network Processing Computer, Neural Network Processing Apparatus, and Neural Network Operation Method
CN111369431A (en) Image processing method and device, readable medium and electronic equipment
CN110444181A (en) Display methods, device, terminal and computer readable storage medium
US10672049B1 (en) Sample color selection for online retail items
CN101201829B (en) Chinese character library system as well as character code display method thereof
US6088016A (en) Dithering method and apparatus using ramp probability logic
JP3708476B2 (en) Color gamut mapping system and method using composite color space
CN109408028B (en) Floating point number operation method and device and storage medium
CN108600746B (en) The eclipsed detection method of Color image of visual, system and device
TWI459220B (en) System and method of predicting color imagery
CN112433798A (en) Page adaptation method and device based on mode switching
CN112569597A (en) Model color transformation method and electronic equipment
TW202131234A (en) Neural network processing device, neural network processing method and neural network processing program including an input buffer, a storage unit, a binary signal acquisition unit, and a convolution computation unit
CN104090764B (en) A kind of terminal

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant