CN114143542A - Color encoding and decoding method, terminal, and computer-readable storage medium - Google Patents

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

Info

Publication number
CN114143542A
CN114143542A CN202111399304.6A CN202111399304A CN114143542A CN 114143542 A CN114143542 A CN 114143542A CN 202111399304 A CN202111399304 A CN 202111399304A CN 114143542 A CN114143542 A CN 114143542A
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.)
Granted
Application number
CN202111399304.6A
Other languages
Chinese (zh)
Other versions
CN114143542B (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

Images

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 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 a corresponding color value, and extracting a plurality of color element values in the color value, wherein the plurality of color element values comprise a red value R, a green value G and a blue value B; integrally converting the plurality of color element values into a first color code X; and outputting the first color code X. The problem of the code volume of calling the colour value great, can occupy a large amount of computer memory, influence the operating rate of computer is solved, this application has the effect of the code volume of reducing input colour value.

Description

Color encoding and decoding method, terminal, and computer-readable storage medium
Technical Field
The present application relates to the field of color display technologies, and in particular, to a color encoding 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 classified into 256 colors at an early stage. 256 colors are the colors of the display controlled by 1 byte (bit), i.e. 8 bits (bit); 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 degree.
With the development of technology, the kinds of colors displayed on a computer display are gradually increased, and the colors experience 16-bit colors and 24-bit colors, and currently 32-bit colors are adopted. Among them, 24-bit colors have been called true colors, which can reach the limit of human eye resolution, and the number of color emissions is 16777215. The 32-bit color is added with 8-bit transparency (255 kinds of transparency), so that a plurality of colors with transparency are derived on the basis of the basic color capable of displaying 16777215 different parameters. Generally, the higher the number of digits in a computer display, the more colors that are displayed, and the better the color display.
At present, the mainstream color coding method of a computer display does not have the effect of compatible and simultaneous use of 8-bit display colors and 32-bit display colors, and the 32-bit display color coding method adopts a (A, R, G, B) four-bit form for storage, so that the form is complex, and a large amount of computer memory is consumed when a color value is called.
Disclosure of Invention
In order to save memory consumption in the process of calling 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 a corresponding color value, and extracting a plurality of color element values in the color value, wherein the plurality of color element values comprise a red value R, a green value G and a blue value B;
integrally 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 the color element values in the color corresponding relationship corresponding to the color value 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 multiple color element values based on a preset encoding algorithm to obtain the first color code X includes:
judging whether the 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+ R256 + T + 256 to obtain a first color code X, wherein C is a conversion coefficient;
and if not, directly substituting the red value R, the green value G and the blue value B into a formula X = C + B + G256 + R256 to obtain a first color code X by calculation.
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, T = 100;
if 2 < A ≦ 252, T =100- (A/2.525), where (A/2.525) is int-type.
In a second aspect, the present application provides a color decoding method, which adopts the following technical solutions:
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 plurality of color element values.
Optionally, judging whether the color corresponding to the first color code X is a brief color;
if yes, determining color element values corresponding to the first color code X in the color correspondence as the plurality of color element values;
and if not, calculating to obtain the multiple color element values based on a decoding algorithm.
Optionally, the calculating based on the decoding algorithm to obtain 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 whether the second color code Y is not less than 256 × 256;
if yes, calculating a transparency value T based on the second color code Y, wherein T = Y/(256 × 256);
calculating a third color code Z based on the second color code Y, wherein Z = Y% (256 × 256), and Z is int-type;
performing bit AND operation on a binary system corresponding to a third color code Z and a binary system corresponding to 0xFF, taking eight lower bits to obtain a blue value B, performing bit AND operation on the binary system corresponding to the third color code Z and the binary system corresponding to 0xFF00, taking eight middle bits to obtain a green value G, performing bit AND operation on the binary system corresponding to the third color code Z and the binary system corresponding to 0xFF0000, and taking eight upper 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 system corresponding to the second color code Y and the binary system corresponding to 0xFF, taking the eight lower bits to obtain a blue value B, performing bit AND operation on the binary system corresponding to the second color code Y and the binary system corresponding to 0xFF00, taking the eight middle bits to obtain a green value G, performing bit AND operation on the binary system corresponding to the second color code Y and the binary system corresponding to 0xFF0000, and taking the eight upper bits to obtain a red value R;
determining the red value R, the green value G, and the blue value B 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 T is 1 ≦ T ≦ 99, a =254- (T × 2.54), where T × 2.54 is 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 that is loadable by the processor and adapted to perform the method of any of the first or second aspects.
In a fourth aspect, the present application provides a computer-readable storage medium, which adopts the following technical solutions:
a computer readable storage medium storing a computer program capable of being loaded by a processor and performing the method of any one of the first or second aspects.
In summary, when a specific color is called by a color value, a plurality of color element values (a, R, G, B) or (R, G, B) need to be input, each color element value at least consists of one byte, and each color value at least consists of 5 bytes, and when a specific color is called by a first color code X, at least one byte is input, so that compared with the case where a specific color is called by a color value, the first color code X reduces a part of code amount, thereby saving memory consumption in the process of calling a color value.
Drawings
Fig. 1 is a schematic flowchart of a color coding method in an embodiment of the present application.
Fig. 2 is a schematic flowchart of a method for encoding a base color in an embodiment of the present application.
Fig. 3 is a schematic flow chart of the substep of step S200 in the embodiment of the present application.
Fig. 4 is a flowchart illustrating a color decoding method in an embodiment of the present application.
Fig. 5 is a schematic flowchart of step S600 in this embodiment of the present application.
Fig. 6 is a block diagram of an intelligent terminal 800 in the embodiment of the present application.
Detailed Description
The present application is described in further detail below with reference to the attached drawings.
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application.
The embodiment provides a color coding method, which may be executed by an intelligent terminal, where the intelligent terminal may be a server or a terminal device, where the server may be an independent physical server, a server cluster or a distributed system formed by multiple physical servers, or a cloud server providing cloud computing services. The terminal device may be a smart phone, a tablet computer, a desktop computer, a notebook computer, etc., but is not limited thereto.
As shown in fig. 1, the present embodiment provides a color coding method, and the main flow of the method is described as follows (steps S100 to S300):
step S100, responding to color selection operation of a user, acquiring a corresponding color value, and extracting a plurality of color element values in the color value, 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 panel of the system by using a mouse, a keyboard, a touch screen, and the like of the intelligent terminal, and the intelligent terminal obtains a color value corresponding to the color in response to a color selection operation of the user, where the color value includes three primary colors including red, green, and blue, and hue values of the three primary colors are referred to as a red value R, a green value G, and a blue value B, respectively.
Step S200, integrating and converting a plurality of color element values into a first color code X;
in this embodiment, the color corresponding to the color value includes a simple color and a combined color, where the simple color is a color corresponding to an 8-bit display color, and the combined color is a color corresponding to a 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 the color corresponding relationship as a first color code X; before obtaining a color value, a color correspondence relationship needs to be generated by encoding a simple color, so as to call the simple color by an integer value. Therefore, as shown in fig. 2, before step S100, the following steps are further included:
step S401, acquiring basic colors in the brief colors;
step S402, distributing color codes for basic colors;
the color of the computer is formed by mixing three primary colors of red, green and blue, in the embodiment, numerical values of the three primary colors of red, green and blue are reasonably selected to construct a mathematical model, and the basic color is determined by determining the primary hue and the secondary hue. In this embodiment, the dominant hue includes pure red (255,0, 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, 0), pure white (255,255, 255); the secondary hues include pure orange red (255,83,0), pure orange yellow (255,204,0), pure yellow green (166,255,0), pure cyan green (0,255, 166), pure blue cyan (0,166,255), pure blue violet (153,0,255), pure magenta red (255,0, 153). In the present embodiment, a light green color (122, 255, 122) is taken as an example for explanation, wherein 255 is a main tone in the color, and 122, 122 is a secondary tone in the color, and different shades of the color are presented by inserting the secondary tone into the main tone; for example, the colors green (0,255,0) (122,255,122) (184,255,184) appear sequentially from dark to light.
In the present embodiment, the brief colors include a basic color, a transparency superimposed color, and an extended color. The intelligent terminal obtains basic colors and distributes color codes for each basic color, wherein the basic colors comprise 256 basic colors. In assigning color codes to the basic colors, first, black, white, and gray systems among the 256 basic colors are extracted, and the black, white, and gray systems are uniformly segmented according to 256/8.256 to form 32 reference colors. Wherein, the black-to-gray color system and the gray-to-white color system are respectively divided into 16 color segments, and the black, white and gray color systems are sequentially ordered according to the shade of the color; the integer values of 0 to 15 are assigned to each color segment of the black-to-gray system in turn, the integer values of 16 to 31 are assigned to each color segment of the gray-to-white system in turn, and 0 to 31 are used as the color codes of the black-white-gray system.
Since human eyes differ in sensitivity to colors, colors are divided into a view narrower color and a view wider color; colors that are more sensitive to the human eye are narrower view colors, e.g., yellow, cyan, violet; colors that are insensitive to the human eye are the wide viewing range colors, e.g., red, green, blue.
In the present embodiment, when color codes are assigned to color systems other than the black, white, and gray color systems of the 256 basic colors, the narrower view area color is divided into fewer color systems on both sides, and the wider view area color is divided into more color systems on both sides; dividing the rest colors into 14 color systems based on hue values, namely, purple red, orange yellow, yellow green, cyan, blue violet and purple, and dividing each color system into 16 color segments according to the color depth; and allocating a color code for 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 from the basic colors, adding a plurality of transparencies to each reference color to obtain a transparency superimposed color, and assigning a color code to each transparency superimposed color.
In this embodiment, the reference color refers to 17 pure colors of 256 basic colors, and the 17 pure colors are respectively pure black, pure white, pure gray, pure magenta, pure red, pure orange yellow, pure yellow green, pure cyan, pure blue violet, and pure violet; nine transparencies are respectively added for each pure color, and in this embodiment, the transparency is added for pure red as an example.
The color value of pure red is (255,0, 0), the first color code corresponding to pure red is 40, the transparency is increased for pure red to obtain a transparent superimposed color, and the color code is allocated for 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,0) is taken as an example for explanation, where 258 is a color code, 20% is an opacity coefficient, 51 is an opacity value, and the opacity value is obtained by 20% × 255, and it should be noted that the opacity value in this embodiment is a transparency value a.
The transparent superposed colors are arranged in the sequence of full transparency, white, gray, black, red, orange yellow, yellow green, cyan, blue violet, and purplish red, wherein the full transparency is only one, and the rest colors respectively have 9 transparencies, and in the embodiment, the value range of the color code of the transparent superposed color is 256-409. In this embodiment, a color code is also reserved for expanding the color, and the expanded color is used to increase the color system in the basic color, wherein the value range of the color code of the expanded color is 410-999.
And if the color value is the combined color, encoding the multiple color element values based on a preset encoding algorithm to obtain a first color code X.
Specifically, as shown in fig. 3, encoding a plurality of color element values based on a preset encoding algorithm includes the following steps:
step S201, judging whether a plurality of color element values contain a transparency value A; if yes, executing step S202, otherwise executing step S204;
in this embodiment, the intelligent terminal obtains 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 there is a transparency value a, step S202 is executed, otherwise step S204 is executed.
Step S202, converting the transparency value A into a transparency value T;
in this embodiment, the intelligent terminal can drag the slider on the color plate to select the transparency value a of the color value in a manner of mouse, keyboard, etc., and convert the acquired transparency value a into the transparency value T to display on the display in the form of the transparency value T. Wherein the value range of the transparency value A is 0-255; the value range of the transparency value T is 100-0, 100 represents full transparency, and 0 represents opacity, so that a user can conveniently understand the transparency.
In this embodiment, the transparency values a are 1, 100, and 253, respectively, for example, 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), where 100/5.525=18.099, and since (a/2.525) is int type, 100/5.525 takes the integer value of 18, so 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 a formula X = C + B + G + 256+ R256 + T + 256+ to calculate and obtain a first color code X, where C is a conversion coefficient;
in this embodiment, a color value (90, 100,0, 0) is taken as an example for explanation, where the transparency value a is 90, the red value is 100, the green value is 0, and the blue value is 0. In the present embodiment, since the maximum value of the first color code X in the color correspondence relationship is 999, in order to make the first color codes X of the respective colors organically and completely merge, the value of C in the present embodiment is 1000, that is, the formula is X =1000+ B + G256 + R256 + T256, 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 substituted into X =1000+100 256+84 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+ T + 256, and the first color code X is calculated and obtained, where the value of T is 0.
In the present embodiment, a color value (100, 50, 0) is taken as an example, where the red value is 100, the green value is 50, and the blue value is 0, and the red value R, the green value G, and the blue value B are substituted to calculate X =0+50 + 256+100 + 256+0= 6566400.
In step S300, the first color code X is output.
In this embodiment, the intelligent terminal obtains the first color code X for output, so as to call the corresponding color through 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, which has already been described above, and is not described herein again.
As shown in FIG. 4, the main flow of the decoding method is described as follows (steps S500 to S700)
Step S500, acquiring a first color code X;
in this embodiment, the intelligent terminal obtains the first color code X 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-2147483648, 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 obtained first color code X is-21474839, the converted first color code X is 2147483647; when the obtained first color code 409 is larger than X and smaller than 999, the unknown color is called, in the embodiment, the unknown color is an expanded color, an unknown color is preset in the basic color, and when the first color code 409 input by the user is larger than X and smaller than 999, the unknown color can be presented on the display of the intelligent terminal.
Searching whether the first color code X exists in the color corresponding relation; if yes, determining color element values corresponding to the first color code X in the color corresponding relation as a plurality of color element values; and if not, calculating and obtaining a plurality of color element values based on a decoding algorithm.
In this embodiment, the intelligent terminal obtains a first color code X, and determines whether the first color code X is within a value range of the first color code X in a color correspondence, where the value range of the first color code X in the color correspondence is 0 to 999; if the first color code X acquired by the intelligent terminal is within the range of 0-999, the intelligent terminal queries the color corresponding to the first color code X in the color corresponding relationship, calls a background color brush, displays the color corresponding to the first color code X on the intelligent terminal display, and if the acquired first color code X does not belong to the color corresponding relationship, then the step S600 is performed 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, where Y = X-C;
step S602, determining whether the second color code Y is not less than 256 × 256; if yes, the process proceeds to step S603, otherwise, the process proceeds to step S608.
The formula of the color coding section is X = C + B + G × 256+ R × 256+ T × 256, and C takes a value of 1000 in the embodiment of the color coding section, and in order to keep the encoding section and the decoding section in agreement, C also takes a value of 1000 in the present embodiment.
In the present embodiment, the first color code X is 1023345640 for example, and the second color code Y is 1023344640, where 256 × 256=16777216 is calculated based on Y = X-C, and in the present embodiment, the second color code Y is greater than 256 × 256, so the process proceeds to step S603.
Step S603, calculating a transparency value T based on the second color code Y, where T = Y/(256 × 256);
in the present embodiment, taking the data in steps S601 and S602 as an example, the transparency value T is calculated based on T = Y/256 × 256, where the transparency value T is 60 because the second color code Y is 1023344640.
Step S604, calculating a third color code Z based on the second color code Y, wherein Z = Y% (256 × 256), and Z is int type;
in the present embodiment, taking the data in step S603 as an example, the third feature code Z is calculated based on Z = Y%256 × 256, where% represents the remainder obtained by dividing Y by 256 × 256, and in the present 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 system corresponding to the third color code Z and the binary system corresponding to 0xFF, taking eight low bits to obtain a blue value B, performing bit AND operation on the binary system corresponding to the third color code Z and the binary system corresponding to 0xFF00, taking eight middle bits to obtain a green value G, performing bit AND operation on the binary system corresponding to the third color code Z and the binary system corresponding to 0xFF0000, and taking eight high bits to obtain a red value R;
in the present embodiment, the data in step S604 is taken as an example, where Z is 16711680, the binary system corresponding to Z is 111111110000000000000000, the binary system 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 rule of the operations is: 0&0=0, 0&1=0, 1&0=0, 1&1=1, so that a result of 000000000000000000000000 is obtained, taking the lower eight bits gives a blue value B, which in this example is 0; the binary system corresponding to 0xFF00 is 1111111111111, the 11111111 is right-shifted by 8 bits to obtain 000000001111111111111111, the 000000001111111111111111 and 111111110000000000000000 are subjected to bitAND operation to 000000000000000000000000, and the middle eight bits are taken to obtain a green value G of 0; the binary system corresponding to 0xFF0000 is 111111111111111111111111, bit AND operation is carried out on 11111111111111111111111 and 111111110000000000000000 to obtain 111111110000000000000000, eight high 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, a transparency value a is calculated based on a =254- (T × 2.54), where T × 2.54 is int-type.
In the present embodiment, the data in step S603 is used as an example, where the transparency value T is 60, and the transparency value a is calculated as 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 used as an example, and thus the obtained color value is (100, 255,0,0)
Step S608, performing bit AND operation on the binary system corresponding to the second color code Y and the binary system corresponding to 0xFF, taking eight low bits to obtain a blue value B, performing bit AND operation on the binary system corresponding to the second color code Y and the binary system corresponding to 0xFF00, taking eight middle bits to obtain a green value G, performing bit AND operation on the binary system corresponding to the second color code Y and the binary system corresponding to 0xFF0000, and taking eight high bits to obtain a red value R;
step S609, determining the red value R, the green value G, and the blue value B as a plurality of color element values;
in this embodiment, the step of calculating the red value R, the green value G and the blue value B is the same as step S605, and is not described herein again.
Step S700, displaying a color corresponding to the first color code X 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 calls a color brush based on the plurality of color element values in the background of the intelligent terminal to display a corresponding color.
Fig. 6 is a block diagram of an intelligent terminal 800 according to an embodiment of the present disclosure. The intelligent terminal 800 may be a mobile phone, a tablet computer, a PC, a server, or the like. 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 executes 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, and instructions for implementing the color encoding and decoding methods provided by the above-described embodiments, and the like; the storage data area may store data and the like involved in the color encoding and decoding methods provided by the above-described embodiments.
The processor 802 may include one or more processing cores. The processor 802 executes or executes instructions, programs, code sets, or instruction sets stored in the memory 801 to invoke data stored in the memory 801 to perform various functions and process data of the present application. The Processor 802 may be at least one of an Application Specific Integrated Circuit (ASIC), a Digital Signal Processor (DSP), a Digital Signal Processing Device (DSPD), a Programmable Logic Device (PLD), a Field Programmable Gate Array (FPGA), a Central Processing Unit (CPU), a controller, a microcontroller, and a microprocessor. It is understood that the electronic devices for implementing the functions of the processor 802 may be other devices, and the embodiments of the present application are not limited thereto.
The communication bus 803 may include a path that conveys information between the aforementioned components. The communication bus 803 may be a PCI (Peripheral Component Interconnect) bus, 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-headed arrow is shown in FIG. 6, but that does not indicate only one bus or one type of bus.
Embodiments of the present application provide a computer-readable storage medium storing a computer program capable of being loaded by a processor and executing the color encoding and/or color decoding method provided by the above embodiments.
In this embodiment, the computer readable storage medium may be a tangible device that retains and stores instructions for use by an instruction execution device. The computer readable storage medium may be, but is not limited to, an electronic memory device, a magnetic memory device, an optical memory device, an electromagnetic memory device, a semiconductor memory device, or any combination of the foregoing. In particular, the computer readable storage medium may be a portable computer diskette, a hard disk, a U-disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a podium random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a Digital Versatile Disc (DVD), a memory stick, a floppy disk, an optical disk, a magnetic disk, a mechanical coding device, and any combination thereof.
In addition, it is to be understood that relational terms such as first and second, and the like, 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 a preferred embodiment of the application and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the application referred to in the present application is not limited to the embodiments with a particular combination of the above-mentioned features, but also encompasses other embodiments with any combination of the above-mentioned features or their equivalents without departing from the spirit of the application. For example, the above features may be replaced with (but not limited to) features having similar functions as those described in this application.

