A text shadow effect processing method, device, equipment and storage medium

By performing pixel offset and area removal on the directed distance field image of the text, the problem of low efficiency in shadow effect drawing in the prior art is solved, and efficient shadow effect drawing within the text is achieved.

CN114820874BActive Publication Date: 2025-09-23BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110118989.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-28
Publication Date
2025-09-23
Estimated Expiration
2041-03-25

AI Technical Summary

Technical Problem

The existing technology is inefficient and ineffective in drawing text shadow effects, and it is difficult to meet the needs of applications in multiple fields.

Method used

By offsetting the pixels in the directed distance field image of the target text, a first distance field image is generated. An initial shadow effect image is drawn based on this image. The target area formed by the offset pixels whose distance field values ​​are greater than a preset value is determined and removed to achieve the inner shadow effect.

Benefits of technology

It achieves efficient drawing of text inner shadow effects, meeting the shadow effect processing requirements of applications in multiple fields.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114820874B_ABST
    Figure CN114820874B_ABST
Patent Text Reader

Abstract

The present disclosure provides a method, device, equipment and storage medium for processing shadow effects of text. The method includes: performing position shifting on pixel points in a directed distance field image of a target text to obtain a first distance field image, wherein the first distance field image includes original pixel points and offset pixel points corresponding to the original pixel points. Then, based on the first distance field image, an initial inner shadow effect image corresponding to the target text is drawn, a target area composed of offset pixel points whose distance field values ​​in the first distance field image are greater than a preset value is determined, and the target area is removed from the initial inner shadow effect image to obtain an inner shadow effect image of the target text. The present disclosure utilizes the feature that pixel points whose distance field values ​​in the directed distance field image of the target text are greater than a preset value are located in the outer area of ​​the target text, and removes the target area composed of pixel points in the outer area of ​​the target text, thereby achieving the drawing of the inner shadow effect of the target text.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of data processing, and in particular to a method, device, equipment and storage medium for processing text shadow effects. Background Art

[0002] Currently, text effect drawing is being applied in more and more fields, such as scene drawing in online games, subtitle display in variety shows, text display in videos, and so on.

[0003] The shadow effect of text is a relatively common text effect. How to draw the shadow effect of text is currently a highly concerned issue. Summary of the Invention

[0004] In order to solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides a method, device, equipment and storage medium for processing text shadow effects, which can draw text shadow effects based on a signed distance field image of the text.

[0005] In a first aspect, the present disclosure provides a method for processing a text shadow effect, the method comprising:

[0006] After performing position shifting on pixel points in the directed distance field image of the target text, a first distance field image is obtained; wherein the first distance field image includes original pixel points and shifted pixel points obtained by shifting the original pixel points;

[0007] Drawing an initial inner shadow effect image corresponding to the target text based on the first distance field image;

[0008] determining a target area consisting of the offset pixel points having distance field values ​​greater than a preset value in the first distance field image;

[0009] The target area is removed from the initial inner shadow effect image to obtain an inner shadow effect image of the target text.

[0010] In an optional implementation, drawing the initial inner shadow effect image corresponding to the target text based on the first distance field image includes:

[0011] Drawing the text body of the target text based on the original pixel points in the first distance field image;

[0012] Based on the offset pixel points in the first distance field image, the inner shadow of the target text is drawn to obtain an initial inner shadow effect image corresponding to the target text.

[0013] In an optional implementation, drawing the inner shadow of the target text based on the offset pixel points in the first distance field image includes:

[0014] Determining a gradient value of the shifted pixel point based on a dot product operation result between an offset coordinate of the shifted pixel point in the first distance field image and a gradient direction vector, wherein the offset coordinate is a difference between a position coordinate of the shifted pixel point and a gradient origin;

[0015] Determining the color value of the pixel after the shift according to the gradient value and the target gradient color;

[0016] The inner shadow of the target text is drawn based on the color value of the offset pixel point.

[0017] In an optional implementation, the method further includes:

[0018] Based on the first distance field image, an outer shadow effect image corresponding to the target text is drawn.

[0019] In an optional implementation, drawing the outer shadow effect image corresponding to the target text based on the first distance field image includes:

