Patent ID: 12198659

DESCRIPTION OF EMBODIMENTS

Embodiments of this application provide a method for adjusting a display attribute, and a related device, to make a display effect of an element on a page more prominent, thereby improving reading experience of a user.

In the specification, claims, and accompanying drawings of this application, the terms “first”, “second”, “third”, “fourth”, and so on (if existent) are intended to distinguish between similar objects but do not necessarily indicate a specific order or sequence. It should be understood that the data termed in such a way are interchangeable in proper circumstances so that the embodiments of this application described herein can be implemented in other orders than the order illustrated or described herein. Moreover, the terms “include”, “have”, and any other variants mean to cover the non-exclusive inclusion, for example, a process, method, system, product, or device that includes a list of steps or units is not necessarily limited to those units, but may include other units not expressly listed or inherent to such a process, method, system, product, or device.

For ease of understanding, the following first describes an application scenario used in the embodiments of this application.

Generally, a user may set, based on preference of the user, a background of a page displayed by a terminal device. For example, the user may set a screen lock interface. As shown inFIG.1, the user may switch a background on a left side ofFIG.1to a background on a right side ofFIG.1. In this process, the user sets only the background of the page, and does not set an element displayed on the page. In this case, a contrast between the background on the right side ofFIG.1and the element of the page may not be obvious. As a result, the element is not prominently displayed in the background of the page. In this case, the terminal device may adjust the page by using the method provided in an embodiment of this application, so that the element can be prominently displayed on the background while the background set by the user is kept, thereby improving reading experience of the user.

In this embodiment, the terminal device is a device with a display apparatus, and the display apparatus may be a black-and-white display apparatus, or may be a color display apparatus. This is not limited herein. Specifically, the terminal device may be a mobile phone, a tablet computer, or another device with a display apparatus. In this embodiment and subsequent embodiments, only a terminal device is used as an example for description.

For ease of understanding, the following describes, with reference to the foregoing application scenario, a procedure of the method for adjusting a display attribute. Specifically, as shown inFIG.2, the terminal device performs the following steps.

201. Obtain a first luminance and a second luminance on a page.

The first luminance is a luminance of an element on the page. The second luminance is a luminance of a background region in which the element is displayed. The luminance refers to a degree of brightness and darkness of the page. The luminance is unrelated to a color of the page. UsingFIG.3Aas an example, in the figure, the luminance is divided into 12 levels, which gradually become darker from 50 to 900. When the darkest level is reached, the region is displayed as black, and when the brightest level is reached, the region is displayed as white. In actual application, if the terminal device divides the luminance into the 12 levels shown inFIG.3A, the first luminance and the second luminance may fall into one or two levels of the 12 levels. Certainly, due to a difference in actual application requirements, the terminal device may alternatively divide the luminance into more levels. This is not specifically limited herein.

In addition, the element includes a text or an icon. For ease of understanding, the following provides description with reference toFIG.3B. As shown inFIG.3B, the element may be a text, for example, numbers shown in301and Chinese characters shown in302. The element may alternatively be an icon, for example, an icon that represents a fingerprint shown in303. In actual application, the element may alternatively be another text or icon. This is not specifically limited herein.

Specifically, a region shown in301inFIG.3Bis used as an example. “06:00” in the dashed line region shown in301is the element, and a luminance of pixels of strokes that display “06:00” is the first luminance. A luminance of pixels other than “06:00” in the dashed line region shown in301is the second luminance.

In this embodiment, after the terminal device obtains the first luminance and the second luminance, the terminal device performs step202.

202. Determine a first contrast ratio between the element and the background region based on the first luminance and the second luminance.

In this embodiment, after obtaining the first luminance and the second luminance, the terminal device may determine the first contrast ratio between the element and the background region based on the first luminance and the second luminance. The contrast ratio refers to a difference in different brightness levels between brightest white and darkest black in bright and dark regions on the page. A larger difference indicates a larger contrast ratio, and a smaller difference indicates a smaller contrast.

