WO2022179544A1 - Handwriting drawing method, apparatus, medium, and interactive tablet - Google Patents

Handwriting drawing method, apparatus, medium, and interactive tablet Download PDF

Info

Publication number
WO2022179544A1
WO2022179544A1 PCT/CN2022/077604 CN2022077604W WO2022179544A1 WO 2022179544 A1 WO2022179544 A1 WO 2022179544A1 CN 2022077604 W CN2022077604 W CN 2022077604W WO 2022179544 A1 WO2022179544 A1 WO 2022179544A1
Authority
WO
WIPO (PCT)
Prior art keywords
handwriting
texture
sdf
buffer
rendering
Prior art date
Application number
PCT/CN2022/077604
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 WO2022179544A1 publication Critical patent/WO2022179544A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/001Texturing; Colouring; Generation of texture or colour
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/048Interaction techniques based on graphical user interfaces [GUI]
    • G06F3/0487Interaction techniques based on graphical user interfaces [GUI] using specific features provided by the input device, e.g. functions controlled by the rotation of a mouse with dual sensing arrangements, or of the nature of the input device, e.g. tap gestures based on pressure sensed by a digitiser
    • G06F3/0488Interaction techniques based on graphical user interfaces [GUI] using specific features provided by the input device, e.g. functions controlled by the rotation of a mouse with dual sensing arrangements, or of the nature of the input device, e.g. tap gestures based on pressure sensed by a digitiser using a touch-screen or digitiser, e.g. input of commands through traced gestures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/20Drawing from basic elements, e.g. lines or circles