[0020] Drawing an outer shadow of the target text based on the offset pixel points in the first distance field image;

[0021] Based on the original pixel points in the first distance field image, the text body of the target text is drawn to obtain an outer shadow effect image corresponding to the target text.

[0022] In an optional implementation, drawing the text body of the target text based on the original pixel points in the first distance field image includes:

[0023] determining a color transparency value of the original pixel point based on the distance field value of the original pixel point in the first distance field image; wherein the absolute value of the distance field value of the original pixel point is inversely proportional to the color transparency value of the original pixel point;

[0024] The text body of the target text is drawn based on the color transparency value of the original pixel point.

[0025] In an optional implementation, drawing the outer shadow of the target text based on the offset pixel points in the first distance field image includes:

[0026] Determining a gradient value of the shifted pixel point based on a dot product operation result between an offset coordinate of the shifted pixel point in the first distance field image and a gradient direction vector, wherein the offset coordinate is a difference between a position coordinate of the shifted pixel point and a gradient origin;

[0027] Determining the color value of the pixel after the shift according to the gradient value and the target gradient color;

[0028] The outer shadow of the target text is drawn based on the color value of the offset pixel point.

[0029] In an optional embodiment, before drawing the initial inner shadow effect image corresponding to the target text based on the first distance field image, the method further includes:

[0030] Color mixing is performed on the original pixel points and the offset pixel points having the same position information in the first distance field image based on the color transparency value.

[0031] In a second aspect, the present disclosure provides a device for processing text shadow effects, the device comprising:

[0032] an offset module, configured to offset the positions of the pixels in the directed distance field image of the target text to obtain a first distance field image; wherein the first distance field image includes the original pixels and the offset pixels obtained by offsetting the original pixels;

[0033] A first drawing module, configured to draw an initial inner shadow effect image corresponding to the target text based on the first distance field image;

[0034] a first determining module, configured to determine a target area consisting of the offset pixel points having distance field values ​​greater than a preset value in the first distance field image;

[0035] The removal module is used to remove the target area from the initial inner shadow effect image to obtain the inner shadow effect image of the target text.

[0036] In a third aspect, the present disclosure provides a computer-readable storage medium, wherein instructions are stored in the computer-readable storage medium. When the instructions are executed on a terminal device, the terminal device implements the above method.

[0037] In a fourth aspect, the present disclosure provides a device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned method when executing the computer program.

[0038] In a fifth aspect, the present disclosure provides a computer program product, which includes a computer program / instructions, and when the computer program / instructions are executed by a processor, the above method is implemented.

[0039] The technical solution provided by the embodiments of the present disclosure has at least the following advantages compared with the prior art:

[0040] The embodiment of the present disclosure provides a method for processing the shadow effect of text. First, the pixel points in the directed distance field image of the target text are positionally offset to obtain a first distance field image, wherein the first distance field image includes the original pixel points and the offset pixel points obtained by position offsetting the original pixel points. Then, based on the first distance field image, the initial inner shadow effect image corresponding to the target text is drawn, and then the target area composed of the offset pixel points whose distance field values ​​in the first distance field image are greater than a preset value is determined, and the target area is removed from the initial inner shadow effect image to obtain the inner shadow effect image of the target text. The present disclosure utilizes the feature that the pixel points whose distance field values ​​in the directed distance field image of the target text are greater than the preset value are located in the external area of ​​the target text, and removes the target area composed of the pixel points in the external area of ​​the target text, thereby achieving the drawing of the inner shadow effect of the target text. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0042] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0043] Figure 1 A flowchart of a method for processing text shadow effects provided by an embodiment of the present disclosure;

[0044] Figure 2 A schematic diagram of an initial inner shadow effect image provided by an embodiment of the present disclosure;

[0045] Figure 3 A schematic diagram of an inner shadow effect image of a target text provided by an embodiment of the present disclosure;

[0046] Figure 4 A schematic diagram of an outer shadow effect image corresponding to a target text provided by an embodiment of the present disclosure;

[0047] Figure 5A schematic structural diagram of a device for processing text shadow effects provided by an embodiment of the present disclosure;

