



技术领域technical field
本发明涉及计算机技术领域,尤其涉及一种根据背景颜色自动改变字体颜色的方法和系统。The invention relates to the field of computer technology, in particular to a method and system for automatically changing font colors according to background colors.
背景技术Background technique
随着信息技术和电子技术的发展,数码产品被越来越广泛的应用于生活以及工作的各个领域中,手机也成为人们必不可少的工具。一般情况下,手机桌面上显示时间的字体都是固定的颜色,而桌面壁纸的颜色是根据用户的爱好而随时更改的。因此,当桌面壁纸的颜色和显示时间的颜色接近时,颜色搭配显得不协调,并且显示效果也不好,使得字体在背景下难以辨认,图3是使用白色背景灰色字体的屏幕显示示意图,图4是使用黑色背景灰色字体的屏幕显示示意图,如图3和图4所示。With the development of information technology and electronic technology, digital products are more and more widely used in various fields of life and work, and mobile phones have also become an indispensable tool for people. Generally, the fonts displaying the time on the mobile phone desktop have fixed colors, while the color of the desktop wallpaper can be changed at any time according to the preferences of the user. Therefore, when the color of the desktop wallpaper is close to the color of the display time, the color matching will appear uncoordinated, and the display effect will not be good, making the font difficult to recognize against the background. Figure 3 is a schematic diagram of the screen display with gray fonts on a white background. 4 is a schematic diagram of screen display using gray fonts on a black background, as shown in FIGS. 3 and 4 .
目前,根据背景颜色自动改变字体颜色的方法还属于正待解决的技术问题。At present, the method of automatically changing the font color according to the background color is still a technical problem to be solved.
发明内容Contents of the invention
本发明提供了一种根据背景颜色自动改变字体颜色的方法和系统,首先获取背景中与字体边缘相邻的点的颜色色值,经过计算后,将字体的颜色设定为与壁纸背景色匹配的颜色,使得字体颜色与背景颜色搭配得当,字体易于辨认。所述技术方案如下:The present invention provides a method and system for automatically changing the font color according to the background color. First, the color value of the point adjacent to the edge of the font in the background is obtained, and after calculation, the font color is set to match the background color of the wallpaper The color of the font makes the font color match the background color properly, and the font is easy to recognize. Described technical scheme is as follows:
一种根据背景颜色自动改变字体颜色的方法,包括:A method to automatically change the font color based on the background color, including:
在背景中,取与字体边缘相邻的点作为参考点;In the background, take the point adjacent to the edge of the font as a reference point;
获得所述所有参考点的颜色色值;Obtaining the color values of all the reference points;
求所述所有参考点的颜色色值的平均值,作为背景颜色的平均色值;Calculate the average value of the color values of all the reference points as the average color value of the background color;
根据所述背景颜色的平均色值,求背景颜色的平均色值所代表的颜色的反色色值;According to the average color value of the background color, find the reverse color value of the color represented by the average color value of the background color;
根据所述背景颜色的平均色值的反色色值,将字体颜色的色值设定为所述背景颜色的平均色值所代表的颜色的反色色值。According to the inverse color value of the average color value of the background color, the color value of the font color is set as the inverse color value of the color represented by the average color value of the background color.
进一步的,求所述所有参考点的颜色色值的平均值包括:Further, calculating the average value of the color values of all the reference points includes:
将用六位十六进制数表示的颜色色值的前两位作为一个十六进制数,求所述所有参考点颜色色值的前两位的平均值,并将平均值仍然以两位十六进制数表示,将得到的两位十六进制数作为背景颜色的平均色值的前两位;The first two digits of the color value represented by six hexadecimal numbers are used as a hexadecimal number, and the average value of the first two digits of the color values of all reference points is calculated, and the average value is still expressed in two One-digit hexadecimal number indicates that the obtained two-digit hexadecimal number is used as the first two digits of the average color value of the background color;
将用六位十六进制数表示的颜色色值的中间两位作为一个十六进制数,求所述所有参考点颜色色值的中间两位的平均值,并将平均值仍然以两位十六进制数表示,将得到的两位十六进制数作为背景颜色的平均色值的中间两位;Use the middle two digits of the color value represented by the six-digit hexadecimal number as a hexadecimal number, calculate the average value of the middle two digits of the color values of all reference points, and use the average value in two One-digit hexadecimal number indicates that the obtained two-digit hexadecimal number is used as the middle two digits of the average color value of the background color;
将用六位十六进制数表示的颜色色值的末尾两位作为一个十六进制数,求所述所有参考点颜色色值的末尾两位的平均值,并将平均值仍然以两位十六进制数表示,将得到的两位十六进制数作为背景颜色的平均色值的末尾两位。The last two digits of the color value represented by six hexadecimal numbers are used as a hexadecimal number, and the average value of the last two digits of the color values of all reference points is calculated, and the average value is still represented by two The two-digit hexadecimal number indicates that the obtained two-digit hexadecimal number is used as the last two digits of the average color value of the background color.
进一步的,求所述背景颜色的平均色值所代表的颜色的反色色值包括:Further, calculating the inverse color value of the color represented by the average color value of the background color includes:
用十六进制数FF减所述背景颜色的平均色值的前两位,得到的差作为所述背景颜色的平均色值所代表颜色的反色色值的前两位;The first two digits of the average color value of the background color are subtracted from the hexadecimal number FF, and the obtained difference is used as the first two digits of the reverse color value of the color represented by the average color value of the background color;
用十六进制数FF减所述背景颜色的平均色值的中间两位,得到的差作为所述背景颜色的平均色值所代表颜色的反色色值的中间两位;Use the hexadecimal number FF to subtract the middle two digits of the average color value of the background color, and the difference obtained is used as the middle two digits of the reverse color value of the color represented by the average color value of the background color;
用十六进制数FF减所述背景颜色的平均色值的末尾两位,得到的差作为所述背景颜色的平均色值所代表颜色的反色色值的末尾两位。The last two digits of the average color value of the background color are subtracted from the hexadecimal number FF, and the obtained difference is used as the last two digits of the reverse color value of the color represented by the average color value of the background color.
一种根据背景颜色自动改变字体颜色的系统,包括:A system for automatically changing the font color based on the background color, including:
参考点提取模块,用于在背景中提取与字体边缘相邻的点作为参考点;The reference point extraction module is used to extract points adjacent to the edge of the font as reference points in the background;
色值获得模块,用于获得所述所有参考点的颜色色值;A color value obtaining module, configured to obtain the color values of all the reference points;
第一计算模块,用于求所述所有参考点的颜色色值的平均值,作为背景颜色的平均色值;The first calculation module is used to calculate the average value of the color values of all the reference points as the average color value of the background color;
第二计算模块,用于根据所述背景颜色的平均色值,求所述背景颜色的平均色值所代表的颜色的反色色值;The second calculation module is used to calculate the reverse color value of the color represented by the average color value of the background color according to the average color value of the background color;
控制模块,用于根据所述背景颜色的平均色值的反色色值,将字体颜色的色值设定为所述背景颜色的平均色值所代表的颜色的反色色值。The control module is configured to set the color value of the font color as the reverse color value of the color represented by the average color value of the background color according to the reverse color value of the average color value of the background color.
进一步的,所述第一计算模块具体用于:Further, the first calculation module is specifically used for:
将用六位十六进制数表示的颜色色值的前两位作为一个十六进制数,求所述所有参考点颜色色值的前两位的平均值,并将平均值仍然以两位十六进制数表示,将得到的两位十六进制数作为背景颜色的平均色值的前两位;The first two digits of the color value represented by six hexadecimal numbers are used as a hexadecimal number, and the average value of the first two digits of the color values of all reference points is calculated, and the average value is still expressed in two One-digit hexadecimal number indicates that the obtained two-digit hexadecimal number is used as the first two digits of the average color value of the background color;
将用六位十六进制数表示的颜色色值的中间两位作为一个十六进制数,求所述所有参考点颜色色值的中间两位的平均值,并将平均值仍然以两位十六进制数表示,将得到的两位十六进制数作为背景颜色的平均色值的中间两位;Use the middle two digits of the color value represented by the six-digit hexadecimal number as a hexadecimal number, calculate the average value of the middle two digits of the color values of all reference points, and use the average value in two One-digit hexadecimal number indicates that the obtained two-digit hexadecimal number is used as the middle two digits of the average color value of the background color;
将用六位十六进制数表示的颜色色值的末尾两位作为一个十六进制数,求所述所有参考点颜色色值的末尾两位的平均值,并将平均值仍然以两位十六进制数表示,将得到的两位十六进制数作为背景颜色的平均色值的末尾两位。The last two digits of the color value represented by six hexadecimal numbers are used as a hexadecimal number, and the average value of the last two digits of the color values of all reference points is calculated, and the average value is still represented by two The two-digit hexadecimal number indicates that the obtained two-digit hexadecimal number is used as the last two digits of the average color value of the background color.
进一步的,所述第二计算模块具体用于:Further, the second calculation module is specifically used for:
用十六进制数FF减所述背景颜色的平均色值的前两位,得到的差作为所述背景颜色的平均色值所代表颜色的反色色值的前两位;The first two digits of the average color value of the background color are subtracted from the hexadecimal number FF, and the obtained difference is used as the first two digits of the reverse color value of the color represented by the average color value of the background color;
用十六进制数FF减所述背景颜色的平均色值的中间两位,得到的差作为所述背景颜色的平均色值所代表颜色的反色色值的中间两位;Use the hexadecimal number FF to subtract the middle two digits of the average color value of the background color, and the difference obtained is used as the middle two digits of the reverse color value of the color represented by the average color value of the background color;
用十六进制数FF减所述背景颜色的平均色值的末尾两位,得到的差作为所述背景颜色的平均色值所代表颜色的反色色值的末尾两位。The last two digits of the average color value of the background color are subtracted from the hexadecimal number FF, and the obtained difference is used as the last two digits of the reverse color value of the color represented by the average color value of the background color.
一种移动终端,其特征在于,所述移动终端包括权利要求4-6中任一所述的根据背景颜色自动改变字体颜色的系统。A mobile terminal, characterized in that the mobile terminal comprises the system for automatically changing the font color according to the background color according to any one of claims 4-6.
本发明提供的技术方案,通过对背景中与字体边缘相邻的点的颜色色值求平均,作为背景平均色色值然后再求平均值的反色色值,将字体的颜色设定为反色,使得字体颜色与背景颜色搭配得当,字体易于辨认。In the technical solution provided by the present invention, by averaging the color values of points adjacent to the edge of the font in the background, as the average color value of the background and then calculating the average reverse color value, the color of the font is set as a reverse color, Make the font color match the background color properly, and the font is easy to recognize.
附图说明Description of drawings
图1是本发明实施例提供的根据背景颜色自动改变字体颜色的方法流程图;Fig. 1 is a flow chart of a method for automatically changing the font color according to the background color provided by an embodiment of the present invention;
图2是本发明实施例提供的根据背景颜色自动改变字体颜色的系统功能模块框图;Fig. 2 is a system functional module block diagram of automatically changing the font color according to the background color provided by the embodiment of the present invention;
图3是现有技术中,使用白色背景灰色字体的屏幕显示示意图;Fig. 3 is a schematic diagram of a screen display using gray fonts on a white background in the prior art;
图4是现有技术中,使用黑色背景灰色字体的屏幕显示示意图。FIG. 4 is a schematic diagram of a screen display using gray fonts on a black background in the prior art.
具体实施方式Detailed ways
下面结合附图和实施例对本发明作进一步的详细说明。可以理解的是,此处所描述的具体实施例,仅仅用于解释本发明,而非对本发明的限定。The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the present invention, but not to limit the present invention.
实施例Example
为了更好的理解本发明,先介绍一下和本发明相关的背景知识,首先介绍RGB颜色模式,这种颜色模式是工业界的一种颜色标准,通过对红(R),绿(G),蓝(B)3个颜色通道的变化以及它们相互之间的叠加来得到各式各样的颜色。RGB即代表红,绿,蓝3个通道的颜色,这个标准几乎包括了人类视力所能感知的所有颜色,是目前运用最为广泛的颜色系统之一,RGB颜色模式适用于在屏幕上观看。In order to better understand the present invention, first introduce the background knowledge related to the present invention, first introduce the RGB color mode, this color mode is a kind of color standard in the industry, by red (R), green (G), Blue (B) The change of the three color channels and their superposition to get a variety of colors. RGB stands for the color of red, green, and blue channels. This standard includes almost all the colors that human vision can perceive. It is one of the most widely used color systems at present. The RGB color mode is suitable for viewing on the screen.
在RGB颜色模式中,颜色由红色、绿色、蓝色混合而成。将颜色由一个十六进制符号来定义,这个符号由红色、绿色和蓝色的值组成(RGB)。每种颜色的最小值是0(十六进制:#00)。最大值是255(十六进制:#FF)。用这些十六进制数可组成颜色的色值。In the RGB color model, colors are a mixture of red, green, and blue. Defines a color by a hexadecimal notation consisting of the values of red, green and blue (RGB). The minimum value for each color is 0 (hex: #00). The maximum value is 255 (hex: #FF). Use these hexadecimal numbers to compose the color value of the color.
色值指的是某种颜色在不同的颜色模式中所对应的颜色值。在电脑及移动终端的显示方面,可以使用颜色的色值改变背景色、文本颜色和链接颜色等。在RGB颜色模式中,用6位的十六进制数表示色值,前两位代表红色值,表示红色在此颜色中的分量,数越大表明含红色越多,中间两位代表绿色值,表示含绿色的分量,末尾两位代表蓝色值,表示含蓝色的分量,每个红色、绿色或蓝色值可以在00(没有那种颜色)到FF(完全是那种颜色)之间变化。如红色在RGB颜色模式中所对应的颜色色值转换成十进制数就是255,0,0(十六进制:#FF0000);绿色在RGB颜色模式中所对应的颜色色值转换成十进制数就是0,255,0(十六进制:#00FF00);蓝色在RGB颜色模式中所对应的颜色色值转换成十进制数就是0,0,255(十六进制:#0000FF)。The color value refers to the color value corresponding to a certain color in different color modes. In the display of computers and mobile terminals, the color value of the color can be used to change the background color, text color and link color, etc. In the RGB color mode, a 6-digit hexadecimal number is used to represent the color value. The first two digits represent the red value, indicating the component of red in this color. The larger the number, the more red it contains, and the middle two digits represent the green value. , indicating the component containing green, the last two digits represent the blue value, indicating the component containing blue, each red, green or blue value can be between 00 (no such color) to FF (completely that color) change between. For example, the color value corresponding to red in the RGB color mode is converted into a decimal number is 255, 0, 0 (hexadecimal: #FF0000); the color value corresponding to green in the RGB color mode is converted into a decimal number is 0, 255, 0 (hexadecimal: #00FF00); the color value corresponding to blue in the RGB color mode is converted into a decimal number is 0, 0, 255 (hexadecimal: #0000FF).
图1是本发明实施例提供的根据背景颜色自动改变字体颜色的方法流程图,如图1所示:一种根据背景颜色自动改变字体颜色的方法,包括:Fig. 1 is a flowchart of a method for automatically changing a font color according to a background color provided by an embodiment of the present invention, as shown in Fig. 1: a method for automatically changing a font color according to a background color, comprising:
步骤101:在背景中,取与字体边缘相邻的点作为参考点;Step 101: In the background, take a point adjacent to the edge of the font as a reference point;
一般情况下,背景的颜色不是单一的,所以只有与字体边缘相邻的背景的颜色会影响到与字体颜色的对比,所以在背景中,取与字体边缘相邻的点作为参考点。In general, the color of the background is not single, so only the color of the background adjacent to the edge of the font will affect the contrast with the font color, so in the background, take the point adjacent to the edge of the font as a reference point.
步骤102:获得所述所有参考点的颜色色值;Step 102: Obtain the color values of all the reference points;
提取所有参考点的颜色的色值。Extract the color values of the colors of all reference points.
步骤103:求所有参考点的颜色色值的平均值,作为背景颜色的平均色值;Step 103: Calculate the average value of the color values of all reference points as the average color value of the background color;
步骤103具体包括步骤1031~步骤1033:Step 103 specifically includes steps 1031 to 1033:
步骤1031:将用六位十六进制数表示的颜色色值的前两位作为一个十六进制数,求所述所有参考点颜色色值的前两位的平均值,并将平均值仍然以两位十六进制数表示,将得到的两位十六进制数作为背景颜色的平均色值背景平均色色值的前两位;Step 1031: use the first two digits of the color value represented by six hexadecimal numbers as a hexadecimal number, calculate the average value of the first two digits of the color values of all reference points, and calculate the average value It is still represented by a two-digit hexadecimal number, and the obtained two-digit hexadecimal number is used as the first two digits of the average color value of the background color;
在RGB颜色模式中,6位十六进制数的色值前两位代表红色值,表示红色在此颜色中的分量,可以在00到FF之间变化。因此,将前两位提取出来,并且求所有参考点颜色色值的前两位的平均值,求得的结果是所有参考点含红色分量的平均值。In the RGB color mode, the first two digits of the 6-digit hexadecimal value represent the red value, indicating the red component in this color, which can vary from 00 to FF. Therefore, the first two digits are extracted, and the average value of the first two digits of the color values of all reference points is calculated, and the obtained result is the average value of the red component of all reference points.
步骤1032:将用六位十六进制数表示的颜色色值的中间两位作为一个十六进制数,求所述所有参考点颜色色值的中间两位的平均值,并将平均值仍然以两位十六进制数表示,将得到的两位十六进制数作为背景颜色的平均色值背景平均色色值的中间两位;Step 1032: use the middle two digits of the color value represented by six hexadecimal numbers as a hexadecimal number, calculate the average value of the middle two digits of the color values of all reference points, and calculate the average value It is still expressed in two hexadecimal numbers, and the obtained two hexadecimal numbers are used as the middle two digits of the average color value of the background color;
在RGB颜色模式中,6位十六进制数的色值中间两位代表绿色值,表示含绿色的分量,可以在00到FF之间变化。将中间两位提取出来,并且求所有参考点颜色色值的中间两位的平均值,求得的结果是所有参考点含绿色分量的平均值。In the RGB color mode, the middle two digits of the 6-digit hexadecimal value represent the green value, indicating the green component, which can vary from 00 to FF. Extract the middle two digits, and calculate the average value of the middle two digits of the color values of all reference points, and the obtained result is the average value of the green components of all reference points.
步骤1033:将用六位十六进制数表示的颜色色值的末尾两位作为一个十六进制数,求所述所有参考点颜色色值的末尾两位的平均值,并将平均值仍然以两位十六进制数表示,将得到的两位十六进制数作为背景颜色的平均色值背景平均色色值的末尾两位;Step 1033: use the last two digits of the color value represented by six hexadecimal numbers as a hexadecimal number, calculate the average value of the last two digits of the color values of all reference points, and calculate the average It is still represented by a two-digit hexadecimal number, and the obtained two-digit hexadecimal number is used as the average color value of the background color, and the last two digits of the background average color value;
在RGB颜色模式中,6位十六进制数的色值末尾两位代表蓝色值,表示含蓝色的分量,可以在00到FF之间变化。将末尾两位提取出来,并且求所有参考点颜色色值的末尾两位的平均值,求得的结果是所有参考点含蓝色分量的平均值。In the RGB color mode, the last two digits of the color value of the 6-digit hexadecimal number represent the blue value, indicating the blue component, which can vary from 00 to FF. Extract the last two digits, and calculate the average value of the last two digits of the color values of all reference points. The result obtained is the average value of the blue component of all reference points.
步骤104:根据所述背景颜色的平均色值,求背景颜色的平均色值所代表的颜色所述背景平均色的反色色值;Step 104: According to the average color value of the background color, calculate the reverse color value of the background average color of the color represented by the average color value of the background color;
反色也称为补色,两种色光以适当比例混合,产生白色感觉,则这两种色光便是补色。在观察颜色的时候,补色会随时随地的跟着主色的出现而产生,这与视网膜上的感光细胞受到光刺激后的疲劳程度或是错觉有关。当人们注视色彩的时候,视觉范围内的各种颜色的色光便刺激视网膜上的锥状感光细胞,而产生所看到的色彩;但是视网膜上的锥状感光细胞一直受到同一色光刺激后,便会有刺激疲劳现象产生,形成补色。另外我们都知道环境色是影响物体色的因素之一,而环境色对物体颜色,最主要的影响是环境色和物体色的对比现象,引起物体色的变化。例如:将洋红色与绿色并列,会显示出洋红色的更红、绿色的更绿,这是因为在洋红色与绿色彼此交接的边缘分别引发其补色绿色和洋红色,所以加强了各别色彩的颜色,产生洋红色更红、绿色更绿的现象。由于颜色对比使得每一个颜色在自己的周围产生与自身颜色色相相反的对立色,此对立色实际上并不存在,这种现象的产生是视觉上的错觉造成的补色。我们将字体的颜色设置为背景色的补色就是为了使背景色和字体的颜色对比明显。Inverse color is also called complementary color, two kinds of shades are mixed in proper proportion to produce white feeling, then these two shades are complementary colors. When observing colors, complementary colors will follow the appearance of main colors anytime and anywhere, which is related to the degree of fatigue or illusion of photoreceptor cells on the retina after being stimulated by light. When people look at the color, the color light of various colors in the visual range stimulates the cone photoreceptor cells on the retina to produce the color they see; but the cone photoreceptor cells on the retina are stimulated by the same color light all the time, then There will be stimulation and fatigue phenomenon, forming a complementary color. In addition, we all know that the environment color is one of the factors that affect the object color, and the main influence of the environment color on the object color is the contrast phenomenon between the environment color and the object color, which causes the change of the object color. For example: juxtaposing magenta and green will show that magenta is redder and green is greener. This is because the complementary colors green and magenta are respectively triggered at the edge where magenta and green meet each other, so the colors of the respective colors are strengthened , resulting in redder magenta and greener green. Due to the color contrast, each color produces an opposite color that is opposite to its own color around itself. This opposite color does not actually exist. This phenomenon is the complementary color caused by visual illusions. We set the color of the font as the complementary color of the background color to make the contrast between the background color and the font color obvious.
我们知道两种色光以适当比例混合,产生白色就是互补色,而白色的色值是#FFFFFF,所以从色值的角度来看,将互补的两种颜色的前两位、中间两位和末尾两位分别相加排列后,得到的色值是#FFFFFF。We know that two color lights are mixed in an appropriate proportion to produce white as a complementary color, and the color value of white is #FFFFFF, so from the perspective of color value, the first two digits, the middle two digits and the end of the two complementary colors After the two bits are added and arranged respectively, the obtained color value is #FFFFFF.
步骤104具体包括步骤1041~步骤1043:Step 104 specifically includes steps 1041 to 1043:
步骤1041:用十六进制数FF减所述背景颜色的平均背景平均色色值的前两位,得到的差作为所述背景颜色的平均色值所代表颜色的背景平均色反色色值的前两位;Step 1041: Subtract the first two digits of the average background average color value of the background color from the hexadecimal number FF, and the obtained difference is used as the first two digits of the background average reverse color value of the color represented by the average color value of the background color two;
步骤1042:用十六进制数FF减所述背景颜色的平均背景平均色色值的中间两位,得到的差作为所述背景颜色的平均色值所代表颜色的背景平均色反色色值的中间两位;Step 1042: Subtract the middle two digits of the average background average color value of the background color from the hexadecimal number FF, and the obtained difference is used as the middle of the background average color inverse color value of the color represented by the average color value of the background color two;
步骤1043:用十六进制数FF减所述背景颜色的平均背景平均色色值的末尾两位,得到的差作为所述背景颜色的平均色值所代表颜色的背景平均色反色色值的末尾两位。Step 1043: Use the hexadecimal number FF to subtract the last two digits of the average background average color value of the background color, and the obtained difference is used as the end of the background average reverse color value of the color represented by the average color value of the background color two.
步骤105:根据所述背景颜色的平均色值背景平均色的反色色值,将字体颜色的色值设定为所述背景颜色的平均色值所代表的颜色背景平均色的反色色值。Step 105: According to the average color value of the background color and the reverse color value of the background average color, set the color value of the font color as the reverse color value of the background average color represented by the background color average color value.
图2是本发明实施例提供的根据背景颜色自动改变字体颜色的系统功能模块框图,如图2所示:Fig. 2 is a block diagram of system function modules that automatically change the font color according to the background color provided by the embodiment of the present invention, as shown in Fig. 2:
一种根据背景颜色自动改变字体颜色的系统,包括:参考点提取模块201,用于在背景中提取与字体边缘相邻的点作为参考点;色值获得模块202,用于获得参考点颜色的色值;第一计算模块203,用于求所有参考点颜色色值的平均值,作为背景颜色的平均色值;第二计算模块204,用于根据所述背景颜色的平均色值,求背景颜色的平均色值色所代表的颜色的反色色值;控制模块205,用于根据所述背景颜色的平均色值的反色色值,将字体颜色的色值设定为所述背景颜色的平均色值所代表的颜色的反色色值。A system for automatically changing the font color according to the background color, comprising: a reference
其中,第一计算模块203具体用于:Wherein, the
将用六位十六进制数表示的颜色色值的前两位作为一个十六进制数,求所述所有参考点颜色色值的前两位的平均值,并将平均值仍然以两位十六进制数表示,将得到的两位十六进制数作为背景颜色的平均色值背景平均色色值的前两位;在RGB颜色模式中,6位十六进制数的色值前两位代表红色值,表示红色在此颜色中的分量,可以在00到FF之间变化。因此,将前两位提取出来,并且求所有参考点颜色色值的前两位的平均值,求得的结果是所有参考点含红色分量的平均值。The first two digits of the color value represented by six hexadecimal numbers are used as a hexadecimal number, and the average value of the first two digits of the color values of all reference points is calculated, and the average value is still expressed in two One-digit hexadecimal number representation, the obtained two-digit hexadecimal number is used as the first two digits of the average color value of the background color; in the RGB color mode, the color value of the six-digit hexadecimal number The first two digits represent the red value, indicating the component of red in this color, which can vary from 00 to FF. Therefore, the first two digits are extracted, and the average value of the first two digits of the color values of all reference points is calculated, and the obtained result is the average value of the red component of all reference points.
将用六位十六进制数表示的颜色色值的中间两位作为一个十六进制数,求所述所有参考点颜色色值的中间两位的平均值,并将平均值仍然以两位十六进制数表示,将得到的两位十六进制数作为背景颜色的平均色值背景平均色色值的中间两位;在RGB颜色模式中,6位十六进制数的色值中间两位代表绿色值,表示含绿色的分量,可以在00到FF之间变化。将中间两位提取出来,并且求所有参考点颜色色值的中间两位的平均值,求得的结果是所有参考点含绿色分量的平均值。Use the middle two digits of the color value represented by the six-digit hexadecimal number as a hexadecimal number, calculate the average value of the middle two digits of the color values of all reference points, and use the average value in two The two-digit hexadecimal number indicates that the obtained two-digit hexadecimal number is used as the average color value of the background color, and the middle two digits of the background average color value; The middle two digits represent the green value, indicating the green component, which can vary from 00 to FF. Extract the middle two digits, and calculate the average value of the middle two digits of the color values of all reference points, and the obtained result is the average value of the green components of all reference points.
将用六位十六进制数表示的颜色色值的末尾两位作为一个十六进制数,求所述所有参考点颜色色值的末尾两位的平均值,并将平均值仍然以两位十六进制数表示,将得到的两位十六进制数作为背景颜色的平均色值背景平均色色值的末尾两位。在RGB颜色模式中,6位十六进制数的色值末尾两位代表蓝色值,表示含蓝色的分量,可以在00到FF之间变化。将末尾两位提取出来,并且求所有参考点颜色色值的末尾两位的平均值,求得的结果是所有参考点含蓝色分量的平均值。The last two digits of the color value represented by six hexadecimal numbers are used as a hexadecimal number, and the average value of the last two digits of the color values of all reference points is calculated, and the average value is still represented by two The two-digit hexadecimal number indicates that the obtained two-digit hexadecimal number is used as the average color value of the background color, and the last two digits of the background average color value. In the RGB color mode, the last two digits of the color value of the 6-digit hexadecimal number represent the blue value, indicating the blue component, which can vary from 00 to FF. Extract the last two digits, and calculate the average value of the last two digits of the color values of all reference points. The result obtained is the average value of the blue component of all reference points.
其中,第二计算模块204具体用于:Wherein, the
用十六进制数FF减所述背景颜色的平均背景平均色色值的前两位,得到的差作为所述背景颜色的平均色值所代表颜色的背景平均色反色色值的前两位;Use the hexadecimal number FF to subtract the first two digits of the average background average color value of the background color, and the difference obtained is used as the first two digits of the background average color reverse color value of the color represented by the average color value of the background color;
用十六进制数FF减所述背景颜色的平均背景平均色色值的中间两位,得到的差作为所述背景颜色的平均色值所代表颜色的背景平均色反色色值的中间两位;用十六进制数FF减所述背景颜色的平均背景平均色色值的末尾两位,得到的差作为所述背景颜色的平均色值所代表颜色的背景平均色反色色值的末尾两位。Use the hexadecimal number FF to subtract the middle two digits of the average background average color value of the background color, and the difference obtained is used as the middle two digits of the background average color inverse color value of the color represented by the average color value of the background color; The last two digits of the average background average color value of the background color are subtracted from the hexadecimal number FF, and the obtained difference is used as the last two digits of the background average reverse color value of the color represented by the average background color value.
本发明提供的技术方案,通过对背景中与字体边缘相邻的点的颜色色值求平均,作为背景平均色色值然后再求平均值的反色色值,将字体的颜色设定为反色,使得字体颜色与背景颜色搭配得当,字体易于辨认。In the technical solution provided by the present invention, by averaging the color values of points adjacent to the edge of the font in the background, as the average color value of the background and then calculating the average reverse color value, the color of the font is set as a reverse color, Make the font color match the background color properly, and the font is easy to recognize.
以上仅是针对本发明的优选实施例及其技术原理所做的说明,而并非对本发明的技术内容所进行的限制,任何熟悉本技术领域的技术人员在本发明所公开的技术范围内,所容易想到的变化或替换,都应涵盖在本发明的保护范围内。The above is only a description of the preferred embodiments of the present invention and its technical principles, rather than limitations on the technical content of the present invention. Any person familiar with the technical field is within the technical scope disclosed in the present invention. Any easily conceivable changes or substitutions shall fall within the protection scope of the present invention.
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN2013100400993ACN103151022A (en) | 2013-01-31 | 2013-01-31 | A method and system for automatically changing font color according to background color |
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN2013100400993ACN103151022A (en) | 2013-01-31 | 2013-01-31 | A method and system for automatically changing font color according to background color |
| Publication Number | Publication Date |
|---|---|
| CN103151022Atrue CN103151022A (en) | 2013-06-12 |
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN2013100400993APendingCN103151022A (en) | 2013-01-31 | 2013-01-31 | A method and system for automatically changing font color according to background color |
| Country | Link |
|---|---|
| CN (1) | CN103151022A (en) |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103544004A (en)* | 2013-08-01 | 2014-01-29 | Tcl集团股份有限公司 | Method and terminal for adjusting background color of icon according to color wheel |
| CN103731608A (en)* | 2013-12-27 | 2014-04-16 | 深圳英飞拓科技股份有限公司 | Character superimposition display method capable of supporting multiple colors and automatic color inverting |
| CN104679380A (en)* | 2013-11-30 | 2015-06-03 | 富泰华工业(深圳)有限公司 | System and method for adjusting background color of user interface |
| CN104967923A (en)* | 2015-06-30 | 2015-10-07 | 北京奇艺世纪科技有限公司 | Subtitle color setting method and device |
| CN105451094A (en)* | 2014-08-20 | 2016-03-30 | 深圳Tcl新技术有限公司 | Subtitle color adjusting method and device |
| CN106055336A (en)* | 2016-06-07 | 2016-10-26 | 青岛海信移动通信技术股份有限公司 | Method and device for setting color of status bar of mobile terminal |
| CN106775747A (en)* | 2016-12-28 | 2017-05-31 | Tcl集团股份有限公司 | A kind of method and apparatus of color configuration |
| CN107450920A (en)* | 2017-07-26 | 2017-12-08 | 上海爱数信息技术股份有限公司 | A kind of color settings method for merging background colour and text color |
| CN110060203A (en)* | 2019-04-22 | 2019-07-26 | 京东方科技集团股份有限公司 | Image display method, image display apparatus, electronic equipment and storage medium |
| CN111125999A (en)* | 2019-12-25 | 2020-05-08 | 上海云从企业发展有限公司 | Character color adjusting method, system, equipment and machine readable medium |
| CN112748576A (en)* | 2020-12-09 | 2021-05-04 | 上海博泰悦臻电子设备制造有限公司 | HUD display method, HUD display system, vehicle and medium |
| US11107258B2 (en) | 2018-07-20 | 2021-08-31 | Microsoft Technology Licensing, Llc. | Providing a dark viewing mode while preserving formatting |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US7184063B2 (en)* | 2004-09-01 | 2007-02-27 | Microsoft Corporation | Adaptive color schemes |
| CN101706718A (en)* | 2009-11-05 | 2010-05-12 | 中兴通讯股份有限公司 | Method and device for automatically changing desktop text color |
| CN102591848A (en)* | 2010-11-22 | 2012-07-18 | 微软公司 | Selection of foreground characteristics based on background |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US7184063B2 (en)* | 2004-09-01 | 2007-02-27 | Microsoft Corporation | Adaptive color schemes |
| CN101706718A (en)* | 2009-11-05 | 2010-05-12 | 中兴通讯股份有限公司 | Method and device for automatically changing desktop text color |
| CN102591848A (en)* | 2010-11-22 | 2012-07-18 | 微软公司 | Selection of foreground characteristics based on background |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN103544004B (en)* | 2013-08-01 | 2017-06-06 | Tcl集团股份有限公司 | A kind of icon background color tone adjusting method and terminal based on colour circle |
| CN103544004A (en)* | 2013-08-01 | 2014-01-29 | Tcl集团股份有限公司 | Method and terminal for adjusting background color of icon according to color wheel |
| CN104679380A (en)* | 2013-11-30 | 2015-06-03 | 富泰华工业(深圳)有限公司 | System and method for adjusting background color of user interface |
| CN103731608B (en)* | 2013-12-27 | 2017-02-08 | 深圳英飞拓科技股份有限公司 | Character superimposition display method capable of supporting multiple colors and automatic color inverting |
| CN103731608A (en)* | 2013-12-27 | 2014-04-16 | 深圳英飞拓科技股份有限公司 | Character superimposition display method capable of supporting multiple colors and automatic color inverting |
| CN105451094A (en)* | 2014-08-20 | 2016-03-30 | 深圳Tcl新技术有限公司 | Subtitle color adjusting method and device |
| CN105451094B (en)* | 2014-08-20 | 2018-11-02 | 深圳Tcl新技术有限公司 | Subtitle color adjustment method and device |
| CN104967923A (en)* | 2015-06-30 | 2015-10-07 | 北京奇艺世纪科技有限公司 | Subtitle color setting method and device |
| CN104967923B (en)* | 2015-06-30 | 2019-02-01 | 北京奇艺世纪科技有限公司 | A kind of method and device that subtitle color is set |
| CN106055336A (en)* | 2016-06-07 | 2016-10-26 | 青岛海信移动通信技术股份有限公司 | Method and device for setting color of status bar of mobile terminal |
| CN106775747A (en)* | 2016-12-28 | 2017-05-31 | Tcl集团股份有限公司 | A kind of method and apparatus of color configuration |
| CN106775747B (en)* | 2016-12-28 | 2020-03-24 | Tcl集团股份有限公司 | Color configuration method and device |
| CN107450920A (en)* | 2017-07-26 | 2017-12-08 | 上海爱数信息技术股份有限公司 | A kind of color settings method for merging background colour and text color |
| US11107258B2 (en) | 2018-07-20 | 2021-08-31 | Microsoft Technology Licensing, Llc. | Providing a dark viewing mode while preserving formatting |
| CN110060203A (en)* | 2019-04-22 | 2019-07-26 | 京东方科技集团股份有限公司 | Image display method, image display apparatus, electronic equipment and storage medium |
| CN111125999A (en)* | 2019-12-25 | 2020-05-08 | 上海云从企业发展有限公司 | Character color adjusting method, system, equipment and machine readable medium |
| CN112748576A (en)* | 2020-12-09 | 2021-05-04 | 上海博泰悦臻电子设备制造有限公司 | HUD display method, HUD display system, vehicle and medium |
| CN112748576B (en)* | 2020-12-09 | 2023-01-10 | 博泰车联网科技(上海)股份有限公司 | HUD display method, HUD display system, vehicle and medium |
| Publication | Publication Date | Title |
|---|---|---|
| CN103151022A (en) | A method and system for automatically changing font color according to background color | |
| Ibraheem et al. | Understanding color models: a review | |
| CN107680556B (en) | A kind of display power-economizing method, device and display | |
| CN110220674B (en) | Display screen health performance evaluation method and device | |
| CN104157261B (en) | Display mode adjustment method of display device and display mode adjustment module thereof | |
| CN102694958B (en) | Image hue determination method and wireless handheld device | |
| WO2017059732A1 (en) | Display device for adjusting display colour gamut and method for adjusting display colour gamut therefor | |
| CN105472364B (en) | The chrominance signal conversion method and device of LCDs | |
| CN102810306A (en) | An automatic control method for display screen wallpaper brightness | |
| CN113132696B (en) | Image tone mapping method, device, electronic device and storage medium | |
| JP2000293129A (en) | Display characteristic recognition device, display characteristic recognition program storage medium, display characteristic adjustment device, and display characteristic adjustment program storage medium | |
| WO2015172336A1 (en) | Display method and display system for image | |
| CN105451094B (en) | Subtitle color adjustment method and device | |
| US20130155121A1 (en) | White balance adjusting method | |
| CN106531097B (en) | A kind of medical display color rendition system and its implementation | |
| CN105654925B (en) | High dynamic range images processing method and system | |
| US20130229430A1 (en) | Method and device for simulation of image at oblique view angle | |
| Meng et al. | Proposal of minimization problem based lightness modification for protanopia and deuteranopia | |
| CN104144332A (en) | Image color adjusting method and electronic device thereof | |
| CN114663549A (en) | Image processing method, device, equipment and storage medium | |
| CN104101909B (en) | Dual-energy x-ray method for displaying image under a kind of HSL color spaces | |
| CN108765502B (en) | A Color Appearance Acquisition Method in a Complex Environment | |
| CN105654915B (en) | display method | |
| CN103021379A (en) | Method and system for color correction based on customized light source duty ratio | |
| CN100535984C (en) | Color image enhancement device and method |
| Date | Code | Title | Description |
|---|---|---|---|
| C06 | Publication | ||
| PB01 | Publication | ||
| C10 | Entry into substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| C12 | Rejection of a patent application after its publication | ||
| RJ01 | Rejection of invention patent application after publication | Application publication date:20130612 |