Definitions

  • the embodiments of the present application relate to the field of interactive tablet counting, for example, to a method, device, medium, and interactive tablet for drawing handwriting.
  • handwriting function As one of the increasingly important functions of interactive smart tablet, has been widely used in people's work and study, which greatly improves people's work and study effect.
  • the teacher can write handwriting on the current interactive tablet, and students can view the handwriting written by the teacher through the interactive tablet.
  • the rendering efficiency is low, and the handwriting cannot be drawn in time and effectively.
  • the present application provides a method, device, medium and interactive tablet for drawing handwriting, which have the advantages of improving rendering efficiency and displaying handwriting in a timely and effective manner.
  • a method for drawing handwriting comprising the following steps:
  • the handwriting is obtained after rendering the rendering buffer based on bilinear interpolation sampling
  • the handwriting is displayed on the touch screen.
  • a writing handwriting drawing device comprising:
  • the writing operation receiving module is used for receiving the writing operation on the touch screen
  • a handwriting axis acquisition module configured to acquire touch point information corresponding to the writing operation, and acquire the handwriting axis corresponding to the writing operation according to the touch point information;
  • a target buffer determining module configured to determine a target buffer according to the size of the handwriting axis and a preset rendering line width
  • a texture buffer acquisition module configured to compress the target buffer according to a preset texture resolution to obtain an SDF texture buffer
  • the texture image acquisition module is used to calculate the shortest distance from the position corresponding to each texel point of the SDF texture buffer in the target buffer to the handwriting axis, and determine the shortest distance as the corresponding
  • the value of the texture pixel point of the SDF texture buffer is described to obtain the SDF texture image
  • mapping relationship acquisition module configured to allocate a rendering buffer according to the target buffer, and establish a mapping relationship between the rendering buffer and the SDF texture image
  • a writing handwriting acquisition module used for obtaining writing handwriting after rendering the rendering buffer based on bilinear interpolation sampling
  • the handwriting display module is used for displaying the writing handwriting on the touch screen.
  • an interactive tablet including a touch screen, a processor, and a memory; the memory stores a computer program, and the computer program is adapted to be loaded and executed by the processor as described above method of writing handwriting.
  • a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, implements the above-described method for drawing handwriting.
  • the embodiment of the present application performs compression processing on the target buffer according to the preset texture resolution to obtain an SDF texture buffer; calculates the position corresponding to each texture pixel of the SDF texture buffer in the target buffer to the The shortest distance of the handwriting axis, and the shortest distance is determined as the value of the texture pixel point of the corresponding SDF texture buffer to obtain an SDF texture image; the SDF texture image is subjected to bilinear interpolation sampling to obtain interpolation sampling The distance value between each texture pixel point and the handwriting axis, and according to the mapping relationship between the rendering buffer and the SDF texture image, and then rendering the rendering buffer based on bilinear interpolation sampling to obtain writing handwriting, Therefore, the handwriting is displayed on the touch screen, and only two triangles need to be rendered through the SDF texture image, the rendering overhead is small, the rendering efficiency is improved, and the handwriting can be displayed in a timely and effective manner.
  • Fig. 1 is the schematic diagram of the handwriting that needs to be drawn in one embodiment of the application
  • FIG. 5 is a schematic diagram of a handwriting axis shown in an embodiment of the application.
  • FIG. 6 is a schematic diagram of the shortest distance shown in an embodiment of the application.
  • FIG. 7 is a flowchart of a method for obtaining a handwriting axis according to an embodiment of the application.
  • FIG. 8 is a flowchart of a method for determining an SDF texture image according to an embodiment of the present application.
  • FIG. 9 is a flowchart of a method for obtaining writing handwriting according to an embodiment of the application.
  • Fig. 11 is another embodiment of the present application showing the effect diagram of drawn handwriting
  • FIG. 12 is a schematic block diagram of a writing handwriting drawing device according to an embodiment of the application.
  • FIG. 13 is a schematic block diagram of a handwriting axis acquisition module according to an embodiment of the application.
  • FIG. 14 is a schematic block diagram of a texture image acquisition module according to an embodiment of the application.
  • 15 is a schematic block diagram of a writing handwriting acquisition module according to an embodiment of the application.
  • FIG. 16 is a schematic structural diagram of an interactive tablet according to an embodiment of the present application.
  • the writing handwriting mentioned in the embodiments of the present application is a special writing handwriting, please refer to FIG. 1 , for example, the starting endpoint, the ending endpoint and the corner of the writing handwriting are all arc shapes.
  • the method for drawing the writing handwriting in the related art is to obtain the handwriting axis of the writing operation according to the touch information of the writing operation; The polygon mesh outline of the writing handwriting; then triangulation is performed in the polygon mesh outline, and finally all triangles in the polygon mesh outline are rendered to obtain the writing handwriting.
  • the writing handwriting drawing method shown in the embodiments of the present application may be executed by a writing handwriting drawing device, the writing handwriting drawing device may be implemented by means of software and/or hardware, and the writing handwriting drawing device may be two or more physical entities Composition can also be a physical entity composition.
  • the writing and handwriting drawing device may be a smart device such as a computer, a mobile phone, a tablet or a smart interactive tablet.
  • an interactive tablet is used as a writing handwriting drawing device for exemplary description.
  • the interactive tablet can be an integrated device that controls the content displayed on the display tablet and realizes human-computer interaction through touch technology. one or more functions.
  • an interactive tablet includes at least one display screen.
  • the interactive tablet is equipped with a display screen with a touch function, and the display screen can be a capacitive screen, a resistive screen or an electromagnetic screen.
  • the user can realize the touch operation by touching the display screen with a finger or a stylus.
  • the interactive tablet detects the touch position, and determines a response scheme according to the touch operation corresponding to the touch position, and then performs the touch operation. response to implement the touch function. For example, it is determined according to the touch position that the corresponding touch operation is writing handwriting, and at this time, the response scheme is displaying handwriting.
  • At least one type of operating system is installed on the interactive tablet, wherein the operating system includes but is not limited to an Android system, a Linux system, and a Windows system.
  • the interactive tablet can install at least one application program based on the operating system, and in the embodiment, an application program with a writing function is used as an example for description.
  • an electronic whiteboard application with a writing function is installed in the interactive tablet.
  • the application program may be an application program that comes with the operating system, or an application program downloaded from a third-party device or server, and the interactive tablet may also be an application program itself.
  • the application program also has other editing functions, such as functions of writing, inserting tables, inserting pictures, inserting multimedia, inserting graphics, and drawing tables.
  • the writing and handwriting drawing method disclosed in the embodiments of the present application is applied to an electronic device, and the following description takes the electronic device as an interactive tablet.
  • FIG. 4 is a flowchart of a method for drawing handwriting according to an embodiment of the present application.
  • Step S110 Receive a writing operation on the touch screen.
  • a writing interface is displayed by turning on the electronic whiteboard on the touch screen, and the interactive tablet will receive the writing operation on the touch screen when touching and writing on the writing interface by hand or a stylus or other writing tool.
  • Step S120 Acquire touch point information corresponding to the writing operation, and acquire the handwriting axis corresponding to the writing operation according to the touch point information.
  • touch point information can be obtained by detecting the writing operation, and a handwriting axis corresponding to the writing operation can be obtained according to the touch point information.
  • Step S130 Determine the target buffer area according to the size of the handwriting axis and the preset rendering line width.
  • the size of the handwriting axis includes the length of the handwriting axis and the width of the handwriting axis; wherein the length of the handwriting axis is the distance between the start point of the handwriting axis and the end point of the handwriting axis , the width of the handwriting axis is the maximum distance between the two ends of the handwriting axis in the length direction perpendicular to the handwriting axis.
  • the rendering line width is the width of the handwriting displayed by drawing, which can be set as required.
  • the buffer is a part of the memory space, that is to say, a storage space of a specified size is reserved in the memory space for temporary storage of input or output data. This part of the reserved space is called a buffer, and the purpose is to reduce The number of times of data reading improves data processing efficiency.
  • the target buffer is the data temporarily stored for determining the rendering buffer and the SDF texture buffer.
  • the determining the target buffer according to the size of the handwriting axis and the preset rendering line width includes: adding the horizontal length of the handwriting axis to the preset rendering line width, and adding the handwriting axis to the preset rendering line width.
  • the vertical length of the axis is added to the preset rendering line width to obtain the target buffer.
  • the target buffer is obtained by adding the horizontal length of the handwriting axis to the preset rendering line width, and adding the vertical length of the handwriting axis to the preset rendering line width, so that the handwriting can be written.
  • the display can be rendered completely unobstructed at render time.
  • Step S140 Compress the target buffer according to the preset texture resolution to obtain an SDF texture buffer.
  • the preset texture resolution may be a texture resolution determined by a preset compression factor. For example, for the target buffer with a resolution of 1600 ⁇ 512, if the preset compression factor is 32, Then, the target buffer can be compressed according to the scaling factor of 32 to obtain an SDF texture buffer, and the texture resolution of the SDF texture buffer is 50 ⁇ 16 at this time.
  • the preset texture resolution can also be a texture resolution that is not directly preset. For example, for the target buffer with a resolution of 1600 ⁇ 512, if the preset texture resolution is 50 ⁇ 16, the compression coefficient can be calculated as 32, and then compress the target buffer to obtain an SDF texture buffer with a texture resolution of 50 ⁇ 16.
  • Step S150 Calculate the shortest distance from the position corresponding to each texel point of the SDF texture buffer in the target buffer to the handwriting axis, and determine the shortest distance as the corresponding SDF texture buffer The value of the texture pixel point of the area, obtain the SDF texture image.
  • calculating the shortest distance from the position corresponding to each texel point of the SDF texture buffer in the target buffer to the handwriting axis includes: traversing each point of the handwriting axis and the target For the distance in the buffer area corresponding to each texture pixel point of the SDF texture buffer area, the value with the smallest distance is selected as the shortest distance.
  • Step S160 Allocate a rendering buffer according to the target buffer, and establish a mapping relationship between the rendering buffer and the SDF texture image.
  • the target buffer has the same resolution as the render buffer, that is, according to the resolution of the target buffer, a render buffer with the same resolution as the target buffer is allocated.
  • Step S170 obtaining writing handwriting after rendering the rendering buffer based on bilinear interpolation sampling.
  • Bilinear interpolation also known as bilinear interpolation.
  • bilinear interpolation is a linear interpolation extension of an interpolation function with two variables, and its core idea is to perform a linear interpolation in two directions respectively.
  • bilinear interpolation is used to interpolate and sample the rendering buffer to obtain writing handwriting, which can make the edge of the writing handwriting smoother.
  • Step S180 Display the handwriting on the touch screen.
  • the embodiment of the present application performs compression processing on the target buffer according to the preset texture resolution to obtain an SDF texture buffer; calculates the position corresponding to each texture pixel of the SDF texture buffer in the target buffer to the The shortest distance of the handwriting axis, and the shortest distance is determined as the value of the texture pixel point of the corresponding SDF texture buffer to obtain an SDF texture image; the SDF texture image is subjected to bilinear interpolation sampling to obtain interpolation sampling The distance value between each texture pixel point and the handwriting axis, and according to the mapping relationship between the rendering buffer and the SDF texture image, and then rendering the rendering buffer based on bilinear interpolation sampling to obtain writing handwriting, Therefore, the handwriting is displayed on the touch screen, and only two triangles need to be rendered through the SDF texture image, the rendering overhead is small, the rendering efficiency is improved, and the handwriting can be displayed in a timely and effective manner.
  • FIG. 7 is a flowchart of a method for obtaining a handwriting axis according to an embodiment of the present application.
  • the touch point information is a plurality of consecutive sampling points collected by the touch screen according to the writing operation; the touch point information obtained in response to the writing operation on the touch screen, according to the touch The point information obtains the handwriting axis corresponding to the writing operation, including:
  • Step S121 obtaining a touch point connection line according to the two adjacent sampling points
  • Step S122 Obtain the handwriting axis corresponding to the writing operation according to the touch point connection.
  • the touch point connection line is obtained by connecting two adjacent sampling points, thereby realizing the quick and accurate acquisition of the handwriting axis.
  • FIG. 8 is a flowchart of a method for determining an SDF texture image according to an embodiment of the present application.
  • the SDF texture buffer includes a horizontal texel count and a vertical texel count.
  • step S150 the shortest distance from the position corresponding to each pixel of the SDF texture buffer in the target buffer to the handwriting axis is calculated, and the shortest distance is determined as the corresponding SDF
  • the value of the texture pixel point of the texture buffer to obtain the SDF texture image including:
  • Step S151 Acquire the number of horizontal texels and the number of vertical texels of the SDF texture buffer.
  • Step S152 Divide the target buffer into a corresponding number of texture grids according to the number of horizontal texels and the number of vertical texels.
  • the number of horizontal texture pixels and the number of vertical texture pixels are 50 and 16 respectively
  • the number of horizontal texture grids divided by the target buffer is 50 and the number of vertical texture grids is 16
  • the number of texture pixels and the number of vertical texture pixels are 50 and 16 respectively
  • the number of horizontal texture grids divided by the target buffer is 25 and the number of vertical texture grids is 8
  • the horizontal texture divided by the target buffer The number of meshes is 25 and the number of longitudinal texture meshes is 8.
  • Step S153 Calculate the shortest distance from the center point of each texture grid in the target buffer to the handwriting axis.
  • Step S154 Determine the shortest distance as the value of the corresponding texture pixel of the SDF texture buffer to obtain an SDF texture image.
  • the shortest distance is determined as The corresponding value of the texture pixel point of the SDF texture image, so that the distance information of the target buffer under high resolution can be fully preserved.
  • the texel in the SDF texture image records the distance value instead of the color value, so that the image compression and stretching will not greatly affect the display effect.
  • FIG. 9 is a flowchart of a method for acquiring handwriting according to an embodiment of the present application.
  • the handwriting obtained after rendering the rendering buffer based on bilinear interpolation sampling includes:
  • Step S171 Perform bilinear interpolation sampling on the SDF texture image to obtain a distance value from each texel point after interpolation sampling to the handwriting axis.
  • Step S172 In the rendering buffer, after color-filling sampling points whose distance from the handwriting axis is less than or equal to the preset rendering line width, the writing handwriting is obtained.
  • Render the rendering buffer perform bilinear interpolation sampling on the SDF texture image, obtain the distance value of each texel point after the interpolation sampling to the handwriting axis, and fill the rendering buffer with a color to match the value of the handwriting axis.
  • the distance value of the handwriting axis is less than or equal to the corresponding point of the preset rendering line width, and the writing handwriting is obtained.
  • the writing handwriting mentioned in the embodiments of the present application is a special writing handwriting.
  • the starting point, the ending point and the corner of the writing handwriting are all arc shapes, that is, when implementing the present application It was found in the process that: for such a handwriting, the shortest distance from any point on the handwriting to the axis of the handwriting is less than or equal to half of the width of the handwriting. For this reason, the present application fills the rendering buffer with the color to the corresponding point where the distance from the handwriting axis is less than or equal to the preset rendering line width, and the obtained writing handwriting is the starting point of the writing handwriting , end endpoints, and corners are arc shapes.
  • the SDF texture image is a rectangular image, so the rendering buffer is also a rectangle, and during rendering, the rendering is usually performed in units of triangles. Therefore, for the rendering buffer
  • the area is also constructed as a rectangle of two triangles for rendering.
  • the rendering buffer is determined by reading the vertices of two triangles, and the SDF texture image is subjected to bilinear interpolation sampling to obtain each texture after the interpolation sampling.
  • the distance value from the pixel point to the handwriting axis and then according to the mapping relationship between the rendering buffer and the SDF texture image, fill the color in the rendering buffer until the distance value from the handwriting axis is less than or equal to the preset value Render the corresponding point of the line width to obtain the handwriting.
  • the resolution of the SDF texture buffer may be inconsistent with the resolution of the target buffer, that is, the resolution of the rendering display.
  • the resolution of the SDF texture buffer is lower , the higher the efficiency of generating SDF texture images, but the lower the accuracy, that is, the generated handwriting is also blurred.
  • the resolution of the SDF texture buffer is higher, the efficiency of generating SDF texture images is lower, but the accuracy is also higher. , that is, the generated handwriting is clearer.
  • the resolution of the SDF texture buffer, that is, the preset texture resolution is smaller than the resolution of the target buffer, that is, the resolution of the rendering display, so as to reduce the amount of calculation and improve the rendering efficiency.
  • the target buffer with a resolution of 1600x512
  • the texture resolution of the SDF texture buffer is 50x16
  • the displayed handwriting is relatively smooth
  • the same resolution is 1600x512
  • the edge of the displayed handwriting will be somewhat distorted, but since the SDF texture graphic of the present application stores the distance value, and adopts double lines Therefore, the displayed handwriting still has good precision, and even if the resolution of the SDF texture buffer, that is, the preset texture resolution is smaller than the resolution of the target buffer, that is, the resolution of the rendering display It also has higher rendering accuracy.
  • FIG. 12 is a schematic block diagram of an apparatus for drawing handwriting according to an embodiment of the present application.
  • a writing and handwriting drawing device 200 disclosed in the embodiment of the present application includes:
  • the writing operation receiving module 210 is used for receiving the writing operation on the touch screen
  • a handwriting axis acquisition module 220 configured to acquire touch point information corresponding to the writing operation, and acquire the handwriting axis corresponding to the writing operation according to the touch point information;
  • a target buffer determining module 230 configured to determine a target buffer according to the size of the handwriting axis and a preset rendering line width
  • a texture buffer acquiring module 240 configured to perform compression processing on the target buffer according to a preset texture resolution to obtain an SDF texture buffer
  • the texture image acquisition module 250 is configured to calculate the shortest distance from the position corresponding to each texel point of the SDF texture buffer in the target buffer to the handwriting axis, and determine the shortest distance as the corresponding the value of the texture pixel point of the SDF texture buffer to obtain the SDF texture image;
  • mapping relationship acquisition module 260 configured to allocate a rendering buffer according to the target buffer, and establish a mapping relationship between the rendering buffer and the SDF texture image;
  • a writing handwriting obtaining module 270 configured to obtain writing handwriting after rendering the rendering buffer based on bilinear interpolation sampling
  • the handwriting display module 280 is used for displaying the writing handwriting on the touch screen.
  • the embodiment of the present application performs compression processing on the target buffer according to the preset texture resolution to obtain an SDF texture buffer; calculates the position corresponding to each texture pixel of the SDF texture buffer in the target buffer to the The shortest distance of the handwriting axis, and the shortest distance is determined as the value of the texture pixel point of the corresponding SDF texture buffer to obtain an SDF texture image; the SDF texture image is subjected to bilinear interpolation sampling to obtain interpolation sampling The distance value between each texture pixel point and the handwriting axis, and according to the mapping relationship between the rendering buffer and the SDF texture image, and then rendering the rendering buffer based on bilinear interpolation sampling to obtain writing handwriting, Therefore, the handwriting is displayed on the touch screen, and only two triangles need to be rendered through the SDF texture image, the rendering overhead is small, the rendering efficiency is improved, and the handwriting can be displayed in a timely and effective manner.
  • the target buffer determining module 230 is configured to determine the target buffer according to the size of the handwriting axis and the preset rendering line width, including: adding the horizontal length of the handwriting axis to The preset rendering line width is obtained by adding the longitudinal length of the handwriting axis to the preset rendering line width to obtain the target buffer.
  • the target buffer is obtained by adding the horizontal length of the handwriting axis to the preset rendering line width, and adding the vertical length of the handwriting axis to the preset rendering line width, so that the handwriting can be rendered The display is rendered completely unobstructed.
  • FIG. 13 is a schematic block diagram of a handwriting axis acquisition module according to an embodiment of the present application.
  • the touch point information is a plurality of consecutive sampling points collected by the touch screen according to the writing operation;
  • the handwriting axis acquisition module 220 is configured to obtain touch point information in response to a writing operation on the touch screen, Obtaining the handwriting axis corresponding to the writing operation according to the touch point information includes:
  • the touch point connection module 221 is used to obtain the touch point connection according to the two adjacent sampling points;
  • the handwriting axis determination module 222 is configured to obtain the handwriting axis corresponding to the writing operation according to the touch point connection.
  • the touch point connection line is obtained by connecting two adjacent sampling points, thereby realizing the quick and accurate acquisition of the handwriting axis.
  • FIG. 14 is a schematic block diagram of a texture image acquisition module according to an embodiment of the present application.
  • the SDF texture buffer includes the number of horizontal texels and the number of vertical texels; the texture image acquisition module 250 includes:
  • Pixel quantity acquisition module 251 for acquiring the horizontal texel quantity and the vertical texel quantity of the SDF texture buffer
  • a texture grid dividing module 252 configured to divide the target buffer into a corresponding number of texture grids according to the number of horizontal texels and the number of vertical texels;
  • a distance calculation module 253, configured to calculate the shortest distance from the center point of each texture grid in the target buffer zone to the handwriting axis;
  • the pixel value determination module 254 is configured to determine the shortest distance as the value of the corresponding texture pixel point of the SDF texture buffer to obtain an SDF texture image.
  • the shortest distance is determined as The corresponding value of the texture pixel point of the SDF texture image, so that the distance information of the target buffer under high resolution can be fully preserved.
  • the texel in the SDF texture image records the distance value instead of the color value, so that the image compression and stretching will not greatly affect the display effect.
  • FIG. 15 is a schematic block diagram of a handwriting acquisition module according to an embodiment of the present application.
  • the handwriting acquisition module 270 includes:
  • the distance obtaining module 271 is configured to perform bilinear interpolation sampling on the SDF texture image to obtain the distance value from each texel point after interpolation sampling to the handwriting axis.
  • the color-filling module 272 is configured to color-fill sampling points whose distance from the handwriting axis is less than or equal to the preset rendering line width in the rendering buffer to obtain handwriting.
  • the following is a device embodiment of the present application, which can be used to execute the content of the method in Embodiment 1 of the present application.
  • the content of the method in Embodiment 1 of the present application please refer to the content of the method in Embodiment 1 of the present application.
  • the present application also provides an electronic device.
  • the electronic device can be any smart terminal including a touch screen, for example, a computer, a mobile phone, a tablet computer, an interactive tablet, etc.
  • the electronic device is an interactive tablet 300, such as an interactive tablet with a large-sized touch screen.
  • the interactive tablet 300 may include: at least one processor 301 , at least one memory 302 , at least one display 303 , at least one network interface 304 , user interface 305 and at least one communication bus 306 .
  • the display 303 includes a display layer and a touch layer, the display layer is used to display data processed by the processor; the touch layer may include: a capacitive screen, an electromagnetic screen or an infrared screen, etc. Generally speaking , the touch layer can receive a touch operation or a writing operation input by a user through a finger or an input device.
  • the user interface 305 is mainly used to provide an input interface for the user, and obtain the data input by the user.
  • the user interface 305 may also include a standard wired interface or a wireless interface.
  • the network interface 304 may optionally include a standard wired interface and a wireless interface (eg, a WI-FI interface).
  • the communication bus 306 is used to realize the connection and communication between these components.
  • the processor 301 may include one or more processing cores.
  • the processor 301 uses various interfaces and lines to connect various parts of the entire interactive tablet 300, and executes by running or executing the instructions, programs, code sets or instruction sets stored in the memory 302, and calling the data stored in the memory 302.
  • Various functions of the interactive tablet 300 and processing data may adopt at least one of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA).
  • DSP Digital Signal Processing
  • FPGA field programmable gate array
  • PLA programmable logic array
  • the processor 301 may integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU), a modem, and the like.
  • CPU Central Processing Unit
  • GPU Graphics Processing Unit
  • the CPU mainly handles the operating system, user interface and application programs, etc.
  • the GPU is used for rendering and drawing the content that needs to be displayed on the display layer
  • the modem is used for handling wireless communication. It can be understood that, the above-mentioned modem may not be integrated into the processor 301, and is implemented by a single chip.
  • the memory 302 may include random access memory (Random Access Memory, RAM), or may include read-only memory (Read-Only Memory).
  • the memory 302 includes a non-transitory computer-readable storage medium.
  • Memory 302 may be used to store instructions, programs, codes, sets of codes, or sets of instructions.
  • the memory 302 may include a stored program area and a stored data area, wherein the stored program area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), Instructions and the like used to implement the above method embodiments; the storage data area may store the data and the like involved in the above method embodiments.
  • the memory 302 may also be at least one storage device located away from the aforementioned processor 301 .
  • the memory 302 as a computer storage medium may include an operating system, a network communication module, and a user.
  • the processor 301 can be used to call the application program of the response delay of the touch screen stored in the memory 302, and perform the following operations: receiving a writing operation on the touch screen; acquiring touch point information corresponding to the writing operation, according to The touch point information obtains the handwriting axis corresponding to the writing operation; the target buffer is determined according to the size of the handwriting axis and the preset rendering line width; the target buffer is compressed according to the preset texture resolution Process, obtain the SDF texture buffer; calculate the shortest distance from the position corresponding to each texel point of the SDF texture buffer in the target buffer to the handwriting axis, and determine the shortest distance as the corresponding The value of the texture pixel point of the SDF texture buffer is obtained, and the SDF texture image is obtained; the rendering buffer is allocated according to the target buffer, and the mapping relationship between the rendering buffer and the SDF texture image is established; based on bilinear interpolation After sampling and rendering the rendering buffer, writing handwriting is obtained; and the writing handwriting is displayed on the touch screen.
  • the embodiment of the present application performs compression processing on the target buffer according to the preset texture resolution to obtain an SDF texture buffer; calculates the position corresponding to each texture pixel of the SDF texture buffer in the target buffer to the The shortest distance of the handwriting axis, and the shortest distance is determined as the value of the texture pixel point of the corresponding SDF texture buffer to obtain an SDF texture image; the SDF texture image is subjected to bilinear interpolation sampling to obtain interpolation sampling The distance value between each texture pixel point and the handwriting axis, and according to the mapping relationship between the rendering buffer and the SDF texture image, and then rendering the rendering buffer based on bilinear interpolation sampling to obtain writing handwriting, Therefore, the handwriting is displayed on the touch screen, and only two triangles need to be rendered through the SDF texture image, the rendering overhead is small, the rendering efficiency is improved, and the handwriting can be displayed in a timely and effective manner.
  • the processor 301 may be configured to call the response delay application of the touch screen stored in the memory 302, and execute the determination of the target buffer according to the size of the handwriting axis and the preset rendering line width , including performing the following operations: adding the horizontal length of the handwriting axis to a preset rendering line width, and adding the vertical length of the handwriting axis to the preset rendering line width to obtain the target buffer.
  • the target buffer is obtained by adding the horizontal length of the handwriting axis to the preset rendering line width, and adding the vertical length of the handwriting axis to the preset rendering line width, so that the handwriting can be rendered
  • the display is rendered completely unobstructed.
  • the touch point information is a plurality of consecutive sampling points collected by the touch screen according to the writing operation; the processor 301 may be configured to call the response delay of the touch screen stored in the memory 302
  • the application program executing the acquisition of touch point information in response to a writing operation on the touch screen, and acquiring the handwriting axis corresponding to the writing operation according to the touch point information, includes executing: obtaining a touch point connection according to two adjacent sampling points. line; obtain the handwriting axis corresponding to the writing operation according to the connection of the touch points.
  • the touch point connection line is obtained by connecting two adjacent sampling points, thereby realizing the quick and accurate acquisition of the handwriting axis.
  • the SDF texture buffer includes the number of horizontal texels and the number of vertical texels; the processor 301 may be configured to call the application program for the response delay of the touch screen stored in the memory 302, and Perform the following operations: obtain the number of horizontal texture pixels and the number of vertical texture pixels in the SDF texture buffer; divide the target buffer into a corresponding number of pixels according to the number of horizontal texture pixels and the number of vertical texture pixels texture grid; calculate the shortest distance from the center point of each texture grid in the target buffer to the handwriting axis; determine the shortest distance as the value of the texture pixel point of the corresponding SDF texture buffer, Get an SDF texture image.
  • the shortest distance is determined as The corresponding value of the texture pixel point of the SDF texture image, so that the distance information of the target buffer under high resolution can be fully preserved.
  • the texel in the SDF texture image records the distance value instead of the color value, so that the image compression and stretching will not greatly affect the display effect.
  • the processor 301 may perform the rendering of the rendering buffer based on bilinear interpolation sampling to obtain writing handwriting, and the specific execution includes: performing bilinear interpolation sampling on the SDF texture image to obtain The distance value of each texel point after interpolation sampling to the handwriting axis; in the rendering buffer, after color filling the sampling point whose distance value from the handwriting axis is less than or equal to the preset rendering line width, Get handwriting.
  • the bilinear interpolation sampling method after color filling the sampling points whose distance value from the handwriting axis is less than or equal to the preset rendering line width, the handwriting is obtained, which can improve the rendering efficiency and prevent the problem of edge distortion. .
  • the present application also provides a computer-readable storage medium, on which a computer program is stored, the instructions are suitable for being loaded by a processor and executing the method steps of the above-mentioned Embodiment 1, and the execution process can refer to the method shown in the first embodiment. The description is not repeated here.
  • the device where the storage medium is located may be an electronic device such as a personal computer, a notebook computer, a smart phone, and a tablet computer.
  • the device embodiments since they basically correspond to the method embodiments, reference may be made to the partial descriptions of the method embodiments for related parts.
  • the device embodiments described above are schematic, wherein the components described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in a local, or it can be distributed over multiple network elements. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of the present application. Those of ordinary skill in the art can understand and implement it without creative effort.
  • the embodiments of the present application may be provided as a method, a system, or a computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
  • computer-usable storage media including, but not limited to, disk storage, CD-ROM, optical storage, etc.
  • These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory result in an article of manufacture comprising instruction means, the instructions
  • An apparatus implements the functions selected in one or more of the flowcharts and/or one or more blocks of the block diagrams.
  • These computer program instructions can also be loaded on a computer or other programmable data processing device to cause a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process such that The instructions provide steps for implementing the functions selected in the flow or blocks of the flowcharts and/or the blocks or blocks of the block diagrams.
  • the computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
  • processors CPUs
  • input/output interfaces network interfaces
  • memory volatile and non-volatile memory
  • Memory may include non-persistent memory in computer readable media, random access memory (RAM) and/or non-volatile memory in the form of, for example, read only memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
  • RAM random access memory
  • ROM read only memory
  • flash RAM flash memory
  • Computer-readable media includes both persistent and non-permanent, removable and non-removable media, and storage of information may be implemented by any method or technology.
  • Information may be computer readable instructions, data structures, modules of programs, or other data.
  • Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), Flash Memory or other memory technology, Compact Disc Read Only Memory (CD-ROM), Digital Versatile Disc (DVD) or other optical storage, Magnetic tape cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission medium that can be used to store information that can be accessed by a computing device.
  • computer-readable media does not include transitory computer-readable media, such as modulated data signals and carrier waves.