[0048] Figure 6 A structural schematic diagram of a text shadow effect processing device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0049] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features therein can be combined with each other in the absence of conflict.

[0050] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.

[0051] Currently, text shadow effects are typically rendered based on bitmap text. Signed distance field images, also known as distance field values, record the shortest distance between each pixel inside and outside the text and the text outline (also known as the border). Distance field values ​​for pixels within the text are set to negative, while those outside the text are set to positive. The inventors have discovered that using signed distance field images based on text makes it easier to create text shadow effects.

[0052] To this end, the present disclosure provides a method for processing the shadow effect of text. First, the pixel points in the directed distance field image of the target text are positionally offset to obtain a first distance field image, wherein the first distance field image includes the original pixel points and the offset pixel points obtained by positionally offsetting the original pixel points. Then, based on the first distance field image, an initial inner shadow effect image corresponding to the target text is drawn, and then a target area composed of offset pixel points in the first distance field image whose distance field values ​​are greater than a preset value is determined, and the target area is removed from the initial inner shadow effect image to obtain an inner shadow effect image of the target text. The present disclosure utilizes the feature that the pixel points in the directed distance field image of the target text whose distance field values ​​are greater than a preset value are located in the outer area of ​​the target text, and removes the target area composed of pixel points in the outer area of ​​the target text, thereby achieving the drawing of the inner shadow effect of the target text.

[0053] Based on this, the embodiment of the present disclosure provides a method for processing the shadow effect of text, referring to Figure 1 , is a flow chart of a method for processing text shadow effects provided by an embodiment of the present disclosure, the method comprising:

[0054] S101: Pixel points in a directed distance field image of target text are shifted to obtain a first distance field image; wherein the first distance field image includes original pixel points and shifted pixel points obtained by shifting the original pixel points.

[0055] In the disclosed embodiment, an offset vector for the shadow effect is predetermined to indicate the offset direction and distance of the shadow effect. For example, the offset vector may be (shadowOffsetX, shadowOffsetY), where shadowOffsetX indicates the offset distance of the shadow effect relative to the text body in the X-axis direction, and shadowOffsetY indicates the offset distance of the shadow effect relative to the text body in the Y-axis direction.

[0056] In practical applications, any pixel point (x, y) in the signed distance field image of the target text is offset based on the offset vector (shadowOffsetX, shadowOffsetY). The resulting offset pixel point is (x-shadowOffsetX, y-shadowOffsetY). The pixel point (x, y) is called the original pixel point, and the pixel point (x-shadowOffsetX, y-shadowOffsetY) is the offset pixel point corresponding to the original pixel point (x, y). After all pixels in the signed distance field image of the target text are offset, a first distance field image is obtained, which includes the original pixel point and the offset pixel point.

[0057] S102: Drawing an initial inner shadow effect image corresponding to the target text based on the first distance field image.

[0058] In the embodiment of the present disclosure, after the first distance field image is determined, an initial shadow effect image corresponding to the target text is drawn based on the distance field values ​​of the original pixel points and the offset pixel points on the first distance field image.

[0059] In one optional implementation, the target text body can be first drawn based on the original pixels in the first distance field image. After the text body is drawn, the inner shadow of the target text body is initially drawn based on the offset pixels in the first distance field image, resulting in an initial inner shadow effect image corresponding to the target text. By controlling the order of the drawing layers, the text body is drawn below the shadow, obscured by the shadow, achieving the effect of the text body having an inner shadow.

[0060] In practical applications, before drawing the text body, the color values ​​of each original pixel can be determined. The target text body can then be drawn based on the original pixel values. Furthermore, before drawing the inner shadow of the target text body, the color values ​​of the offset pixel values ​​can be determined. The inner shadow of the target text body can then be drawn based on the offset pixel values, resulting in an initial inner shadow effect image corresponding to the target text. This approach allows the drawing of a colored text body and inner shadow.

[0061] Additionally, if both original and offset pixels with identical positional information in the first distance field image have color transparency values, color blending can be performed on the original and offset pixels with identical positional information based on the color transparency values. The manner in which color blending is performed based on color transparency values ​​is not limited in the disclosed embodiments.

