WO2022160946A1 - Text shadow effect processing method and apparatus, device and storage medium - Google Patents

Text shadow effect processing method and apparatus, device and storage medium Download PDF

Info

Publication number
WO2022160946A1
WO2022160946A1 PCT/CN2021/135953 CN2021135953W WO2022160946A1 WO 2022160946 A1 WO2022160946 A1 WO 2022160946A1 CN 2021135953 W CN2021135953 W CN 2021135953W WO 2022160946 A1 WO2022160946 A1 WO 2022160946A1
Authority
WO
WIPO (PCT)
Prior art keywords
distance field
offset
field image
target text
text
Prior art date
Application number
PCT/CN2021/135953
Other languages
French (fr)
Chinese (zh)
Inventor
徐力有
赵陈翔
Original Assignee
北京字跳网络技术有限公司
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 北京字跳网络技术有限公司 filed Critical 北京字跳网络技术有限公司
Publication of WO2022160946A1 publication Critical patent/WO2022160946A1/en
Priority to US18/357,651 priority Critical patent/US20240005573A1/en

Links

Images

Classifications

    • 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

Definitions

  • the present disclosure provides a method, apparatus, device and storage medium for processing shadow effects of characters, which can draw shadow effects of characters based on directional distance field images of characters.
  • an outer shadow effect image corresponding to the target text is drawn.
  • the drawing an outer shadow effect image corresponding to the target text based on the first distance field image includes:
  • the drawing of the outer shadow of the target text based on the offset pixels in the first distance field image includes:
  • the present disclosure provides a text shadow effect processing device, the device comprising:
  • 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
  • the present disclosure provides a computer-readable storage medium, where instructions are stored in the computer-readable storage medium, and when the instructions are executed on a terminal device, the terminal device is made to implement the above method.
  • the present disclosure provides a device comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor, when the processor executes the computer program, Implement the above method.
  • an initial shadow effect image corresponding to the target text is drawn based on the original pixel point on the first distance field image and the distance field value of the offset pixel point.
  • the inner shadow effect in the initial inner shadow effect image corresponding to the target text may be drawn as a gradient color effect.
  • the gradient of the offset pixel is determined based on the dot product operation result between the offset coordinates of the offset pixel in the first distance field image and the gradient direction vector value.
  • the offset coordinate is the difference between the position coordinate of the offset pixel and the gradient origin. Then, combine the gradient value and the target gradient color to determine the color value of the pixel point after the offset, and then draw the inner shadow of the target text based on the color value of the pixel point after the offset.
  • the embodiment of the present disclosure in the inner shadow effect drawn based on the offset pixels in the first distance field image, there is an area that does not overlap with the text body. As shown in FIG. Schematic of the initial inner shadow effect image. In order to ensure the inner shadow drawing effect of the target text, the embodiment of the present disclosure needs to cut out the area that does not overlap with the text body.
  • S104 Remove the target area from the initial inner shadow effect image to obtain an inner shadow effect image of the target text.
  • a first distance field image is obtained, wherein, in the first distance field image Including the original pixel point and the offset pixel point obtained by the position offset of the original pixel point. Then, based on the first distance field image, draw the initial inner shadow effect image corresponding to the target text, and then determine the target area composed of the offset pixels whose distance field value in the first distance field image is greater than the preset value, and the target area is The area is removed from the initial inner shadow effect image to obtain the inner shadow effect map of the target text.
  • the outer shadow of the target text is drawn based on the offset pixels in the first distance field image; then, based on the offset pixels in the first distance field image; For the original pixel point, the text body of the target text is drawn to obtain an outer shadow effect image corresponding to the target text.
  • FIG. 4 it is a schematic diagram of an outer shadow effect image corresponding to a target text according to an embodiment of the present disclosure.
  • the text body is drawn above the shadow, so that the shadow is blocked by the text body, so that the text body has an outer shadow drawing effect.
  • the offset module 501 is used to obtain a first distance field image after performing position offset on the pixel points in the directional distance field image of the target text; wherein, the first distance field image includes the original pixel point and the The offset pixel point obtained by the original pixel point after the position offset;
  • the first drawing module includes:
  • the fourth drawing sub-module 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.
  • the second determination sub-module is configured to determine, based on the dot product operation result between the offset coordinates of the offset pixel points and the gradient direction vector in the first distance field image, the offset value of the offset pixel point. Gradient value; wherein, the offset coordinate is the difference between the position coordinate of the pixel point after the offset and the gradient origin;
  • the seventh drawing sub-module is configured to draw the outer shadow of the target text based on the color value of the offset pixel.
  • a mixing module configured to perform color mixing on the original pixel points with the same position information in the first distance field image and the shifted pixel points based on the color transparency value.
  • the embodiment of the present disclosure utilizes the feature that the pixels whose distance field value is greater than the preset value in the directional distance field image of the target character are located in the outer area of the target character, and removes the target area formed by the pixels in the outer area of the target character, so as to realize The inner shadow effect of the target text is drawn.
  • the processor 601 loads the executable files corresponding to the processes of one or more application programs into the memory 602 according to the following instructions, and the processor 601 executes the executable files stored in the memory 602 application, so as to realize various functions of the above-mentioned text shadow effect processing device.

Abstract

The present disclosure provides a text shadow effect processing method and apparatus, a device, and a storage medium. The method comprises: after offsetting the positions of pixel points in a signed distance field image of a target text, obtaining a first distance field image, which comprises original pixel points and offset pixel points corresponding to the original pixel points; on the basis of the first distance field image, drawing an initial inner shadow effect image corresponding to the target text; determining a target area composed of offset pixel points in the first distance field image of which distance field values are greater than a preset value; and removing the target area 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 in the signed distance field image of the target text of which distance field values are greater than a preset value are located outside of the target text, and removes the target area composed of pixel points located outside of the target text, thereby drawing the inner shadow effect of the target text.

Description