Abstract

The embodiments of the present application provide a handwriting drawing method, an apparatus, a medium, and an interactive tablet. Said method comprises: acquiring touch point information corresponding to a handwriting operation, and acquiring, according to the touch point information, a handwriting axis corresponding to the handwriting operation; according to the size of the handwriting axis and a preset rendering line width, determining a target buffer region; performing compression processing on the target buffer region according to a preset texture resolution to obtain an SDF texture buffer region; calculating a shortest distance from a position corresponding to each texture pixel point of the SDF texture buffer region in the target buffer region to the handwriting axis, and determining the shortest distance as the value of the texture pixel point of the corresponding SDF texture buffer region to obtain an SDF texture image; allocating a rendering buffer region according to the target buffer region, and establishing a mapping relationship between the rendering buffer region and the SDF texture image; and rendering the rendering buffer region on the basis of bilinear interpolation sampling, and then obtaining a handwriting. The present application has small rendering overhead, can improve rendering efficiency, and can timely and effectively display handwriting.

Description

书写笔迹绘制方法、装置、介质以及交互平板Writing and handwriting drawing method, device, medium and interactive tablet
本申请要求于2021年2月25日提交国家知识产权局、申请号为202110209969.X、发明名称为“书写笔迹绘制方法、装置、介质以及交互平板”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application filed on February 25, 2021, with the application number 202110209969.X and the invention titled "writing and handwriting drawing method, device, medium and interactive tablet", the entire content of which is Incorporated herein by reference.
技术领域technical field
本申请实施例涉及交互平板计数领域,例如是涉及一种书写笔迹绘制方法、装置、介质以及交互平板。The embodiments of the present application relate to the field of interactive tablet counting, for example, to a method, device, medium, and interactive tablet for drawing handwriting.
背景技术Background technique
在交互平板领域,笔迹书写功能作为交互智能平板越来越重要的功能之一,已经广泛的应用于在人们的工作和学习之中,极大的提高了人们的工作及学习效果。例如,在教学场景下,老师可以在当前交互平板上进行笔迹书写,学生通过交互平板能够观看到老师书写的笔迹。在实现本申请的过程中,发现相关技术中至少存在以下问题:在交互平板上进行大量的笔迹书写后,渲染效率低,无法及时有效地绘制书写笔迹。In the field of interactive tablet, handwriting function, as one of the increasingly important functions of interactive smart tablet, has been widely used in people's work and study, which greatly improves people's work and study effect. For example, in a teaching scenario, the teacher can write handwriting on the current interactive tablet, and students can view the handwriting written by the teacher through the interactive tablet. In the process of implementing the present application, it is found that there are at least the following problems in the related art: after a large amount of handwriting is written on the interactive tablet, the rendering efficiency is low, and the handwriting cannot be drawn in time and effectively.
发明内容SUMMARY OF THE INVENTION
为克服相关技术中存在的问题,本申请提供一种书写笔迹绘制方法、装置、介质以及交互平板,具有提高渲染效率,可及时有效地显示书写笔迹的优点。In order to overcome the problems existing in the related art, the present application provides a method, device, medium and interactive tablet for drawing handwriting, which have the advantages of improving rendering efficiency and displaying handwriting in a timely and effective manner.
根据本申请实施例的第一方面,提供一种书写笔迹绘制方法,包括如下步骤:According to a first aspect of the embodiments of the present application, there is provided a method for drawing handwriting, comprising the following steps:
接收在触摸屏上的书写操作;Receive the writing operation on the touch screen;
获取所述书写操作对应的触摸点信息,根据所述触摸点信息获取所述书写操作对应的笔迹轴线;acquiring touch point information corresponding to the writing operation, and acquiring the handwriting axis corresponding to the writing operation according to the touch point information;
根据所述笔迹轴线的尺寸和预设的渲染线宽,确定目标缓冲区;Determine the target buffer according to the size of the handwriting axis and the preset rendering line width;
根据预设的纹理分辨率对所述目标缓冲区进行压缩处理,获得SDF纹理缓冲区;Compress the target buffer according to the preset texture resolution to obtain an SDF texture buffer;
计算所述目标缓冲区中与所述SDF纹理缓冲区的每个纹理像素点对应的位置到所述笔迹轴线的最短距离,并将所述最短距离确定为对应的所述SDF纹理缓冲区的纹理像素点的值,获得SDF纹理图像;Calculate the shortest distance from the position corresponding to each texel point of the SDF texture buffer in the target buffer to the handwriting axis, and determine the shortest distance as the texture of the corresponding SDF texture buffer The value of the pixel point to obtain the SDF texture image;
根据所述目标缓冲区分配渲染缓冲区,建立所述渲染缓冲区与所述SDF纹理图像的映射关系;Allocate a rendering buffer according to the target buffer, and establish a mapping relationship between the rendering buffer and the SDF texture image;
基于双线性插值采样对所述渲染缓冲区进行渲染后获得书写笔迹;The handwriting is obtained after rendering the rendering buffer based on bilinear interpolation sampling;
在所述触摸屏上显示所述书写笔迹。The handwriting is displayed on the touch screen.
根据本申请实施例的第二方面,提供一种书写笔迹绘制装置,包括:According to a second aspect of the embodiments of the present application, there is provided a writing handwriting drawing device, comprising:
书写操作接收模块,用于接收在触摸屏上的书写操作;The writing operation receiving module is used for receiving the writing operation on the touch screen;
笔迹轴线获取模块,用于获取所述书写操作对应的触摸点信息,根据所述触摸点信息获取所述书写操作对应的笔迹轴线;a handwriting axis acquisition module, configured to acquire touch point information corresponding to the writing operation, and acquire the handwriting axis corresponding to the writing operation according to the touch point information;
目标缓冲区确定模块,用于根据所述笔迹轴线的尺寸和预设的渲染线宽,确定目标缓冲区;a target buffer determining module, configured to determine a target buffer according to the size of the handwriting axis and a preset rendering line width;
纹理缓冲区获取模块,用于根据预设的纹理分辨率对所述目标缓冲区进行压缩处理,获得SDF纹理缓冲区;a texture buffer acquisition module, configured to compress the target buffer according to a preset texture resolution to obtain an SDF texture buffer;
纹理图像获取模块,用于计算所述目标缓冲区中与所述SDF纹理缓冲区的每个纹理像素点对应的位置到所述笔迹轴线的最短距离,并将所述最短距离确定为对应的所述SDF纹理缓冲区的纹理像素点的值,获得SDF纹理图像;The texture image acquisition module is used to calculate the shortest distance from the position corresponding to each texel point of the SDF texture buffer in the target buffer to the handwriting axis, and determine the shortest distance as the corresponding The value of the texture pixel point of the SDF texture buffer is described to obtain the SDF texture image;
映射关系获取模块,用于根据所述目标缓冲区分配渲染缓冲区,建立所述渲染缓冲区与所述SDF纹理图像的映射关系;a mapping relationship acquisition module, configured to allocate a rendering buffer according to the target buffer, and establish a mapping relationship between the rendering buffer and the SDF texture image;
书写笔迹获取模块,用于基于双线性插值采样对所述渲染缓冲区进行渲染后获得书写笔迹;a writing handwriting acquisition module, used for obtaining writing handwriting after rendering the rendering buffer based on bilinear interpolation sampling;
笔迹显示模块,用于在所述触摸屏上显示所述书写笔迹。The handwriting display module is used for displaying the writing handwriting on the touch screen.
根据本申请实施例的第三方面,提供一种交互平板,包括触摸屏、处理器和存储器;所述存储器存储有计算机程序,所述计算机程序适于由所述处理器加载并执行如上述所述的书写笔迹绘制方法。According to a third aspect of the embodiments of the present application, an interactive tablet is provided, including a touch screen, a processor, and a memory; the memory stores a computer program, and the computer program is adapted to be loaded and executed by the processor as described above method of writing handwriting.
根据本申请实施例的第四方面,提供一种计算机可读存储介质,其上储存有计算机程序,该计算机程序被处理器执行时实现如上述所述的书写笔迹绘制方法。According to a fourth aspect of the embodiments of the present application, there is provided a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, implements the above-described method for drawing handwriting.
本申请实施例根据预设纹理分辨率对目标缓冲区进行压缩处理,获得SDF纹理缓冲区;计算所述目标缓冲区中与所述SDF纹理缓冲区的每个纹理像素点对应的位置到所述笔迹轴线的最短距离,并将所述最短距离确定为对应的所述SDF纹理缓冲区的纹理像素点的值,获得SDF纹理图像;对所述SDF纹理图像进行双线性插值采样,获得插值采样后的各纹理像素点到所述笔迹轴线的距离值,且根据渲染缓冲区与所述SDF纹理图像的映射关系,进而基于双线性插值采样对所述渲染缓冲区进行渲染后获得书写笔迹,从而在所述触摸屏上显示书写笔迹,进而通过所述SDF纹理图像只需要渲染两个三角形,渲染开销小,进而提高了渲染效率,可及时有效地显示书写笔迹。当书写笔迹不变,而需要渲染不同宽度的书写笔迹时,只需要一次预处理生成SDF纹理图像,后续直接通过该同一张SDF纹理图像渲染显示不同宽度的书写笔迹。本申请由于SDF纹理为描述距离信息而不是颜色信息,进而结合双线性插值采样方 法,可以通过小分辨率的SDF纹理图像进行大分辨率的笔迹绘制时,不容易出现边缘失真的问题。The embodiment of the present application performs compression processing on the target buffer according to the preset texture resolution to obtain an SDF texture buffer; calculates the position corresponding to each texture pixel of the SDF texture buffer in the target buffer to the The shortest distance of the handwriting axis, and the shortest distance is determined as the value of the texture pixel point of the corresponding SDF texture buffer to obtain an SDF texture image; the SDF texture image is subjected to bilinear interpolation sampling to obtain interpolation sampling The distance value between each texture pixel point and the handwriting axis, and according to the mapping relationship between the rendering buffer and the SDF texture image, and then rendering the rendering buffer based on bilinear interpolation sampling to obtain writing handwriting, Therefore, the handwriting is displayed on the touch screen, and only two triangles need to be rendered through the SDF texture image, the rendering overhead is small, the rendering efficiency is improved, and the handwriting can be displayed in a timely and effective manner. When the writing handwriting does not change, and writing handwriting of different widths needs to be rendered, only one preprocessing is required to generate an SDF texture image, and then the same SDF texture image is directly used to render and display the writing handwriting of different widths. In the present application, because the SDF texture is to describe the distance information rather than the color information, and then combined with the bilinear interpolation sampling method, the problem of edge distortion is not easy to occur when the SDF texture image of small resolution can be used to draw large-resolution handwriting.
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本申请。It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not limiting of the present application.
为了更好地理解和实施,下面结合附图详细说明本申请。For better understanding and implementation, the present application is described in detail below with reference to the accompanying drawings.
附图说明Description of drawings
为了更清楚地说明本申请实施例或相关技术中的技术方案,下面将对实施例或相关技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to illustrate the technical solutions in the embodiments of the present application or related technologies more clearly, the following briefly introduces the accompanying drawings that are used in the description of the embodiments or related technologies. Obviously, the drawings in the following description are the drawings of the present application For some embodiments of the present invention, for those of ordinary skill in the art, other drawings can also be obtained from these drawings without any creative effort.
图1为本申请一个实施例中需要绘制的书写笔迹的示意图;Fig. 1 is the schematic diagram of the handwriting that needs to be drawn in one embodiment of the application;
图2为本申请相关技术中对书写笔迹进行三角剖分的示意图;2 is a schematic diagram of triangulating handwriting in the related art of the application;
图3为本申请相关技术中对书写笔迹进行渲染的效果图;3 is an effect diagram of rendering handwriting in the related art of the application;
图4为本申请一个实施例示出的书写笔迹绘制方法的流程图;4 is a flowchart of a method for drawing handwriting according to an embodiment of the application;
图5为本申请一个实施例示出的笔迹轴线的示意图;5 is a schematic diagram of a handwriting axis shown in an embodiment of the application;
图6为本申请一个实施例示出的最短距离的示意图;6 is a schematic diagram of the shortest distance shown in an embodiment of the application;
图7为本申请一个实施例示出的获取笔迹轴线的方法的流程图;7 is a flowchart of a method for obtaining a handwriting axis according to an embodiment of the application;
图8为本申请一个实施例示出的确定SDF纹理图像的方法的流程图;8 is a flowchart of a method for determining an SDF texture image according to an embodiment of the present application;
图9为本申请一个实施例示出的获取书写笔迹的方法的流程图;FIG. 9 is a flowchart of a method for obtaining writing handwriting according to an embodiment of the application;
图10为本申请一个实施例示出的绘制出的书写笔迹的效果图;10 is an effect diagram of the drawn handwriting shown in an embodiment of the application;
图11为本申请另一个实施例示出绘制出的书写笔迹的效果图;Fig. 11 is another embodiment of the present application showing the effect diagram of drawn handwriting;
图12为本申请一个实施例示出的书写笔迹绘制装置的示意框图;12 is a schematic block diagram of a writing handwriting drawing device according to an embodiment of the application;
图13为本申请一个实施例示出的笔迹轴线获取模块的示意框图;13 is a schematic block diagram of a handwriting axis acquisition module according to an embodiment of the application;
图14为本申请一个实施例示出的纹理图像获取模块的示意框图;14 is a schematic block diagram of a texture image acquisition module according to an embodiment of the application;
图15为本申请一个实施例示出的书写笔迹获取模块的示意框图;15 is a schematic block diagram of a writing handwriting acquisition module according to an embodiment of the application;
图16为本申请一个实施例示出的交互平板的结构示意图。FIG. 16 is a schematic structural diagram of an interactive tablet according to an embodiment of the present application.
具体实施方式Detailed ways
为使本申请的目的、技术方案和优点更加清楚,下面将结合附图对本申请实施例方式作详细描述。In order to make the objectives, technical solutions and advantages of the present application clearer, the embodiments of the present application will be described in detail below with reference to the accompanying drawings.
应当明确,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请 中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其它实施例,都属于本申请保护的范围。It should be clear that the described embodiments are some, but not all, embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.
下面的描述涉及附图时,除非另有表示,不同附图中的相同数字表示相同或相似的要素。以下示例性实施例中所描述的实施方式并不代表与本申请相一致的所有实施方式。相反,它们仅是如所附权利要求书中所详述的、本申请的一些方面相一致的装置和方法的例子。Where the following description refers to the drawings, the same numerals in different drawings refer to the same or similar elements unless otherwise indicated. The implementations described in the illustrative examples below are not intended to represent all implementations consistent with this application. Rather, they are merely examples of apparatus and methods consistent with some aspects of the present application, as recited in the appended claims.
在本申请的描述中,需要理解的是,术语“第一”、“第二”、“第三”等仅用于区别类似的对象,而不必用于描述特定的顺序或先后次序,也不能理解为指示或暗示相对重要性。对于本领域的普通技术人员而言,可以根据情况理解上述术语在本申请中的含义。在本申请和所附权利要求书中所使用的单数形式的“一种”、“所述”和“该”也旨在包括多数形式,除非上下文清楚地表示其他含义。在此所使用的词语“如果”/“若”可以被解释成为“在……时”或“当……时”或“响应于确定”。此外,在本申请的描述中,除非另有说明,“多个”是指两个或两个以上。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。字符“/”一般表示前后关联对象是一种“或”的关系。In the description of this application, it should be understood that the terms "first", "second", "third", etc. are only used to distinguish similar objects, and are not necessarily used to describe a specific sequence or sequence, nor can understood as indicating or implying relative importance. For those of ordinary skill in the art, the meanings of the above terms in the present application can be understood according to the situation. As used in this application and the appended claims, the singular forms "a," "the," and "the" are intended to include the plural forms as well, unless the context clearly dictates otherwise. The words "if"/"if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining". Also, in the description of the present application, unless otherwise specified, "a plurality" means two or more. "And/or", which describes the association relationship of the associated objects, means that there can be three kinds of relationships, for example, A and/or B, which can mean that A exists alone, A and B exist at the same time, and B exists alone. The character "/" generally indicates that the associated objects are an "or" relationship.
为了更好的理解本申请的技术方案,下面将对相关技术中的书写笔迹的绘制方法进行说明。需要说明的是,本申请实施例提到的书写笔迹为一种特殊的书写笔迹,请参阅图1,例如书写笔迹的起始端点、结束端点以及拐角均为圆弧形状。请参阅图2和图3,相关技术中对所述书写笔迹的绘制方法是根据书写操作的触摸信息,获得所述书写操作的笔迹轴线;然后根据预设的笔迹宽度和颜色等属性,构造组成书写笔迹的多边形网格轮廓;接着在多边形网格轮廓内进行三角形剖分,最后对多边形网格轮廓内所有的三角形进行渲染,获得书写笔迹。在实现本申请的过程中,发现相关技术中至少存在以下问题:由于一个书写笔迹对应剖分的三角形数目已经很多,当书写笔迹一旦多起来,则三角形的数据会变得非常巨大,进而降低渲染显示书写笔迹的效率。而且即使书写出现微小的变化,均需要重新生成多边形网格轮廓,再对多边形轮廓内重新生成三角形进行渲染,增加了复杂度,降低了渲染效率。为此,本申请提出了一种书写笔迹绘制方法。In order to better understand the technical solutions of the present application, the method for drawing handwriting in the related art will be described below. It should be noted that the writing handwriting mentioned in the embodiments of the present application is a special writing handwriting, please refer to FIG. 1 , for example, the starting endpoint, the ending endpoint and the corner of the writing handwriting are all arc shapes. Please refer to FIG. 2 and FIG. 3 , the method for drawing the writing handwriting in the related art is to obtain the handwriting axis of the writing operation according to the touch information of the writing operation; The polygon mesh outline of the writing handwriting; then triangulation is performed in the polygon mesh outline, and finally all triangles in the polygon mesh outline are rendered to obtain the writing handwriting. In the process of realizing this application, it is found that there are at least the following problems in the related art: since there are already many triangles corresponding to a writing handwriting, once the writing handwriting increases, the data of the triangles will become very huge, thereby reducing the rendering time. Shows the efficiency of handwriting. Moreover, even if there is a slight change in writing, the polygon mesh outline needs to be regenerated, and then the regenerated triangles in the polygon outline are rendered, which increases the complexity and reduces the rendering efficiency. To this end, the present application proposes a method for drawing handwriting.
本申请实施例示出的书写笔迹绘制方法可以由书写笔迹绘制设备执行,所述书写笔迹绘制设备可以通过软件和/或硬件的方式实现,所述书写笔迹绘制设备可以是两个或多个物理实体构成,也可以是一个物理实体构成。例如,所述书写笔迹绘制设备可以是电脑、手机、平板或智能交互平板等智能设备。The writing handwriting drawing method shown in the embodiments of the present application may be executed by a writing handwriting drawing device, the writing handwriting drawing device may be implemented by means of software and/or hardware, and the writing handwriting drawing device may be two or more physical entities Composition can also be a physical entity composition. For example, the writing and handwriting drawing device may be a smart device such as a computer, a mobile phone, a tablet or a smart interactive tablet.
为了便于理解,实施例中以交互平板为书写笔迹绘制设备进行示例性描述。其中,交互平板可以是通过触控技术对显示在显示平板上的内容进行操控和实现人机交互操作的一体化 设备,其集成了投影机、电子白板、幕布、音响、电视机以及视频会议终端等一种或多种功能。For ease of understanding, in the embodiments, an interactive tablet is used as a writing handwriting drawing device for exemplary description. Among them, the interactive tablet can be an integrated device that controls the content displayed on the display tablet and realizes human-computer interaction through touch technology. one or more functions.
一般而言,交互平板包括至少一块显示屏。例如,交互平板配置有一块具有触控功能的显示屏,且该显示屏可以是电容屏、电阻屏或者电磁屏。在一实施例中,用户可以通过手指或触控笔触控显示屏的方式实现触控操作,相应的,交互平板检测触控位置,并根据触控位置对应的触控操作确定响应方案,进而进行响应,以实现触控功能。例如,根据触控位置确定对应的触控操作为书写笔迹,此时,响应方案为显示笔迹。在一实施例中,交互平板安装有至少一类操作系统,其中,操作系统包括但不限定于安卓系统、Linux系统及Windows系统。在一实施例中,交互平板可以基于操作系统安装至少一个应用程序,实施例中,以具有书写功能的应用程序进行示例性描述。例如,交互平板中安装有具有书写功能的电子白板应用程序。其中,该应用程序可以为操作系统自带的应用程序,也可以为从第三方设备或者服务器中下载的应用程序,交互平板也可以为应用程序本身。可选的,应用程序除具备书写功能外,还具有其他编辑功能,如书写、插入表格、插入图片、插入多媒体、插入图形、绘制表格等功能。Generally speaking, an interactive tablet includes at least one display screen. For example, the interactive tablet is equipped with a display screen with a touch function, and the display screen can be a capacitive screen, a resistive screen or an electromagnetic screen. In one embodiment, the user can realize the touch operation by touching the display screen with a finger or a stylus. Correspondingly, the interactive tablet detects the touch position, and determines a response scheme according to the touch operation corresponding to the touch position, and then performs the touch operation. response to implement the touch function. For example, it is determined according to the touch position that the corresponding touch operation is writing handwriting, and at this time, the response scheme is displaying handwriting. In one embodiment, at least one type of operating system is installed on the interactive tablet, wherein the operating system includes but is not limited to an Android system, a Linux system, and a Windows system. In one embodiment, the interactive tablet can install at least one application program based on the operating system, and in the embodiment, an application program with a writing function is used as an example for description. For example, an electronic whiteboard application with a writing function is installed in the interactive tablet. The application program may be an application program that comes with the operating system, or an application program downloaded from a third-party device or server, and the interactive tablet may also be an application program itself. Optionally, in addition to the writing function, the application program also has other editing functions, such as functions of writing, inserting tables, inserting pictures, inserting multimedia, inserting graphics, and drawing tables.
实施例1Example 1
本申请实施例公开的书写笔迹绘制方法,应用于电子设备,下面以所述电子设备为交互平板进行说明。The writing and handwriting drawing method disclosed in the embodiments of the present application is applied to an electronic device, and the following description takes the electronic device as an interactive tablet.
下面将结合附图4至图11,对本申请实施例提供的书写笔迹绘制方法进行详细介绍。The method for drawing handwriting provided by the embodiments of the present application will be described in detail below with reference to FIGS. 4 to 11 .
请参阅图4,其为本申请一个实施例示出的书写笔迹绘制方法的流程图。Please refer to FIG. 4 , which is a flowchart of a method for drawing handwriting according to an embodiment of the present application.
本申请实施例提供的书写笔迹绘制方法,包括如下步骤:The method for drawing handwriting provided by the embodiment of the present application includes the following steps:
步骤S110:接收在触摸屏上的书写操作。Step S110: Receive a writing operation on the touch screen.
在一些例子中,通过在触摸屏上打开电子白板显示书写界面,通过手或者触摸笔或其他书写工具在所述书写界面上触摸书写时,交互平板将接收在触摸屏上的书写操作。In some examples, a writing interface is displayed by turning on the electronic whiteboard on the touch screen, and the interactive tablet will receive the writing operation on the touch screen when touching and writing on the writing interface by hand or a stylus or other writing tool.
步骤S120:获取所述书写操作对应的触摸点信息,根据所述触摸点信息获取所述书写操作对应的笔迹轴线。Step S120: Acquire touch point information corresponding to the writing operation, and acquire the handwriting axis corresponding to the writing operation according to the touch point information.
请参阅图5,通过检测所述书写操作可获得触摸点信息,根据所述触摸点信息获取所述书写操作对应的笔迹轴线。Referring to FIG. 5 , touch point information can be obtained by detecting the writing operation, and a handwriting axis corresponding to the writing operation can be obtained according to the touch point information.
步骤S130:根据所述笔迹轴线的尺寸和预设的渲染线宽,确定目标缓冲区。Step S130: Determine the target buffer area according to the size of the handwriting axis and the preset rendering line width.
在一些例子中,所述笔迹轴线的尺寸包括所述笔迹轴线的长度和所述笔迹轴线的宽度;其中,所述笔迹轴线的长度为所述笔迹轴线起点到所述笔迹轴线终点之间的距离,所述笔迹轴线的宽度为垂直于所述笔迹轴线的长度方向上所述笔迹轴线的两端的最大距离。In some examples, the size of the handwriting axis includes the length of the handwriting axis and the width of the handwriting axis; wherein the length of the handwriting axis is the distance between the start point of the handwriting axis and the end point of the handwriting axis , the width of the handwriting axis is the maximum distance between the two ends of the handwriting axis in the length direction perpendicular to the handwriting axis.
在一些例子中,所述渲染线宽为绘制显示的书写笔迹的宽度大小,其可以根据需要设置。In some examples, the rendering line width is the width of the handwriting displayed by drawing, which can be set as required.
缓冲区是内存空间的一部分,也就是说,在内存空间中预留指定大小的存储空间用来对输入或输出的数据的临时存储,这部分预留的空间就叫做缓冲区,目的是为了减少数据读取次数,提高数据处理效率,在本申请实施例中,所述目标缓冲区为确定渲染缓冲区以及SDF纹理缓冲区而临时存储的数据。The buffer is a part of the memory space, that is to say, a storage space of a specified size is reserved in the memory space for temporary storage of input or output data. This part of the reserved space is called a buffer, and the purpose is to reduce The number of times of data reading improves data processing efficiency. In this embodiment of the present application, the target buffer is the data temporarily stored for determining the rendering buffer and the SDF texture buffer.
在一些例子中,所述根据所述笔迹轴线的尺寸和预设的渲染线宽,确定目标缓冲区,包括:将所述笔迹轴线的横向长度加上预设的渲染线宽、将所述笔迹轴线的纵向长度加上预设的渲染线宽,获得所述目标缓冲区。本申请实施例通过将所述笔迹轴线的横向长度加上预设的渲染线宽、将所述笔迹轴线的纵向长度加上预设的渲染线宽,获得所述目标缓冲区,可使书写笔迹在渲染时能够完全不遮挡地渲染显示。In some examples, the determining the target buffer according to the size of the handwriting axis and the preset rendering line width includes: adding the horizontal length of the handwriting axis to the preset rendering line width, and adding the handwriting axis to the preset rendering line width. The vertical length of the axis is added to the preset rendering line width to obtain the target buffer. In this embodiment of the present application, the target buffer is obtained by adding the horizontal length of the handwriting axis to the preset rendering line width, and adding the vertical length of the handwriting axis to the preset rendering line width, so that the handwriting can be written. The display can be rendered completely unobstructed at render time.
步骤S140:根据预设的纹理分辨率对所述目标缓冲区进行压缩处理,获得SDF纹理缓冲区。Step S140: Compress the target buffer according to the preset texture resolution to obtain an SDF texture buffer.
其中,SDF(signed distance filed,有向距离场)为对每个像素值存储距离。在一些例子中,所述预设的纹理分辨率可以为通过预设的压缩系数确定的纹理分辨率,例如,对于分辨率为1600x512的所述目标缓冲区,若预设的压缩系数为32,则对所述目标缓冲区按照缩放系数为32进行压缩可以获得SDF纹理缓冲区,此时所述SDF纹理缓冲区的纹理分辨率为50x16。所述预设的纹理分辨率也可以未直接预设的纹理分辨率,例如,对于分辨率为1600x512的所述目标缓冲区,若预设的纹理分辨率为50x16,则可计算获得压缩系数为32,进而对所述目标缓冲区进行压缩,获得纹理分辨率为50x16的SDF纹理缓冲区。Among them, SDF (signed distance filed, directional distance field) stores the distance for each pixel value. In some examples, the preset texture resolution may be a texture resolution determined by a preset compression factor. For example, for the target buffer with a resolution of 1600×512, if the preset compression factor is 32, Then, the target buffer can be compressed according to the scaling factor of 32 to obtain an SDF texture buffer, and the texture resolution of the SDF texture buffer is 50×16 at this time. The preset texture resolution can also be a texture resolution that is not directly preset. For example, for the target buffer with a resolution of 1600×512, if the preset texture resolution is 50×16, the compression coefficient can be calculated as 32, and then compress the target buffer to obtain an SDF texture buffer with a texture resolution of 50×16.
步骤S150:计算所述目标缓冲区中与所述SDF纹理缓冲区的每个纹理像素点对应的位置到所述笔迹轴线的最短距离,并将所述最短距离确定为对应的所述SDF纹理缓冲区的纹理像素点的值,获得SDF纹理图像。Step S150: Calculate the shortest distance from the position corresponding to each texel point of the SDF texture buffer in the target buffer to the handwriting axis, and determine the shortest distance as the corresponding SDF texture buffer The value of the texture pixel point of the area, obtain the SDF texture image.
请参阅图6,计算所述目标缓冲区中与所述SDF纹理缓冲区的每个纹理像素点对应的位置到所述笔迹轴线的最短距离包括:遍历所述笔迹轴线的各点与所述目标缓冲区中与所述SDF纹理缓冲区的各个纹理像素点对应的位置的距离,选取距离最小的值确定为最短距离。Referring to FIG. 6 , calculating the shortest distance from the position corresponding to each texel point of the SDF texture buffer in the target buffer to the handwriting axis includes: traversing each point of the handwriting axis and the target For the distance in the buffer area corresponding to each texture pixel point of the SDF texture buffer area, the value with the smallest distance is selected as the shortest distance.
步骤S160:根据所述目标缓冲区分配渲染缓冲区,建立所述渲染缓冲区与所述SDF纹理图像的映射关系。Step S160: Allocate a rendering buffer according to the target buffer, and establish a mapping relationship between the rendering buffer and the SDF texture image.
在一些例子中,所述目标缓冲区与所述渲染缓冲区分辨率相同,即根据所述目标缓冲区的分辨率,分配与所述目标缓冲区分辨率相同的渲染缓冲区。In some examples, the target buffer has the same resolution as the render buffer, that is, according to the resolution of the target buffer, a render buffer with the same resolution as the target buffer is allocated.
步骤S170:基于双线性插值采样对所述渲染缓冲区进行渲染后获得书写笔迹。Step S170 : obtaining writing handwriting after rendering the rendering buffer based on bilinear interpolation sampling.
双线性插值,又称为双线性内插。在数学上,双线性插值是有两个变量的插值函数的线 性插值扩展,其核心思想是在两个方向分别进行一次线性插值。Bilinear interpolation, also known as bilinear interpolation. Mathematically, bilinear interpolation is a linear interpolation extension of an interpolation function with two variables, and its core idea is to perform a linear interpolation in two directions respectively.
本申请实施例中根据所述渲染缓冲区与所述SDF纹理图像的映射关系,采用双线性插值对所述渲染缓冲区进行插值采样得到的书写笔迹,可以使书写笔迹的边缘更加平滑。In the embodiment of the present application, according to the mapping relationship between the rendering buffer and the SDF texture image, bilinear interpolation is used to interpolate and sample the rendering buffer to obtain writing handwriting, which can make the edge of the writing handwriting smoother.
步骤S180:在所述触摸屏上显示所述书写笔迹。Step S180: Display the handwriting on the touch screen.
本申请实施例根据预设纹理分辨率对目标缓冲区进行压缩处理,获得SDF纹理缓冲区;计算所述目标缓冲区中与所述SDF纹理缓冲区的每个纹理像素点对应的位置到所述笔迹轴线的最短距离,并将所述最短距离确定为对应的所述SDF纹理缓冲区的纹理像素点的值,获得SDF纹理图像;对所述SDF纹理图像进行双线性插值采样,获得插值采样后的各纹理像素点到所述笔迹轴线的距离值,且根据渲染缓冲区与所述SDF纹理图像的映射关系,进而基于双线性插值采样对所述渲染缓冲区进行渲染后获得书写笔迹,从而在所述触摸屏上显示书写笔迹,进而通过所述SDF纹理图像只需要渲染两个三角形,渲染开销小,进而提高了渲染效率,可及时有效地显示书写笔迹。当书写笔迹不变,而需要渲染不同宽度的书写笔迹时,只需要一次预处理生成SDF纹理图像,后续直接通过该同一张SDF纹理图像渲染显示不同宽度的书写笔迹。本申请由于SDF纹理为描述距离信息而不是颜色信息,进而结合双线性插值采样方法,可以通过小分辨率的SDF纹理图像进行大分辨率的笔迹绘制时,不容易出现边缘失真的问题。The embodiment of the present application performs compression processing on the target buffer according to the preset texture resolution to obtain an SDF texture buffer; calculates the position corresponding to each texture pixel of the SDF texture buffer in the target buffer to the The shortest distance of the handwriting axis, and the shortest distance is determined as the value of the texture pixel point of the corresponding SDF texture buffer to obtain an SDF texture image; the SDF texture image is subjected to bilinear interpolation sampling to obtain interpolation sampling The distance value between each texture pixel point and the handwriting axis, and according to the mapping relationship between the rendering buffer and the SDF texture image, and then rendering the rendering buffer based on bilinear interpolation sampling to obtain writing handwriting, Therefore, the handwriting is displayed on the touch screen, and only two triangles need to be rendered through the SDF texture image, the rendering overhead is small, the rendering efficiency is improved, and the handwriting can be displayed in a timely and effective manner. When the writing handwriting does not change, and writing handwriting of different widths needs to be rendered, only one preprocessing is required to generate an SDF texture image, and then the same SDF texture image is directly used to render and display the writing handwriting of different widths. In the present application, since the SDF texture describes distance information rather than color information, and combined with the bilinear interpolation sampling method, the problem of edge distortion is not easy to occur when large-resolution handwriting drawing can be performed by using a small-resolution SDF texture image.
请参阅图7,其为本申请一个实施例示出的获取笔迹轴线的方法的流程图。Please refer to FIG. 7 , which is a flowchart of a method for obtaining a handwriting axis according to an embodiment of the present application.
在一些例子中,步骤S120中,所述触摸点信息为所述触摸屏根据所述书写操作采集的多个连续的采样点;所述响应于触摸屏上的书写操作获得触摸点信息,根据所述触摸点信息获取所述书写操作对应的笔迹轴线,包括:In some examples, in step S120, the touch point information is a plurality of consecutive sampling points collected by the touch screen according to the writing operation; the touch point information obtained in response to the writing operation on the touch screen, according to the touch The point information obtains the handwriting axis corresponding to the writing operation, including:
步骤S121:根据相邻的两个所述采样点,得到触摸点连线;Step S121: obtaining a touch point connection line according to the two adjacent sampling points;
步骤S122:根据所述触摸点连线,获得所述书写操作对应的笔迹轴线。Step S122: Obtain the handwriting axis corresponding to the writing operation according to the touch point connection.
通过将两个相邻的采样点进行连线获得触摸点连线,进而实现快捷准确地获得笔迹轴线。The touch point connection line is obtained by connecting two adjacent sampling points, thereby realizing the quick and accurate acquisition of the handwriting axis.
请参阅图8,其为本申请一个实施例示出的确定SDF纹理图像的方法的流程图。Please refer to FIG. 8 , which is a flowchart of a method for determining an SDF texture image according to an embodiment of the present application.
在一些例子中,所述SDF纹理缓冲区包括横向纹理像素点数量和纵向纹理像素点数量。步骤S150中,所述计算所述目标缓冲区中与所述SDF纹理缓冲区的每个像素点对应的位置到所述笔迹轴线的最短距离,并将所述最短距离确定为对应的所述SDF纹理缓冲区的纹理像素点的值,获得SDF纹理图像,包括:In some examples, the SDF texture buffer includes a horizontal texel count and a vertical texel count. In step S150, the shortest distance from the position corresponding to each pixel of the SDF texture buffer in the target buffer to the handwriting axis is calculated, and the shortest distance is determined as the corresponding SDF The value of the texture pixel point of the texture buffer to obtain the SDF texture image, including:
步骤S151:获取所述SDF纹理缓冲区的横向纹理像素点数量和纵向纹理像素点数量。Step S151: Acquire the number of horizontal texels and the number of vertical texels of the SDF texture buffer.
步骤S152:根据所述横向纹理像素点数量和纵向纹理像素点数量,将所述目标缓冲区划分为对应数量的纹理网格。Step S152: Divide the target buffer into a corresponding number of texture grids according to the number of horizontal texels and the number of vertical texels.
例如,若所述横向纹理像素点数量和纵向纹理像素点数量分别为50和16,则所述目标缓冲区划分的横向纹理网格数量为50和纵向纹理网格数量为16;若所述横向纹理像素点数量和纵向纹理像素点数量分别为50和16,则所述目标缓冲区划分的横向纹理网格数量为25和纵向纹理网格数量为8,则所述目标缓冲区划分的横向纹理网格数量为25和纵向纹理网格数量为8。For example, if the number of horizontal texture pixels and the number of vertical texture pixels are 50 and 16 respectively, the number of horizontal texture grids divided by the target buffer is 50 and the number of vertical texture grids is 16; The number of texture pixels and the number of vertical texture pixels are 50 and 16 respectively, then the number of horizontal texture grids divided by the target buffer is 25 and the number of vertical texture grids is 8, then the horizontal texture divided by the target buffer The number of meshes is 25 and the number of longitudinal texture meshes is 8.
步骤S153:计算所述目标缓冲区中每个纹理网格的中心点到所述笔迹轴线的最短距离。Step S153: Calculate the shortest distance from the center point of each texture grid in the target buffer to the handwriting axis.
步骤S154:将所述最短距离确定为对应的所述SDF纹理缓冲区的纹理像素点的值,获得SDF纹理图像。Step S154: Determine the shortest distance as the value of the corresponding texture pixel of the SDF texture buffer to obtain an SDF texture image.
通过将所述目标缓冲区划分为与所述SDF纹理缓冲区对应数量的纹理网格,进而计算每个纹理网格的中心点到所述笔迹轴线的最短距离,从而将所述最短距离确定为对应的所述SDF纹理图像的纹理像素点的值,进而可以充分保留高分辨率下的所述目标缓冲区的距离信息。所述SDF纹理图像中的纹理像素点中记录距离值而不是记录颜色值,从而对图像的压缩和拉伸等处理都不会太大影响显示效果。By dividing the target buffer into texture grids corresponding to the SDF texture buffer, and then calculating the shortest distance from the center point of each texture grid to the handwriting axis, the shortest distance is determined as The corresponding value of the texture pixel point of the SDF texture image, so that the distance information of the target buffer under high resolution can be fully preserved. The texel in the SDF texture image records the distance value instead of the color value, so that the image compression and stretching will not greatly affect the display effect.
请参阅图9,其为本申请一个实施例示出的获取书写笔迹的方法的流程图。Please refer to FIG. 9 , which is a flowchart of a method for acquiring handwriting according to an embodiment of the present application.
在一个实施例中,所述基于双线性插值采样对所述渲染缓冲区进行渲染后获得书写笔迹,包括:In one embodiment, the handwriting obtained after rendering the rendering buffer based on bilinear interpolation sampling includes:
步骤S171:对所述SDF纹理图像进行双线性插值采样,获得插值采样后的各纹理像素点到所述笔迹轴线的距离值。Step S171: Perform bilinear interpolation sampling on the SDF texture image to obtain a distance value from each texel point after interpolation sampling to the handwriting axis.
步骤S172:在所述渲染缓冲区中,将与所述笔迹轴线的距离值小于或等于预设渲染线宽的采样点进行颜色填充后,获得书写笔迹。Step S172: In the rendering buffer, after color-filling sampling points whose distance from the handwriting axis is less than or equal to the preset rendering line width, the writing handwriting is obtained.
对所述渲染缓冲区进行渲染,对所述SDF纹理图像进行双线性插值采样,获得插值采样后的各纹理像素点到所述笔迹轴线的距离值,在所述渲染缓冲区填充颜色至与所述笔迹轴线的距离值小于或等于预设渲染线宽的对应点,获得书写笔迹。Render the rendering buffer, perform bilinear interpolation sampling on the SDF texture image, obtain the distance value of each texel point after the interpolation sampling to the handwriting axis, and fill the rendering buffer with a color to match the value of the handwriting axis. The distance value of the handwriting axis is less than or equal to the corresponding point of the preset rendering line width, and the writing handwriting is obtained.
需要说明的是,本申请实施例提到的书写笔迹为一种特殊的书写笔迹,例如,所述书写笔迹的起始端点、结束端点以及拐角均为圆弧形状,也即,在实现本申请的过程中发现:对于这样的书写笔迹,所述书写笔迹上的任意一点到所述笔迹轴线的最短距离均小于或等于所述笔迹宽度的一半。为此,本申请在所述渲染缓冲区填充颜色至与所述笔迹轴线的距离值小于或等于预设渲染线宽的对应点,获得的所述书写笔迹即为所述书写笔迹的起始端点、结束端点以及拐角均为圆弧形状。It should be noted that the writing handwriting mentioned in the embodiments of the present application is a special writing handwriting. For example, the starting point, the ending point and the corner of the writing handwriting are all arc shapes, that is, when implementing the present application It was found in the process that: for such a handwriting, the shortest distance from any point on the handwriting to the axis of the handwriting is less than or equal to half of the width of the handwriting. For this reason, the present application fills the rendering buffer with the color to the corresponding point where the distance from the handwriting axis is less than or equal to the preset rendering line width, and the obtained writing handwriting is the starting point of the writing handwriting , end endpoints, and corners are arc shapes.
请参阅图10,在一些例子中,所述SDF纹理图像为矩形图像,因此,所述渲染缓冲区也为矩形,而在渲染时,通常是以三角形为单位进行渲染的,因此,对于渲染缓冲区也构建为 两个三角形组成的矩形进行渲染。在一个实施例中,对所述渲染缓冲区进行渲染时,通过读取两个三角形的顶点确定出渲染缓冲区,对所述SDF纹理图像进行双线性插值采样,获得插值采样后的各纹理像素点到所述笔迹轴线的距离值,再根据所述渲染缓冲区与所述SDF纹理图像的映射关系,在所述渲染缓冲区填充颜色至与所述笔迹轴线的距离值小于或等于预设渲染线宽的对应点,获得书写笔迹。Referring to FIG. 10, in some examples, the SDF texture image is a rectangular image, so the rendering buffer is also a rectangle, and during rendering, the rendering is usually performed in units of triangles. Therefore, for the rendering buffer The area is also constructed as a rectangle of two triangles for rendering. In one embodiment, when rendering the rendering buffer, the rendering buffer is determined by reading the vertices of two triangles, and the SDF texture image is subjected to bilinear interpolation sampling to obtain each texture after the interpolation sampling. The distance value from the pixel point to the handwriting axis, and then according to the mapping relationship between the rendering buffer and the SDF texture image, fill the color in the rendering buffer until the distance value from the handwriting axis is less than or equal to the preset value Render the corresponding point of the line width to obtain the handwriting.
在一些例子中,所述SDF纹理缓冲区的分辨率即预设的纹理分辨率与所述目标缓冲区的分辨率即渲染显示的分辨率可以不一致,当SDF纹理缓冲区的分辨率越低时,生成SDF纹理图像的效率越高,但是精度也越低,即生成的书写笔迹也模糊,当SDF纹理缓冲区的分辨率越高时,生成SDF纹理图像的效率越低,但是精度也越高,即生成的书写笔迹也越清楚。在一些例子中,所述SDF纹理缓冲区的分辨率即预设的纹理分辨率小于所述目标缓冲区的分辨率即渲染显示的分辨率,以减少计算量,提高渲染效率。请参阅图10,对于分辨率为1600x512的所述目标缓冲区,若所述SDF纹理缓冲区的纹理分辨率为50x16,则显示的笔迹比较平滑,请参阅图11,同样是分辨率为1600x512的所述目标缓冲区,若所述SDF纹理缓冲区的纹理分辨率为25x8,则显示的笔迹的边缘会有点失真,但是由于本申请的SDF纹理图形中存储的是距离值,而且采用了双线性插值的方式,因此,显示的笔迹的仍然有很好的精度,进而即使所述SDF纹理缓冲区的分辨率即预设的纹理分辨率小于所述目标缓冲区的分辨率即渲染显示的分辨率,也有较高的渲染精度。In some examples, the resolution of the SDF texture buffer, that is, the preset texture resolution may be inconsistent with the resolution of the target buffer, that is, the resolution of the rendering display. When the resolution of the SDF texture buffer is lower , the higher the efficiency of generating SDF texture images, but the lower the accuracy, that is, the generated handwriting is also blurred. When the resolution of the SDF texture buffer is higher, the efficiency of generating SDF texture images is lower, but the accuracy is also higher. , that is, the generated handwriting is clearer. In some examples, the resolution of the SDF texture buffer, that is, the preset texture resolution is smaller than the resolution of the target buffer, that is, the resolution of the rendering display, so as to reduce the amount of calculation and improve the rendering efficiency. Please refer to Figure 10, for the target buffer with a resolution of 1600x512, if the texture resolution of the SDF texture buffer is 50x16, the displayed handwriting is relatively smooth, please refer to Figure 11, the same resolution is 1600x512 In the target buffer, if the texture resolution of the SDF texture buffer is 25×8, the edge of the displayed handwriting will be somewhat distorted, but since the SDF texture graphic of the present application stores the distance value, and adopts double lines Therefore, the displayed handwriting still has good precision, and even if the resolution of the SDF texture buffer, that is, the preset texture resolution is smaller than the resolution of the target buffer, that is, the resolution of the rendering display It also has higher rendering accuracy.
实施例2Example 2
下述为本申请装置实施例,可以用于执行本申请实施例1中方法的内容。对于本申请装置实施例中未披露的细节,请参照本申请实施例1中方法的内容。The following is an apparatus embodiment of the present application, which can be used to execute the content of the method in Embodiment 1 of the present application. For details not disclosed in the device embodiments of the present application, please refer to the content of the method in Embodiment 1 of the present application.
请参阅图12,其为本申请一个实施例示出的书写笔迹绘制装置的示意框图。Please refer to FIG. 12 , which is a schematic block diagram of an apparatus for drawing handwriting according to an embodiment of the present application.
本申请实施例公开的一种书写笔迹绘制装置200,包括:A writing and handwriting drawing device 200 disclosed in the embodiment of the present application includes:
书写操作接收模块210,用于接收在触摸屏上的书写操作;The writing operation receiving module 210 is used for receiving the writing operation on the touch screen;
笔迹轴线获取模块220,用于获取所述书写操作对应的触摸点信息,根据所述触摸点信息获取所述书写操作对应的笔迹轴线;A handwriting axis acquisition module 220, configured to acquire touch point information corresponding to the writing operation, and acquire the handwriting axis corresponding to the writing operation according to the touch point information;
目标缓冲区确定模块230,用于根据所述笔迹轴线的尺寸和预设的渲染线宽,确定目标缓冲区;a target buffer determining module 230, configured to determine a target buffer according to the size of the handwriting axis and a preset rendering line width;
纹理缓冲区获取模块240,用于根据预设的纹理分辨率对所述目标缓冲区进行压缩处理,获得SDF纹理缓冲区;a texture buffer acquiring module 240, configured to perform compression processing on the target buffer according to a preset texture resolution to obtain an SDF texture buffer;
纹理图像获取模块250,用于计算所述目标缓冲区中与所述SDF纹理缓冲区的每个纹理像素点对应的位置到所述笔迹轴线的最短距离,并将所述最短距离确定为对应的所述SDF纹 理缓冲区的纹理像素点的值,获得SDF纹理图像;The texture image acquisition module 250 is configured to calculate the shortest distance from the position corresponding to each texel point of the SDF texture buffer in the target buffer to the handwriting axis, and determine the shortest distance as the corresponding the value of the texture pixel point of the SDF texture buffer to obtain the SDF texture image;
映射关系获取模块260,用于根据所述目标缓冲区分配渲染缓冲区,建立所述渲染缓冲区与所述SDF纹理图像的映射关系;a mapping relationship acquisition module 260, configured to allocate a rendering buffer according to the target buffer, and establish a mapping relationship between the rendering buffer and the SDF texture image;
书写笔迹获取模块270,用于基于双线性插值采样对所述渲染缓冲区进行渲染后获得书写笔迹;A writing handwriting obtaining module 270, configured to obtain writing handwriting after rendering the rendering buffer based on bilinear interpolation sampling;
笔迹显示模块280,用于在所述触摸屏上显示所述书写笔迹。The handwriting display module 280 is used for displaying the writing handwriting on the touch screen.
本申请实施例根据预设纹理分辨率对目标缓冲区进行压缩处理,获得SDF纹理缓冲区;计算所述目标缓冲区中与所述SDF纹理缓冲区的每个纹理像素点对应的位置到所述笔迹轴线的最短距离,并将所述最短距离确定为对应的所述SDF纹理缓冲区的纹理像素点的值,获得SDF纹理图像;对所述SDF纹理图像进行双线性插值采样,获得插值采样后的各纹理像素点到所述笔迹轴线的距离值,且根据渲染缓冲区与所述SDF纹理图像的映射关系,进而基于双线性插值采样对所述渲染缓冲区进行渲染后获得书写笔迹,从而在所述触摸屏上显示书写笔迹,进而通过所述SDF纹理图像只需要渲染两个三角形,渲染开销小,进而提高了渲染效率,可及时有效地显示书写笔迹。当书写笔迹不变,而需要渲染不同宽度的书写笔迹时,只需要一次预处理生成SDF纹理图像,后续直接通过该同一张SDF纹理图像渲染显示不同宽度的书写笔迹。本申请由于SDF纹理为描述距离信息而不是颜色信息,进而结合双线性插值采样方法,可以通过小分辨率的SDF纹理图像进行大分辨率的笔迹绘制时,不容易出现边缘失真的问题。The embodiment of the present application performs compression processing on the target buffer according to the preset texture resolution to obtain an SDF texture buffer; calculates the position corresponding to each texture pixel of the SDF texture buffer in the target buffer to the The shortest distance of the handwriting axis, and the shortest distance is determined as the value of the texture pixel point of the corresponding SDF texture buffer to obtain an SDF texture image; the SDF texture image is subjected to bilinear interpolation sampling to obtain interpolation sampling The distance value between each texture pixel point and the handwriting axis, and according to the mapping relationship between the rendering buffer and the SDF texture image, and then rendering the rendering buffer based on bilinear interpolation sampling to obtain writing handwriting, Therefore, the handwriting is displayed on the touch screen, and only two triangles need to be rendered through the SDF texture image, the rendering overhead is small, the rendering efficiency is improved, and the handwriting can be displayed in a timely and effective manner. When the writing handwriting does not change, and writing handwriting of different widths needs to be rendered, only one preprocessing is required to generate an SDF texture image, and then the same SDF texture image is directly used to render and display the writing handwriting of different widths. In the present application, since the SDF texture describes distance information rather than color information, and combined with the bilinear interpolation sampling method, the problem of edge distortion is not easy to occur when large-resolution handwriting drawing can be performed by using a small-resolution SDF texture image.
在一些例子中,所述目标缓冲区确定模块230用于根据所述笔迹轴线的尺寸和预设的渲染线宽,确定目标缓冲区时,包括用于:将所述笔迹轴线的横向长度加上预设的渲染线宽、将所述笔迹轴线的纵向长度加上预设的渲染线宽,获得所述目标缓冲区。通过将所述笔迹轴线的横向长度加上预设的渲染线宽、将所述笔迹轴线的纵向长度加上预设的渲染线宽,获得所述目标缓冲区,从而使书写笔迹在渲染时能够完全不遮挡地渲染显示。In some examples, the target buffer determining module 230 is configured to determine the target buffer according to the size of the handwriting axis and the preset rendering line width, including: adding the horizontal length of the handwriting axis to The preset rendering line width is obtained by adding the longitudinal length of the handwriting axis to the preset rendering line width to obtain the target buffer. The target buffer is obtained by adding the horizontal length of the handwriting axis to the preset rendering line width, and adding the vertical length of the handwriting axis to the preset rendering line width, so that the handwriting can be rendered The display is rendered completely unobstructed.
请参阅图13,其为本申请一个实施例示出的笔迹轴线获取模块的示意框图。Please refer to FIG. 13 , which is a schematic block diagram of a handwriting axis acquisition module according to an embodiment of the present application.
在一些例子中,所述触摸点信息为所述触摸屏根据所述书写操作采集的多个连续的采样点;所述笔迹轴线获取模块220,用于响应于触摸屏上的书写操作获得触摸点信息,根据所述触摸点信息获取所述书写操作对应的笔迹轴线,包括用于:In some examples, the touch point information is a plurality of consecutive sampling points collected by the touch screen according to the writing operation; the handwriting axis acquisition module 220 is configured to obtain touch point information in response to a writing operation on the touch screen, Obtaining the handwriting axis corresponding to the writing operation according to the touch point information includes:
触摸点连线模块221,用于根据相邻的两个所述采样点,得到触摸点连线;The touch point connection module 221 is used to obtain the touch point connection according to the two adjacent sampling points;
笔迹轴线确定模块222,用于根据所述触摸点连线,获得所述书写操作对应的笔迹轴线。The handwriting axis determination module 222 is configured to obtain the handwriting axis corresponding to the writing operation according to the touch point connection.
通过将两个相邻的采样点进行连线获得触摸点连线,进而实现快捷准确地获得笔迹轴线。The touch point connection line is obtained by connecting two adjacent sampling points, thereby realizing the quick and accurate acquisition of the handwriting axis.
请参阅图14,其为本申请一个实施例示出的纹理图像获取模块的示意框图。Please refer to FIG. 14 , which is a schematic block diagram of a texture image acquisition module according to an embodiment of the present application.
在一些例子中,所述SDF纹理缓冲区包括横向纹理像素点数量和纵向纹理像素点数量;所述纹理图像获取模块250,包括:In some examples, the SDF texture buffer includes the number of horizontal texels and the number of vertical texels; the texture image acquisition module 250 includes:
像素点数量获取模块251,用于获取所述SDF纹理缓冲区的横向纹理像素点数量和纵向纹理像素点数量;Pixel quantity acquisition module 251, for acquiring the horizontal texel quantity and the vertical texel quantity of the SDF texture buffer;
纹理网格划分模块252,用于根据所述横向纹理像素点数量和纵向纹理像素点数量,将所述目标缓冲区划分为对应数量的纹理网格;a texture grid dividing module 252, configured to divide the target buffer into a corresponding number of texture grids according to the number of horizontal texels and the number of vertical texels;
距离计算模块253,用于计算所述目标缓冲区中每个纹理网格的中心点到所述笔迹轴线的最短距离;A distance calculation module 253, configured to calculate the shortest distance from the center point of each texture grid in the target buffer zone to the handwriting axis;
像素值确定模块254,用于将所述最短距离确定为对应的所述SDF纹理缓冲区的纹理像素点的值,获得SDF纹理图像。The pixel value determination module 254 is configured to determine the shortest distance as the value of the corresponding texture pixel point of the SDF texture buffer to obtain an SDF texture image.
通过将所述目标缓冲区划分为与所述SDF纹理缓冲区对应数量的纹理网格,进而计算每个纹理网格的中心点到所述笔迹轴线的最短距离,从而将所述最短距离确定为对应的所述SDF纹理图像的纹理像素点的值,进而可以充分保留高分辨率下的所述目标缓冲区的距离信息。所述SDF纹理图像中的纹理像素点中记录距离值而不是记录颜色值,从而对图像的压缩和拉伸等处理都不会太大影响显示效果。By dividing the target buffer into texture grids corresponding to the SDF texture buffer, and then calculating the shortest distance from the center point of each texture grid to the handwriting axis, the shortest distance is determined as The corresponding value of the texture pixel point of the SDF texture image, so that the distance information of the target buffer under high resolution can be fully preserved. The texel in the SDF texture image records the distance value instead of the color value, so that the image compression and stretching will not greatly affect the display effect.
请参阅图15,其为本申请一个实施例示出的书写笔迹获取模块的示意框图。Please refer to FIG. 15 , which is a schematic block diagram of a handwriting acquisition module according to an embodiment of the present application.
在一个实施例中,书写笔迹获取模块270包括:In one embodiment, the handwriting acquisition module 270 includes:
距离获取模块271,用于对所述SDF纹理图像进行双线性插值采样,获得插值采样后的各纹理像素点到所述笔迹轴线的距离值。The distance obtaining module 271 is configured to perform bilinear interpolation sampling on the SDF texture image to obtain the distance value from each texel point after interpolation sampling to the handwriting axis.
颜色填充模块272,用于在所述渲染缓冲区中,将与所述笔迹轴线的距离值小于或等于预设渲染线宽的采样点进行颜色填充后,获得书写笔迹。The color-filling module 272 is configured to color-fill sampling points whose distance from the handwriting axis is less than or equal to the preset rendering line width in the rendering buffer to obtain handwriting.
实施例3Example 3
下述为本申请设备实施例,可以用于执行本申请实施例1中方法的内容。对于本申请装置实施例中未披露的细节,请参照本申请实施例1中方法的内容。The following is a device embodiment of the present application, which can be used to execute the content of the method in Embodiment 1 of the present application. For details not disclosed in the device embodiments of the present application, please refer to the content of the method in Embodiment 1 of the present application.
请参阅图16,本申请还提供一种电子设备,所述电子设备可以为任何包括触摸屏的任何智能端,例如,可以为计算机、手机、平板电脑、交互平板等,在本申请实施例中,所述电子设备为交互平板300,例如是具有大尺寸的触摸屏的交互平板。所述交互平板300可以包括:至少一个处理器301、至少一个存储器302,至少一个显示器303,至少一个网络接口304,用户接口305以及至少一个通信总线306。Please refer to FIG. 16 , the present application also provides an electronic device. The electronic device can be any smart terminal including a touch screen, for example, a computer, a mobile phone, a tablet computer, an interactive tablet, etc. In this embodiment of the present application, The electronic device is an interactive tablet 300, such as an interactive tablet with a large-sized touch screen. The interactive tablet 300 may include: at least one processor 301 , at least one memory 302 , at least one display 303 , at least one network interface 304 , user interface 305 and at least one communication bus 306 .
其中,所述显示器303包括显示层和触控层,所述显示层用于显示经过处理器处理后的数据;所述触控层可以包括:电容屏,电磁屏或红外屏等,一般而言,所述触控层可以接收 用户通过手指或者输入设备输入的触摸操作或书写操作。The display 303 includes a display layer and a touch layer, the display layer is used to display data processed by the processor; the touch layer may include: a capacitive screen, an electromagnetic screen or an infrared screen, etc. Generally speaking , the touch layer can receive a touch operation or a writing operation input by a user through a finger or an input device.
其中,所述用户接口305主要用于为用户提供输入的接口,获取用户输入的数据。可选的,所述用户接口305还可以包括标准的有线接口、无线接口。Wherein, the user interface 305 is mainly used to provide an input interface for the user, and obtain the data input by the user. Optionally, the user interface 305 may also include a standard wired interface or a wireless interface.
其中,所述网络接口304可选的可以包括标准的有线接口、无线接口(如WI-FI接口)。Wherein, the network interface 304 may optionally include a standard wired interface and a wireless interface (eg, a WI-FI interface).
其中,所述通信总线306用于实现这些组件之间的连接通信。Wherein, the communication bus 306 is used to realize the connection and communication between these components.
其中,所述处理器301可以包括一个或者多个处理核心。处理器301利用各种接口和线路连接整个交互平板300内的各个部分,通过运行或执行存储在存储器302内的指令、程序、代码集或指令集,以及调用存储在存储器302内的数据,执行交互平板300的各种功能和处理数据。可选的,处理器301可以采用数字信号处理(Digital Signal Processing,DSP)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)、可编程逻辑阵列(Programmable Logic Array,PLA)中的至少一种硬件形式来实现。处理器301可集成中央处理器(Central Processing Unit,CPU)、图像处理器(Graphics Processing Unit,GPU)和调制解调器等中的一种或几种的组合。其中,CPU主要处理操作系统、用户界面和应用程序等;GPU用于负责显示层所需要显示的内容的渲染和绘制;调制解调器用于处理无线通信。可以理解的是,上述调制解调器也可以不集成到处理器301中,单独通过一块芯片进行实现。The processor 301 may include one or more processing cores. The processor 301 uses various interfaces and lines to connect various parts of the entire interactive tablet 300, and executes by running or executing the instructions, programs, code sets or instruction sets stored in the memory 302, and calling the data stored in the memory 302. Various functions of the interactive tablet 300 and processing data. Optionally, the processor 301 may adopt at least one of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). A hardware form is implemented. The processor 301 may integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU), a modem, and the like. Among them, the CPU mainly handles the operating system, user interface and application programs, etc.; the GPU is used for rendering and drawing the content that needs to be displayed on the display layer; the modem is used for handling wireless communication. It can be understood that, the above-mentioned modem may not be integrated into the processor 301, and is implemented by a single chip.
其中,存储器302可以包括随机存储器(Random Access Memory,RAM),也可以包括只读存储器(Read-Only Memory)。可选的,该存储器302包括非瞬时性计算机可读介质(non-transitory computer-readable storage medium)。存储器302可用于存储指令、程序、代码、代码集或指令集。存储器302可包括存储程序区和存储数据区,其中,存储程序区可存储用于实现操作系统的指令、用于至少一个功能的指令(比如触控功能、声音播放功能、图像播放功能等)、用于实现上述各个方法实施例的指令等;存储数据区可存储上面各个方法实施例中涉及到的数据等。存储器302可选的还可以是至少一个位于远离前述处理器301的存储装置。如图16所示,作为一种计算机存储介质的存储器302中可以包括操作系统、网络通信模块、用户。The memory 302 may include random access memory (Random Access Memory, RAM), or may include read-only memory (Read-Only Memory). Optionally, the memory 302 includes a non-transitory computer-readable storage medium. Memory 302 may be used to store instructions, programs, codes, sets of codes, or sets of instructions. The memory 302 may include a stored program area and a stored data area, wherein the stored program area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), Instructions and the like used to implement the above method embodiments; the storage data area may store the data and the like involved in the above method embodiments. Optionally, the memory 302 may also be at least one storage device located away from the aforementioned processor 301 . As shown in FIG. 16 , the memory 302 as a computer storage medium may include an operating system, a network communication module, and a user.
所述处理器301可以用于调用所述存储器302中存储的触摸屏的响应延时的应用程序,并执行以下操作:接收在触摸屏上的书写操作;获取所述书写操作对应的触摸点信息,根据所述触摸点信息获取所述书写操作对应的笔迹轴线;根据所述笔迹轴线的尺寸和预设的渲染线宽,确定目标缓冲区;根据预设的纹理分辨率对所述目标缓冲区进行压缩处理,获得SDF纹理缓冲区;计算所述目标缓冲区中与所述SDF纹理缓冲区的每个纹理像素点对应的位置到所述笔迹轴线的最短距离,并将所述最短距离确定为对应的所述SDF纹理缓冲区的纹理像素点的值,获得SDF纹理图像;根据所述目标缓冲区分配渲染缓冲区,建立所述渲染缓冲区与 所述SDF纹理图像的映射关系;基于双线性插值采样对所述渲染缓冲区进行渲染后获得书写笔迹;在所述触摸屏上显示所述书写笔迹。The processor 301 can be used to call the application program of the response delay of the touch screen stored in the memory 302, and perform the following operations: receiving a writing operation on the touch screen; acquiring touch point information corresponding to the writing operation, according to The touch point information obtains the handwriting axis corresponding to the writing operation; the target buffer is determined according to the size of the handwriting axis and the preset rendering line width; the target buffer is compressed according to the preset texture resolution Process, obtain the SDF texture buffer; calculate the shortest distance from the position corresponding to each texel point of the SDF texture buffer in the target buffer to the handwriting axis, and determine the shortest distance as the corresponding The value of the texture pixel point of the SDF texture buffer is obtained, and the SDF texture image is obtained; the rendering buffer is allocated according to the target buffer, and the mapping relationship between the rendering buffer and the SDF texture image is established; based on bilinear interpolation After sampling and rendering the rendering buffer, writing handwriting is obtained; and the writing handwriting is displayed on the touch screen.
本申请实施例根据预设纹理分辨率对目标缓冲区进行压缩处理,获得SDF纹理缓冲区;计算所述目标缓冲区中与所述SDF纹理缓冲区的每个纹理像素点对应的位置到所述笔迹轴线的最短距离,并将所述最短距离确定为对应的所述SDF纹理缓冲区的纹理像素点的值,获得SDF纹理图像;对所述SDF纹理图像进行双线性插值采样,获得插值采样后的各纹理像素点到所述笔迹轴线的距离值,且根据渲染缓冲区与所述SDF纹理图像的映射关系,进而基于双线性插值采样对所述渲染缓冲区进行渲染后获得书写笔迹,从而在所述触摸屏上显示书写笔迹,进而通过所述SDF纹理图像只需要渲染两个三角形,渲染开销小,进而提高了渲染效率,可及时有效地显示书写笔迹。当书写笔迹不变,而需要渲染不同宽度的书写笔迹时,只需要一次预处理生成SDF纹理图像,后续直接通过该同一张SDF纹理图像渲染显示不同宽度的书写笔迹。本申请由于SDF纹理为描述距离信息而不是颜色信息,进而结合双线性插值采样方法,可以通过小分辨率的SDF纹理图像进行大分辨率的笔迹绘制时,不容易出现边缘失真的问题。The embodiment of the present application performs compression processing on the target buffer according to the preset texture resolution to obtain an SDF texture buffer; calculates the position corresponding to each texture pixel of the SDF texture buffer in the target buffer to the The shortest distance of the handwriting axis, and the shortest distance is determined as the value of the texture pixel point of the corresponding SDF texture buffer to obtain an SDF texture image; the SDF texture image is subjected to bilinear interpolation sampling to obtain interpolation sampling The distance value between each texture pixel point and the handwriting axis, and according to the mapping relationship between the rendering buffer and the SDF texture image, and then rendering the rendering buffer based on bilinear interpolation sampling to obtain writing handwriting, Therefore, the handwriting is displayed on the touch screen, and only two triangles need to be rendered through the SDF texture image, the rendering overhead is small, the rendering efficiency is improved, and the handwriting can be displayed in a timely and effective manner. When the writing handwriting does not change, and writing handwriting of different widths needs to be rendered, only one preprocessing is required to generate an SDF texture image, and then the same SDF texture image is directly used to render and display the writing handwriting of different widths. In the present application, since the SDF texture describes distance information rather than color information, and combined with the bilinear interpolation sampling method, the problem of edge distortion is not easy to occur when large-resolution handwriting drawing can be performed by using a small-resolution SDF texture image.
在一些例子中,所述处理器301可以用于调用所述存储器302中存储的触摸屏的响应延时的应用程序,执行根据所述笔迹轴线的尺寸和预设的渲染线宽,确定目标缓冲区时,包括执行以下操作:将所述笔迹轴线的横向长度加上预设的渲染线宽、将所述笔迹轴线的纵向长度加上预设的渲染线宽,获得所述目标缓冲区。通过将所述笔迹轴线的横向长度加上预设的渲染线宽、将所述笔迹轴线的纵向长度加上预设的渲染线宽,获得所述目标缓冲区,从而使书写笔迹在渲染时能够完全不遮挡地渲染显示。In some examples, the processor 301 may be configured to call the response delay application of the touch screen stored in the memory 302, and execute the determination of the target buffer according to the size of the handwriting axis and the preset rendering line width , including performing the following operations: adding the horizontal length of the handwriting axis to a preset rendering line width, and adding the vertical length of the handwriting axis to the preset rendering line width to obtain the target buffer. The target buffer is obtained by adding the horizontal length of the handwriting axis to the preset rendering line width, and adding the vertical length of the handwriting axis to the preset rendering line width, so that the handwriting can be rendered The display is rendered completely unobstructed.
在一些例子中,所述触摸点信息为所述触摸屏根据所述书写操作采集的多个连续的采样点;所述处理器301可以用于调用所述存储器302中存储的触摸屏的响应延时的应用程序,执行响应于触摸屏上的书写操作获得触摸点信息,根据所述触摸点信息获取所述书写操作对应的笔迹轴线,包括执行:根据相邻的两个所述采样点,得到触摸点连线;根据所述触摸点连线,获得所述书写操作对应的笔迹轴线。通过将两个相邻的采样点进行连线获得触摸点连线,进而实现快捷准确地获得笔迹轴线。In some examples, the touch point information is a plurality of consecutive sampling points collected by the touch screen according to the writing operation; the processor 301 may be configured to call the response delay of the touch screen stored in the memory 302 The application program, executing the acquisition of touch point information in response to a writing operation on the touch screen, and acquiring the handwriting axis corresponding to the writing operation according to the touch point information, includes executing: obtaining a touch point connection according to two adjacent sampling points. line; obtain the handwriting axis corresponding to the writing operation according to the connection of the touch points. The touch point connection line is obtained by connecting two adjacent sampling points, thereby realizing the quick and accurate acquisition of the handwriting axis.
在一些例子中,所述SDF纹理缓冲区包括横向纹理像素点数量和纵向纹理像素点数量;所述处理器301可以用于调用所述存储器302中存储的触摸屏的响应延时的应用程序,并执行以下操作:获取所述SDF纹理缓冲区的横向纹理像素点数量和纵向纹理像素点数量;根据所述横向纹理像素点数量和纵向纹理像素点数量,将所述目标缓冲区划分为对应数量的纹理网格;计算所述目标缓冲区中每个纹理网格的中心点到所述笔迹轴线的最短距离;将所述最 短距离确定为对应的所述SDF纹理缓冲区的纹理像素点的值,获得SDF纹理图像。通过将所述目标缓冲区划分为与所述SDF纹理缓冲区对应数量的纹理网格,进而计算每个纹理网格的中心点到所述笔迹轴线的最短距离,从而将所述最短距离确定为对应的所述SDF纹理图像的纹理像素点的值,进而可以充分保留高分辨率下的所述目标缓冲区的距离信息。所述SDF纹理图像中的纹理像素点中记录距离值而不是记录颜色值,从而对图像的压缩和拉伸等处理都不会太大影响显示效果。In some examples, the SDF texture buffer includes the number of horizontal texels and the number of vertical texels; the processor 301 may be configured to call the application program for the response delay of the touch screen stored in the memory 302, and Perform the following operations: obtain the number of horizontal texture pixels and the number of vertical texture pixels in the SDF texture buffer; divide the target buffer into a corresponding number of pixels according to the number of horizontal texture pixels and the number of vertical texture pixels texture grid; calculate the shortest distance from the center point of each texture grid in the target buffer to the handwriting axis; determine the shortest distance as the value of the texture pixel point of the corresponding SDF texture buffer, Get an SDF texture image. By dividing the target buffer into texture grids corresponding to the SDF texture buffer, and then calculating the shortest distance from the center point of each texture grid to the handwriting axis, the shortest distance is determined as The corresponding value of the texture pixel point of the SDF texture image, so that the distance information of the target buffer under high resolution can be fully preserved. The texel in the SDF texture image records the distance value instead of the color value, so that the image compression and stretching will not greatly affect the display effect.
在一个实施例中,所述处理器301可以执行基于双线性插值采样对所述渲染缓冲区进行渲染后获得书写笔迹,具体执行包括:对所述SDF纹理图像进行双线性插值采样,获得插值采样后的各纹理像素点到所述笔迹轴线的距离值;在所述渲染缓冲区中,将与所述笔迹轴线的距离值小于或等于预设渲染线宽的采样点进行颜色填充后,获得书写笔迹。结合双线性插值采样方法,将与所述笔迹轴线的距离值小于或等于预设渲染线宽的采样点进行颜色填充后,获得书写笔迹,可以提高渲染效率,同时可以防止出现边缘失真的问题。In one embodiment, the processor 301 may perform the rendering of the rendering buffer based on bilinear interpolation sampling to obtain writing handwriting, and the specific execution includes: performing bilinear interpolation sampling on the SDF texture image to obtain The distance value of each texel point after interpolation sampling to the handwriting axis; in the rendering buffer, after color filling the sampling point whose distance value from the handwriting axis is less than or equal to the preset rendering line width, Get handwriting. Combined with the bilinear interpolation sampling method, after color filling the sampling points whose distance value from the handwriting axis is less than or equal to the preset rendering line width, the handwriting is obtained, which can improve the rendering efficiency and prevent the problem of edge distortion. .
实施例4Example 4
本申请还提供一种计算机可读存储介质,其上储存有计算机程序,所述指令适于由处理器加载并执行上述所示实施例1的方法步骤,执行过程可以参见实施例1所示的说明,在此不进行赘述。所述存储介质所在设备可以是个人计算机、笔记本电脑、智能手机、平板电脑等电子设备。The present application also provides a computer-readable storage medium, on which a computer program is stored, the instructions are suitable for being loaded by a processor and executing the method steps of the above-mentioned Embodiment 1, and the execution process can refer to the method shown in the first embodiment. The description is not repeated here. The device where the storage medium is located may be an electronic device such as a personal computer, a notebook computer, a smart phone, and a tablet computer.
对于设备实施例而言,由于其基本对应于方法实施例,所以相关之处参见方法实施例的部分说明即可。以上所描述的设备实施例是示意性的,其中所述作为分离部件说明的组件可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本申请方案的目的。本领域普通技术人员在不付出创造性劳动的情况下,即可以理解并实施。For the device embodiments, since they basically correspond to the method embodiments, reference may be made to the partial descriptions of the method embodiments for related parts. The device embodiments described above are schematic, wherein the components described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in a local, or it can be distributed over multiple network elements. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of the present application. Those of ordinary skill in the art can understand and implement it without creative effort.
本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。As will be appreciated by those skilled in the art, the embodiments of the present application may be provided as a method, a system, or a computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一 个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中选定的功能的装置。这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中选定的功能。The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present application. It will be understood that each flow and/or block in the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to the processor of a general purpose computer, special purpose computer, embedded processor or other programmable data processing device to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing device produce Means for implementing the functions selected in one or more of the flowcharts and/or one or more blocks of the block diagrams. These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory result in an article of manufacture comprising instruction means, the instructions An apparatus implements the functions selected in one or more of the flowcharts and/or one or more blocks of the block diagrams.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中选定的功能的步骤。These computer program instructions can also be loaded on a computer or other programmable data processing device to cause a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process such that The instructions provide steps for implementing the functions selected in the flow or blocks of the flowcharts and/or the blocks or blocks of the block diagrams.
在一个可选的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。In an optional configuration, the computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
存储器可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。存储器是计算机可读介质的示例。Memory may include non-persistent memory in computer readable media, random access memory (RAM) and/or non-volatile memory in the form of, for example, read only memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。Computer-readable media includes both persistent and non-permanent, removable and non-removable media, and storage of information may be implemented by any method or technology. Information may be computer readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), Flash Memory or other memory technology, Compact Disc Read Only Memory (CD-ROM), Digital Versatile Disc (DVD) or other optical storage, Magnetic tape cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media, such as modulated data signals and carrier waves.
还需要说明的是,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、商品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、商品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括要素的过程、方法、商品或者设备中还存在另外的相同要素。It should also be noted that 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 comprising a series of elements includes not only those elements, but also Other elements not expressly listed, or which are inherent to such a process, method, article of manufacture, or apparatus are also included. Without further limitation, an element qualified by the phrase "comprising a..." does not preclude the presence of additional identical elements in the process, method, article of manufacture or apparatus that includes the element.
以上仅为本申请的实施例而已,并不用于限制本申请。对于本领域技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本申请的权利要求范围之内。The above are merely examples of the present application, and are not intended to limit the present application. Various modifications and variations of this application are possible for those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this application shall be included within the scope of the claims of this application.