[0062] In an optional embodiment, the text body in the initial inner shadow effect image corresponding to the target text can be rendered with a glowing effect. Specifically, before rendering the text body, the color transparency value of the original pixel is determined based on the distance field value of the original pixel in the first distance field image. The distance field value is inversely proportional to the color transparency value, that is, the farther the pixel is from the text body, the lower the color transparency, thereby achieving a glowing text effect. Then, based on the color transparency value of the original pixel, the text body of the target text is rendered.

[0063] In another optional implementation, the inner shadow effect in the initial inner shadow effect image corresponding to the target text can be drawn as a gradient color effect. Specifically, before drawing the inner shadow of the target text, the gradient value of the offset pixel point is determined based on the dot product result between the offset coordinates of the offset pixel point in the first distance field image and the gradient direction vector. The offset coordinates are the difference between the position coordinates of the offset pixel point and the gradient origin. Then, the color value of the offset pixel point is determined in combination with the gradient value and the target gradient color. After that, the inner shadow of the target text is drawn based on the color value of the offset pixel point.

[0064] The target gradient colors are typically two colors, such as white and black, and the gradient effect is one that transitions from black to white, or vice versa. The gradient origin is typically the center of the text itself, specifically determining the point where one color in the target gradient transitions to another.

[0065] S103: Determine a target area consisting of the offset pixel points having distance field values ​​greater than a preset value in the first distance field image.

[0066] The preset threshold value may be set based on the requirement for the inner shadow effect. Specifically, the preset threshold value may be 0, or a value between 0 and 0.5.

[0067] In the embodiment of the present disclosure, in the inner shadow effect drawn based on the offset pixel points in the first distance field image, there is an area that does not overlap with the text body, such as Figure 2 FIG. 1 is a schematic diagram of an initial inner shadow effect image provided by an embodiment of the present disclosure. In order to ensure the inner shadow drawing effect of the target text, the embodiment of the present disclosure needs to cut off the area that does not overlap with the text body.

[0068] To this end, the embodiment of the present disclosure determines a target area consisting of offset pixels in the first distance field image whose distance field values ​​are greater than a preset value (e.g., 0) based on the characteristic that the distance field values ​​of the pixels located outside the text in the directed distance field image are negative.

[0069] S104: removing the target area from the initial inner shadow effect image to obtain the inner shadow effect image of the target text.

[0070] In the disclosed embodiment, the target area is composed of offset pixels whose distance field values ​​are greater than a preset value, wherein the offset pixels whose distance field values ​​are greater than the preset value are located in the area surrounding the target text. To achieve an inner shadow effect for the target text, the offset pixels whose distance field values ​​are greater than the preset value in the area surrounding the target text need to be removed.

[0071] Therefore, after determining the target area, the embodiment of the present disclosure removes the target area from the initial inner shadow effect image to ensure that there is no area that does not overlap with the text body in the final inner shadow effect image, thereby ensuring the inner shadow effect of the target text. Figure 3 , which is a schematic diagram of an inner shadow effect image of a target text provided by an embodiment of the present disclosure.

[0072] In the text shadow effect processing method provided by the embodiment of the present disclosure, first, the pixel points in the directed distance field image of the target text are positionally offset to obtain a first distance field image, wherein the first distance field image includes the original pixel points and the offset pixel points obtained by position offsetting the original pixel points. Then, based on the first distance field image, the initial inner shadow effect image corresponding to the target text is drawn, and then the target area composed of the offset pixel points whose distance field values ​​in the first distance field image are greater than a preset value is determined, and the target area is removed from the initial inner shadow effect image to obtain the inner shadow effect image of the target text. The embodiment of the present disclosure utilizes the feature that the pixel points whose distance field values ​​in the directed distance field image of the target text are greater than the preset value are located in the outer area of ​​the target text, and removes the target area composed of the pixel points in the outer area of ​​the target text, thereby achieving the drawing of the inner shadow effect of the target text.

[0073] The disclosed embodiment further provides a method for processing an outer shadow effect of a target text. Specifically, based on the first distance field image, an outer shadow effect image corresponding to the target text is drawn. The drawing of the outer shadow effect can be performed by drawing the outer shadow and then drawing the text body.