Specifically, the terminal device may calculate the first contrast ratio by using a plurality of algorithms. This is not specifically limited herein. In this embodiment and subsequent embodiments, the first contrast ratio is determined by a ratio between luminances. For ease of understanding, the following provides description with reference to a specific example. Assuming that a value of the first luminance is less than that of the second luminance, in this case, the terminal device may calculate a ratio of the value of the second luminance to the value of the first luminance, to obtain the first contrast ratio. In this case, the terminal device may compare the first contrast ratio with a preset contrast ratio. The preset contrast ratio may be a contrast ratio preset during production of the terminal device, or may be a contrast ratio set by a user based on a use habit. This is not specifically limited herein. Generally, the preset contrast ratio may be set to 4.5:1. When the first contrast ratio is less than the preset contrast ratio, the terminal device performs step203.

203. Adjust a line thickness value of the element.

In this embodiment, the display attribute of the element includes the line thickness value of the element. Generally, a larger line thickness value indicates a thicker line.

Specifically, when the element is a text, the line thickness value of the element indicates a thickness of a stroke of the text. For example, a text shown inFIG.3Cmay be divided into a total of 12 values: 25 JF to 105 JF.

In addition, when the element is an icon, the line thickness value of the element indicates a line thickness of the icon. For example, a thickness value of an icon shown inFIG.3Dconstantly increases from left to right, and a line thickness of the icon also constantly increases.

In this embodiment, when the first contrast ratio is less than the preset contrast ratio, the terminal device may adjust the line thickness value of the element. Specifically, the terminal device may adjust the line thickness value of the element based on a preset correspondence and the first contrast ratio, where the preset correspondence is a correspondence between the first contrast ratio and the line thickness value of the element. More specifically, the terminal device may determine, based on a difference between the preset contrast ratio and the first contrast ratio, a quantity of thickness levels for adjustment. For ease of understanding, description is provided with reference to an example shown in Table 1.

TABLE 1PresetFirstSecondThirdcontrastcontrastcontrastcontrast—ratioratio 1ratio 2ratio 3—4.5:13:13.5:14:1Difference—1.510.5between thepreset contrastratio and thefirst contrastratioQuantity of—321thickness levelsfor adjustment

When the first contrast ratio is 3:1 and the preset contrast ratio is 4.5:1, because the first contrast ratio is less than the preset contrast ratio, the terminal device may calculate a difference between the preset contrast ratio and the first contrast ratio, and adjust the line thickness value of the element based on a correspondence between the difference and the quantity of thickness levels for adjustment in Table 1. For example, when the difference between the preset contrast ratio and the first contrast ratio is 1.5, the line thickness value of the element is increased by three levels. Assuming that an initial line thickness level of the element is55S shown inFIG.3C, a line thickness of the element is adjusted to70S.

In this embodiment, in addition to adjusting the line thickness value of the element based on the foregoing preset thickness levels, the terminal device may further calculate the thickness value based on the first luminance and the second luminance. For ease of understanding, the following formula is used as an example for description. It is assumed that when the second luminance is the darkest (that is, pure dark), the value of the second luminance is 0; when the second luminance is the brightest (that is, pure white), the value of the second luminance is 1000; and 570 is selected as a median value of the luminance. If preset line thickness values of the element are S0, S1000, and S570, when the second luminance changes, the line thickness value slof the element is as follows:

sl={s0+s5⁢7⁢0-s05⁢7⁢0⁢l0<l<570s5⁢7⁢0+s1⁢0⁢0⁢0-s5⁢7⁢04⁢3⁢0⁢(l-570)5⁢70<l<1000

Specifically, in actual application, the calculation formula may vary with an application scenario. This is not specifically limited herein.

In this embodiment, for ease of understanding, only the element301shown inFIG.3Bis used as an example to display an adjustment effect. After the terminal device adjusts the line thickness value of the element in the foregoing manner, for a display effect of the page, refer toFIG.4A. A left side ofFIG.4Ashows an element whose line thickness value is not adjusted, and a right side ofFIG.4Ashows an element whose line thickness value is adjusted. In this case, lines of the element on the page become thicker, so that the user can more easily distinguish, during reading, the element from the background in which the element is displayed. Therefore, reading experience of the user can be appropriately improved.

204. Adjust a luminance of the element.

Step204is an optional step, and there is no explicit limitation on a time sequence between step204and step203.

When the first contrast ratio is less than the preset contrast ratio, the terminal device adjusts the luminance of the element, where the element is a text or an icon. Specifically, the terminal device may adjust the luminance of the element to a first target luminance, where a second contrast ratio between the first target luminance and the luminance of the background region is greater than the preset contrast ratio. For ease of understanding, the following provides description with reference to a specific example. It is assumed that the first luminance is less than the second luminance, the first luminance is 100, and the second luminance is 300. In this case, a ratio of the second luminance to the first luminance is 3:1, which is less than 4.5:1. Therefore, the terminal device adjusts the first luminance to the first target luminance, provided that the first target luminance is less than 100. of understanding, the element301shown inFIG.3Bis still used as an example to display an adjustment effect. After the terminal device adjusts the luminance of the element in the foregoing manner, for a display effect of the page, refer toFIG.4B. A left side ofFIG.4Bshows an element whose luminance is not adjusted, and a right side ofFIG.4Bshows an element whose luminance is adjusted. In this case, lines of the element on the page become brighter, so that the user can more easily distinguish, during reading, the element from the background in which the element is displayed. Therefore, reading experience of the user can be appropriately improved.

205. Set a shadow of the element.

Step205is an optional step, and there is no explicit limitation on a time sequence between step205and steps203and204.

When the first contrast ratio is less than the preset contrast ratio, the terminal device may set the shadow of the element, where a color of the shadow is different from that of the element. For ease of understanding, in this embodiment, the element301shown inFIG.3Bis still used as an example to display an adjustment effect. After the terminal device adjusts the shadow of the element in the foregoing manner, for a display effect of the page, refer toFIG.4CandFIG.4D. A left side ofFIG.4Cand a left side ofFIG.4Dshow an element whose shadow is not adjusted. A right side ofFIG.4Cshows a scenario in which the shadow overlaps a text. In this case, the shadow forms outer edge lines of the text. A right side ofFIG.4Dshows a scenario in which the shadow does not completely overlap the text. In this case, an effect of illuminating the text by a light source on the left side is presented. In actual application, the terminal device may further set another type of shadow effect, to meet preference requirements of different users.

206. Adjust a luminance of the background region.

Step206is an optional step, and there is no explicit limitation on a time sequence between step206and steps203to205.

In this embodiment, when the first contrast ratio is less than the preset contrast ratio, the terminal device may adjust the luminance of the background region to a second target luminance, where a third contrast ratio between the second target luminance and the luminance of the element is greater than the preset contrast ratio. For ease of understanding, the following provides description with reference to a specific example. It is assumed that the first luminance is less than the second luminance, the first luminance is 100, and the second luminance is 300. In this case, a ratio of the second luminance to the first luminance is 3:1, which is less than 4.5:1. Therefore, the terminal device adjusts the second luminance to a second target luminance, provided that the second target luminance is less than 100.

In this embodiment, the element301shown inFIG.3Bis still used as an example to display an adjustment effect. After the terminal device adjusts the luminance of the background region in the foregoing manner, for a display effect of the page, refer toFIG.4E. A left side ofFIG.4Eshows an element that is not adjusted, and a right side ofFIG.4Eshows an effect obtained after the luminance of the background region is adjusted. In this case, because the background region becomes darker, lines of the element on the page become brighter, so that the user can more easily distinguish, during reading, the element from the background in which the element is displayed. Therefore, reading experience of the user can be appropriately improved.

The foregoing describes the method for adjusting a display attribute in this embodiment of this application. The following describes a terminal device used in the method for adjusting a display attribute. Specifically, as shown inFIG.5, the terminal device50includes:an obtaining module501, configured to obtain a first luminance and a second luminance on a page, where the first luminance is a luminance of an element on the page, and the second luminance is a luminance of a background region in which the element is displayed;a determining module502, configured to determine a first contrast ratio between the element and the background region based on the first luminance and the second luminance; andan adjustment module503, configured to adjust a display attribute of the element when the first contrast ratio is less than a preset contrast ratio.

In this embodiment of this application, the terminal device may determine the first contrast ratio between the element and the background region based on the luminance of the element and the luminance of the background region, and adjust the display attribute of the element when the first contrast ratio is less than the preset contrast ratio. Therefore, the display attribute of the element may vary with a display attribute of the background region of the element, so that a probability that a display effect of the element in the background is not prominent due to a decrease in the contrast ratio between the element and the background region may be reduced, thereby improving reading experience of a user.

Optionally, the element includes a text or an icon. In this implementation, a specific implementation of the element is specified, which may be a text or may be an icon.

Optionally, the display attribute of the element includes a line thickness value of the element. In this implementation, the display attribute of the element is specified. The terminal device may adjust the line thickness value of the element, so that the element can be displayed on the page relatively prominently.

In a feasible implementation, the adjustment module503is specifically configured to adjust a line thickness value of the element based on a preset correspondence and the first contrast ratio, where the preset correspondence is a correspondence between the first contrast ratio and the line thickness value of the element. In this implementation, a specific implementation of adjusting the line thickness value is specified. The terminal device may adjust the line thickness value based on the first contrast ratio, so that the element corresponding to the adjusted line thickness value can be prominently displayed on the page, thereby improving reading experience of a user.

In another feasible implementation, the display attribute of the element further includes the luminance of the element; and the adjustment module503is further configured to adjust the luminance of the element to a first target luminance, where a second contrast ratio between the first target luminance and the luminance of the background region is greater than the preset contrast ratio. In this implementation, in addition to adjusting the line thickness value of the element, the terminal device may further adjust the first luminance, that is, adjust the luminance of the element, so that a line of the element can become brighter or darker while becoming thicker.

In another feasible implementation, the display attribute of the element further includes a shadow of the element; and the adjustment module503is further configured to set the shadow of the element, where a color of the shadow is different from that of the element. In this implementation, in addition to adjusting the line thickness value of the element and the luminance of the element, the terminal device may further set the shadow for the element, so that the element can be prominently displayed on the page, thereby improving reading experience of a user.

In another feasible implementation, the adjustment module503is further configured to adjust the luminance of the background region to a second target luminance, where a third contrast ratio between the second target luminance and the luminance of the element is greater than the preset contrast ratio. In this implementation, in addition to adjusting the line thickness value of the element and the luminance of the element, and setting the shadow, the terminal device may further adjust the luminance of the background region, so that the element can be prominently displayed on the page, thereby improving reading experience of a user.

This embodiment provides a schematic structural diagram of another terminal device60. The terminal device60may be a mobile terminal device with a display apparatus, or may be a chip or a system-on-a-chip in the mobile terminal device.

The terminal device60includes a processor601and a memory602. The memory602is configured to store programs. The processor601is configured to execute the programs in the memory602, to implement functions of the terminal device in the method embodiments of this application.

The processor601may include one or more processors. The memory602may include one or more storage media (for example, one or more mass storage devices).

Optionally, the terminal device60further includes an input/output interface603. The input/output interface603may be used for communication between the terminal device60and another device. Power supply604is connected to each of the processor601, memory602and input/output interface603to provide suitable power to each of these components.

It should be further understood that, in the method embodiment corresponding toFIG.2, steps performed by the terminal device may be based on the structure of the terminal device60shown inFIG.6.

An embodiment of this application further provides a computer program product including instructions. When the instructions are run on a computer, the computer is enabled to perform functions of the foregoing communications devices.

All or some of the foregoing embodiments may be implemented by using software, hardware, firmware, or any combination thereof. When software is used to implement the embodiments, the embodiments may be implemented completely or partially in a form of a computer program product.

An embodiment of this application provides a computer-readable storage medium. The computer-readable storage medium is configured to store the foregoing instructions, so that the computer can run the instructions to implement functions of the foregoing communications devices.

It may be clearly understood by persons skilled in the art that, for the purpose of convenient and brief description, for a detailed working process of the foregoing system, device, module or unit, refer to a corresponding process in the foregoing method embodiments, and details are not described herein again.

The foregoing embodiments are merely intended for describing the technical solutions of this application, but not for limiting this application. Although this application is described in detail with reference to the foregoing embodiments, persons of ordinary skill in the art should understand that they may still make modifications to the technical solutions described in the foregoing embodiments or make equivalent replacements to some technical features thereof, without departing from the spirit and scope of the technical solutions of the embodiments of this application.