Claims (11)

  1. 一种书写笔迹绘制方法,其中,包括如下步骤:A method for drawing handwriting, comprising the following steps:
    接收在触摸屏上的书写操作;Receive the writing operation on the touch screen;
    获取所述书写操作对应的触摸点信息,根据所述触摸点信息获取所述书写操作对应的笔迹轴线;acquiring touch point information corresponding to the writing operation, and acquiring the handwriting axis corresponding to the writing operation according to the touch point information;
    根据所述笔迹轴线的尺寸和预设的渲染线宽,确定目标缓冲区;Determine the target buffer according to the size of the handwriting axis and the preset rendering line width;
    根据预设的纹理分辨率对所述目标缓冲区进行压缩处理,获得SDF纹理缓冲区;Compress the target buffer according to the preset texture resolution to obtain an SDF texture buffer;
    计算所述目标缓冲区中与所述SDF纹理缓冲区的每个纹理像素点对应的位置到所述笔迹轴线的最短距离,并将所述最短距离确定为对应的所述SDF纹理缓冲区的纹理像素点的值,获得SDF纹理图像;Calculate the shortest distance from the position corresponding to each texel point of the SDF texture buffer in the target buffer to the handwriting axis, and determine the shortest distance as the texture of the corresponding SDF texture buffer The value of the pixel point to obtain the SDF texture image;
    根据所述目标缓冲区分配渲染缓冲区,建立所述渲染缓冲区与所述SDF纹理图像的映射关系;Allocate a rendering buffer according to the target buffer, and establish a mapping relationship between the rendering buffer and the SDF texture image;
    基于双线性插值采样对所述渲染缓冲区进行渲染后获得书写笔迹;The handwriting is obtained after rendering the rendering buffer based on bilinear interpolation sampling;
    在所述触摸屏上显示所述书写笔迹。The handwriting is displayed on the touch screen.
  2. 根据权利要求1所述的书写笔迹绘制方法,其中,The method for drawing handwriting according to claim 1, wherein,
    所述基于双线性插值采样对所述渲染缓冲区进行渲染后获得书写笔迹,包括:The handwriting obtained after rendering the rendering buffer based on bilinear interpolation sampling includes:
    对所述SDF纹理图像进行双线性插值采样,获得插值采样后的各纹理像素点到所述笔迹轴线的距离值;Perform bilinear interpolation sampling on the SDF texture image, and obtain the distance value from each texture pixel point after the interpolation sampling to the handwriting axis;
    在所述渲染缓冲区中,将与所述笔迹轴线的距离值小于或等于预设渲染线宽的采样点进行颜色填充后,获得书写笔迹。In the rendering buffer, the handwriting is obtained after color-filling sampling points whose distance value from the handwriting axis is less than or equal to the preset rendering line width.
  3. 根据权利要求1所述的书写笔迹绘制方法,其中,The method for drawing handwriting according to claim 1, wherein,
    所述SDF纹理缓冲区包括横向纹理像素点数量和纵向纹理像素点数量;The SDF texture buffer includes the number of horizontal texture pixels and the number of vertical texture pixels;
    所述计算所述目标缓冲区中与所述SDF纹理缓冲区的每个纹理像素点对应的位置到所述笔迹轴线的最短距离,并将所述最短距离确定为对应的所述SDF纹理缓冲区的纹理像素点的值,获得SDF纹理图像,包括:calculating the shortest distance from the position corresponding to each texel point of the SDF texture buffer in the target buffer to the handwriting axis, and determining the shortest distance as the corresponding SDF texture buffer The value of the texel point to obtain the SDF texture image, including:
    获取所述SDF纹理缓冲区的横向纹理像素点数量和纵向纹理像素点数量;Obtain the number of horizontal texels and the number of vertical texels of the SDF texture buffer;
    根据所述横向纹理像素点数量和纵向纹理像素点数量,将所述目标缓冲区划分为对应数量的纹理网格;Divide the target buffer into a corresponding number of texture grids according to the number of horizontal texels and the number of vertical texels;
    计算所述目标缓冲区中每个纹理网格的中心点到所述笔迹轴线的最短距离;Calculate the shortest distance from the center point of each texture grid in the target buffer to the handwriting axis;
    将所述最短距离确定为对应的所述SDF纹理缓冲区的纹理像素点的值,获得SDF纹理图 像。The shortest distance is determined as the value of the texture pixel point of the corresponding SDF texture buffer to obtain an SDF texture image.
  4. 根据权利要求1所述的书写笔迹绘制方法,其中,The method for drawing handwriting according to claim 1, wherein,
    所述纹理分辨率小于所述目标缓冲区的分辨率。The texture resolution is less than the resolution of the target buffer.
  5. 根据权利要求1所述的书写笔迹绘制方法,其中,The method for drawing handwriting according to claim 1, wherein,
    所述笔迹轴线的尺寸包括所述笔迹轴线的横向长度和所述笔迹轴线的纵向长度;The size of the handwriting axis includes the lateral length of the handwriting axis and the longitudinal length of the handwriting axis;
    所述根据所述笔迹轴线的尺寸和预设的渲染线宽,确定目标缓冲区,包括:The determining of the target buffer according to the size of the handwriting axis and the preset rendering line width includes:
    将所述笔迹轴线的横向长度加上预设的渲染线宽、将所述笔迹轴线的纵向长度加上预设的渲染线宽,获得目标缓冲区。The target buffer is obtained by adding the horizontal length of the handwriting axis to the preset rendering line width, and adding the vertical length of the handwriting axis to the preset rendering line width.
  6. 根据权利要求1所述的书写笔迹绘制方法,其中,The method for drawing handwriting according to claim 1, wherein,
    所述触摸点信息为所述触摸屏根据所述书写操作采集的多个连续的采样点;The touch point information is a plurality of continuous sampling points collected by the touch screen according to the writing operation;
    所述响应于触摸屏上的书写操作获得触摸点信息,根据所述触摸点信息获取所述书写操作对应的笔迹轴线,包括:The obtaining touch point information in response to a writing operation on the touch screen, and obtaining the handwriting axis corresponding to the writing operation according to the touch point information, includes:
    根据相邻的两个所述采样点,得到触摸点连线;According to the two adjacent sampling points, the touch point connection line is obtained;
    根据所述触摸点连线,获得所述书写操作对应的笔迹轴线。According to the touch point connection, the handwriting axis corresponding to the writing operation is obtained.
  7. 一种书写笔迹绘制装置,其中,包括:A writing and handwriting drawing device, comprising:
    书写操作接收模块,用于接收在触摸屏上的书写操作;The writing operation receiving module is used for receiving the writing operation on the touch screen;
    笔迹轴线获取模块,用于获取所述书写操作对应的触摸点信息,根据所述触摸点信息获取所述书写操作对应的笔迹轴线;a handwriting axis acquisition module, configured to acquire touch point information corresponding to the writing operation, and acquire the handwriting axis corresponding to the writing operation according to the touch point information;
    目标缓冲区确定模块,用于根据所述笔迹轴线的尺寸和预设的渲染线宽,确定目标缓冲区;a target buffer determining module, configured to determine a target buffer according to the size of the handwriting axis and a preset rendering line width;
    纹理缓冲区获取模块,用于根据预设的纹理分辨率对所述目标缓冲区进行压缩处理,获得SDF纹理缓冲区;a texture buffer acquisition module, configured to compress the target buffer according to a preset texture resolution to obtain an SDF texture buffer;
    纹理图像获取模块,用于计算所述目标缓冲区中与所述SDF纹理缓冲区的每个纹理像素点对应的位置到所述笔迹轴线的最短距离,并将所述最短距离确定为对应的所述SDF纹理缓冲区的纹理像素点的值,获得SDF纹理图像;The texture image acquisition module is used to calculate the shortest distance from the position corresponding to each texel point of the SDF texture buffer in the target buffer to the handwriting axis, and determine the shortest distance as the corresponding The value of the texture pixel point of the SDF texture buffer is described to obtain the SDF texture image;
    映射关系获取模块,用于根据所述目标缓冲区分配渲染缓冲区,建立所述渲染缓冲区与所述SDF纹理图像的映射关系;a mapping relationship acquisition module, configured to allocate a rendering buffer according to the target buffer, and establish a mapping relationship between the rendering buffer and the SDF texture image;
    书写笔迹获取模块,用于基于双线性插值采样对所述渲染缓冲区进行渲染后获得书写笔迹;a writing handwriting acquisition module, used for obtaining writing handwriting after rendering the rendering buffer based on bilinear interpolation sampling;
    笔迹显示模块,用于在所述触摸屏上显示所述书写笔迹。The handwriting display module is used for displaying the writing handwriting on the touch screen.
  8. 根据权利要求7所述的书写笔迹绘制装置,其中,The writing and handwriting drawing device according to claim 7, wherein,
    所述SDF纹理缓冲区包括横向纹理像素点数量和纵向纹理像素点数量;The SDF texture buffer includes the number of horizontal texture pixels and the number of vertical texture pixels;
    所述纹理图像获取模块,包括:The texture image acquisition module includes:
    像素点数量获取模块,用于获取所述SDF纹理缓冲区的横向纹理像素点数量和纵向纹理像素点数量;a pixel number acquisition module, used to acquire the horizontal texture pixel number and the vertical texture pixel number of the SDF texture buffer;
    纹理网格划分模块,用于根据所述横向纹理像素点数量和纵向纹理像素点数量,将所述目标缓冲区划分为对应数量的纹理网格;a texture grid dividing module, configured to divide the target buffer into a corresponding number of texture grids according to the number of horizontal texels and the number of vertical texels;
    距离计算模块,用于计算所述目标缓冲区中每个纹理网格的中心点到所述笔迹轴线的最短距离;A distance calculation module for calculating the shortest distance from the center point of each texture grid in the target buffer to the handwriting axis;
    像素值确定模块,用于将所述最短距离确定为对应的所述SDF纹理缓冲区的纹理像素点的值,获得SDF纹理图像。A pixel value determination module, configured to determine the shortest distance as the value of the corresponding texture pixel point of the SDF texture buffer to obtain an SDF texture image.
  9. 根据权利要求7所述的书写笔迹绘制装置,其中,The writing and handwriting drawing device according to claim 7, wherein,
    所述纹理分辨率小于所述目标缓冲区的分辨率。The texture resolution is less than the resolution of the target buffer.
  10. 一种交互平板,包括触摸屏、处理器和存储器;其中,所述存储器存储有计算机程序,所述计算机程序适于由所述处理器加载并执行如权利要求1至6中任意一项所述的书写笔迹绘制方法。An interactive tablet comprising a touch screen, a processor and a memory; wherein the memory stores a computer program, the computer program is adapted to be loaded by the processor and execute the method according to any one of claims 1 to 6 How to draw handwriting.
  11. 一种计算机可读存储介质,其上储存有计算机程序,其中,该计算机程序被处理器执行时实现如权利要求1至6中任意一项所述的书写笔迹绘制方法。A computer-readable storage medium on which a computer program is stored, wherein, when the computer program is executed by a processor, the method for drawing handwriting according to any one of claims 1 to 6 is implemented.