[0074] In an optional embodiment, first, the outer shadow of the target text is drawn based on the offset pixel points in the first distance field image; then, the text body of the target text is drawn based on the original pixel points in the first distance field image to obtain the outer shadow effect image corresponding to the target text. Figure 4 , which is a schematic diagram of an outer shadow effect image corresponding to a target text provided by an embodiment of the present disclosure.

[0075] By controlling the order of drawing layers, the text body is drawn above the shadow, so that the shadow is blocked by the text body, achieving a drawing effect in which the text body has an outer shadow.

[0076] It is worth noting that, in the first distance field image used for drawing the outer shadow effect image corresponding to the target text, the offset vector and offset distance used for position offset of the pixel points may be different from those for the inner shadow effect drawing.

[0077] In one optional embodiment, when drawing the outer shadow effect of the target text, the text body in the initial outer shadow effect image corresponding to the target text can be rendered as a luminous effect. Specifically, before drawing the text body, the color transparency value of the original pixel point is determined based on the distance field value of the original pixel point in the first distance field image. The distance field value is inversely proportional to the color transparency value, that is, the farther the pixel point is from the text body, the lower the color transparency value, thereby achieving the text luminous effect. Then, based on the color transparency value of the original pixel point, the text body of the target text is drawn.

[0078] In another optional implementation, the outer shadow effect in the initial outer shadow effect image corresponding to the target text can be drawn as a gradient color effect. Specifically, before drawing the outer shadow of the target text, the gradient value of the offset pixel point is determined based on the dot product result between the offset coordinates of the offset pixel point in the first distance field image and the gradient direction vector. The offset coordinates are the difference between the position coordinates of the offset pixel point and the gradient origin. Then, the color value of the offset pixel point is determined in combination with the gradient value and the target gradient color. Finally, the outer shadow of the target text is drawn based on the color value of the offset pixel point.

[0079] The text shadow effect processing method provided by the embodiments of the present disclosure can not only draw the inner shadow effect of the target text based on the signed distance field image of the target text, but also draw the outer shadow effect of the target text based on the signed distance field image of the target text, meeting the user's processing requirements for text shadow effects.

[0080] Based on the same inventive concept as the above method embodiment, the present disclosure also provides a text shadow effect processing device, referring to Figure 5 , is a structural diagram of a text shadow effect processing device provided by an embodiment of the present disclosure, the device comprising:

[0081] An offset module 501 is configured to offset the positions of the pixels in the directed distance field image of the target text to obtain a first distance field image; wherein the first distance field image includes the original pixels and the offset pixels obtained by offsetting the original pixels;

[0082] A first drawing module 502 is configured to draw an initial inner shadow effect image corresponding to the target text based on the first distance field image;

[0083] A first determining module 503 is configured to determine a target area consisting of the offset pixel points in the first distance field image whose distance field values ​​are greater than a preset value;

[0084] The removal module 504 is configured to remove the target area from the initial inner shadow effect image to obtain an inner shadow effect image of the target text.

[0085] In an optional implementation, the first drawing module includes:

[0086] A first drawing submodule, configured to draw a text body of the target text based on the original pixel points in the first distance field image;

[0087] The second drawing submodule is configured to draw the inner shadow of the target text based on the offset pixel points in the first distance field image to obtain an initial inner shadow effect image corresponding to the target text.

[0088] In an optional embodiment, the device further includes:

[0089] The second drawing module is configured to draw an outer shadow effect image corresponding to the target text based on the first distance field image.

[0090] In an optional implementation, the second drawing module includes:

[0091] a third drawing submodule, configured to draw an outer shadow of the target text based on the offset pixel points in the first distance field image;

[0092] The fourth drawing submodule is configured to draw the text body of the target text based on the original pixel points in the first distance field image to obtain an outer shadow effect image corresponding to the target text.

[0093] In an optional implementation, the first drawing submodule or the fourth drawing submodule includes:

[0094] a first determining submodule, configured to determine a color transparency value of the original pixel point based on the distance field value of the original pixel point in the first distance field image; wherein the distance field value of the original pixel point is inversely proportional to the color transparency value of the original pixel point;