Claims (10)

1. A color coding method, comprising:
responding to a color selection operation of a user, acquiring a corresponding color value, and extracting a plurality of color element values in the color value, wherein the plurality of color element values comprise a red value R, a green value G and a blue value B;
integrally converting the plurality of color element values into a first color code X;
and outputting the first color code X.
2. The method of claim 1, wherein the integrated conversion of the plurality of color element values into a first color code X comprises:
if the color value is a brief color, determining a color code corresponding to the color element values in the color corresponding relationship corresponding to the color value 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.
3. The method according to claim 2, wherein the encoding the plurality of color element values based on a preset encoding algorithm to obtain the first color code X comprises:
judging whether the 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+ R256 + T + 256 to obtain a first color code X, wherein C is a conversion coefficient;
and if not, directly substituting the red value R, the green value G and the blue value B into a formula X = C + B + G256 + R256 to obtain a first color code X by calculation.
4. The method of claim 3, wherein converting the transparency value A to a transparency value T comprises:
if a > 252, T =0;
if A is less than or equal to 2, T = 100;
if 2 < A ≦ 252, T =100- (A/2.525), where (A/2.525) is int-type.
5. 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 plurality of color element values.
6. The method of claim 5, wherein prior to converting the first color code X into a plurality of color element values, further comprising:
judging whether the color corresponding to the first color code X is a brief color; (ii) a
If yes, determining color element values corresponding to the first color code X in the color corresponding relation as the plurality of color element values;
and if not, calculating to obtain the multiple color element values based on a decoding algorithm.
7. The method of claim 6, wherein said calculating a plurality of color element values based on a decoding algorithm comprises:
calculating a second color code Y based on the first color code X, wherein Y = X-C;
judging whether the second color code Y is not less than 256 × 256;
if yes, calculating a transparency value T based on the second color code Y, wherein T = Y/(256 × 256);
calculating a third color code Z based on the second color code Y, wherein Z = Y% (256 × 256), and Z is int-type;
performing bit AND operation on a binary system corresponding to a third color code Z and a binary system corresponding to 0xFF, taking eight lower bits to obtain a blue value B, performing bit AND operation on the binary system corresponding to the third color code Z and the binary system corresponding to 0xFF00, taking eight middle bits to obtain a green value G, performing bit AND operation on the binary system corresponding to the third color code Z and the binary system corresponding to 0xFF0000, and taking eight upper 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 system corresponding to the second color code Y and the binary system corresponding to 0xFF, taking the eight lower bits to obtain a blue value B, performing bit AND operation on the binary system corresponding to the second color code Y and the binary system corresponding to 0xFF00, taking the eight middle bits to obtain a green value G, performing bit AND operation on the binary system corresponding to the second color code Y and the binary system corresponding to 0xFF0000, and taking the eight upper bits to obtain a red value R;
determining the red value R, the green value G, and the blue value B as the plurality of color element values.
8. The method of claim 7, wherein converting the transparency value T to a transparency value A comprises:
if T < 1, a = 255;
if T > 99, a =0;
if T is 1 ≦ T ≦ 99, a =254- (T × 2.54), where T × 2.54 is int type.
9. An intelligent terminal, comprising a memory and a processor, the memory having stored thereon a computer program that can be loaded by the processor and that executes the method according to any one of claims 1 to 8.
10. A computer-readable storage medium, in which a computer program is stored which can be loaded by a processor and which executes the method of any one of claims 1 to 8.
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 true CN114143542A (en) 2022-03-04
CN114143542B 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 (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110018891A1 (en) * 2009-07-22 2011-01-27 Chunghwa Picture Tubes, Ltd. Device and method for converting three color values to four color values
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
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
US20160337650A1 (en) * 2015-05-11 2016-11-17 Google Inc. Color space compression

Patent Citations (6)

* 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
US20110018891A1 (en) * 2009-07-22 2011-01-27 Chunghwa Picture Tubes, Ltd. Device and method for converting three color values to four color values
CN102231208A (en) * 2011-06-28 2011-11-02 北京新媒传信科技有限公司 Method for compressing types of image colors
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
US20160337650A1 (en) * 2015-05-11 2016-11-17 Google Inc. Color space compression

Also Published As

Publication number Publication date
CN114143542B (en) 2024-08-09

Similar Documents

Publication Publication Date Title
CN105957125B (en) A kind of processing method and mobile terminal of icon text
CN110865856B (en) Interface element color display method and device
CN108320312B (en) Image color matching method and device and computer terminal
CN104076928B (en) A kind of method for adjusting text importing image
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
CN107025464A (en) A kind of colour selecting method and terminal
CN111562955B (en) Method and device for configuring theme colors of terminal equipment and terminal equipment
CN110444181A (en) Display methods, device, terminal and computer readable storage medium
CN111369431A (en) Image processing method and device, readable medium and electronic equipment
US10672049B1 (en) Sample color selection for online retail items
CN114143542B (en) Color coding and decoding method, terminal and computer readable storage medium
AU2010257408A1 (en) Colour encoding clustering
CN106445501A (en) Display method of notification bar, and terminal
US5586236A (en) Universal color look up table and method of generation
JP3708476B2 (en) Color gamut mapping system and method using composite color space
CN105190737B (en) Reproduced using the spectral color of higher-dimension reflected displaying device
CN111653232B (en) LED screen color gamut calibration method and device
CN106303154A (en) A kind of information processing method and electronic equipment
CN114707013A (en) Image color matching method and device, terminal and readable storage medium
CN104754313A (en) Image collecting method and electronic device
WO2019125448A1 (en) Tonal palette generation
TWI459220B (en) System and method of predicting color imagery
CN112569597A (en) Model color transformation method and electronic equipment
WO2024193632A1 (en) Data large-screen page processing method and apparatus, and related device

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