PCT/CN2022/077604 2021-02-25 2022-02-24 Handwriting drawing method, apparatus, medium, and interactive tablet WO2022179544A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110209969.XA CN114972558A (en) 2021-02-25 2021-02-25 Handwriting drawing method, device, medium and interactive panel
CN202110209969.X 2021-02-25

Publications (1)

Publication Number Publication Date
WO2022179544A1 true WO2022179544A1 (en) 2022-09-01

Family

ID=82974195

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/077604 WO2022179544A1 (en) 2021-02-25 2022-02-24 Handwriting drawing method, apparatus, medium, and interactive tablet

Country Status (2)

Country Link
CN (1) CN114972558A (en)
WO (1) WO2022179544A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117333637B (en) * 2023-12-01 2024-03-08 北京渲光科技有限公司 Modeling and rendering method, device and equipment for three-dimensional scene

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104731390A (en) * 2013-12-18 2015-06-24 深圳富泰宏精密工业有限公司 System and method for saving original handwriting
CN108564639A (en) * 2018-04-27 2018-09-21 广州视源电子科技股份有限公司 Person's handwriting store method, device, intelligent interaction device and readable storage medium storing program for executing
US20200279415A1 (en) * 2019-02-28 2020-09-03 Monotype Imaging Inc. Efficiently Computed Distance Fields
US20200320779A1 (en) * 2017-08-28 2020-10-08 Will Dobbie System and method for rendering a graphical shape

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104731390A (en) * 2013-12-18 2015-06-24 深圳富泰宏精密工业有限公司 System and method for saving original handwriting
US20200320779A1 (en) * 2017-08-28 2020-10-08 Will Dobbie System and method for rendering a graphical shape
CN108564639A (en) * 2018-04-27 2018-09-21 广州视源电子科技股份有限公司 Person's handwriting store method, device, intelligent interaction device and readable storage medium storing program for executing
US20200279415A1 (en) * 2019-02-28 2020-09-03 Monotype Imaging Inc. Efficiently Computed Distance Fields

