Dark mode generation method for user interface, electronic device and storage medium
By applying dark processing to the target images in the user interface, especially images consisting of logos and text, the problem of text not being able to be displayed clearly in dark mode is solved, and a clear display effect in dark mode is achieved.
Patent Information
- Application Number
- CN202010880273.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-27
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2040-08-27
AI Technical Summary
After the user interface switches to dark mode, the text in the image cannot be displayed clearly, especially the pictures composed of logos and text, which makes the content unable to be presented clearly.
By identifying the target image in the user interface, it is determined that it is an image with a transparent background and colors including dark and non-dark colors, and the target image is brightened using the first dark processing method. At the same time, other images are inverted or inverted in brightness using the second dark processing method to ensure that the content is clearly displayed in dark mode.
The clear display of the target image in dark mode is achieved, the algorithm complexity of identifying the target image is reduced, and the image recognition rate is improved.
Smart Images

Figure CN114119778B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a method for generating a dark mode of a user interface and an electronic device. Background Art
[0002] The user interfaces of current electronic devices usually have a dark mode (e.g., night mode). There are two main ways to implement dark mode: one is for application developers to adapt a dark theme as the dark mode of the electronic device, and the other is for the electronic device's system to automatically convert the colors of the graphics, text, and images of the application (Force Dark, Auto Dark, or Smart Dark) to generate a dark mode. However, when the user interface includes dark content, after switching to dark mode, the original dark content will not be clearly displayed.
[0003] For example, reference Figure 1 As shown, when a user interface includes a picture composed of a logo and text, after the user interface is switched to dark mode, the text in the picture will be affected by the background of the dark mode, resulting in the text in the picture not being clearly displayed in the dark mode. For example, Figure 1 The image includes the logo and the words "Read Books". Figure 1 After switching the picture to dark mode, only the logo can be displayed, and the text content of "Reading Bar" in the picture cannot be clearly presented. Summary of the Invention
[0004] In view of the above, it is necessary to provide a dark mode generation method for a user interface and an electronic device to brighten pictures, text, etc. in the dark mode so that they can be clearly presented in the dark mode.
[0005] In a first aspect, an embodiment of the present application provides a method for generating a dark mode of a user interface, specifically comprising:
[0006] Get the view data of the user interface;
[0007] classifying the view data into graphics, texts and images according to view elements;
[0008] Determining whether each of the images is a target image, wherein the target image is an image with a transparent background and a color including dark and non-dark colors;
[0009] Performing dark processing on the target image according to a first dark processing method to brighten the target image;
[0010] The graphics, the text, and images other than the target image are respectively subjected to dark processing according to a second dark processing method.
[0011] In an embodiment of the present application, a target image with a transparent background and colors including dark and non-dark colors can be identified from the images contained in the user interface, and the target image can be dark-processed according to a first dark processing method to brighten the target image, thereby clearly displaying the image content of the dark part of the target image.
[0012] In one possible design, determining whether each of the images is a target image specifically includes:
[0013] Dividing each of the images into a first predetermined number of blocks;
[0014] Set the sampling point for color sampling in each block;
[0015] Sampling the colors of the sampling points of each block of each image in sequence according to a preset scanning order to obtain the colors of the sampling points of each block;
[0016] Determine the color type of each block according to the color of the sampling point of each block, wherein the color type includes dark block, light block, colored block and transparent block;
[0017] Determine whether the proportion of the number of dark color blocks in each of the images to all blocks in each of the images is greater than a preset threshold; and
[0018] If the number of dark-color blocks in each of the images is greater than a preset threshold, each of the images is determined to be a target image.
[0019] Through the above technical solution, the target image in the image can be quickly identified, reducing the complexity of the algorithm for identifying the target image.
[0020] In a possible design, the sampling points for color sampling in each block are set to include:
[0021] The points at the upper left, upper right, lower left, lower right, and center of each block are used as sampling points. The sampling points obtained by the above technical solution can accurately represent the color characteristics of each block.
[0022] In a possible design, sampling the colors of the sampling points of each block of each image in sequence according to a preset scanning order to obtain the colors of the sampling points of each block specifically includes:
[0023] determining a size type of each image according to an aspect ratio of each image, wherein the size type includes a first type and a second type, the first type being that the image width is greater than the image height, and the second type being that the image height is not less than the image width;
[0024] When the size type of each image is the first type, sampling the colors of the sampling points of each block of each image in sequence from bottom to top and from right to left; and
[0025] When the size type of each image is the second type, the colors of the sampling points of each block of each image are sampled in sequence from right to left and from bottom to top.
[0026] In a possible design, determining the color type of each block according to the color of the sampling point of each block specifically includes:
[0027] Get the argb values of all sampling points in each block;
[0028] Get the brightness values of all sampling points in each block;
[0029] If the alpha channel value in the argb values of all sampling points of each block is 0, the block is determined to be a transparent block;
[0030] If the alpha channel value in the argb values of all sampling points of each block is not 0 and the brightness values of all sampling points are less than a preset brightness threshold, the block is determined to be a dark block;
[0031] If the alpha channel value in the argb value of all sampling points of each block is not 0 and the brightness value of all sampling points is not less than the preset brightness threshold, the block is determined to be a light-colored block;
[0032] If the block is not a transparent block, a dark block, or a light block, it is determined to be a colored block.
[0033] Through the above technical solution, the recognition rate of the color type of each block can be improved.
[0034] In a possible design, performing dark processing on the target image according to the first dark processing manner specifically includes:
[0035] Acquire pixels of the target image;
[0036] Multiply the pixels of the target image by the pixel matrix, where the pixel matrix is Where s is the color value scaling ratio, r_offset is the offset of the red value, g_offset is the offset of the green value, and b_offset is the offset of the blue value. Through the above technical solution, the dark part of the target image can be effectively brightened.
[0037] In a possible design, performing dark processing on the graphics, the text, and the images other than the target image according to the second dark processing method specifically includes:
[0038] The graphics, the text, and the images other than the target image are respectively subjected to inverted color processing. Through the inverted color processing, the graphics, the text, and the images other than the target image in the user interface can be subjected to dark color processing.
[0039] In a possible design, performing dark processing on the graphics, the text, and the images other than the target image according to the second dark processing manner specifically includes:
[0040] The graphics, the text, and the images other than the target image are respectively subjected to inverse brightness processing. Through the inverse brightness processing, the graphics, the text, and the images other than the target image in the user interface can be subjected to dark color processing.
[0041] In a second aspect, an embodiment of the present application provides an electronic device, comprising a device for executing the steps executed in the method of the above-mentioned first aspect and any possible design thereof.
[0042] In a third aspect, an embodiment of the present application provides a computer storage medium storing program instructions. When the program instructions are run on an electronic device, the electronic device executes the method for generating a dark mode of a user interface in the first aspect of the embodiment of the present application and any possible design thereof.
[0043] In addition, the technical effects brought about by the second to third aspects can be found in the descriptions of the methods of each design in the above method section, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 This is a schematic diagram of performing dark processing on an image according to an embodiment of the present invention.
[0045] Figure 2 Schematic diagram of the connection between the electronic device and the server in an embodiment of the present invention.
[0046] Figure 3 This is a flowchart of a method for generating a dark mode for a user interface according to an embodiment of the present invention.
[0047] Figure 4 2 is a schematic diagram of a process for performing dark color processing on a target image in an embodiment of the present invention.
[0048] Figure 5 Schematic diagram of the target image determination process in an embodiment of the present invention.
[0049] Figure 6a FIG. 4 is a schematic diagram of dividing an image into blocks according to an embodiment of the present invention.
[0050] Figure 6b FIG. 4 is a schematic diagram of setting block sampling points in an embodiment of the present invention.
[0051] Figures 7a-7b , which is a schematic diagram of determining a preset scanning order of an image in an embodiment of the present invention.
[0052] Figure 8 FIG. 4 is a schematic diagram of a process for determining the color type of a block in an embodiment of the present invention.
[0053] Figure 9 Schematic diagram of a target image after dark color processing according to an embodiment of the present invention.
[0054] Figure 10 Schematic diagram of the structure of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION
[0055] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or design schemes. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a concrete way.
[0056] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application belongs. The terms used in the specification of this application are for the purpose of describing specific embodiments only and are not intended to limit the invention. It should be understood that, unless otherwise specified in this application, " / " means or. For example, A / B can mean A or B. "And / or" in this application is merely a way to describe the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. "At least one" means one or more. "Multiple" means two or more than two. For example, at least one of a, b or c can mean: a, b, c, a and b, a and c, b and c, a, b and c.
[0057] refer to Figure 2FIG. 1 is a schematic diagram showing the connection between the electronic device 10 and the server 20 in one embodiment of the present invention. Figure 2 As shown, the electronic device 10 exchanges data with the server 20. For example, the electronic device 10 sends a data request instruction to the server 20, and the server 20 responds to the instruction by sending data to the electronic device 10. In this way, the server 20 provides the electronic device 10 with view data.
[0058] In this embodiment, the electronic device 10 is communicatively connected to the server 20 via a communication module. For example, the electronic device 10 is communicatively connected to the server 20 via a Wi-Fi communication module, a 3G\4G\5G communication module. For example, the electronic device 10 and the server 20 are in the same local area network, and the electronic device 10 and the server 20 are connected to the same router. For another example, the electronic device 10 and the server 20 may not be in the same local area network, the electronic device 10 is in a first local area network and is connected to a first router, and the server 20 is connected to a second local area network and is connected to a second router, wherein the first router is connected to the second router.
[0059] In this embodiment, the electronic device 10 is a mobile phone, a tablet computer, a laptop computer, a personal digital assistant, a wearable device, etc. The server 20 is a single server, a server cluster, or a cloud server.
[0060] The electronic device 10 is configured to obtain user interface view data and classify the user interface view data into graphics, text, and images. The electronic device 10 uses an image with a transparent background and a combination of dark and non-dark colors as a target image. The electronic device 10 performs dark processing on the user interface and brightens the target image, so that the target image in the user interface of the electronic device 10 can be clearly displayed in dark mode.
[0061] refer to Figure 3 As shown in FIG, it is a flow chart of a method for generating a dark mode of a user interface according to an embodiment of the present invention. Figure 3 As shown, the dark mode generation method of the user interface is applied in the electronic device 10. The dark mode generation method of the user interface provided in the present application is specifically implemented in the following steps.
[0062] Step S301: Acquire view data of the user interface.
[0063] In one embodiment, the electronic device 10 obtains user interface view data from the server 20. Specifically, the electronic device 10 sends a command requesting access to the user interface to the server 20, and the server 20 sends the user interface view data to the electronic device 10 in response to the command requesting access to the user interface. In another embodiment, the electronic device 10 stores the user interface view data in its memory, and the electronic device 10 obtains the user interface view data from the memory. In this embodiment, the electronic device 10 displays the obtained user interface view data.
[0064] Step S302: Classify the view data into graphics, text, and images according to view elements.
[0065] In this embodiment, view data refers to a rectangular block displayed on the display unit of the electronic device 10, such as graphics, text, images or videos. View data can be nested in a hierarchical relationship. In this embodiment, the electronic device 10 classifies the nested view data into graphics, text and images according to the view elements according to the nesting level of the view tree. In this embodiment, the graphics include a frame of the user interface, the text is a plain text content including numbers, letters, symbols, text, or any combination of numbers, letters, symbols, and text, and the image includes an icon, a text image, and a combination of an icon and a text image. In this embodiment, the number of the images is one or more.
[0066] Step S303 , determining whether each of the images is a target image, wherein the target image is an image with a transparent background and a color including dark and non-dark colors.
[0067] In this embodiment, the dark color is a low-purity color, such as black, red, and blue. The non-dark color is a high-purity color, such as pink, white, and yellow. In this embodiment, the background of the target image is transparent and the colors of the target image include dark colors and non-dark colors.
[0068] The detailed process of determining whether each image is a target image can be referred to Figure 5 And the following for Figure 5 Detailed description.
[0069] Step S304: Perform dark processing on the target image according to the first dark processing method to brighten the target image. The detailed process of the first dark processing method can be referred to Figure 4 And the following for Figure 4 Detailed description.
[0070] Step S305 , performing dark processing on the graphics, the text, and the images other than the target image according to a second dark processing method.
[0071] In this embodiment, performing dark processing on the graphics, text, and images other than the target image in accordance with the second dark processing method includes inverting the graphics, text, and images other than the target image. In this embodiment, for ease of description, the images other than the target image are referred to as second images.
[0072] Specifically, the electronic device 10 respectively obtains the three primary colors (RGB) values of the graphic, the three primary colors values of the text, and the three primary colors values of the second image; performs calculation processing on the three primary colors values of the graphic through the formula (R1, G1, B1) = (255, 255, 255) - (r1, g1, b1) to achieve inversion processing of the graphic, wherein (r1, g1, b1) are the three primary colors values of the obtained graphic, (R1, G1, B1) are the three primary colors values of the graphic after inversion processing, and (255, 255, 255) are the three primary colors values corresponding to white; and performs calculation processing on the three primary colors values of the graphic through the formula (R2, G2, B2) = (255, 255, 2 55)-(r2, g2, b2) are performed on the three primary color values of the text to achieve inversion processing of the text, wherein (r2, g2, b2 are the obtained three primary color values of the text, and (R2, G2, B2) are the three primary color values of the text after inversion processing; and the three primary color values of the second image are performed on the three primary color values through the formula (R3, G3, B3) = (255, 255, 255)-(r3, g3, b3) to achieve inversion processing of the second image, wherein (r3, g3, b3) are the obtained three primary color values of the second image, and (R3, G3, B3) are the three primary color values of the second image after inversion processing.
[0073] For example, the electronic device 10 obtains the three primary color values of the graphic as (239, 228, 176) (the corresponding color is light yellow), and performs inversion processing on the graphic by subtracting the three primary color values of white (255, 255, 255) from (239, 228, 176). After the inversion processing, the three primary color values of the graphic are (16, 27, 79) (the corresponding color is dark blue).
[0074] For another example, the electronic device 10 obtains the three primary color values of the text as (255, 255, 255) (corresponding to white), and performs inversion processing on the text by subtracting the three primary color values of white (255, 255, 255) from (255, 255, 255). After the inversion processing, the three primary color values of the text are (0, 0, 0) (corresponding to black). For example, the electronic device 10 obtains the three primary color values of the second image as (153, 217, 234) (corresponding to light cyan), and performs inversion processing on the second image by subtracting the three primary color values of white (255, 255, 255) from (153, 217, 234). After the inversion processing, the three primary color values of the second image are (102, 38, 21) (corresponding to dark reddish brown).
[0075] In another embodiment, performing dark processing on the graphics, the text, and the second image according to a second dark processing method includes: performing inverse brightness processing on the graphics, the text, and the second image.
[0076] Specifically, in one embodiment, the electronic device 10 respectively obtains the L channel value of the LAB color space of the graphic, the L channel value of the LAB color space of the text, and the L channel value of the LAB color space of the second image; calculates and processes the L channel value of the LAB color space of the graphic through the formula Y1=100-y1 to implement the inverse brightness processing of the graphic, wherein y1 is the L channel value of the LAB color space of the acquired graphic, and Y1 is the L channel value of the LAB color space of the graphic after the inverse brightness processing; calculates and processes the L channel value of the LAB color space of the graphic through the formula Y2=100-y2 The L channel value of the LAB color space of the text is calculated and processed to implement the inverse brightness processing of the text, wherein y2 is the obtained L channel value of the LAB color space of the text, and Y2 is the L channel value of the LAB color space of the text after the inverse brightness processing; the L channel value of the LAB color space of the second image is calculated and processed by the formula Y3=100-y3 to implement the inverse brightness processing of the second image, wherein y3 is the obtained L channel value of the LAB color space of the second image, and Y3 is the L channel value of the LAB color space of the second image after the inverse brightness processing. For example, the electronic device 10 obtains the L channel value of the LAB color space of the graphic as 50, and implements the inverse brightness processing of the graphic through the calculation processing of Y1=100-50=50. After the inverse brightness processing, the L channel value of the LAB color space of the graphic is 80.
[0077] In another embodiment, performing inverse brightness processing on the graphic, the text and the second image includes: the electronic device 10 respectively obtains the grayscale value of the graphic, the grayscale value of the text and the grayscale value of the second image; calculating and processing the grayscale value of the graphic through the formula T1=255-t1 to achieve inverse brightness processing on the graphic, wherein t1 is the obtained grayscale value of the graphic, and T1 is the grayscale value of the graphic after inverse brightness processing; calculating and processing the grayscale value of the text through the formula T2=255-t2 to achieve inverse brightness processing on the text, wherein t2 is the obtained grayscale value of the text, and T2 is the grayscale value of the text after inverse brightness processing; calculating and processing the grayscale value of the second image through the formula T3=255-t3 to achieve inverse brightness processing on the second image, wherein t3 is the obtained grayscale value of the second image, and T3 is the grayscale value of the second image after inverse brightness processing.
[0078] For example, the electronic device 10 obtains a grayscale value of 175 for the text, and performs inverse brightness processing on the text through a calculation of T2=255-175=80. After the inverse brightness processing, the grayscale value of the text is 80.
[0079] refer to Figure 4 , which is a schematic diagram of a process for performing dark processing on a target image according to an embodiment of the present invention, may specifically include the following steps:
[0080] Step S401, obtaining pixels of the target image;
[0081] Step S402: Multiply the pixels of the target image by a pixel matrix, wherein the pixel matrix is Where s is the scaling ratio of the color value, r_offset is the offset of the red value, g_offset is the offset of the green value, and b_offset is the offset of the blue value. In this embodiment, s is set to 0.7, and r_offset, g_offset, and b_offset are set to 70.
[0082] refer to Figure 5 , which is a schematic diagram of a process for determining whether each image in the image is a target image in one embodiment of the present invention. Specifically, the following steps may be included:
[0083] Step S501, dividing each image into a first preset number of blocks;
[0084] Step S502, setting the sampling points for color sampling in each block;
[0085] Step S503, sampling the colors of the sampling points of each block of each image in sequence according to a preset scanning order to obtain the colors of the sampling points of each block;
[0086] Step S504: determine the color type of each block according to the color of the sampling point of each block, wherein the color type includes dark block, light block, color block and transparent block. The association between color and color type can be pre-set. For detailed process, please refer to Figure 8 And the following for Figure 8 Detailed description of
[0087] Step S505 determines whether the percentage of dark color blocks in each image is greater than a preset threshold. For example, the preset threshold may be 40%. The electronic device 10 determines whether the percentage of dark color blocks in each image is greater than 40% of the percentage of dark color blocks in each image. In other embodiments, the preset threshold may be set to other values, such as 30%, 50%, etc., as needed.
[0088] If the proportion of the number of dark blocks in each image to all blocks in each image is greater than a preset threshold, step S506 is executed; if the proportion of the number of dark blocks in each image to all blocks in each image is less than or equal to the preset threshold, step S507 is executed; and
[0089] Step S506: Determine whether the image is a target image.
[0090] Step S507: Determine whether the image is a target image.
[0091] refer to Figure 6a FIG2 is a schematic diagram of dividing an image into blocks according to an embodiment of the present invention. In this embodiment, each image is divided into blocks of the same size, for example, each image is divided into M*N blocks.
[0092] refer to Figure 6b , which is a schematic diagram of setting sampling points for blocks according to an embodiment of the present invention. In this embodiment, the points located at the upper left, upper right, lower left, lower right, and center of each block are used as sampling points. In this embodiment, the electronic device 10 determines the size type of each image based on the aspect ratio of each image, determines a corresponding preset scanning order based on the size type of each image, and sequentially samples the colors of the sampling points of each block of each image according to the determined preset scanning order to obtain the colors of the sampling points of each block.
[0093] refer to Figures 7a-7bAs shown in FIG, it is a schematic diagram of determining the corresponding preset scanning order according to the size type of the image in an embodiment of the present invention. Figure 7a As shown, the electronic device 10 determines the size type of each image according to the aspect ratio of each image, and when it is determined that the image width of each image is greater than the image height, the size type of each image is determined to be the first type, and when the size type of each image is determined to be the first type, the size type of each image is determined to be the first type in the order from bottom to top and from right to left (see Figure 7a The arrow M1 in FIG1 samples the colors of the sampling points of each block of each image in sequence.
[0094] like Figure 7b As shown, when the electronic device 10 determines that the image width of each image is less than or equal to the image height, the size type of each image is determined to be the second type, and when the size type of each image is determined to be the second type, the size type of each image is determined to be the second type, from right to left and from bottom to top (see Figure 7b The colors of the sampling points of each block of each image are sampled in sequence as shown in the arrow M2 in FIG.
[0095] In this embodiment, since the blocks between the first and last rows or the first and last columns of each image often do not contain important user interface information after each image is divided into blocks, it is not necessary to sample the blocks between the first and last rows or the first and last columns of each image. Specifically, when it is determined that the size type of each image is the first type, the electronic device 10 samples all blocks from the second row to the second-to-last row of each image in order from bottom to top and from right to left; when it is determined that the size type of each image is the second type, the electronic device 10 samples all blocks from the second column to the second-to-last column of each image in order from right to left and from bottom to top.
[0096] refer to Figure 8 , which is a flow chart showing a process of determining the color type of a block based on the color of the sampling points of the block in one embodiment of the present invention. Specifically, the process may include the following steps:
[0097] Step S801, obtaining the argb values of all sampling points of each block, where the argb values include the alpha channel value, the red channel value, the green channel value, and the blue channel value. The alpha channel value indicates that the sampling point is transparent, the red channel value indicates the red value of the sampling point, the green channel value indicates the green value of the sampling point, and the blue channel value indicates the blue value of the sampling point.
[0098] Step S802, obtaining the brightness values of all sampling points in each block;
[0099] Step S803 , if the alpha channel value in the argb values of all sampling points of each block is 0, the block is determined to be a transparent block;
[0100] Step S804 , if the alpha channel value in the argb values of all sampling points of each block is not 0 and the brightness values of all sampling points are less than a preset brightness threshold, the block is determined to be a dark block;
[0101] Step S805 , if the alpha channel value in the argb values of all sampling points of each block is not 0 and the brightness values of all sampling points are not less than a preset brightness threshold, the block is determined to be a light-colored block;
[0102] Step S806 : If the block is not a transparent block, a dark block, or a light block, it is determined to be a colored block.
[0103] refer to Figure 9 , which is a schematic diagram showing a target image after dark processing according to the first dark processing method in one embodiment of the present invention. Figure 9 As shown, after multiplying the pixels of the target image with the pixel matrix shown, the dark part in the target image, namely the text content of "xxx Agricultural Bank", can be brightened, and the text content in the target image can be clearly displayed.
[0104] Please refer to Figure 10 , shown is a schematic structural diagram of an electronic device 10 provided in one embodiment of the present invention. The electronic device 10 includes, but is not limited to, a communication module 12, a display unit 13, a processor 14, and a memory 15. The above-mentioned components can be connected via one or more communication buses 16. The memory 15 is used to store one or more computer programs 17. The one or more computer programs 17 are configured to be executed by the processor 14. The one or more computer programs 17 include instructions, and the above-mentioned instructions can be used to execute the various steps of the above-mentioned method for generating a dark mode of the user interface by the electronic device 10 in the above-mentioned embodiment, so as to realize the dark mode generation function of the user interface of the electronic device 10.
[0105] This embodiment further provides a computer storage medium, which stores computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the above-mentioned related method steps to implement the unlocking control method in the above-mentioned embodiment.
[0106] This embodiment further provides a computer program product. When the computer program product is run on a computer, the computer is caused to execute the above-mentioned related steps to implement the unlocking control method in the above-mentioned embodiment.
[0107] In addition, an embodiment of the present application also provides a device, which can specifically be a chip, component or module, and the device may include a connected processor and memory; wherein the memory is used to store computer-executable instructions, and when the device is running, the processor can execute the computer-executable instructions stored in the memory to enable the chip to execute the unlocking control method in the above-mentioned method embodiments.
[0108] Among them, the electronic device, computer storage medium, computer program product or chip provided in this embodiment is used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above, and will not be repeated here.
[0109] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0110] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0111] The units described as separate components may or may not be physically separate, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0112] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0113] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0114] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not limiting. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention.
Claims
1. A method for generating a dark mode of a user interface, characterized in that: The method comprises: Get the view data of the user interface; Classifying the view data into graphics, texts and images according to view elements; Determining whether each of the images is a target image, wherein the target image is an image with a transparent background and a color including dark and non-dark colors; Performing dark processing on the target image according to a first dark processing method; performing dark processing on the graphics, the text, and images other than the target image according to a second dark processing method; The step of determining whether each of the images is a target image comprises: Dividing each of the images into a first predetermined number of blocks; Set the sampling point for color sampling in each block; Determining a size type of each image according to an aspect ratio of each image, and sequentially sampling the colors of sampling points of each block of each image according to a preset scanning order corresponding to the size type to obtain the colors of the sampling points of each block; Determine the color type of each block according to the color of the sampling point of each block; If the proportion of the number of dark color blocks in each of the images to all blocks in each of the images is greater than a preset threshold, each of the images is determined to be a target image.
2. The method for generating a dark mode of a user interface according to claim 1, wherein: The color types include dark blocks, light blocks, colored blocks, and transparent blocks.
3. The method for generating a dark mode of a user interface according to claim 1, wherein: The setting of the sampling points for color sampling of each block includes: The points at the upper left position, upper right position, lower left position, lower right position and center position of each block are taken as sampling points.
4. The method for generating a dark mode of a user interface according to claim 1, wherein: The size type includes a first type and a second type, the first type being that the image width is greater than the image height, and the second type being that the image height is not less than the image width, and the sampling of the colors of the sampling points of each block of each image in sequence according to the preset scanning order corresponding to the size type, to obtain the colors of the sampling points of each block includes: When the size type of each of the images is the first type, sampling the colors of the sampling points of each block of each of the images in sequence from bottom to top and from right to left; and When the size type of each image is the second type, the colors of the sampling points of each block of each image are sampled in sequence from right to left and from bottom to top.
5. The method for generating a dark mode of a user interface according to claim 1, wherein: Determining the color type of each block according to the color of the sampling point of each block includes: Get the argb values of all sampling points in each block; Get the brightness values of all sampling points in each block; If the alpha channel value in the argb values of all sampling points of each block is 0, the block is determined to be a transparent block; If the alpha channel value in the argb values of all sampling points of each block is not 0 and the brightness values of all sampling points are less than a preset brightness threshold, the block is determined to be a dark block; If the alpha channel value in the argb value of all sampling points of each block is not 0 and the brightness value of all sampling points is not less than the preset brightness threshold, the block is determined to be a light-colored block; If the block is not a transparent block, a dark block, or a light block, it is determined to be a colored block.
6. The method for generating a dark mode of a user interface according to claim 1, wherein: The performing dark processing on the target image according to the second dark processing method includes: Acquire pixels of the target image; Multiply the pixels of the target image by the pixel matrix, where the pixel matrix is , where s is the scaling factor of the color value, r_offset is the offset of the red value, g_offset is the offset of the green value, and b_offset is the offset of the blue value.
7. The method for generating a dark mode of a user interface according to claim 1, wherein: The step of performing dark processing on the graphics, the text, and the images other than the target image according to the second dark processing method comprises: The graphics, the text, and the images other than the target image are respectively subjected to color inversion processing.
8. The method for generating a dark mode of a user interface according to claim 1, wherein: The step of performing dark processing on the graphics, the text, and the images other than the target image according to the second dark processing method comprises: The graphics, the text and the images other than the target image are respectively subjected to inverse brightness processing.
9. An electronic device, characterized in that: The electronic device comprises a memory and a processor: Wherein, the memory is used to store program instructions; The processor is used to read and execute the program instructions stored in the memory. When the program instructions are executed by the processor, the electronic device executes the dark mode generation method for the user interface as described in any one of claims 1 to 8.
10. A computer storage medium, characterized in that The computer storage medium stores program instructions, and when the program instructions are executed on an electronic device, the electronic device executes the method for generating a dark mode of a user interface according to any one of claims 1 to 8.
Citation Information
Patent Citations
Dark mode display interface processing method, electronic equipment and storage medium
CN110609722A
Mode generation method, computing device and storage medium
CN111427573A
Display control method and device, computer readable medium and terminal equipment
CN111552451A