一种文字的阴影效果处理方法、装置、设备及存储介质A text shadow effect processing method, device, device and storage medium
本公开要求于2021年01月28日提交中国专利局、申请号为202110118989.6、发明名称为“一种文字的阴影效果处理方法、装置、设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本公开中。This disclosure claims the priority of the Chinese patent application filed on January 28, 2021 with the application number 202110118989.6 and the invention titled "A method, device, device and storage medium for processing shadow effects of text", all of which are The contents are incorporated by reference in this disclosure.
技术领域technical field
本公开涉及数据处理领域,尤其涉及一种文字的阴影效果处理方法、装置、设备及存储介质。The present disclosure relates to the field of data processing, and in particular, to a method, device, device and storage medium for processing shadow effects of characters.
背景技术Background technique
目前,文字效果的绘制在越来越多的领域得到应用,例如网络游戏的场景绘制中、综艺节目的字幕显示、视频中的文字显示中等等。At present, the drawing of text effects is applied in more and more fields, such as the scene drawing of online games, the display of subtitles in variety shows, and the display of text in videos, and so on.
文字的阴影效果是一种比较常用的文字效果,如何对文字的阴影效果进行绘制,是目前备受关注的问题。The shadow effect of text is a commonly used text effect. How to draw the shadow effect of text is a problem that has attracted much attention at present.
发明内容SUMMARY OF THE INVENTION
为了解决上述技术问题或者至少部分地解决上述技术问题,本公开提供了一种文字的阴影效果处理方方法、装置、设备及存储介质,能够基于文字的有向距离场图像绘制文字的阴影效果。In order to solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides a method, apparatus, device and storage medium for processing shadow effects of characters, which can draw shadow effects of characters based on directional distance field images of characters.
第一方面,本公开提供了一种文字的阴影效果处理方法,所述方法包括:In a first aspect, the present disclosure provides a method for processing shadow effects of text, the method comprising:
对目标文字的有向距离场图像中的像素点进行位置偏移后,得到第一距离场图像;其中,所述第一距离场图像中包括原像素点以及由所述原像素点经过位置偏移后得到的偏移后像素点;After the pixel points in the directional distance field image of the target text are shifted in position, a first distance field image is obtained; wherein, the first distance field image includes the original pixel point and the position offset by the original pixel point. The offset pixels obtained after shifting;
基于所述第一距离场图像,绘制所述目标文字对应的初始内阴影效果图像;Drawing an initial inner shadow effect image corresponding to the target text based on the first distance field image;
确定由所述第一距离场图像中距离场值大于预设数值的所述偏移后像素点构成的目标区域;determining a target area formed by the offset pixels whose distance field value in the first distance field image is greater than a preset value;
将所述目标区域从所述初始内阴影效果图像中去除,得到所述目标文字的内阴影效果图。The target area is removed from the initial inner shadow effect image to obtain an inner shadow effect image of the target text.
一种可选的实施方式中,所述基于所述第一距离场图像,绘制所述目标文字对应的初始内阴影效果图像,包括:In an optional implementation manner, the drawing of the initial inner shadow effect image corresponding to the target text based on the first distance field image includes:
基于所述第一距离场图像中的所述原像素点,对所述目标文字的文字本体进行绘制;drawing the text body of the target text based on the original pixel point in the first distance field image;
基于所述第一距离场图像中的所述偏移后像素点,对所述目标文字的内阴影进行绘制,得到所述目标文字对应的初始内阴影效果图像。Based on the offset pixels 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.
一种可选的实施方式中,所述基于所述第一距离场图像中的所述偏移后像素点,对所述目标文字的内阴影进行绘制,包括:In an optional embodiment, the drawing of the inner shadow of the target text based on the offset pixels in the first distance field image includes:
基于所述第一距离场图像中的所述偏移后像素点的偏移坐标与渐变方向向量之间的点积运算结果,确定所述偏移后像素点的渐变值;其中,所述偏移坐标为所述偏移后像素点 的位置坐标与渐变原点的差值;Based on a dot product operation result between the offset coordinates of the offset pixels and the gradient direction vector in the first distance field image, the gradient values of the offset pixels are determined; wherein the offset The shift coordinate is the difference between the position coordinate of the pixel point after the offset and the gradient origin;
根据所述渐变值与目标渐变颜色,确定所述偏移后像素点的颜色值;Determine the color value of the pixel point after the offset according to the gradient value and the target gradient color;
基于所述偏移后像素点的颜色值,对所述目标文字的内阴影进行绘制。Based on the color value of the offset pixel, the inner shadow of the target text is drawn.
一种可选的实施方式中,所述方法还包括:In an optional embodiment, the method further includes:
基于所述第一距离场图像,绘制所述目标文字对应的外阴影效果图像。Based on the first distance field image, an outer shadow effect image corresponding to the target text is drawn.
一种可选的实施方式中,所述基于所述第一距离场图像,绘制所述目标文字对应的外阴影效果图像,包括:In an optional implementation manner, the drawing an outer shadow effect image corresponding to the target text based on the first distance field image includes:
基于所述第一距离场图像中的所述偏移后像素点,对所述目标文字的外阴影进行绘制;drawing the outer shadow of the target text based on the offset pixels 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.
一种可选的实施方式中,所述基于所述第一距离场图像中的所述原像素点,对所述目标文字的文字本体进行绘制,包括:In an optional implementation manner, the drawing on the text body of the target text based on the original pixel points in the first distance field image includes:
基于所述第一距离场图像中的所述原像素点的距离场值,确定所述原像素点的颜色透明度值;其中,所述原像素点的距离场值的绝对值与所述原像素点的颜色透明度值成反比;Determine the 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 and the original pixel point The color transparency value of the point is inversely proportional;
基于所述原像素点的颜色透明度值,对所述目标文字的文字本体进行绘制。Based on the color transparency value of the original pixel point, the text body of the target text is drawn.
一种可选的实施方式中,所述基于所述第一距离场图像中的所述偏移后像素点,对所述目标文字的外阴影进行绘制,包括:In an optional embodiment, the drawing of the outer shadow of the target text based on the offset pixels in the first distance field image includes:
基于所述第一距离场图像中的所述偏移后像素点的偏移坐标与渐变方向向量之间的点积运算结果,确定所述偏移后像素点的渐变值;其中,所述偏移坐标为所述偏移后像素点的位置坐标与渐变原点的差值;Based on a dot product operation result between the offset coordinates of the offset pixels and the gradient direction vector in the first distance field image, the gradient values of the offset pixels are determined; wherein the offset The shift coordinate is the difference between the position coordinate of the pixel point after the offset and the gradient origin;
根据所述渐变值与目标渐变颜色,确定所述偏移后像素点的颜色值;Determine the color value of the pixel point after the offset according to the gradient value and the target gradient color;
基于所述偏移后像素点的颜色值,对所述目标文字的外阴影进行绘制。Based on the color value of the offset pixel, the outer shadow of the target text is drawn.
一种可选的实施方式中,所述基于所述第一距离场图像,绘制所述目标文字对应的初始内阴影效果图像之前,还包括:In an optional implementation manner, before the initial inner shadow effect image corresponding to the target text is drawn based on the first distance field image, the method further includes:
基于颜色透明度值,对所述第一距离场图像中位置信息相同的所述原像素点和所述偏移后像素点进行颜色混合。Based on the color transparency value, color mixing is performed on the original pixel point and the offset pixel point with the same position information in the first distance field image.
第二方面,本公开提供了一种文字的阴影效果处理装置,所述装置包括:In a second aspect, the present disclosure provides a text shadow effect processing device, the device comprising:
偏移模块,用于对目标文字的有向距离场图像中的像素点进行位置偏移后,得到第一距离场图像;其中,所述第一距离场图像中包括原像素点以及由所述原像素点经过位置偏移后得到的偏移后像素点;The offset module is used to obtain a first distance field image after performing position offset on the pixel points in the directional distance field image of the target text; wherein, the first distance field image includes the original pixel points and the The offset pixel point obtained after the original pixel point is shifted by the position;
第一绘制模块,用于基于所述第一距离场图像,绘制所述目标文字对应的初始内阴影效果图像;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;
第一确定模块,用于确定由所述第一距离场图像中距离场值大于预设数值的所述偏移后像素点构成的目标区域;a first determination module, configured to determine a target area formed by the offset pixels whose distance field values in the first distance field image are greater than a preset value;
去除模块,用于将所述目标区域从所述初始内阴影效果图像中去除,得到所述目标文字的内阴影效果图。A removal module, configured to remove the target area from the initial inner shadow effect image to obtain an inner shadow effect image of the target text.
第三方面,本公开提供了一种计算机可读存储介质,所述计算机可读存储介质中存储 有指令,当所述指令在终端设备上运行时,使得所述终端设备实现上述的方法。In a third aspect, the present disclosure provides a computer-readable storage medium, where instructions are stored in the computer-readable storage medium, and when the instructions are executed on a terminal device, the terminal device is made to implement the above method.
第四方面,本公开提供了一种设备,包括:存储器,处理器,及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时,实现上述的方法。In a fourth aspect, the present disclosure provides a device comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor, when the processor executes the computer program, Implement the above method.
第五方面,本公开提供了一种计算机程序产品,所述计算机程序产品包括计算机程序/指令,所述计算机程序/指令被处理器执行时,实现上述的方法。In a fifth aspect, the present disclosure provides a computer program product, wherein the computer program product includes a computer program/instruction, and when the computer program/instruction is executed by a processor, the above-mentioned method is implemented.
本公开实施例提供的技术方案与现有技术相比至少具有如下优点:Compared with the prior art, the technical solutions provided by the embodiments of the present disclosure have at least the following advantages:
本公开实施例提供了一种文字的阴影效果处理方法中,首先,对目标文字的有向距离场图像中的像素点进行位置偏移后,得到第一距离场图像,其中,第一距离场图像中包括原像素点以及由原像素点经过位置偏移后的到的偏移后像素点。然后,基于第一距离场图像,绘制目标文字对应的初始内阴影效果图像,进而确定由第一距离场图像中距离场值大于预设数值的偏移后像素点构成的目标区域,并将目标区域从初始内阴影效果图像中去除,得到目标文字的内阴影效果图。本公开利用目标文字的有向距离场图像中距离场值大于预设数值的像素点处于目标文字的外部区域的特征,将处于目标文字的外部区域的像素点构成的目标区域去除,实现了目标文字的内阴影效果的绘制。An embodiment of the present disclosure provides a method for processing shadow effects of characters. First, after performing position offsets on pixels in a directional distance field image of a target character, a first distance field image is obtained, wherein the first distance field image is The image includes the original pixel point and the offset pixel point obtained by the position offset of the original pixel point. Then, based on the first distance field image, draw the initial inner shadow effect image corresponding to the target text, and then determine the target area composed of the offset pixels whose distance field value in the first distance field image is greater than the preset value, and the target area is The area is removed from the initial inner shadow effect image to obtain the inner shadow effect map of the target text. The present disclosure utilizes the feature that the pixels whose distance field value is greater than the preset value in the directional distance field image of the target character are located in the outer area of the target character, and removes the target area formed by the pixels in the outer area of the target character, thereby achieving the target The drawing of the inner shadow effect of the text.
附图说明Description of drawings
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本公开的实施例,并与说明书一起用于解释本公开的原理。The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description serve to explain the principles of the disclosure.
为了更清楚地说明本公开实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,对于本领域普通技术人员而言,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the accompanying drawings that are required to be used in the description of the embodiments or the prior art will be briefly introduced below. In other words, on the premise of no creative labor, other drawings can also be obtained from these drawings.
图1为本公开实施例提供的一种文字的阴影效果处理方法的流程图;1 is a flowchart of a method for processing shadow effects of text according to an embodiment of the present disclosure;
图2为本公开实施例提供的一种初始内阴影效果图像的示意图;2 is a schematic diagram of an initial inner shadow effect image provided by an embodiment of the present disclosure;
图3为本公开实施例提供的一种目标文字的内阴影效果图像的示意图;3 is a schematic diagram of an inner shadow effect image of a target text according to an embodiment of the present disclosure;
图4为本公开实施例提供的一种目标文字对应的外阴影效果图像的示意图;4 is a schematic diagram of an outer shadow effect image corresponding to a target text according to an embodiment of the present disclosure;
图5为本公开实施例提供的一种文字的阴影效果处理装置的结构示意图;FIG. 5 is a schematic structural diagram of a text shadow effect processing device according to an embodiment of the present disclosure;
图6为本公开实施例提供的一种文字的阴影效果处理设备的结构示意图。FIG. 6 is a schematic structural diagram of a text shadow effect processing device according to an embodiment of the present disclosure.
具体实施方式Detailed ways
为了能够更清楚地理解本公开的上述目的、特征和优点,下面将对本公开的方案进行进一步描述。需要说明的是,在不冲突的情况下,本公开的实施例及实施例中的特征可以相互组合。In order to more clearly understand the above objects, features and advantages of the present disclosure, the solutions of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments may be combined with each other under the condition of no conflict.
在下面的描述中阐述了很多具体细节以便于充分理解本公开,但本公开还可以采用其他不同于在此描述的方式来实施;显然,说明书中的实施例只是本公开的一部分实施例,而不是全部的实施例。Many specific details are set forth in the following description to facilitate a full understanding of the present disclosure, but the present disclosure can also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only a part of the embodiments of the present disclosure, and Not all examples.
目前,文字的阴影效果通常是基于位图文字进行绘制的,而有向距离场图像记录有文 字内部及其周围外部的各个像素点距离文字轮廓(也可称为边界)的最短距离值,也称为距离场值。其中,处于文字内部区域的像素点的距离场值设为负数,而处于文字周围外部区域的像素点的距离场值设为正数。发明人发现,基于文字的有向距离场图像能够更便于对文字的阴影效果进行绘制。At present, the shadow effect of text is usually drawn based on bitmap text, and the directional distance field image records the shortest distance value of each pixel inside and outside the text from the text outline (also called the border), also known as the boundary. called the distance field value. Among them, the distance field value of the pixel points in the inner area of the text is set as a negative number, and the distance field value of the pixel points in the outer area around the text is set as a positive number. The inventors found that the text-based directional distance field image can be more convenient to draw the shadow effect of the text.
为此,本公开提供了一种文字的阴影效果处理方法,首先,对目标文字的有向距离场图像中的像素点进行位置偏移后,得到第一距离场图像,其中,第一距离场图像中包括原像素点以及由原像素点经过位置偏移后的到的偏移后像素点。然后,基于第一距离场图像,绘制目标文字对应的初始内阴影效果图像,进而确定由第一距离场图像中距离场值大于预设数值的偏移后像素点构成的目标区域,并将目标区域从初始内阴影效果图像中去除,得到目标文字的内阴影效果图。本公开利用目标文字的有向距离场图像中距离场值大于预设数值的像素点处于目标文字的外部区域的特征,将处于目标文字的外部区域的像素点构成的目标区域去除,实现了目标文字的内阴影效果的绘制。To this end, the present disclosure provides a text shadow effect processing method. First, after the pixel points in the directional distance field image of the target text are shifted in position, a first distance field image is obtained, wherein the first distance field image is The image includes the original pixel point and the offset pixel point obtained by the position offset of the original pixel point. Then, based on the first distance field image, draw the initial inner shadow effect image corresponding to the target text, and then determine the target area composed of the offset pixels whose distance field value in the first distance field image is greater than the preset value, and the target area is The area is removed from the initial inner shadow effect image to obtain the inner shadow effect map of the target text. The present disclosure utilizes the feature that the pixels whose distance field value is greater than the preset value in the directional distance field image of the target character are located in the outer area of the target character, and removes the target area formed by the pixels in the outer area of the target character, thereby achieving the target The drawing of the inner shadow effect of the text.
基于此,本公开实施例提供了一种文字的阴影效果处理方法,参考图1,为本公开实施例提供的一种文字的阴影效果处理方法的流程图,该方法包括:Based on this, an embodiment of the present disclosure provides a method for processing shadow effects of text. Referring to FIG. 1 , a flowchart of a method for processing shadow effects of text provided by an embodiment of the present disclosure includes:
S101:对目标文字的有向距离场图像中的像素点进行位置偏移后,得到第一距离场图像;其中,所述第一距离场图像中包括原像素点以及由所述原像素点经过位置偏移后得到的偏移后像素点。S101: After performing position offset on the pixel points in the directional distance field image of the target character, a first distance field image is obtained; wherein, the first distance field image includes the original pixel points and the pixels passing through the original pixel points. The offset pixel point obtained after the position offset.
本公开实施例中,预先确定阴影效果的偏移向量,用于表示阴影效果的偏移方向和偏移距离等。例如,偏移向量可以为(shadowOffsetX,shadowOffsetY),其中,shadowOffsetX用于表示阴影效果相对于文字本体在X轴方向上的偏移距离,shadowOffsetY用于表示阴影效果相对于文字本体在Y轴方向上的偏移距离。In the embodiment of the present disclosure, the offset vector of the shadow effect is predetermined, which is used to represent the offset direction and offset distance of the shadow effect, and the like. For example, the offset vector can be (shadowOffsetX, shadowOffsetY), where shadowOffsetX is used to represent the offset distance of the shadow effect relative to the text body in the X-axis direction, and shadowOffsetY is used to represent the shadow effect relative to the text body in the Y-axis direction offset distance.
实际应用中,针对目标文字的有向距离场图像中的任一像素点(x,y),基于偏移向量(shadowOffsetX,shadowOffsetY)进行位置偏移后,得到的偏移后像素点为(x-shadowOffsetX,y-shadowOffsetY)。其中,像素点(x,y)称为原像素点,像素点(x-shadowOffsetX,y-shadowOffsetY)为原像素点(x,y)对应的偏移后像素点。在目标文字的有向距离场图像中的各个像素点均完成位置偏移后,得到包括原像素点和偏移后像素点的第一距离场图像。In practical applications, for any pixel point (x, y) in the directional distance field image of the target text, after the position offset is performed based on the offset vector (shadowOffsetX, shadowOffsetY), the obtained 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 each pixel point in the directional distance field image of the target character has completed the position shift, a first distance field image including the original pixel point and the shifted pixel point is obtained.
S102:基于所述第一距离场图像,绘制所述目标文字对应的初始内阴影效果图像。S102: Based on the first distance field image, draw an initial inner shadow effect image corresponding to the target text.
本公开实施例中,在确定第一距离场图像后,基于第一距离场图像上的原像素点和偏移后像素点的距离场值,绘制目标文字对应的初始阴影效果图像。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 original pixel point on the first distance field image and the distance field value of the offset pixel point.
一种可选的实施方式中,首先,可以基于第一距离场图像中的原像素点,对目标文字的文字本体进行绘制。在完成文字本体的绘制后,再基于第一距离场图像中的偏移后像素点,对目标文字的文字本体的内阴影进行初步绘制,得到目标文字对应的初始内阴影效果图像。通过控制绘制层级先后顺序,使得文字本体绘制在阴影的下方,使得文字本体被阴影遮挡,达到文字本体具有内阴影的绘制效果。In an optional implementation manner, first, the text body of the target text may be drawn based on the original pixel points in the first distance field image. After the text body is drawn, the inner shadow of the text body of the target text is initially drawn based on the offset pixels in the first distance field image to obtain an initial inner shadow effect image corresponding to the target text. By controlling the sequence of drawing levels, the text body is drawn below the shadow, so that the text body is blocked by the shadow, so that the text body has an inner shadow drawing effect.
实际应用中,在对文字本体进行绘制之前,还可以确定各个原像素点的颜色值,然后基于具有颜色值的原像素点,绘制目标文字的文字本体。另外,在对目标文字的文字本体 的内阴影进行绘制之前,可以首先确定偏移后像素点的颜色值,然后基于具有颜色值的偏移后像素点,绘制目标文字的文字本体的内阴影,得到目标文字对应的初始内阴影效果图像。基于上述方式,可以绘制出带有颜色的文字本体和内阴影。In practical applications, before the text body is drawn, the color value of each original pixel can also be determined, and then the text body of the target text is drawn based on the original pixel with the color value. In addition, before the inner shadow of the text body of the target text is drawn, the color value of the offset pixel can be determined first, and then the inner shadow of the text body of the target text can be drawn based on the offset pixel with the color value. Obtain the initial inner shadow effect image corresponding to the target text. Based on the above method, the text body and inner shadow with color can be drawn.
另外,如果第一距离场图像中位置信息相同的原像素点和偏移后像素点均存在颜色透明度值,则可以基于颜色透明度值,对位置信息相同的原像素点和偏移后像素点进行颜色混合。基于颜色透明度值进行颜色混合的方式在本公开实施例中不做限制。In addition, if both the original pixel point and the offset pixel point with the same position information in the first distance field image have a color transparency value, then based on the color transparency value, the original pixel point and the offset pixel point with the same position information can be processed. Color mixing. The manner of performing color mixing based on the color transparency value is not limited in this embodiment of the present disclosure.
一种可选的实施方式中,可以将目标文字对应的初始内阴影效果图像中的文字本体绘制为发光效果。具体的,在绘制文字本体之前,基于第一距离场图像中的原像素点的距离场值,确定该原像素点的颜色透明度值,其中,距离场值与颜色透明度值成反比,即距离文字本体越远的像素点的颜色透明度越低,从而实现文字发光效果。然后,基于原像素点的颜色透明度值,对目标文字的文字本体进行绘制。In an optional implementation manner, the text body in the initial inner shadow effect image corresponding to the target text may be drawn as a light-emitting effect. Specifically, before the text body is drawn, 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, wherein the distance field value is inversely proportional to the color transparency value, that is, the distance from the text The farther the body is, the lower the color transparency is, so that the text glow effect is realized. Then, based on the color transparency value of the original pixel, the text body of the target text is drawn.
另一种可选的实施方式中,可以将目标文字对应的初始内阴影效果图像中的内阴影效果绘制为渐变色效果。具体的,在绘制目标文字的内阴影之前,基于第一距离场图像中的偏移后像素点的偏移坐标与渐变方向向量之间的点积运算结果,确定该偏移后像素点的渐变值。其中,偏移坐标为该偏移后像素点的位置坐标与渐变原点的差值。然后,结合渐变值和目标渐变颜色,确定偏移后像素点的颜色值,之后,基于偏移后像素点的颜色值,对目标文字的内阴影进行绘制。In another optional implementation manner, the inner shadow effect in the initial inner shadow effect image corresponding to the target text may be drawn as a gradient color effect. Specifically, before drawing the inner shadow of the target text, the gradient of the offset pixel is determined based on the dot product operation result between the offset coordinates of the offset pixel in the first distance field image and the gradient direction vector value. The offset coordinate is the difference between the position coordinate of the offset pixel and the gradient origin. Then, combine the gradient value and the target gradient color to determine the color value of the pixel point after the offset, and then draw the inner shadow of the target text based on the color value of the pixel point after the offset.
其中,目标渐变颜色通常为两种颜色,例如白色和黑色,渐变色效果则为由黑色渐变为白色的效果,或者由黑色渐变为白色的效果。渐变原点通常为文字本体的中心点,具体用于确定目标渐变颜色中的其中一种颜色向另一种颜色过渡的点。Among them, the target gradient color is usually two colors, such as white and black, and the gradient color effect is the effect of gradient from black to white, or the effect of gradient from black to white. The origin of the gradient is usually the center point of the text body, which is specifically used to determine the transition point from one color to another in the target gradient color.
S103:确定由所述第一距离场图像中距离场值大于预设数值的所述偏移后像素点构成的目标区域。S103: Determine a target area formed by the offset pixels whose distance field values in the first distance field image are greater than a preset value.
其中,预设阈值可以基于对内阴影效果的需求进行设置,具体的,预设阈值可以为0,或者,也可以为0-0.5之间的数值。Wherein, the preset threshold may be set based on the requirements for the inner shadow effect, and specifically, the preset threshold may be 0, or may also be a value between 0 and 0.5.
本公开实施例中,基于第一距离场图像中的偏移后像素点绘制的内阴影效果中,存在不重叠于文字本体的区域,如图2所示,为本公开实施例提供的一种初始内阴影效果图像的示意图。为了保证目标文字的内阴影绘制效果,本公开实施例需要将不重叠于文字本体的区域裁剪掉。In the embodiment of the present disclosure, in the inner shadow effect drawn based on the offset pixels in the first distance field image, there is an area that does not overlap with the text body. As shown in FIG. Schematic of the initial inner shadow effect image. In order to ensure the inner shadow drawing effect of the target text, the embodiment of the present disclosure needs to cut out the area that does not overlap with the text body.
为此,本公开实施例基于有向距离场图像中位于文字外部区域的像素点的距离场值为负数的特征,确定由第一距离场图像中距离场值大于预设数值(例如0)的偏移后像素点构成的目标区域。To this end, the embodiment of the present disclosure determines, based on the characteristic that the distance field value of the pixels located in the outer area of the text in the directional distance field image is negative, the distance field value in the first distance field image is greater than a preset value (for example, 0). The target area composed of pixels after offset.
S104:将所述目标区域从所述初始内阴影效果图像中去除,得到所述目标文字的内阴影效果图像。S104: Remove the target area from the initial inner shadow effect image to obtain an inner shadow effect image of the target text.
本公开实施例中,目标区域由距离场值大于预设数值的偏移后像素点构成,其中,距离场值大于预设数值的偏移后像素点位于目标文本的周围外部区域。为了实现目标文字的内阴影效果,需要将位于目标文字的周围外部区域的距离场值大于预设数值的偏移后像素点去除。In the embodiment of the present disclosure, the target area is composed of offset pixels with a distance field value greater than a preset value, wherein the offset pixels with a distance field value greater than the preset value are located in an outer area around the target text. In order to realize the inner shadow effect of the target text, it is necessary to remove the offset pixels whose distance field value is greater than the preset value in the outer area around the target text.
为此,本公开实施例在确定目标区域后,将目标区域从初始内阴影效果图像中去除,以保证最终获得到的内阴影效果图像中不存在不重叠于文字本体的区域,保证目标文字的内阴影效果。如图3,为本公开实施例提供的一种目标文字的内阴影效果图像的示意图。For this reason, after determining the target area in the embodiment of the present disclosure, the target area is removed from the initial inner shadow effect image, so as to ensure that there is no area that does not overlap with the text body in the finally obtained inner shadow effect image, so as to ensure that the target text does not overlap. Inner shadow effect. FIG. 3 is a schematic diagram of an inner shadow effect image of a target text according to an embodiment of the present disclosure.
本公开实施例提供的文字的阴影效果处理方法中,首先,对目标文字的有向距离场图像中的像素点进行位置偏移后,得到第一距离场图像,其中,第一距离场图像中包括原像素点以及由原像素点经过位置偏移后的到的偏移后像素点。然后,基于第一距离场图像,绘制目标文字对应的初始内阴影效果图像,进而确定由第一距离场图像中距离场值大于预设数值的偏移后像素点构成的目标区域,并将目标区域从初始内阴影效果图像中去除,得到目标文字的内阴影效果图。本公开实施例利用目标文字的有向距离场图像中距离场值大于预设数值的像素点处于目标文字的外部区域的特征,将处于目标文字的外部区域的像素点构成的目标区域去除,实现了目标文字的内阴影效果的绘制。In the text shadow effect processing method provided by the embodiment of the present disclosure, firstly, after performing position offset on the pixel points in the directional distance field image of the target text, a first distance field image is obtained, wherein, in the first distance field image Including the original pixel point and the offset pixel point obtained by the position offset of the original pixel point. Then, based on the first distance field image, draw the initial inner shadow effect image corresponding to the target text, and then determine the target area composed of the offset pixels whose distance field value in the first distance field image is greater than the preset value, and the target area is The area is removed from the initial inner shadow effect image to obtain the inner shadow effect map of the target text. The embodiment of the present disclosure utilizes the feature that the pixels whose distance field value is greater than the preset value in the directional distance field image of the target character are located in the outer area of the target character, and removes the target area formed by the pixels located in the outer area of the target character. The inner shadow effect of the target text is drawn.
本公开实施例还提供了一种目标文字的外阴影效果处理方法,具体的,基于第一距离场图像,绘制目标文字对应的外阴影效果图像,其中,对于外阴影效果的绘制可以是对外阴影进行绘制,然后再对文字本体进行绘制。Embodiments of the present disclosure also provide a method for processing an outer shadow effect of a target character. Specifically, an outer shadow effect image corresponding to the target character is drawn based on a first distance field image, wherein the outer shadow effect may be drawn by an outer shadow. Draw, and then draw the text body.
一种可选的实施方式中,首先,基于第一距离场图像中的所述偏移后像素点,对所述目标文字的外阴影进行绘制;然后,基于所述第一距离场图像中的所述原像素点,对所述目标文字的文字本体进行绘制,得到所述目标文字对应的外阴影效果图像。如图4所示,为本公开实施例提供的一种目标文字对应的外阴影效果图像的示意图。In an optional implementation manner, first, the outer shadow of the target text is drawn based on the offset pixels in the first distance field image; then, based on the offset pixels in the first distance field image; For the original pixel point, the text body of the target text is drawn to obtain an outer shadow effect image corresponding to the target text. As shown in FIG. 4 , it is a schematic diagram of an outer shadow effect image corresponding to a target text according to an embodiment of the present disclosure.
通过控制绘制层级先后顺序,使得文字本体绘制在阴影的上方,使得阴影被文字本体遮挡,达到文字本体具有外阴影的绘制效果。By controlling the order of drawing levels, the text body is drawn above the shadow, so that the shadow is blocked by the text body, so that the text body has an outer shadow drawing effect.
值得注意的是,用于绘制目标文字对应的外阴影效果图像的第一距离场图像中,用于对像素点进行位置偏移的偏移向量和偏移距离可以与内阴影效果绘制不同。It is worth noting that, in the first distance field image used to draw the outer shadow effect image corresponding to the target text, the offset vector and the offset distance used to offset the pixel point may be different from the inner shadow effect drawing.
一种可选的实施方式中,在对目标文字的外阴影效果绘制时,可以将目标文字对应的初始外阴影效果图像中的文字本体绘制为发光效果。具体的,在绘制文字本体之前,基于第一距离场图像中的原像素点的距离场值,确定该原像素点的颜色透明度值,其中,距离场值与颜色透明度值成反比,即距离文字本体越远的像素点的颜色透明度越低,从而实现文字发光效果。然后,基于原像素点的颜色透明度值,对目标文字的文字本体进行绘制。In an optional embodiment, when the outer shadow effect of the target text is drawn, the text body in the initial outer shadow effect image corresponding to the target text may be drawn as a luminous effect. Specifically, before the text body is drawn, 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, wherein the distance field value is inversely proportional to the color transparency value, that is, the distance from the text The farther the body is, the lower the color transparency is, so that the text glow effect is realized. Then, based on the color transparency value of the original pixel, the text body of the target text is drawn.
另一种可选的实施方式中,可以将目标文字对应的初始外阴影效果图像中的外阴影效果绘制为渐变色效果。具体的,在绘制目标文字的外阴影之前,基于第一距离场图像中的偏移后像素点的偏移坐标与渐变方向向量之间的点积运算结果,确定该偏移后像素点的渐变值。其中,偏移坐标为该偏移后像素点的位置坐标与渐变原点的差值。然后,结合渐变值和目标渐变颜色,确定偏移后像素点的颜色值,最终,基于偏移后像素点的颜色值,对目标文字的外阴影进行绘制。In another optional implementation manner, the outer shadow effect in the initial outer shadow effect image corresponding to the target text may be drawn as a gradient color effect. Specifically, before drawing the outer shadow of the target text, the gradient of the offset pixel is determined based on the dot product operation result between the offset coordinates of the offset pixel and the gradient direction vector in the first distance field image value. The offset coordinate is the difference between the position coordinate of the offset pixel and the gradient origin. Then, combined with the gradient value and the target gradient color, the color value of the offset pixel is determined, and finally, based on the color value of the offset pixel, the outer shadow of the target text is drawn.
本公开实施例提供的文字的阴影效果处理方法中,不仅能够基于目标文字的有向距离场图像绘制目标文字的内阴影效果,还可以基于目标文字的有向距离场图像绘制目标文字的外阴影效果,满足了用户对文字阴影效果的处理需求。In the text shadow effect processing method provided by the embodiment of the present disclosure, not only the inner shadow effect of the target text can be drawn based on the directional distance field image of the target text, but also the outer shadow of the target text can be drawn based on the directional distance field image of the target text effect, which satisfies the user's processing needs for the text shadow effect.
与上述方法实施例基于同一个发明构思,本公开还提供了一种文字的阴影效果处理装 置,参考图5,为本公开实施例提供的一种文字的阴影效果处理装置的结构示意图,所述装置包括:Based on the same inventive concept as the above method embodiments, the present disclosure also provides a text shadow effect processing device. Referring to FIG. 5 , a schematic structural diagram of a text shadow effect processing device provided in an embodiment of the present disclosure, the The device includes:
偏移模块501,用于对目标文字的有向距离场图像中的像素点进行位置偏移后,得到第一距离场图像;其中,所述第一距离场图像中包括原像素点以及由所述原像素点经过位置偏移后得到的偏移后像素点;The offset module 501 is used to obtain a first distance field image after performing position offset on the pixel points in the directional distance field image of the target text; wherein, the first distance field image includes the original pixel point and the The offset pixel point obtained by the original pixel point after the position offset;
第一绘制模块502,用于基于所述第一距离场图像,绘制所述目标文字对应的初始内阴影效果图像;a first drawing module 502, configured to draw an initial inner shadow effect image corresponding to the target text based on the first distance field image;
第一确定模块503,用于确定由所述第一距离场图像中距离场值大于预设数值的所述偏移后像素点构成的目标区域;A first determination module 503, configured to determine a target area formed by the offset pixels whose distance field value in the first distance field image is greater than a preset value;
去除模块504,用于将所述目标区域从所述初始内阴影效果图像中去除,得到所述目标文字的内阴影效果图。The removing 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.
一种可选的实施方式中,所述第一绘制模块,包括:In an optional implementation manner, the first drawing module includes:
第一绘制子模块,用于基于所述第一距离场图像中的所述原像素点,对所述目标文字的文字本体进行绘制;a first drawing sub-module for drawing the text body of the target text based on the original pixel in the first distance field image;
第二绘制子模块,用于基于所述第一距离场图像中的所述偏移后像素点,对所述目标文字的内阴影进行绘制,得到所述目标文字对应的初始内阴影效果图像。The second drawing sub-module is configured to draw the inner shadow of the target text based on the offset pixels in the first distance field image, to obtain an initial inner shadow effect image corresponding to the target text.
一种可选的实施方式中,所述装置还包括:In an optional embodiment, the device further includes:
第二绘制模块,用于基于所述第一距离场图像,绘制所述目标文字对应的外阴影效果图像。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.
一种可选的实施方式中,所述第二绘制模块,包括:In an optional implementation manner, the second drawing module includes:
第三绘制子模块,用于基于所述第一距离场图像中的所述偏移后像素点,对所述目标文字的外阴影进行绘制;a third drawing sub-module for drawing the outer shadow of the target text based on the offset pixels in the first distance field image;
第四绘制子模块,用于基于所述第一距离场图像中的所述原像素点,对所述目标文字的文字本体进行绘制,得到所述目标文字对应的外阴影效果图像。The fourth drawing sub-module 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.
一种可选的实施方式中,所述第一绘制子模块或所述第四绘制子模块,包括:In an optional embodiment, the first drawing sub-module or the fourth drawing sub-module includes:
第一确定子模块,用于基于所述第一距离场图像中的所述原像素点的距离场值,确定所述原像素点的颜色透明度值;其中,所述原像素点的距离场值与所述原像素点的颜色透明度值成反比;a first determination submodule, configured to determine the 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 Inversely proportional to the color transparency value of the original pixel;
第五绘制子模块,用于基于所述原像素点的颜色透明度值,对所述目标文字的文字本体进行绘制。The fifth drawing sub-module is configured to draw the text body of the target text based on the color transparency value of the original pixel.
一种可选的实施方式中,所述第二绘制子模块,包括:In an optional embodiment, the second drawing submodule includes:
第二确定子模块,用于基于所述第一距离场图像中的所述偏移后像素点的偏移坐标与渐变方向向量之间的点积运算结果,确定所述偏移后像素点的渐变值;其中,所述偏移坐标为所述偏移后像素点的位置坐标与渐变原点的差值;The second determination sub-module is configured to determine, based on the dot product operation result between the offset coordinates of the offset pixel points and the gradient direction vector in the first distance field image, the offset value of the offset pixel point. Gradient value; wherein, the offset coordinate is the difference between the position coordinate of the pixel point after the offset and the gradient origin;
第三确定子模块,用于根据所述渐变值与目标渐变颜色,确定所述偏移后像素点的颜色值;a third determination submodule, configured to determine the color value of the pixel after the offset according to the gradient value and the target gradient color;
第六绘制子模块,用于基于所述偏移后像素点的颜色值,对所述目标文字的内阴影进 行绘制。The sixth drawing sub-module is used for drawing the inner shadow of the target text based on the color value of the pixel after the offset.
一种可选的实施方式中,所述第三绘制子模块,包括:In an optional embodiment, the third drawing sub-module includes:
第四确定子模块,用于基于所述第一距离场图像中的所述偏移后像素点的偏移坐标与渐变方向向量之间的点积运算结果,确定所述偏移后像素点的渐变值;其中,所述偏移坐标为所述偏移后像素点的位置坐标与渐变原点的差值;The fourth determination sub-module is configured to determine, based on the dot product operation result between the offset coordinates of the offset pixel point and the gradient direction vector in the first distance field image, the offset value of the offset pixel point. Gradient value; wherein, the offset coordinate is the difference between the position coordinate of the pixel point after the offset and the gradient origin;
第五确定子模块,用于根据所述渐变值与目标渐变颜色,确定所述偏移后像素点的颜色值;The fifth determination submodule is used to determine the color value of the pixel point after the offset according to the gradient value and the target gradient color;
第七绘制子模块,用于基于所述偏移后像素点的颜色值,对所述目标文字的外阴影进行绘制。The seventh drawing sub-module is configured to draw the outer shadow of the target text based on the color value of the offset pixel.
一种可选的实施方式中,所述装置还包括:In an optional embodiment, the device further includes:
混合模块,用于基于颜色透明度值,对所述第一距离场图像中位置信息相同的所述原像素点和所述偏移后像素点进行颜色混合。A mixing module, configured to perform color mixing on the original pixel points with the same position information in the first distance field image and the shifted pixel points based on the color transparency value.
本公开实施例提供的文字的阴影效果处理装置中,首先,对目标文字的有向距离场图像中的像素点进行位置偏移后,得到第一距离场图像,其中,第一距离场图像中包括原像素点以及由原像素点经过位置偏移后的到的偏移后像素点。然后,基于第一距离场图像,绘制目标文字对应的初始内阴影效果图像,进而确定由第一距离场图像中距离场值大于预设数值的偏移后像素点构成的目标区域,并将目标区域从初始内阴影效果图像中去除,得到目标文字的内阴影效果图。本公开实施例利用目标文字的有向距离场图像中距离场值大于预设数值的像素点处于目标文字的外部区域的特征,将处于目标文字的外部区域的像素点构成的目标区域去除,实现了目标文字的内阴影效果的绘制。In the text shadow effect processing device provided by the embodiment of the present disclosure, firstly, after performing position offset on the pixel points in the directional distance field image of the target text, a first distance field image is obtained, wherein, in the first distance field image Including the original pixel point and the offset pixel point obtained by the position offset of the original pixel point. Then, based on the first distance field image, draw the initial inner shadow effect image corresponding to the target text, and then determine the target area formed by the offset pixels whose distance field value in the first distance field image is greater than the preset value, and the target area is The area is removed from the initial inner shadow effect image to obtain the inner shadow effect map of the target text. The embodiment of the present disclosure utilizes the feature that the pixels whose distance field value is greater than the preset value in the directional distance field image of the target character are located in the outer area of the target character, and removes the target area formed by the pixels in the outer area of the target character, so as to realize The inner shadow effect of the target text is drawn.
除了上述方法和装置以外,本公开实施例还提供了一种计算机可读存储介质,计算机可读存储介质中存储有指令,当所述指令在终端设备上运行时,使得所述终端设备实现本公开实施例所述的文字的阴影效果处理方法。In addition to the above method and apparatus, embodiments of the present disclosure also provide a computer-readable storage medium, where instructions are stored in the computer-readable storage medium, and when the instructions are executed on a terminal device, the terminal device is made to implement the present invention. The method for processing the shadow effect of text according to the embodiment is disclosed.
本公开实施例还提供了一种计算机程序产品,包括计算机程序/指令,该计算机程序/指令被处理器执行时实现本公开实施例所述的文字的阴影效果处理方法。Embodiments of the present disclosure further provide a computer program product, including computer programs/instructions, which, when executed by a processor, implement the method for processing shadow effects of characters described in the embodiments of the present disclosure.
另外,本公开实施例还提供了一种文字的阴影效果处理设备,参见图6所示,可以包括:In addition, an embodiment of the present disclosure also provides a text shadow effect processing device, as shown in FIG. 6 , which may include:
处理器601、存储器602、输入装置603和输出装置604。文字的阴影效果处理设备中的处理器601的数量可以一个或多个,图6中以一个处理器为例。在本公开的一些实施例中,处理器601、存储器602、输入装置603和输出装置604可通过总线或其它方式连接,其中,图6中以通过总线连接为例。 Processor 601 , memory 602 , input device 603 and output device 604 . The number of processors 601 in the text shadow effect processing device may be one or more, and one processor is taken as an example in FIG. 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 by a bus or in other ways, wherein the connection by a bus is taken as an example in FIG. 6 .
存储器602可用于存储软件程序以及模块,处理器601通过运行存储在存储器602的软件程序以及模块,从而执行如本公开所示的文字的阴影效果处理设备的各种功能应用以及数据处理。存储器602可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序等。此外,存储器602可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。输入装置603可用于接收输入的数字或字符信息,以及产生与文字的阴 影效果处理设备的用户设置以及功能控制有关的信号输入。The memory 602 can be used to store software programs and modules, and the processor 601 executes 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 stored program area and a stored data area, wherein the stored program area may store an operating system, an application program required for at least one function, and the like. Additionally, memory 602 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. The input device 603 may be used to receive input numerical or character information, and to generate signal input related to user settings and function control of the text shading effect processing device.
具体在本实施例中,处理器601会按照如下的指令,将一个或一个以上的应用程序的进程对应的可执行文件加载到存储器602中,并由处理器601来运行存储在存储器602中的应用程序,从而实现上述文字的阴影效果处理设备的各种功能。Specifically in this embodiment, the processor 601 loads the executable files corresponding to the processes of one or more application programs into the memory 602 according to the following instructions, and the processor 601 executes the executable files stored in the memory 602 application, so as to realize various functions of the above-mentioned text shadow effect processing device.
需要说明的是,在本文中,诸如“第一”和“第二”等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者设备中还存在另外的相同要素。It should be noted that, in this document, relational terms such as "first" and "second" etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply these There is no such actual relationship or sequence between entities or operations. Moreover, the terms "comprising", "comprising" or any other variation thereof are intended to encompass a non-exclusive inclusion such that a process, method, article or device that includes a list of elements includes not only those elements, but also includes not explicitly listed or other elements inherent to such a process, method, article or apparatus. Without further limitation, an element qualified by the phrase "comprising a..." does not preclude the presence of additional identical elements in a process, method, article or apparatus that includes the element.
以上所述仅是本公开的具体实施方式,使本领域技术人员能够理解或实现本公开。对这些实施例的多种修改对本领域的技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本公开的精神或范围的情况下,在其它实施例中实现。因此,本公开将不会被限制于本文所述的这些实施例,而是要符合与本文所公开的原理和新颖特点相一致的最宽的范围。The above descriptions are only specific embodiments of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic 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 is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (12)

  1. 一种文字的阴影效果处理方法,其特征在于,所述方法包括:A method for processing shadow effects of characters, characterized in that the method comprises:
    对目标文字的有向距离场图像中的像素点进行位置偏移后,得到第一距离场图像;其中,所述第一距离场图像中包括原像素点以及由所述原像素点经过位置偏移后得到的偏移后像素点;After the pixel points in the directional distance field image of the target text are shifted in position, a first distance field image is obtained; wherein, the first distance field image includes the original pixel point and the position offset by the original pixel point. The offset pixels obtained after shifting;
    基于所述第一距离场图像,绘制所述目标文字对应的初始内阴影效果图像;Drawing an initial inner shadow effect image corresponding to the target text based on the first distance field image;
    确定由所述第一距离场图像中距离场值大于预设数值的所述偏移后像素点构成的目标区域;determining a target area formed by the offset pixels whose distance field value in the first distance field image is greater than a preset value;
    将所述目标区域从所述初始内阴影效果图像中去除,得到所述目标文字的内阴影效果图。The target area is removed from the initial inner shadow effect image to obtain an inner shadow effect image of the target text.
  2. 根据权利要求1所述的方法,其特征在于,所述基于所述第一距离场图像,绘制所述目标文字对应的初始内阴影效果图像,包括:The method according to claim 1, wherein the drawing an initial inner shadow effect image corresponding to the target text based on the first distance field image comprises:
    基于所述第一距离场图像中的所述原像素点,对所述目标文字的文字本体进行绘制;drawing the text body of the target text based on the original pixel point in the first distance field image;
    基于所述第一距离场图像中的所述偏移后像素点,对所述目标文字的内阴影进行绘制,得到所述目标文字对应的初始内阴影效果图像。Based on the offset pixels 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. 根据权利要求2所述的方法,其特征在于,所述基于所述第一距离场图像中的所述偏移后像素点,对所述目标文字的内阴影进行绘制,包括:The method according to claim 2, wherein the drawing the inner shadow of the target text based on the offset pixels in the first distance field image comprises:
    基于所述第一距离场图像中的所述偏移后像素点的偏移坐标与渐变方向向量之间的点积运算结果,确定所述偏移后像素点的渐变值;其中,所述偏移坐标为所述偏移后像素点的位置坐标与渐变原点的差值;Based on a dot product operation result between the offset coordinates of the offset pixels and the gradient direction vector in the first distance field image, the gradient values of the offset pixels are determined; wherein the offset The shift coordinate is the difference between the position coordinate of the pixel point after the offset and the gradient origin;
    根据所述渐变值与目标渐变颜色,确定所述偏移后像素点的颜色值;Determine the color value of the pixel point after the offset according to the gradient value and the target gradient color;
    基于所述偏移后像素点的颜色值,对所述目标文字的内阴影进行绘制。Based on the color value of the offset pixel, the inner shadow of the target text is drawn.
  4. 根据权利要求1所述的方法,其特征在于,所述方法还包括: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. 根据权利要求4所述的方法,其特征在于,所述基于所述第一距离场图像,绘制所述目标文字对应的外阴影效果图像,包括:The method according to claim 4, wherein the drawing an outer shadow effect image corresponding to the target text based on the first distance field image comprises:
    基于所述第一距离场图像中的所述偏移后像素点,对所述目标文字的外阴影进行绘制;drawing the outer shadow of the target text based on the offset pixels 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. 根据权利要求2或5所述的方法,其特征在于,所述基于所述第一距离场图像中的所述原像素点,对所述目标文字的文字本体进行绘制,包括:The method according to claim 2 or 5, wherein the drawing the text body of the target text based on the original pixel points in the first distance field image comprises:
    基于所述第一距离场图像中的所述原像素点的距离场值,确定所述原像素点的颜色透明度值;其中,所述原像素点的距离场值的绝对值与所述原像素点的颜色透明度值成反比;Determine the 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 and the original pixel point The color transparency value of the point is inversely proportional;
    基于所述原像素点的颜色透明度值,对所述目标文字的文字本体进行绘制。Based on the color transparency value of the original pixel point, the text body of the target text is drawn.
  7. 根据权利要求5所述的方法,其特征在于,所述基于所述第一距离场图像中的所述偏移后像素点,对所述目标文字的外阴影进行绘制,包括:The method according to claim 5, wherein the drawing the outer shadow of the target text based on the offset pixels in the first distance field image comprises:
    基于所述第一距离场图像中的所述偏移后像素点的偏移坐标与渐变方向向量之间的点 积运算结果,确定所述偏移后像素点的渐变值;其中,所述偏移坐标为所述偏移后像素点的位置坐标与渐变原点的差值;Based on a dot product operation result between the offset coordinates of the offset pixels and the gradient direction vector in the first distance field image, the gradient values of the offset pixels are determined; wherein the offset The shift coordinate is the difference between the position coordinate of the pixel point after the offset and the gradient origin;
    根据所述渐变值与目标渐变颜色,确定所述偏移后像素点的颜色值;Determine the color value of the pixel point after the offset according to the gradient value and the target gradient color;
    基于所述偏移后像素点的颜色值,对所述目标文字的外阴影进行绘制。Based on the color value of the offset pixel, the outer shadow of the target text is drawn.
  8. 根据权利要求1所述的方法,其特征在于,所述基于所述第一距离场图像,绘制所述目标文字对应的初始内阴影效果图像之前,还包括:The method according to claim 1, wherein before the drawing the initial inner shadow effect image corresponding to the target text based on the first distance field image, the method further comprises:
    基于颜色透明度值,对所述第一距离场图像中位置信息相同的所述原像素点和所述偏移后像素点进行颜色混合。Based on the color transparency value, color mixing is performed on the original pixel point and the shifted pixel point with the same position information in the first distance field image.
  9. 一种文字的阴影效果处理装置,其特征在于,所述装置包括:A device for processing shadow effects of characters, characterized in that the device comprises:
    偏移模块,用于对目标文字的有向距离场图像中的像素点进行位置偏移后,得到第一距离场图像;其中,所述第一距离场图像中包括原像素点以及由所述原像素点经过位置偏移后得到的偏移后像素点;The offset module is used to obtain a first distance field image after performing position offset on the pixel points in the directional distance field image of the target text; wherein, the first distance field image includes the original pixel points and the The offset pixel point obtained after the original pixel point is shifted by the position;
    第一绘制模块,用于基于所述第一距离场图像,绘制所述目标文字对应的初始内阴影效果图像;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;
    第一确定模块,用于确定由所述第一距离场图像中距离场值大于预设数值的所述偏移后像素点构成的目标区域;a first determination module, configured to determine a target area formed by the offset pixels whose distance field values in the first distance field image are greater than a preset value;
    去除模块,用于将所述目标区域从所述初始内阴影效果图像中去除,得到所述目标文字的内阴影效果图。A removal module, configured to remove the target area from the initial inner shadow effect image to obtain an inner shadow effect image of the target text.
  10. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有指令,当所述指令在终端设备上运行时,使得所述终端设备实现如权利要求1-8任一项所述的方法。A computer-readable storage medium, wherein instructions are stored in the computer-readable storage medium, and when the instructions are executed on a terminal device, the terminal device is made to implement any one of claims 1-8. the method described.
  11. 一种设备,其特征在于,包括:存储器,处理器,及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时,实现如权利要求1-8任一项所述的方法。A device, characterized in that it comprises: a memory, a processor, and a computer program stored in the memory and running on the processor, when the processor executes the computer program, the computer program as claimed in the claims is realized. The method of any one of 1-8.
  12. 一种计算机程序产品,其特征在于,所述计算机程序产品包括计算机程序/指令,所述计算机程序/指令被处理器执行时实现如权利要求1-8任一项所述的方法。A computer program product, characterized in that, the computer program product includes a computer program/instruction, and when the computer program/instruction is executed by a processor, the method according to any one of claims 1-8 is implemented.
PCT/CN2021/135953 2021-01-28 2021-12-07 Text shadow effect processing method and apparatus, device and storage medium WO2022160946A1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US18/357,651 US20240005573A1 (en) 2021-01-28 2023-07-24 Method for generating signed distance field image, method for generating text effect image, device and medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110118989.6A CN114820874A (en) 2021-01-28 2021-01-28 Method, device and equipment for processing shadow effect of characters and storage medium
CN202110118989.6 2021-01-28

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/072915 Continuation-In-Part WO2022161237A1 (en) 2021-01-28 2022-01-20 Text contour effect processing method and apparatus, device, and storage medium

Related Child Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/133879 Continuation-In-Part WO2022160914A1 (en) 2021-01-28 2021-11-29 Effect processing method and apparatus, and device and storage medium

Publications (1)

Publication Number Publication Date
WO2022160946A1 true WO2022160946A1 (en) 2022-08-04

Family

ID=82525455

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/135953 WO2022160946A1 (en) 2021-01-28 2021-12-07 Text shadow effect processing method and apparatus, device and storage medium

Country Status (2)

Country Link
CN (1) CN114820874A (en)
WO (1) WO2022160946A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116483359A (en) * 2023-04-25 2023-07-25 成都赛力斯科技有限公司 New mimicry drawing method and device, electronic equipment and readable storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105957125A (en) * 2016-05-20 2016-09-21 广东欧珀移动通信有限公司 Icon character processing method and mobile terminal
CN109410300A (en) * 2018-10-10 2019-03-01 苏州好玩友网络科技有限公司 Shadows Processing method and device and terminal device in a kind of scene of game
US20200184687A1 (en) * 2018-12-07 2020-06-11 Microsoft Technology Licensing, Llc Gpu calculation of signed distance fields
CN111292405A (en) * 2020-02-06 2020-06-16 腾讯科技(深圳)有限公司 Image rendering method and related device
CN111311724A (en) * 2020-01-20 2020-06-19 稿定(厦门)科技有限公司 Shadow adding method, medium, device and apparatus for 3D characters
CN111803942A (en) * 2020-07-20 2020-10-23 网易(杭州)网络有限公司 Soft shadow generation method and device, electronic equipment and storage medium
CN112256367A (en) * 2020-10-19 2021-01-22 北京字节跳动网络技术有限公司 Graphical user interface display method, device, terminal and storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105957125A (en) * 2016-05-20 2016-09-21 广东欧珀移动通信有限公司 Icon character processing method and mobile terminal
CN109410300A (en) * 2018-10-10 2019-03-01 苏州好玩友网络科技有限公司 Shadows Processing method and device and terminal device in a kind of scene of game
US20200184687A1 (en) * 2018-12-07 2020-06-11 Microsoft Technology Licensing, Llc Gpu calculation of signed distance fields
CN111311724A (en) * 2020-01-20 2020-06-19 稿定(厦门)科技有限公司 Shadow adding method, medium, device and apparatus for 3D characters
CN111292405A (en) * 2020-02-06 2020-06-16 腾讯科技(深圳)有限公司 Image rendering method and related device
CN111803942A (en) * 2020-07-20 2020-10-23 网易(杭州)网络有限公司 Soft shadow generation method and device, electronic equipment and storage medium
CN112256367A (en) * 2020-10-19 2021-01-22 北京字节跳动网络技术有限公司 Graphical user interface display method, device, terminal and storage medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
LI YANCHEN: "Study on Signed Distance Field for Soft Shadow Generation", MASTER THESIS, TIANJIN POLYTECHNIC UNIVERSITY, CN, no. 8, 15 August 2019 (2019-08-15), CN , XP055955086, ISSN: 1674-0246 *
ZHANG XINKUI: "Application of Photoshop CS Layer Styles in Creating Text Effects", COMPUTER KNOWLEDGE AND TECHNOLOGY, CN, no. 11, 31 December 2007 (2007-12-31), CN , pages 93 - 95, XP055955090, ISSN: 1009-3044 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116483359A (en) * 2023-04-25 2023-07-25 成都赛力斯科技有限公司 New mimicry drawing method and device, electronic equipment and readable storage medium
CN116483359B (en) * 2023-04-25 2024-03-12 重庆赛力斯凤凰智创科技有限公司 New mimicry drawing method and device, electronic equipment and readable storage medium