Also Published As

Publication number Publication date
CN114972558A (en) 2022-08-30

Similar Documents

Publication Publication Date Title
Akinci et al. Parallel surface reconstruction for particle‐based fluids
TWI637355B (en) Methods of compressing a texture image and image data processing system and methods of generating a 360-degree panoramic video thereof
US9558586B2 (en) Method for estimating the opacity level in a scene and corresponding device
US7483035B2 (en) Texture cache control using a data dependent slot selection scheme
CN107154063A (en) The shape method to set up and device in image shows region
WO2016107461A1 (en) Application icon generation method and apparatus, and mobile device
US11062499B2 (en) Distance-field texture interpolation optimizations
US10592242B2 (en) Systems and methods for rendering vector data on static and dynamic-surfaces using screen space decals and a depth texture
JP2006120158A (en) Method for hardware accelerated anti-aliasing in three-dimension
WO2019085906A1 (en) Exposure calculation method and device, terminal, and readable storage medium
CN105913481B (en) Shadow rendering apparatus and control method thereof
US8854392B2 (en) Circular scratch shader
WO2022179544A1 (en) Handwriting drawing method, apparatus, medium, and interactive tablet
WO2020199616A1 (en) Line segment attraction method, apparatus, device, and storage medium
WO2019169699A1 (en) House model rendering method and apparatus, terminal device, and medium
KR102282189B1 (en) Mipmap Generation Method and apparatus
KR20170036419A (en) Graphics processing apparatus and method for determining LOD (level of detail) for texturing of graphics pipeline thereof
US6346939B1 (en) View dependent layer ordering method and system
WO2024051756A1 (en) Special effect image drawing method and apparatus, device, and medium
US11645793B2 (en) Curve antialiasing based on curve-pixel intersection
CN112465692A (en) Image processing method, device, equipment and storage medium
CN117744187B (en) CAD drawing method, device, computer equipment and storage medium
CN113538623B (en) Method, device, electronic equipment and storage medium for determining target image
US11288788B2 (en) Anti-aliasing for distance field graphics rendering
WO2023202367A1 (en) Graphics processing unit, system, apparatus, device, and method

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: 22758908

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE