CN107358637B - Character drawing method and device, terminal and storage medium - Google Patents

Character drawing method and device, terminal and storage medium Download PDF

Info

Publication number
CN107358637B
CN107358637B CN201710508903.4A CN201710508903A CN107358637B CN 107358637 B CN107358637 B CN 107358637B CN 201710508903 A CN201710508903 A CN 201710508903A CN 107358637 B CN107358637 B CN 107358637B
Authority
CN
China
Prior art keywords
pixel point
component
target
color
transparency
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710508903.4A
Other languages
Chinese (zh)
Other versions
CN107358637A (en
Inventor
李华东
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chengdu kugou business incubator management Co.,Ltd.
Original Assignee
Guangzhou Kugou Computer Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangzhou Kugou Computer Technology Co Ltd filed Critical Guangzhou Kugou Computer Technology Co Ltd
Priority to CN201710508903.4A priority Critical patent/CN107358637B/en
Publication of CN107358637A publication Critical patent/CN107358637A/en
Application granted granted Critical
Publication of CN107358637B publication Critical patent/CN107358637B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/001Texturing; Colouring; Generation of texture or colour
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/60Editing figures and text; Combining figures or text

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Image Generation (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The invention discloses a character drawing method and device, a terminal and a storage medium, and belongs to the technical field of image processing. The method comprises the following steps: drawing the characters to be drawn on the temporary base map by adopting the preset color value of each pixel point of the characters to be drawn; comparing whether the color component of the first pixel point on the temporary base map is different from the pre-configured color component of the corresponding pixel point of the character to be drawn; if the color component of the first pixel point on the temporary base map is different from the color component which is configured in advance of the corresponding pixel point of the character to be drawn, determining the target color value of the second pixel point, wherein the target color value is obtained based on the color component of the first pixel point and the transparency of the target base map; and drawing a second pixel point on the target base map by adopting the target color value. The invention makes the color of the drawn characters closer to the expected color, and improves the accuracy of the color of the drawn characters. The invention is used for drawing characters on the image.

Description

Character drawing method and device, terminal and storage medium
Technical Field
The present invention relates to the field of image processing technologies, and in particular, to a method and an apparatus for rendering text, a terminal, and a storage medium.
Background
In order to improve the display effect of the image, it is usually necessary to draw a text with a preset transparency and a preset color value in the target base map of the image. In the related art, a Graphic Device Interface (GDI) and a text rendering function are used to render a text having a predetermined transparency and color value in a target base map having a certain transparency and color.
Since the related art does not consider the influence of the target base map on the drawn text when the text is drawn, a certain difference may occur between the color of the text drawn in the target base map and the expected color.
Disclosure of Invention
In order to solve the problem that the influence of the target base map on the drawn characters is not considered in the related art, which may cause a certain difference between the color of the characters drawn in the target base map and the expected color, embodiments of the present invention provide a character drawing method and apparatus, a terminal, and a storage medium. The technical scheme is as follows:
in a first aspect, a method for drawing a text is provided, including:
the method comprises the steps that a preset color value of each pixel point of a character to be drawn is adopted, the character to be drawn is drawn on a temporary base map, each character consists of a plurality of pixel points, the color value comprises a transparency component and a plurality of color components, the transparency component and the color component of all the pixel points in the temporary base map are both 0, and the character to be drawn is a character to be drawn on a target base map;
comparing whether the color component of a first pixel point on the temporary base map is different from the pre-configured color component of a corresponding pixel point of the character to be drawn, wherein the first pixel point is any pixel point drawn on the temporary base map;
if the color component of a first pixel point on the temporary base map is different from the color component configured in advance of a corresponding pixel point of the character to be drawn, determining a target color value of a second pixel point, wherein the target color value is obtained based on the color component of the first pixel point and the transparency of the target base map, and the second pixel point is the pixel point of the character to be drawn corresponding to the first pixel point;
and drawing a second pixel point on the target base map by adopting the target color value.
Optionally, the contrast between the target color value and the target base map is smaller than the contrast between the color value of the first pixel point and the target base map.
Optionally, the target color values comprise: determining a target color value of the second pixel point includes:
acquiring a transparency component of the target base map;
acquiring a transparency component of the first pixel point, wherein the transparency component of the first pixel point is determined according to the color component of the first pixel point;
and determining the target transparency component according to the transparency component of the target base map and the transparency component of the first pixel point.
Optionally, the target color values comprise: a plurality of color components of the object are selected,
the determining a target color value of the second pixel point further includes:
judging whether the target transparency component is larger than a first color component, wherein the first color component is any one of a plurality of color components of the first pixel point;
when the target transparency component is larger than the first color component, determining the target transparency component as a first target color component, wherein the first target color component is a target color component corresponding to the first color component in the plurality of target color components.
Optionally, the method further comprises:
determining the first color component as the first target color component when the target transparency component is not greater than the first color component.
Optionally, the method further comprises:
and if the color component of the first pixel point is not different from the pre-configured color component of the corresponding pixel point of the character to be drawn, drawing the second pixel point on the target base map by adopting the color value of the first pixel point.
Optionally, the obtaining the transparency component of the first pixel point includes:
determining an average value of a plurality of color components of the first pixel point;
and determining the average value as the transparency component of the first pixel point.
Optionally, the determining the target transparency component according to the transparency component of the target base map and the transparency component of the first pixel point includes:
based on the transparency component of the target base map and the transparency component of the first pixel point, determining the target transparency component according to a target transparency component calculation formula, wherein the target transparency component calculation formula is as follows: TargetA ═ (1- (1-textA/255) × (1-backsa/255)) × 255;
wherein, the targetA is the target transparency component, the textA is the transparency component of the first pixel point, and the backsA is the transparency component of the target base map.
Optionally, the plurality of color components comprises: a red color component, a green color component, and a blue color component.
In a second aspect, there is provided a text drawing apparatus comprising:
the system comprises a first drawing module, a second drawing module and a third drawing module, wherein the first drawing module is used for drawing characters to be drawn on a temporary base map by adopting a preset color value of each pixel point of the characters to be drawn, each character consists of a plurality of pixel points, the color value comprises a transparency component and a plurality of color components, the transparency component and the color component of all the pixel points in the temporary base map are both 0, and the characters to be drawn are characters to be drawn on a target base map;
the comparison module is used for comparing whether the color component of a first pixel point on the temporary base map is different from the pre-configured color component of a corresponding pixel point of the character to be drawn or not, wherein the first pixel point is any pixel point drawn on the temporary base map;
a determining module, configured to determine a target color value of a second pixel point if a color component of a first pixel point on the temporary base map differs from a preconfigured color component of a corresponding pixel point of the character to be drawn, where the target color value is obtained based on the color component of the first pixel point and a transparency of the target base map, and the second pixel point is a pixel point of the character to be drawn corresponding to the first pixel point;
and the second drawing module is used for drawing a second pixel point on the target base map by adopting the target color value.
Optionally, the contrast between the target color value and the target base map is smaller than the contrast between the color value of the first pixel point and the target base map.
Optionally, the target color values comprise: a target transparency component, the determining module comprising:
the first obtaining submodule is used for obtaining a transparency component of the target base map;
the second obtaining submodule is used for obtaining the transparency component of the first pixel point, and the transparency component of the first pixel point is determined according to the color component of the first pixel point;
and the first determining submodule is used for determining the target transparency component according to the transparency component of the target base map and the transparency component of the first pixel point.
Optionally, the target color values comprise: a plurality of color components of the object are selected,
the determining module further comprises:
the judgment submodule is used for judging whether the target transparency component is larger than a first color component, wherein the first color component is any one of a plurality of color components of the first pixel point;
a second determining sub-module, configured to determine the target transparency component as a first target color component when the target transparency component is greater than the first color component, where the first target color component is a target color component corresponding to the first color component in the multiple target color components.
Optionally, the determining module further comprises:
a third determining sub-module for determining the first color component as the first target color component when the target transparency component is not greater than the first color component.
Optionally, the apparatus further comprises:
and the third drawing module is used for drawing the second pixel point on the target base map by adopting the color value of the first pixel point if the color component of the first pixel point is not different from the color component which is configured in advance of the corresponding pixel point of the character to be drawn.
Optionally, the second obtaining sub-module is specifically configured to:
determining an average value of a plurality of color components of the first pixel point;
and determining the average value as the transparency component of the first pixel point.
Optionally, the first determining submodule is specifically configured to:
based on the transparency component of the target base map and the transparency component of the first pixel point, determining the target transparency component according to a target transparency component calculation formula, wherein the target transparency component calculation formula is as follows: TargetA ═ (1- (1-textA/255) × (1-backsa/255)) × 255;
wherein, the targetA is the target transparency component, the textA is the transparency component of the first pixel point, and the backsA is the transparency component of the target base map.
Optionally, the plurality of color components comprises: a red color component, a green color component, and a blue color component.
In a third aspect, a storage medium is provided, where instructions are stored, and when the storage medium runs on a computer, the computer is caused to execute the text drawing method according to any one of the first aspect.
In a fourth aspect, a terminal is provided, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the method for drawing a text according to any one of the first aspect is implemented.
The technical scheme provided by the embodiment of the invention has the following beneficial effects:
in the text rendering method and apparatus, the terminal and the storage medium provided in the embodiments of the present invention, by comparing whether a color component of a first pixel point on the temporary base map differs from a color component of a corresponding pixel point of the text to be rendered, when the color component of the first pixel point differs from a transparency of the target base map, a target color value of a pixel point corresponding to the first pixel point of the text to be rendered is determined based on the color component of the first pixel point and the transparency of the target base map, and a target color value is used to render a second pixel point on the target base map.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a flowchart of a text rendering method according to an embodiment of the present invention;
FIG. 2 is a flow chart of another text rendering method according to an embodiment of the present invention;
fig. 3 is a flowchart of a method for determining a target color value of a second pixel according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a character drawn on a target base graph according to a preconfigured color value by a related-art character drawing method;
fig. 5 is a schematic diagram of a text drawn on a target base graph according to a preconfigured color value by using the text drawing method according to the embodiment of the present invention;
fig. 6 is a schematic structural diagram of a text rendering apparatus according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of a determining module according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of another text rendering apparatus according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail with reference to the accompanying drawings.
In some application scenarios, in order to improve the display effect of the displayed image, it is generally required to draw a text with a certain transparency and color in the target base map of the image, for example: when making a poster, some characters need to be drawn in the target base map with the pattern so as to improve the display effect of the poster. In the related art, when a GDI and a text drawing function are used to draw a text in a target base map with a certain transparency and color, since the influence of the target base map on the drawn text is not considered, a difference between the color of the text drawn in the target base map and an expected color may occur, for example: when black characters are drawn on a white target base map with certain transparency by using the GDI and the character drawing function, the drawn characters have black outlines, and the colors of the drawn characters are different from expected colors because the black outlines are not the contents originally intended to be drawn. To solve the problem, the embodiment of the invention provides a character drawing method. Fig. 1 is a flowchart of a text rendering method according to an embodiment of the present invention, and as shown in fig. 1, the method may include:
step 101, drawing the character to be drawn on the temporary base map by using the preset color value of each pixel point of the character to be drawn.
Each character consists of a plurality of pixel points, the color value comprises a transparency component and a plurality of color components, the transparency components and the color components of all the pixel points in the temporary base map are 0, and the character to be drawn is the character to be drawn on the target base map.
And 102, comparing whether the color component of the first pixel point on the temporary base map is different from the pre-configured color component of the corresponding pixel point of the character to be drawn.
The first pixel point is any pixel point drawn on the temporary base map.
And 103, if the color component of the first pixel point on the temporary base map is different from the pre-configured color component of the corresponding pixel point of the character to be drawn, determining the target color value of the second pixel point.
The target color value is obtained based on the color component of the first pixel point and the transparency of the target base map, and the second pixel point is a pixel point of the character to be drawn, which corresponds to the first pixel point.
And 104, drawing a second pixel point on the target base map by adopting the target color value.
In summary, in the text rendering method provided in the embodiment of the present invention, by comparing whether there is a difference between a color component of a first pixel point on the temporary base map and a color component configured in advance for a pixel point corresponding to the text to be rendered, and when there is a difference between the two, based on the transparency of the color component of the first pixel point and the target base map, a target color value of the pixel point corresponding to the first pixel point of the text to be rendered is determined, and a target color value is used to render a second pixel point on the target base map.
Fig. 2 is a flowchart of another text rendering method according to an embodiment of the present invention, and as shown in fig. 2, the method may include:
step 201, using the preset color value of each pixel point of the character to be drawn, drawing the character to be drawn on the temporary base map.
Wherein, the color value of pixel point can include transparency component and a plurality of color component, and this a plurality of color component can include: the embodiment of the present invention does not limit this, and the transparency components and the color components of all pixel points in the temporary base map may be 0, so that the influence on the color values of the pixel points drawn on the temporary base map may be reduced to a greater extent.
For example, assuming that the preconfigured color value of a certain pixel point of the text to be rendered is (255, 0, 0), the pixel point may be rendered on the temporary base map by using the color value (255, 0, 0).
Step 202, obtaining a color value of a first pixel point drawn on the temporary base map.
When a first pixel point is drawn on a temporary base map, the first pixel point is generally drawn in the neighborhood of the drawn pixel point, the color value of the drawn pixel point may have a certain influence on the color value of the first pixel point, the influence is usually expressed as making the color of the drawn first pixel point brighter, so that the color value of the drawn first pixel point is smaller than the pre-configured color value, that is, the color component of the first pixel point may be different from the pre-configured color component, therefore, before the pixel point of the character to be drawn is drawn on the target base map, the color value of the first pixel point drawn on the temporary base map needs to be obtained first, and then whether a plurality of color components in the color value of the first pixel point on the temporary base map are different from the pre-configured color component of the corresponding pixel point of the character to be drawn or not needs to be compared, and then determining how to draw a pixel point corresponding to the first pixel point of the character to be drawn on the target base map according to the comparison result.
Step 203, comparing whether the color component of the first pixel point on the temporary base map is different from the pre-configured color component of the corresponding pixel point of the character to be drawn.
When any color component of the first pixel point is not equal to the corresponding color component of the corresponding pixel point of the character to be drawn, the color component of the first pixel point is considered to be different from the color component of the corresponding pixel point of the character to be drawn, and at this time, step 204 is executed; when all the color components of the first pixel point are equal to the color components pre-configured for the corresponding pixel point of the character to be drawn, it can be determined that there is no difference between the color components, and at this time, step 206 is executed.
Exemplarily, assuming that the color value of the first pixel point is (128, 128, 2), the preconfigured color component of the corresponding pixel point of the text to be drawn is (255, 0, 0), when comparing the red color component of the color value, the red color component of the first pixel point is 128, the preconfigured red color component of the corresponding pixel point of the text to be drawn is 255, and it is known that the color component of the first pixel point is different from the preconfigured color component of the corresponding pixel point of the text to be drawn, step 204 is executed.
And 204, if the color component of the first pixel point on the temporary base map is different from the pre-configured color component of the corresponding pixel point of the character to be drawn, determining the target color value of the second pixel point.
Because the target color value is obtained based on the color component of the first pixel point and the transparency of the target base map, the obtained target color value comprehensively considers the influence of the color component of the first pixel point and the target base map, and the contrast between the target color value and the target base map is smaller than the contrast between the color value of the first pixel point and the target base map. Optionally, the target color values may include: a target transparency component. Specifically, as shown in fig. 3, the process of determining the target color value of the second pixel point may include:
and 2041, obtaining a transparency component of the target base map.
In the method for drawing characters provided by the embodiment of the invention, the characters are drawn on the target base map drawn with the image, and the transparency component and the color component of the pixel point in the image of the target base map drawn with the image are known, so that the transparency component of the target base map can be obtained by detecting the transparency component of the pixel point and the like. Illustratively, assume that the transparency component of the acquired target base map is 191.
Step 2042, the transparency component of the first pixel point is obtained.
Optionally, the transparency component of the first pixel point may be determined according to the color component of the first pixel point, specifically, an average value of the color components may be determined according to the color components of the first pixel point, and then the average value is determined as the transparency component of the first pixel point.
For example, assuming that the color value of the first pixel is (128, 128, 2), and the average value of the 3 color components is (128+128+2)/3 ═ 86, the average value 86 may be determined as the transparency component of the first pixel, i.e., the obtained transparency component of the first pixel is 86.
And 2043, determining a target transparency component according to the transparency component of the target base map and the transparency component of the first pixel point.
Specifically, the target transparency component may be determined according to a target transparency component calculation formula based on the transparency component of the target base map and the transparency component of the first pixel point, where the target transparency component calculation formula is: TargetA ═ (1- (1-textA/255) × (1-backsa/255)) × 255.
Wherein, targetA is the transparency component of the target, textA is the transparency component of the first pixel point, and back A is the transparency component of the target base map.
For example, assuming that the transparency component backsa of the target base map is 191 and the transparency component textA of the first pixel point is 86, the target transparency component TargetA is (1- (1-86/255) × (1-191/255)) × 255 is 213.
Step 2044, determine whether the target transparency component is greater than the first color component.
The first color component is any one of the color components of the first pixel, that is, the first color component may be any one of a red color component, a green color component, or a blue color component.
Optionally, the target color value of the second pixel point may be determined according to the target transparency component and the first color component, and the determined target color value and the target transparency component determined in step 2043 form the target color value of the second pixel point together. Specifically, it may be determined whether the target transparency component is greater than the first color component, and when the target transparency component is greater than the first color component, step 2045 is performed, and when the target transparency component is not greater than the first color component, step 2046 is performed.
Exemplarily, assuming that the first color component is 128, the target transparency component is 213, and the target transparency component is greater than the first color component, step 2045 is performed.
Step 2045, when the target transparency component is greater than the first color component, determine the target transparency component as the first target color component.
The first target color component is a target color component corresponding to the first color component in the plurality of target color components.
When the target transparency component is larger than the first color component, the target transparency component is closer to the pre-configured color component, and therefore, the target transparency component can be determined as the first target color component to reduce the difference between the color of the drawn text and the expected color.
For example, assuming that the first color component is 128, the target transparency component is 213, and the target transparency component is greater than the first color component, the target transparency component may be determined as the first target color component, i.e., the first target color component is 213.
As can be seen from the above, the preconfigured color component of a certain pixel of the text to be drawn is 255, the corresponding first color component of the first pixel drawn on the temporary base map is 128, and the corresponding first target color component is 213, and the first target color component is closer to the preconfigured color component than the first color component drawn on the temporary base map, and when the pixel is drawn on the target base map by using the color component, the difference between the color of the drawn text and the preconfigured color can be reduced.
Step 2046, when the target transparency component is not greater than the first color component, determine the first color component as the first target color component.
When the target transparency component is not larger than the first color component, the first color component is closer to the pre-configured color component, and therefore, the first color component can be determined as the first target color component, so as to reduce the difference between the color of the drawn text and the expected color.
For example, assuming that the first color component is 228, the target transparency component is 213, and the target transparency component is smaller than the first color component, the first color component may be determined as the first target color component, i.e., the first target color component is 228.
In practical application, in the process of determining the target color value of the second pixel point, only step 2041 to step 2043 may be included, that is, the target transparency component may be determined only according to the transparency component of the target base map and the transparency component of the first pixel point, and then the determined target transparency component and the plurality of color components of the first pixel point are determined as the target color value of the second pixel point, so as to reduce the difference between the color of the drawn text and the expected color to a certain extent.
In practical applications, steps 2044 to 2046 may be performed on each color component of the first pixel, which is only an example of the first color component in the embodiment of the present invention, and the determining process of the target color component of the other color components in the first pixel may refer to the determining process of the first target color component, which is not described in detail in the embodiment of the present invention.
And step 205, drawing a second pixel point on the target base map by adopting the target color value.
After the target color value of the second pixel point is determined according to the color component of the first pixel point and the transparency of the target base map, the second pixel point can be drawn according to the determined target color value.
For example, assuming that on a white target base map (whose color value is (0, 0, 0)), the preconfigured color of each pixel point of the text to be drawn is black (whose color value is (255, 255, 255)), referring to fig. 4 for a schematic diagram of the text drawn on the target base map according to the preconfigured color value by using a text drawing method of the related art, referring to fig. 5 for a schematic diagram of the text drawn on the target base map according to the preconfigured color value by using a text drawing method provided by an embodiment of the present invention, as can be obtained by comparing fig. 4 and fig. 5, a layer of black shadow appears on the text drawn by using a text drawing method of the related art, and the difference between the color of the drawn text and the preconfigured color value is large, the text drawn by using the text drawing method provided by the embodiment of the present invention has almost no shadow, and the difference between the color of the drawn character and the preset color value is smaller, so that the color of the character drawn by using the character drawing method provided by the embodiment of the invention is closer to the expected color, and the accuracy of the color of the drawn character is improved.
And step 206, if the color component of the first pixel point is not different from the color component of the corresponding pixel point of the character to be drawn, drawing a second pixel point on the target base map by adopting the color value of the first pixel point.
The color component of the first pixel point and the color component of the corresponding pixel point of the character to be drawn which is configured in advance do not have difference, that is, the color component of the first pixel point and the color component of the corresponding pixel point of the character to be drawn which is configured in advance are equal, when the character is drawn according to the color component, the influence of the target base map on the drawn character can be reduced to the minimum, therefore, the color value of the first pixel point can be adopted to directly draw the second pixel point on the target base map.
In practical applications, steps 201 to 206 may be performed on each pixel point of the text to be drawn, the embodiment of the present invention is only described with reference to the first pixel point as an example, and the drawing process of other pixel points of the text to be drawn may refer to the drawing process of the first pixel point, which is not described in detail in the embodiment of the present invention.
In summary, in the text rendering method provided in the embodiment of the present invention, by comparing whether there is a difference between a color component of a first pixel point on the temporary base map and a color component configured in advance for a pixel point corresponding to the text to be rendered, and when there is a difference between the two, based on the transparency of the color component of the first pixel point and the target base map, a target color value of the pixel point corresponding to the first pixel point of the text to be rendered is determined, and a target color value is used to render a second pixel point on the target base map.
It should be noted that the order of the steps of the text drawing method provided by the embodiment of the present invention may be appropriately adjusted, and the steps may also be increased or decreased according to the situation. Any method that can be easily conceived by those skilled in the art within the technical scope of the present disclosure is covered by the protection scope of the present disclosure, and thus, the detailed description thereof is omitted.
An embodiment of the present invention provides a text drawing apparatus, as shown in fig. 6, the apparatus 600 may include:
the first drawing module 601 is configured to draw the text to be drawn on the temporary base map by using a preconfigured color value of each pixel point of the text to be drawn, where each text is composed of a plurality of pixel points, the color value includes a transparency component and a plurality of color components, the transparency component and the color component of all the pixel points in the temporary base map are both 0, and the text to be drawn is the text to be drawn on the target base map.
The comparing module 602 is configured to compare whether there is a difference between a color component of a first pixel point on the temporary base map and a color component configured in advance for a corresponding pixel point of the text to be drawn, where the first pixel point is any pixel point drawn on the temporary base map.
The determining module 603 is configured to determine a target color value of a second pixel point if a color component of a first pixel point on the temporary base map differs from a preconfigured color component of a corresponding pixel point of the text to be drawn, where the target color value is obtained based on the color component of the first pixel point and a transparency of the target base map, and the second pixel point is a pixel point of the text to be drawn corresponding to the first pixel point.
And a second rendering module 604, configured to render a second pixel point on the target base map by using the target color value.
In summary, in the text rendering apparatus provided in the embodiment of the present invention, the comparison module compares whether the color component of the first pixel point on the temporary base map is different from the color component of the corresponding pixel point of the text to be rendered, and when the color component of the first pixel point is different from the color component of the target base map, the determination module determines the target color value of the pixel point corresponding to the first pixel point of the text to be rendered, and the second rendering module renders the second pixel point on the target base map by using the target color value.
Optionally, the contrast between the target color value and the target base map is smaller than the contrast between the color value of the first pixel point and the target base map.
Optionally, the target color values comprise: the target transparency component, as shown in fig. 7, the determining module 603, may include:
the first obtaining sub-module 6031 is configured to obtain a transparency component of the target base map.
The second obtaining sub-module 6032 is configured to obtain a transparency component of the first pixel point, where the transparency component of the first pixel point is determined according to the color component of the first pixel point.
The first determining submodule 6033 is configured to determine a transparency component of the target according to the transparency component of the target base map and the transparency component of the first pixel point.
Optionally, the target color values comprise: the plurality of target color components, as shown in fig. 7, the determining module 603 may further include:
the determining submodule 6034 is configured to determine whether the target transparency component is greater than a first color component, where the first color component is any color component of the multiple color components of the first pixel point.
The second determining sub-module 6035 is configured to determine the target transparency component as the first target color component when the target transparency component is larger than the first color component, where the first target color component is a target color component corresponding to the first color component in the plurality of target color components.
Optionally, as shown in fig. 7, the determining module 603 may further include:
a third determining sub-module 6036 for determining the first color component as the first target color component when the target transparency component is not greater than the first color component.
Optionally, as shown in fig. 8, the apparatus 600 may further include:
the third drawing module 605 is configured to draw a second pixel point on the target base map by using the color value of the first pixel point if there is no difference between the color component of the first pixel point and the preconfigured color component of the corresponding pixel point of the character to be drawn.
Optionally, the second obtaining sub-module 6032 may specifically be configured to:
and determining the average value of the plurality of color components of the first pixel point.
And determining the average value as the transparency component of the first pixel point.
Optionally, the first determining sub-module 6033 may specifically be configured to:
based on the transparency component of the target base map and the transparency component of the first pixel point, determining the target transparency component according to a target transparency component calculation formula, wherein the target transparency component calculation formula is as follows: TargetA ═ (1- (1-textA/255) × (1-backsa/255)) × 255.
Wherein, targetA is the transparency component of the target, textA is the transparency component of the first pixel point, and back A is the transparency component of the target base map.
Optionally, the plurality of color components comprises: a red color component, a green color component, and a blue color component.
In summary, in the text rendering apparatus provided in the embodiment of the present invention, the comparison module compares whether the color component of the first pixel point on the temporary base map is different from the color component of the corresponding pixel point of the text to be rendered, and when the color component of the first pixel point is different from the color component of the target base map, the determination module determines the target color value of the pixel point corresponding to the first pixel point of the text to be rendered, and the second rendering module renders the second pixel point on the target base map by using the target color value.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described apparatuses, modules and sub-modules may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
The embodiment of the invention also provides a storage medium, wherein the storage medium is stored with instructions, and when the storage medium runs on a computer, the computer is enabled to execute the character drawing method provided by the method embodiment.
The embodiment of the invention also provides a terminal which comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, wherein when the processor executes the computer program, the character drawing method provided by the embodiment of the method is realized.
The embodiment of the invention also provides a computer program product containing instructions, which when running on a computer, enables the computer to execute the character drawing method provided by the method embodiment.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.

Claims (14)

1. A method for rendering text, comprising:
the method comprises the steps that a preset color value of each pixel point of a character to be drawn is adopted, the character to be drawn is drawn on a temporary base map, each character consists of a plurality of pixel points, the color value comprises a transparency component and a plurality of color components, the transparency component and the color component of all the pixel points in the temporary base map are both 0, and the character to be drawn is a character to be drawn on a target base map;
comparing whether the color component of a first pixel point on the temporary base map is different from the pre-configured color component of a corresponding pixel point of the character to be drawn, wherein the first pixel point is any pixel point drawn on the temporary base map;
if the color component of the first pixel point on the temporary base map is different from the pre-configured color component of the corresponding pixel point of the character to be drawn, determining a target color value of a second pixel point, wherein the target color value comprises: a target transparency component or a plurality of target color components, wherein determining a target color value of the second pixel point comprises: acquiring a transparency component of the target base map; acquiring a transparency component of the first pixel point, wherein the transparency component of the first pixel point is determined according to the color component of the first pixel point; determining the target transparency component according to the transparency component of the target base map and the transparency component of the first pixel point; judging whether the target transparency component is larger than a first color component, wherein the first color component is any one of a plurality of color components of the first pixel point; when the target transparency component is larger than the first color component, determining the target transparency component as a first target color component, wherein the first target color component is a target color component corresponding to the first color component in the plurality of target color components; determining the first color component as the first target color component when the target transparency component is not greater than the first color component; the target color value is obtained based on the color component of the first pixel point and the transparency of the target base map, and the second pixel point is a pixel point of the character to be drawn, which corresponds to the first pixel point;
and drawing a second pixel point on the target base map by adopting the target color value.
2. The method of claim 1, wherein the contrast of the target color value to the target base map is less than the contrast of the color value of the first pixel point to the target base map.
3. The method of claim 1, further comprising:
and if the color component of the first pixel point is not different from the pre-configured color component of the corresponding pixel point of the character to be drawn, drawing the second pixel point on the target base map by adopting the color value of the first pixel point.
4. The method of claim 1, wherein said obtaining the transparency component of the first pixel point comprises:
determining an average value of a plurality of color components of the first pixel point;
and determining the average value as the transparency component of the first pixel point.
5. The method of claim 1, wherein determining the target transparency component from the transparency component of the target base map and the transparency component of the first pixel point comprises:
based on the transparency component of the target base map and the transparency component of the first pixel point, determining the target transparency component according to a target transparency component calculation formula, wherein the target transparency component calculation formula is as follows: target a ═ (1- (1-text a/255) × (1-back a/255)) × 255;
the Target A is the Target transparency component, the text A is the transparency component of the first pixel point, and the back A is the transparency component of the Target base map.
6. The method of claim 1, wherein the plurality of color components comprises: a red color component, a green color component, and a blue color component.
7. A character drawing apparatus, comprising:
the system comprises a first drawing module, a second drawing module and a third drawing module, wherein the first drawing module is used for drawing characters to be drawn on a temporary base map by adopting a preset color value of each pixel point of the characters to be drawn, each character consists of a plurality of pixel points, the color value comprises a transparency component and a plurality of color components, the transparency component and the color component of all the pixel points in the temporary base map are both 0, and the characters to be drawn are characters to be drawn on a target base map;
the comparison module is used for comparing whether the color component of a first pixel point on the temporary base map is different from the pre-configured color component of a corresponding pixel point of the character to be drawn or not, wherein the first pixel point is any pixel point drawn on the temporary base map;
a determining module, configured to determine a target color value of a second pixel point if a color component of a first pixel point on the temporary base map differs from a preconfigured color component of a corresponding pixel point of the character to be drawn, where the target color value is obtained based on the color component of the first pixel point and a transparency of the target base map, and the second pixel point is a pixel point of the character to be drawn corresponding to the first pixel point; the target color values include: a target transparency component or a plurality of target color components, the determination module comprising:
the first obtaining submodule is used for obtaining a transparency component of the target base map;
the second obtaining submodule is used for obtaining the transparency component of the first pixel point, and the transparency component of the first pixel point is determined according to the color component of the first pixel point;
the first determining submodule is used for determining the target transparency component according to the transparency component of the target base map and the transparency component of the first pixel point;
the judgment submodule is used for judging whether the target transparency component is larger than a first color component, wherein the first color component is any one of a plurality of color components of the first pixel point;
a second determining sub-module, configured to determine the target transparency component as a first target color component when the target transparency component is greater than the first color component, where the first target color component is a target color component corresponding to the first color component in the plurality of target color components;
a third determination submodule for determining the first color component as the first target color component when the target transparency component is not greater than the first color component;
and the second drawing module is used for drawing a second pixel point on the target base map by adopting the target color value.
8. The apparatus of claim 7, wherein the contrast of the target color value to the target base map is smaller than the contrast of the color value of the first pixel point to the target base map.
9. The apparatus of claim 7, further comprising:
and the third drawing module is used for drawing the second pixel point on the target base map by adopting the color value of the first pixel point if the color component of the first pixel point is not different from the color component which is configured in advance of the corresponding pixel point of the character to be drawn.
10. The apparatus according to claim 7, wherein the second obtaining sub-module is specifically configured to:
determining an average value of a plurality of color components of the first pixel point;
and determining the average value as the transparency component of the first pixel point.
11. The apparatus of claim 7, wherein the first determining submodule is specifically configured to:
based on the transparency component of the target base map and the transparency component of the first pixel point, determining the target transparency component according to a target transparency component calculation formula, wherein the target transparency component calculation formula is as follows: target a ═ (1- (1-text a/255) × (1-back a/255)) × 255;
the Target A is the Target transparency component, the text A is the transparency component of the first pixel point, and the back A is the transparency component of the Target base map.
12. The apparatus of claim 10, wherein the plurality of color components comprises: a red color component, a green color component, and a blue color component.
13. A storage medium having instructions stored therein, which when run on a computer, causes the computer to perform the text rendering method of any one of claims 1 to 6.
14. A terminal comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of text rendering according to any of claims 1 to 6 when executing the computer program.
CN201710508903.4A 2017-06-28 2017-06-28 Character drawing method and device, terminal and storage medium Active CN107358637B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710508903.4A CN107358637B (en) 2017-06-28 2017-06-28 Character drawing method and device, terminal and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710508903.4A CN107358637B (en) 2017-06-28 2017-06-28 Character drawing method and device, terminal and storage medium

Publications (2)

Publication Number Publication Date
CN107358637A CN107358637A (en) 2017-11-17
CN107358637B true CN107358637B (en) 2020-09-25

Family

ID=60272610

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710508903.4A Active CN107358637B (en) 2017-06-28 2017-06-28 Character drawing method and device, terminal and storage medium

Country Status (1)

Country Link
CN (1) CN107358637B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101753851A (en) * 2008-12-17 2010-06-23 华为终端有限公司 Method for replacing background, method for synthesizing virtual scene, as well as relevant system and equipment
CN101908216A (en) * 2010-07-20 2010-12-08 中兴通讯股份有限公司 Method and device for realizing vector fonts
CN103136169A (en) * 2011-11-29 2013-06-05 中兴通讯股份有限公司 Method and device of displaying characters
CN104919399A (en) * 2013-01-23 2015-09-16 朴宰贤 Device and method for changing color of text displayed on display device
CN105957125A (en) * 2016-05-20 2016-09-21 广东欧珀移动通信有限公司 Icon character processing method and mobile terminal
CN106126140A (en) * 2016-06-16 2016-11-16 北京金山安全软件有限公司 Method and device for rendering characters and electronic equipment

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101753851A (en) * 2008-12-17 2010-06-23 华为终端有限公司 Method for replacing background, method for synthesizing virtual scene, as well as relevant system and equipment
CN101908216A (en) * 2010-07-20 2010-12-08 中兴通讯股份有限公司 Method and device for realizing vector fonts
CN103136169A (en) * 2011-11-29 2013-06-05 中兴通讯股份有限公司 Method and device of displaying characters
WO2013078788A1 (en) * 2011-11-29 2013-06-06 中兴通讯股份有限公司 Text display method and apparatus
CN104919399A (en) * 2013-01-23 2015-09-16 朴宰贤 Device and method for changing color of text displayed on display device
CN105957125A (en) * 2016-05-20 2016-09-21 广东欧珀移动通信有限公司 Icon character processing method and mobile terminal
CN106126140A (en) * 2016-06-16 2016-11-16 北京金山安全软件有限公司 Method and device for rendering characters and electronic equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于感知颜色空间的透明度估计方法;林生佑;《计算机工程》;20071031;第33卷(第20期);第40-42页 *

Also Published As

Publication number Publication date
CN107358637A (en) 2017-11-17

Similar Documents

Publication Publication Date Title
US9558542B2 (en) Method and device for image processing
US10437420B2 (en) Method and apparatus for setting background picture of unlocking interface of application, and electronic device
CN110009712B (en) Image-text typesetting method and related device thereof
CN107622504B (en) Method and device for processing pictures
CN110211030B (en) Image generation method and device
US20120219219A1 (en) Image processing apparatus, storage medium storing image processing program, and image processing method
CN113923474B (en) Video frame processing method, device, electronic equipment and storage medium
CN114527980A (en) Display rendering method and device, electronic equipment and readable storage medium
CN113657518B (en) Training method, target image detection method, device, electronic device, and medium
US11657484B2 (en) Image processing apparatus to enhance contrast of image, image processing method, and non-transitory computer-readable storage medium
CN109615583B (en) Game map generation method and device
CN110618852A (en) View processing method, view processing device and terminal equipment
US20230237946A1 (en) Display Effect Enhancement Method, Apparatus, and Device
CN107358637B (en) Character drawing method and device, terminal and storage medium
CN111861965B (en) Image backlight detection method, image backlight detection device and terminal equipment
CN104917969B (en) The method and mobile terminal of a kind of image procossing
CN113391779B (en) Parameter adjusting method, device and equipment for paper-like screen
CN113139921B (en) Image processing method, display device, electronic device and storage medium
CN111653232B (en) LED screen color gamut calibration method and device
US11782850B2 (en) Information processing method, server, terminal, and computer storage medium
CN114820874A (en) Method, device and equipment for processing shadow effect of characters and storage medium
CN114792283A (en) Image processing method, device and equipment and computer readable storage medium
CN111986144A (en) Image blur judgment method and device, terminal equipment and medium
CN110852936B (en) Method and device for mixing pictures
CN112053277B (en) Method, device, equipment and storage medium for changing image skin

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 510660 Guangzhou City, Guangzhou, Guangdong, Whampoa Avenue, No. 315, self - made 1-17

Applicant after: Guangzhou KuGou Networks Co., Ltd.

Address before: 510000 B1, building, No. 16, rhyme Road, Guangzhou, Guangdong, China 13F

Applicant before: Guangzhou KuGou Networks Co., Ltd.

GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20220406

Address after: 4119, 41st floor, building 1, No.500, middle section of Tianfu Avenue, Chengdu hi tech Zone, China (Sichuan) pilot Free Trade Zone, Chengdu, Sichuan 610000

Patentee after: Chengdu kugou business incubator management Co.,Ltd.

Address before: No. 315, Huangpu Avenue middle, Tianhe District, Guangzhou City, Guangdong Province

Patentee before: GUANGZHOU KUGOU COMPUTER TECHNOLOGY Co.,Ltd.