[0095] The fifth drawing submodule is configured to draw the text body of the target text based on the color transparency value of the original pixel point.

[0096] In an optional implementation manner, the second drawing submodule includes:

[0097] a second determining submodule, configured to determine a gradient value of the shifted pixel point based on a dot product operation result between an offset coordinate of the shifted pixel point in the first distance field image and a gradient direction vector; wherein the offset coordinate is a difference between a position coordinate of the shifted pixel point and a gradient origin;

[0098] A third determining submodule is configured to determine the color value of the offset pixel point according to the gradient value and the target gradient color;

[0099] The sixth drawing submodule is configured to draw an inner shadow of the target text based on the color value of the offset pixel point.

[0100] In an optional implementation, the third drawing submodule includes:

[0101] a fourth determining submodule, configured to determine a gradient value of the shifted pixel point based on a dot product operation result between the offset coordinates of the shifted pixel point in the first distance field image and the gradient direction vector; wherein the offset coordinates are the difference between the position coordinates of the shifted pixel point and the gradient origin;

[0102] a fifth determining submodule, configured to determine a color value of the offset pixel point according to the gradient value and a target gradient color;

[0103] The seventh drawing submodule is configured to draw an outer shadow of the target text based on the color value of the offset pixel point.

[0104] In an optional embodiment, the device further includes:

[0105] A blending module is configured to perform color blending on the original pixel points and the offset pixel points having the same position information in the first distance field image based on a color transparency value.

[0106] In the text shadow effect processing device provided by the embodiment of the present disclosure, first, the pixel points in the directed distance field image of the target text are positionally offset to obtain a first distance field image, wherein the first distance field image includes the original pixel points and the offset pixel points obtained by position offsetting the original pixel points. Then, based on the first distance field image, the initial inner shadow effect image corresponding to the target text is drawn, and then the target area composed of the offset pixel points whose distance field values ​​in the first distance field image are greater than a preset value is determined, and the target area is removed from the initial inner shadow effect image to obtain the inner shadow effect image of the target text. The embodiment of the present disclosure utilizes the feature that the pixel points whose distance field values ​​in the directed distance field image of the target text are greater than the preset value are located in the outer area of ​​the target text, and removes the target area composed of the pixel points in the outer area of ​​the target text, thereby achieving the drawing of the inner shadow effect of the target text.

[0107] In addition to the above-mentioned methods and devices, the embodiments of the present disclosure also provide a computer-readable storage medium, which stores instructions. When the instructions are executed on a terminal device, the terminal device implements the text shadow effect processing method described in the embodiments of the present disclosure.

[0108] The embodiments of the present disclosure further provide a computer program product, including a computer program / instruction, which, when executed by a processor, implements the text shadow effect processing method described in the embodiments of the present disclosure.

[0109] In addition, the embodiment of the present disclosure also provides a text shadow effect processing device, see Figure 6As shown, this may include:

[0110] Processor 601, memory 602, input device 603 and output device 604. The number of processors 601 in the text shadow effect processing device can be one or more. Figure 6 In some embodiments of the present disclosure, the processor 601, the memory 602, the input device 603 and the output device 604 may be connected via a bus or other means, wherein: Figure 6 The bus connection is taken as an example.

[0111] The memory 602 can be used to store software programs and modules. The processor 601 executes the various functional applications and data processing of the text shadow effect processing device as shown in the present disclosure by running the software programs and modules stored in the memory 602. The memory 602 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc. In addition, the memory 602 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device. The input device 603 can be used to receive input digital or character information, and to generate signal input related to user settings and function control of the text shadow effect processing device.

[0112] Specifically in this embodiment, the processor 601 will load the executable files corresponding to the processes of one or more applications into the memory 602 according to the following instructions, and the processor 601 will run the applications stored in the memory 602, thereby realizing the various functions of the above-mentioned text shadow effect processing device.

[0113] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.

[0114] The foregoing description is intended only to provide specific embodiments of the present disclosure, intended to enable those skilled in the art to understand and implement the present disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the embodiments described herein, but rather to be construed in the broadest manner consistent with the principles and novel features disclosed herein.

Claims

1. A method for processing text shadow effects, characterized in that: The method comprises: After performing position shifting on pixel points in the directed distance field image of the target text, a first distance field image is obtained; wherein the first distance field image includes original pixel points and shifted pixel points obtained by shifting the original pixel points; Drawing an initial inner shadow effect image corresponding to the target text based on the original pixel points and the offset pixel points in the first distance field image; determining a target area consisting of the offset pixel points having distance field values ​​greater than a preset value in the first distance field image; The target area is removed from the initial inner shadow effect image to obtain an inner shadow effect image of the target text.

2. The method according to claim 1, characterized in that Drawing the initial inner shadow effect image corresponding to the target text based on the original pixel points and the offset pixel points in the first distance field image includes: Drawing the text body of the target text based on the original pixel points in the first distance field image; Based on the offset pixel points in the first distance field image, the inner shadow of the target text is drawn to obtain an initial inner shadow effect image corresponding to the target text.

3. The method according to claim 2, characterized in that Drawing the inner shadow of the target text based on the offset pixel points in the first distance field image includes: Determining a gradient value of the shifted pixel point based on a dot product operation result between an offset coordinate of the shifted pixel point in the first distance field image and a gradient direction vector, wherein the offset coordinate is a difference between a position coordinate of the shifted pixel point and a gradient origin; Determining the color value of the pixel after the shift according to the gradient value and the target gradient color; The inner shadow of the target text is drawn based on the color value of the offset pixel point.

4. The method according to claim 1, wherein The method further comprises: Based on the first distance field image, an outer shadow effect image corresponding to the target text is drawn.

5. The method according to claim 4, characterized in that Drawing the outer shadow effect image corresponding to the target text based on the first distance field image includes: Drawing an outer shadow of the target text based on the offset pixel points in the first distance field image; Based on the original pixel points in the first distance field image, the text body of the target text is drawn to obtain an outer shadow effect image corresponding to the target text.

6. The method according to claim 2 or 5, characterized in that Drawing the target text body based on the original pixel points in the first distance field image includes: determining a color transparency value of the original pixel point based on the distance field value of the original pixel point in the first distance field image; wherein the absolute value of the distance field value of the original pixel point is inversely proportional to the color transparency value of the original pixel point; The text body of the target text is drawn based on the color transparency value of the original pixel point.

7. The method according to claim 5, characterized in that Drawing the outer shadow of the target text based on the offset pixel points in the first distance field image includes: Determining a gradient value of the shifted pixel point based on a dot product operation result between an offset coordinate of the shifted pixel point in the first distance field image and a gradient direction vector, wherein the offset coordinate is a difference between a position coordinate of the shifted pixel point and a gradient origin; Determining the color value of the pixel after the shift according to the gradient value and the target gradient color; The outer shadow of the target text is drawn based on the color value of the offset pixel point.

8. The method according to claim 1, characterized in that Before drawing the initial inner shadow effect image corresponding to the target text based on the first distance field image, the method further includes: Color mixing is performed on the original pixel points and the offset pixel points having the same position information in the first distance field image based on the color transparency value.

9. A device for processing text shadow effects, characterized in that: The device comprises: an offset module, configured to offset the positions of the pixels in the directed distance field image of the target text to obtain a first distance field image; wherein the first distance field image includes the original pixels and the offset pixels obtained by offsetting the original pixels; A first drawing module is configured to draw an initial inner shadow effect image corresponding to the target text based on the original pixel points and the offset pixel points in the first distance field image; a first determining module, configured to determine a target area consisting of the offset pixel points having distance field values ​​greater than a preset value in the first distance field image; The removal module is used to remove the target area from the initial inner shadow effect image to obtain the inner shadow effect image of the target text.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores instructions, and when the instructions are executed on a terminal device, the terminal device implements the method according to any one of claims 1 to 8.

11. A device, characterized in that include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method according to any one of claims 1 to 8 is implemented.

12. A computer program product, characterized in that The computer program product comprises a computer program / instruction, and when the computer program / instruction is executed by a processor, the method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Image rendering method and related device

    CN111292405A

  • Image processing apparatus and method, and computer executable program

    JP2010147610A