Also Published As

Publication number Publication date
CN114820874A (en) 2022-07-29

Similar Documents

Publication Publication Date Title
CN107729790B (en) Two-dimensional code positioning method and device
WO2022160946A1 (en) Text shadow effect processing method and apparatus, device and storage medium
JP6491957B2 (en) Electronic apparatus and image processing method
CN110288670B (en) High-performance rendering method for UI (user interface) tracing special effect
CN108989704B (en) Image generation method and device and terminal equipment
WO2022160914A1 (en) Effect processing method and apparatus, and device and storage medium
WO2022161237A1 (en) Text contour effect processing method and apparatus, device, and storage medium
WO2022160915A1 (en) Text illumination effect processing method, apparatus, device, and storage medium
CN109509237B (en) Filter processing method and device and electronic equipment
US9799103B2 (en) Image processing method, non-transitory computer-readable storage medium and electrical device
WO2022160945A1 (en) Gradient color effect processing method and apparatus, and device and storage medium
US20230281892A1 (en) Image drawing method and apparatus, and device and storage medium
CN113391779B (en) Parameter adjusting method, device and equipment for paper-like screen
JP4569785B2 (en) Binarization device and binarization processing program
CN112650458B (en) Display screen adjusting method, storage medium and terminal equipment
US20060119897A1 (en) Output apparatus and program thereof
WO2023020316A1 (en) Image processing method and apparatus, and device and storage medium
JP6107270B2 (en) Image processing apparatus and computer program
US9727808B1 (en) Method and system for rendering rectangle drawing objects using a clip region
CN110992462A (en) Batch processing drawing method for 3D simulation scene image based on edge calculation
CN111951367B (en) Character rendering method, character processing method and device
CN111968042B (en) Digital document shadow removing method, system, device and storage medium
CN111626935B (en) Pixel map scaling method, game content generation method and device
CN113656134B (en) Color matching method, device, equipment and storage medium for interface element
CN107358637B (en) Character drawing method and device, terminal and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21922536

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 06.11.2023)