Writing handwriting drawing method, device, medium and interactive tablet
By calculating the shortest distance of the handwriting axis on the interactive tablet and generating SDF texture images, combining bilinear interpolation sampling and rendering buffer mapping relationship, the problem of low rendering efficiency of handwriting writing on the interactive tablet is solved, achieving efficient rendering and clear edges the handwriting of the writing.
Patent Information
- Application Number
- CN202110209969.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-25
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2041-02-25
AI Technical Summary
After writing a large amount of handwriting on the interactive tablet, the rendering efficiency is low and the writing handwriting cannot be drawn in time and effectively.
By responsive to writing operations on the touch screen, the shortest distance of the handwriting axis is calculated, the SDF texture image is generated, and the rendering is rendered through bilinear interpolation sampling and rendering buffer mapping relationship, filling the color to the preset rendering line width, realizing Efficient rendering of writing handwriting.
Improve rendering efficiency, can display writing handwriting in a timely and effective manner, reduce rendering overhead, and avoid edge distortion problems.
Smart Images

Figure CN114972558B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of interactive tablet counting, and in particular to a writing handwriting drawing method, device, medium and interactive tablet. Background Art
[0002] In the field of interactive tablets, the handwriting function, as one of the increasingly important functions of interactive smart tablets, has been widely used in people's work and study, greatly improving people's work and learning results. For example, in a teaching scenario, a teacher can write handwriting on the current interactive tablet, and students can see the handwriting of the teacher through the interactive tablet. In the process of realizing the present invention, the inventor found that there are at least the following problems in the traditional technology: after a large amount of handwriting is done on the interactive tablet, the rendering efficiency is low, and the handwriting cannot be drawn in a timely and effective manner. Summary of the invention
[0003] In order to overcome the problems existing in the related art, the present application provides a handwriting drawing method, device, medium and interactive tablet, which have the advantages of improving rendering efficiency and being able to display handwriting in a timely and effective manner.
[0004] According to a first aspect of an embodiment of the present application, a method for drawing handwriting is provided, comprising the following steps:
[0005] Acquire touch point information in response to a writing operation on the touch screen, and acquire a handwriting axis corresponding to the writing operation according to the touch point information;
[0006] Determining a target buffer according to the size of the handwriting axis and a preset rendering line width;
[0007] Compressing the target buffer according to a preset texture resolution to obtain an SDF texture buffer;
[0008] Calculate the shortest distance from the position corresponding to each texture pixel point of the SDF texture buffer in the target buffer to the handwriting axis, and determine the shortest distance as the value of the texture pixel point of the corresponding SDF texture buffer to obtain an SDF texture image;
[0009] Allocating a rendering buffer according to the target buffer, and establishing a mapping relationship between the rendering buffer and the SDF texture image;
[0010] Rendering the rendering buffer, performing bilinear interpolation sampling on the SDF texture image, obtaining the distance value from each texture pixel point to the handwriting axis after interpolation sampling, filling the rendering buffer with color to the corresponding point whose distance value from the handwriting axis is less than or equal to the preset rendering line width, and obtaining the writing handwriting;
[0011] The written handwriting is displayed on the touch screen.
[0012] According to a second aspect of an embodiment of the present application, there is provided a handwriting drawing device, comprising:
[0013] A handwriting axis acquisition module, used to obtain touch point information in response to a writing operation on the touch screen, and to obtain a handwriting axis corresponding to the writing operation according to the touch point information;
[0014] A target buffer determination module, used for determining a target buffer according to the size of the handwriting axis and a preset rendering line width;
[0015] A texture buffer acquisition module, used for compressing the target buffer according to a preset texture resolution to obtain an SDF texture buffer;
[0016] A texture image acquisition module, used for calculating the shortest distance from the position corresponding to each texture pixel point of the SDF texture buffer in the target buffer to the handwriting axis, and determining the shortest distance as the value of the texture pixel point of the corresponding SDF texture buffer to obtain an SDF texture image;
[0017] Establishing a mapping module, used for allocating a rendering buffer according to the target buffer, and establishing a mapping relationship between the rendering buffer and the SDF texture image;
[0018] A writing handwriting acquisition module is used to render the rendering buffer, perform bilinear interpolation sampling on the SDF texture image, obtain the distance value from each texture pixel point to the handwriting axis after interpolation sampling, fill the rendering buffer with color to the corresponding point whose distance value from the handwriting axis is less than or equal to the preset rendering line width, and obtain the writing handwriting;
[0019] The display module is used to display the writing handwriting on the touch screen.
[0020] According to a third aspect of an embodiment of the present application, an interactive tablet is provided, comprising a touch screen, a processor and a memory; the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the handwriting handwriting drawing method as described above.
[0021] According to a fourth aspect of an embodiment of the present application, there is provided a computer-readable storage medium on which a computer program is stored, wherein the computer program, when executed by a processor, implements the handwriting handwriting drawing method as described above.
[0022] The embodiment of the present application compresses the target buffer according to the preset texture resolution to obtain the SDF texture buffer; calculates the shortest distance from the position corresponding to each texture pixel point of the SDF texture buffer in the target buffer to the handwriting axis, and determines the shortest distance as the value of the texture pixel point of the corresponding SDF texture buffer to obtain the SDF texture image; performs bilinear interpolation sampling on the SDF texture image to obtain the distance value from each texture pixel point to the handwriting axis after interpolation sampling, and renders the rendering buffer according to the mapping relationship between the rendering buffer and the SDF texture image, fills the color to the corresponding point whose distance value from the handwriting axis is less than or equal to the preset rendering line width, and displays the handwriting on the touch screen, and then only needs to render two triangles through the SDF texture image, the rendering overhead is small, and the rendering efficiency is improved, and the handwriting can be displayed in a timely and effective manner. Furthermore, when the handwriting remains unchanged and handwriting of different widths needs to be rendered, only one preprocessing is required to generate the SDF texture image, and the handwriting of different widths is subsequently directly rendered and displayed through the same SDF texture image. Furthermore, since the SDF texture of the present application describes distance information rather than color information, and is combined with a bilinear interpolation sampling method, it is not easy to cause edge distortion problems when a large-resolution handwriting is drawn using a small-resolution SDF texture image.
[0023] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application.
[0024] For better understanding and implementation, the present invention is described in detail below with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0026] Figure 1 A schematic diagram of handwriting that needs to be drawn in one embodiment of the present application;
[0027] Figure 2 A schematic diagram of triangulating handwriting in some techniques of this application;
[0028] Figure 3 This is an effect diagram of rendering handwriting in some technologies of this application;
[0029] Figure 4A flowchart of a handwriting drawing method shown in one embodiment of the present application;
[0030] Figure 5 A schematic diagram of determining a handwriting axis according to an embodiment of the present application;
[0031] Figure 6 A schematic diagram of determining the shortest distance according to an embodiment of the present application;
[0032] Figure 7 This is an effect diagram of handwriting drawn according to an embodiment of the present application;
[0033] Figure 8 A flowchart of a method for determining an SDF texture image is shown as an embodiment of the present application;
[0034] Fig. 9 This is a rendering of handwriting drawn according to another embodiment of the present application;
[0035] Fig.10 A schematic block diagram of a handwriting drawing device according to an embodiment of the present application;
[0036] Fig.11 A schematic block diagram of a texture image acquisition module according to an embodiment of the present application;
[0037] Fig.12 This is a schematic diagram of the structure of an interactive tablet according to an embodiment of the present application. DETAILED DESCRIPTION
[0038] In order to make the objectives, technical solutions and advantages of the present application more clear, the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.
[0039] It should be clear that the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0040] When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Instead, they are only examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.
[0041] In the description of the present 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 order or sequence, nor can they be understood as indicating or implying relative importance. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood according to the specific circumstances. The singular forms of "a", "said", and "the" used in the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. The words "if" / "if" used herein can be interpreted as "at the time of" or "when" or "in response to determination". In addition, in the description of the present application, unless otherwise specified, "multiple" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships can exist, for example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship.
[0042] In order to better understand the technical solution of the present application, the following will explain some methods of drawing handwriting in the technology. It should be noted that the handwriting mentioned in the embodiment of the present application is a special kind of handwriting. Figure 1 Specifically, the starting point, the ending point and the corner of the handwriting are all in arc shape. Figure 2 and Figure 3 In some technologies, the method for drawing the handwriting is to obtain the handwriting axis of the writing operation based on the touch information of the writing operation; then, according to the preset handwriting width, color and other attributes, construct the polygonal mesh outline that constitutes the handwriting; then, perform triangulation within the polygonal mesh outline, and finally render all the triangles within the polygonal mesh outline to obtain the handwriting. In the process of implementing the present invention, the inventors found that some technologies have at least the following problems: Since the number of triangles corresponding to a handwriting is already large, once the number of handwriting increases, the data of the triangle will become very large, thereby reducing the efficiency of rendering and displaying the handwriting. Moreover, even if there is a slight change in the handwriting, the polygonal mesh outline needs to be regenerated, and then the regenerated triangles within the polygonal outline need to be rendered, which increases the complexity and further reduces the rendering efficiency. To this end, the present application proposes a method for drawing handwriting.
[0043] The handwriting handwriting drawing method shown in the embodiment of the present application can be executed by a handwriting handwriting drawing device, which can be implemented by software and / or hardware, and can be composed of two or more physical entities, or can be composed of one physical entity. For example, the handwriting handwriting drawing device can be a computer, a mobile phone, a tablet, or an intelligent interactive tablet or other intelligent device.
[0044] For ease of understanding, the embodiments are described by taking an interactive tablet as a writing handwriting drawing device. 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, and integrates one or more functions such as a projector, an electronic whiteboard, a screen, a sound system, a television, and a video conferencing terminal.
[0045] Generally speaking, the 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 implement the touch operation by touching the display screen with a finger or a stylus. Accordingly, the interactive tablet detects the touch position, and determines the response scheme according to the touch operation corresponding to the touch position, and then responds to implement the touch function. For example, the corresponding touch operation is determined to be writing handwriting according to the touch position. At this time, the response scheme is to display handwriting. Typically, the interactive tablet is installed with at least one type of operating system, wherein the operating system includes but is not limited to Android system, Linux system and Windows system. In one embodiment, the interactive tablet can install at least one application based on the operating system. In the embodiment, an application with a writing function is described exemplarily. For example, an electronic whiteboard application with a writing function is installed in the interactive tablet. Among them, the application can be an application that comes with the operating system, or it can be an application downloaded from a third-party device or server, and the interactive tablet can also be the application itself. Optionally, in addition to the writing function, the application also has other editing functions, such as writing, inserting tables, inserting pictures, inserting multimedia, inserting graphics, drawing tables and the like.
[0046] Example 1
[0047] The handwriting drawing method disclosed in the embodiment of the present application is applied to an electronic device, and the electronic device is described below as an interactive tablet.
[0048] The following will be combined with the attached Figures 4 to 9 , the handwriting drawing method provided in the embodiment of the present application is introduced in detail.
[0049] See also Figure 4 The handwriting drawing method provided in the embodiment of the present application comprises the following steps:
[0050] Step S110: obtaining touch point information in response to a writing operation on the touch screen, and obtaining a handwriting axis corresponding to the writing operation according to the touch point information.
[0051] See also Figure 5In some examples, by opening an electronic whiteboard on a touch screen to display a writing interface, when touching and writing on the writing interface with a hand or a touch pen or other writing tool, touch point information can be obtained, and the handwriting axis corresponding to the writing operation can be obtained based on the touch point information.
[0052] Step S120: determining a target buffer according to the size of the handwriting axis and a preset rendering line width.
[0053] 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 starting point of the handwriting axis and the end point of the handwriting axis, and 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, which can be set as needed. The buffer is a part of the memory space, that is, a storage space of a specified size is reserved in the memory space for temporary storage of input or output data. This reserved space is called a buffer. The purpose is to reduce the number of data reads and improve data processing efficiency. In the embodiment of the present application, the target buffer is data temporarily stored for determining the rendering buffer and the SDF texture buffer.
[0054] In some examples, determining the target buffer according to the size of the handwriting axis and the preset rendering line width includes: adding the preset rendering line width to the horizontal length of the handwriting axis and adding the preset rendering line width to the vertical length of the handwriting axis to obtain the target buffer. By adding the preset rendering line width to the horizontal length of the handwriting axis and adding the preset rendering line width to the vertical length of the handwriting axis to obtain the target buffer, the handwriting can be rendered and displayed completely without obstruction during rendering.
[0055] Step S130: compressing the target buffer according to a preset texture resolution to obtain an SDF texture buffer.
[0056] Among them, SDF (signed distance field) is a distance stored for each pixel value. In some examples, the preset texture resolution can be a texture resolution determined by a preset compression coefficient. For example, for the target buffer with a resolution of 1600x512, if the preset compression coefficient is 32, the target buffer is compressed according to a scaling factor of 32 to obtain an SDF texture buffer. At this time, the texture resolution of the SDF texture buffer is 50x16. 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 1600x512, if the preset texture resolution is 50x16, the compression coefficient can be calculated to be 32, and then the target buffer is compressed to obtain an SDF texture buffer with a texture resolution of 50x16.
[0057] Step S140: Calculate the shortest distance from the position corresponding to each texture pixel point of the SDF texture buffer in the target buffer to the handwriting axis, and determine the shortest distance as the value of the texture pixel point of the corresponding SDF texture buffer to obtain an SDF texture image.
[0058] See also Figure 6 , calculating the shortest distance from the position corresponding to each texture pixel point in the SDF texture buffer in the target buffer to the handwriting axis includes: traversing the distance between each point of the handwriting axis and the position corresponding to each texture pixel point in the SDF texture buffer in the target buffer, and selecting the value with the smallest distance to determine as the shortest distance.
[0059] Step S150: allocating a rendering buffer according to the target buffer, and establishing a mapping relationship between the rendering buffer and the SDF texture image.
[0060] In some examples, the target buffer has the same resolution as the rendering buffer, that is, a rendering buffer having the same resolution as the target buffer is allocated according to the resolution of the target buffer.
[0061] Step S160: Render the rendering buffer, perform bilinear interpolation sampling on the SDF texture image, obtain the distance value from each texture pixel point to the handwriting axis after interpolation sampling, fill the rendering buffer with color to the corresponding point whose distance value from the handwriting axis is less than or equal to the preset rendering line width, and obtain the writing handwriting.
[0062] It should be noted that the handwriting mentioned in the embodiment of the present application is a special kind of handwriting, specifically, the starting endpoint, ending endpoint and corner of the handwriting are all in the shape of arcs, that is, the inventor discovered in the process of implementing the present invention that for such 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 handwriting width. To this end, the present application fills the rendering buffer with color to the corresponding point whose distance value from the axis of the handwriting is less than or equal to the preset rendering line width, and the handwriting obtained is the handwriting whose starting endpoint, ending endpoint and corner are all in the shape of arcs.
[0063] See also Figure 7 In some examples, the SDF texture image is a rectangular image, so the rendering buffer is also a rectangle. When rendering, it is usually rendered in units of triangles. Therefore, the rendering buffer is also constructed as a rectangle composed of two triangles for rendering. Specifically, when rendering the rendering buffer, the rendering buffer is determined by reading the vertices of the two triangles, and the SDF texture image is bilinearly interpolated and sampled to obtain the distance value from each texture pixel point to the handwriting axis after the interpolation sampling. Then, according to the mapping relationship between the rendering buffer and the SDF texture image, the rendering buffer is filled with color to the corresponding point whose distance value from the handwriting axis is less than or equal to the preset rendering line width, and the writing handwriting is obtained.
[0064] Step S170: Displaying the writing handwriting on the touch screen.
[0065] The embodiment of the present application compresses the target buffer according to the preset texture resolution to obtain the SDF texture buffer; calculates the shortest distance from the position corresponding to each texture pixel point of the SDF texture buffer in the target buffer to the handwriting axis, and determines the shortest distance as the value of the texture pixel point of the corresponding SDF texture buffer to obtain the SDF texture image; performs bilinear interpolation sampling on the SDF texture image to obtain the distance value from each texture pixel point to the handwriting axis after interpolation sampling, and renders the rendering buffer according to the mapping relationship between the rendering buffer and the SDF texture image, fills the color to the corresponding point whose distance value from the handwriting axis is less than or equal to the preset rendering line width, and displays the handwriting on the touch screen, and then only needs to render two triangles through the SDF texture image, the rendering overhead is small, and the rendering efficiency is improved, and the handwriting can be displayed in a timely and effective manner. Furthermore, when the handwriting remains unchanged and handwriting of different widths needs to be rendered, only one preprocessing is required to generate the SDF texture image, and the handwriting of different widths is subsequently directly rendered and displayed through the same SDF texture image. Furthermore, since the SDF texture of the present application describes distance information rather than color information, and is combined with a bilinear interpolation sampling method, it is not easy to cause edge distortion problems when a large-resolution handwriting is drawn using a small-resolution SDF texture image.
[0066] In some examples, in step S110, the touch point information is a plurality of continuous sampling points collected by the touch screen according to the writing operation; the step of obtaining the touch point information in response to the writing operation on the touch screen, and obtaining the handwriting axis corresponding to the writing operation according to the touch point information includes:
[0067] Step S111: obtaining a touch point connection line according to two adjacent sampling points;
[0068] Step S112: obtaining a handwriting axis corresponding to the writing operation according to the touch point connection line.
[0069] The touch point line is obtained by connecting two adjacent sampling points, thereby achieving quick and accurate acquisition of the handwriting axis.
[0070] See also Figure 8 In some examples, the SDF texture buffer includes a number of horizontal texture pixels and a number of vertical texture pixels. In step S140, the shortest distance from a 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 value of the texture pixel of the corresponding SDF texture buffer to obtain the SDF texture image, including:
[0071] Step S141: Obtain the number of horizontal texture pixel points and the number of vertical texture pixel points in the SDF texture buffer.
[0072] Step S142: Divide the target buffer into a corresponding number of texture grids according to the number of horizontal texture pixel points and the number of vertical texture pixel points.
[0073] 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 into the target buffer is 50 and the number of vertical texture grids is 16; 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 into the target buffer is 25 and the number of vertical texture grids is 8, the number of horizontal texture grids divided into the target buffer is 25 and the number of vertical texture grids is 8.
[0074] Step S143: Calculate the shortest distance from the center point of each texture grid in the target buffer to the handwriting axis.
[0075] Step S144: Determine the shortest distance as the value of the texture pixel point of the corresponding SDF texture buffer to obtain an SDF texture image.
[0076] By dividing the target buffer into texture grids corresponding to the number of 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 value of the texture pixel of the corresponding SDF texture image, so that the distance information of the target buffer at high resolution can be fully retained. Furthermore, the texture pixel in the SDF texture image records the distance value instead of the color value, so that the compression and stretching of the image will not greatly affect the display effect.
[0077] In some examples, the resolution of the SDF texture buffer, i.e., the preset texture resolution, may be inconsistent with the resolution of the target buffer, i.e., the resolution of the rendered display. When the resolution of the SDF texture buffer is lower, the efficiency of generating the SDF texture image is higher, but the precision is also lower, i.e., the generated handwriting is also blurred. When the resolution of the SDF texture buffer is higher, the efficiency of generating the SDF texture image is lower, but the precision is also higher, i.e., the generated handwriting is also clearer. In some examples, the resolution of the SDF texture buffer, i.e., the preset texture resolution, is smaller than the resolution of the target buffer, i.e., the resolution of the rendered display, to reduce the amount of calculation and improve rendering efficiency. Please refer to Figure 7 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 Fig. 9 , the target buffer also has a resolution of 1600x512. If the texture resolution of the SDF texture buffer is 25x8, the edge of the displayed handwriting will be a little distorted. However, since the SDF texture graphics of the present application store distance values and use bilinear interpolation, the displayed handwriting still has good accuracy. Therefore, 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, there is still a high rendering accuracy.
[0078] Example 2
[0079] The following is an embodiment of the device 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 embodiment of the device of the present application, please refer to the content of the method in Embodiment 1 of the present application.
[0080] See also Fig.10 , a writing handwriting drawing device 200 disclosed in an embodiment of the present application includes:
[0081] A handwriting axis acquisition module 210, for obtaining touch point information in response to a writing operation on the touch screen, and obtaining a handwriting axis corresponding to the writing operation according to the touch point information;
[0082] The target buffer determination module 220 is used to determine the target buffer according to the size of the handwriting axis and the preset rendering line width;
[0083] The texture buffer acquisition module 230 is used to compress the target buffer according to a preset texture resolution to obtain an SDF texture buffer;
[0084] The texture image acquisition module 240 is used to calculate the shortest distance from the position corresponding to each texture pixel point of the SDF texture buffer in the target buffer to the handwriting axis, and determine the shortest distance as the value of the texture pixel point of the corresponding SDF texture buffer to obtain the SDF texture image;
[0085] Establishing a mapping module 250, for allocating a rendering buffer according to the target buffer, and establishing a mapping relationship between the rendering buffer and the SDF texture image;
[0086] The writing handwriting acquisition module 260 is used to render the rendering buffer, perform bilinear interpolation sampling on the SDF texture image, obtain the distance value from each texture pixel point to the handwriting axis after interpolation sampling, fill the rendering buffer with color to the corresponding point whose distance value from the handwriting axis is less than or equal to the preset rendering line width, and obtain the writing handwriting;
[0087] The display module 270 is used to display the writing handwriting on the touch screen.
[0088] The embodiment of the present application compresses the target buffer according to the preset texture resolution to obtain the SDF texture buffer; calculates the shortest distance from the position corresponding to each texture pixel point of the SDF texture buffer in the target buffer to the handwriting axis, and determines the shortest distance as the value of the texture pixel point of the corresponding SDF texture buffer to obtain the SDF texture image; performs bilinear interpolation sampling on the SDF texture image to obtain the distance value from each texture pixel point to the handwriting axis after interpolation sampling, and renders the rendering buffer according to the mapping relationship between the rendering buffer and the SDF texture image, fills the color to the corresponding point whose distance value from the handwriting axis is less than or equal to the preset rendering line width, and displays the handwriting on the touch screen, and then only needs to render two triangles through the SDF texture image, the rendering overhead is small, and the rendering efficiency is improved, and the handwriting can be displayed in a timely and effective manner. Furthermore, when the handwriting remains unchanged and handwriting of different widths needs to be rendered, only one preprocessing is required to generate the SDF texture image, and the handwriting of different widths is subsequently directly rendered and displayed through the same SDF texture image. Furthermore, since the SDF texture of the present application describes distance information rather than color information, and is combined with a bilinear interpolation sampling method, it is not easy to cause edge distortion problems when a large-resolution handwriting is drawn using a small-resolution SDF texture image.
[0089] In some examples, the target buffer determination module 220 is used to determine the target buffer according to the size of the handwriting axis and the preset rendering line width, including: adding the preset rendering line width to the horizontal length of the handwriting axis and adding the preset rendering line width to the vertical length of the handwriting axis to obtain the target buffer. The target buffer is obtained by adding the preset rendering line width to the horizontal length of the handwriting axis and adding the preset rendering line width to the vertical length of the handwriting axis, so that the handwriting can be rendered and displayed without any obstruction during rendering.
[0090] In some examples, the touch point information is a plurality of continuous sampling points collected by the touch screen according to the writing operation; the handwriting axis acquisition module 210 is used to obtain the touch point information in response to the writing operation on the touch screen, and to obtain the handwriting axis corresponding to the writing operation according to the touch point information, including:
[0091] A touch point connection module (not shown in the figure), used to obtain a touch point connection according to two adjacent sampling points;
[0092] The handwriting axis determination module (not shown in the figure) is used to obtain the handwriting axis corresponding to the writing operation according to the touch point connection line.
[0093] The touch point line is obtained by connecting two adjacent sampling points, thereby achieving quick and accurate acquisition of the handwriting axis.
[0094] See also Fig.11 In some examples, the SDF texture buffer includes a horizontal texture pixel number and a vertical texture pixel number; the texture image acquisition module 240 includes:
[0095] The pixel number acquisition module 241 is used to acquire the horizontal texture pixel number and the vertical texture pixel number of the SDF texture buffer;
[0096] A texture grid division module 242, configured to divide the target buffer into a corresponding number of texture grids according to the number of horizontal texture pixels and the number of vertical texture pixels;
[0097] A distance calculation module 243, used for calculating the shortest distance from the center point of each texture grid in the target buffer to the handwriting axis;
[0098] The pixel value determination module 244 is used to determine the shortest distance as the value of the texture pixel point of the corresponding SDF texture buffer to obtain an SDF texture image.
[0099] By dividing the target buffer into texture grids corresponding to the number of 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 value of the texture pixel of the corresponding SDF texture image, so that the distance information of the target buffer at high resolution can be fully retained. Furthermore, the texture pixel in the SDF texture image records the distance value instead of the color value, so that the compression and stretching of the image will not greatly affect the display effect.
[0100] Example 3
[0101] The following is an embodiment of the device 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 embodiment of the device of the present application, please refer to the content of the method in Embodiment 1 of the present application.
[0102] See also Fig.12The present application also provides an electronic device, which can be any intelligent terminal including a touch screen, for example, a computer, a mobile phone, a tablet computer, an interactive tablet, etc. In the embodiment of the present application, the electronic device is an interactive tablet 300, especially an interactive tablet with a large-size 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, a user interface 305, and at least one communication bus 306.
[0103] Among them, the display 303 includes a display layer and a touch layer, the display layer is used to display the 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 touch operations or writing operations input by the user through fingers or input devices.
[0104] The user interface 305 is mainly used to provide an input interface for the user and obtain data input by the user. Optionally, the user interface 305 may also include a standard wired interface or a wireless interface.
[0105] The network interface 304 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).
[0106] The communication bus 306 is used to realize the connection and communication between these components.
[0107] Among them, 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 various functions and processes data of the interactive tablet 300 by running or executing instructions, programs, code sets or instruction sets stored in the memory 302, and calling data stored in the memory 302. Optionally, the processor 301 can be implemented in at least one hardware form 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). The processor 301 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed by the display layer; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 301, and can be implemented separately through a chip.
[0108] Among them, the memory 302 may include a random access memory (Random Access Memory, RAM) and may also include a read-only memory (Read-Only Memory). Optionally, the memory 302 includes a non-transitory computer-readable storage medium. The memory 302 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 302 may include a program storage area and a data storage area, wherein the program storage 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 for implementing the above-mentioned method embodiments, etc.; the data storage area may store data involved in the above-mentioned method embodiments, etc. The memory 302 may optionally be at least one storage device located away from the aforementioned processor 301. As Fig. 9 As shown, the memory 302 as a computer storage medium may include an operating system, a network communication module, and a user.
[0109] 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 specifically perform the following operations: obtain touch point information in response to a writing operation on the touch screen, and obtain 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; compress the target buffer according to the preset texture resolution to obtain an SDF texture buffer; calculate the shortest distance from the position corresponding to each texture pixel point of the SDF texture buffer in the target buffer to the handwriting axis, and determine the shortest distance as the value of the texture pixel point of the corresponding SDF texture buffer to obtain an SDF texture image; allocate a rendering buffer according to the target buffer, and establish a mapping relationship between the rendering buffer and the SDF texture image; render the rendering buffer, perform bilinear interpolation sampling on the SDF texture image, obtain the distance value of each texture pixel point after interpolation sampling to the handwriting axis, fill the rendering buffer with color to the corresponding point whose distance value to the handwriting axis is less than or equal to the preset rendering line width, and obtain the writing handwriting; display the writing handwriting on the touch screen.
[0110] The embodiment of the present application compresses the target buffer according to the preset texture resolution to obtain the SDF texture buffer; calculates the shortest distance from the position corresponding to each texture pixel point of the SDF texture buffer in the target buffer to the handwriting axis, and determines the shortest distance as the value of the texture pixel point of the corresponding SDF texture buffer to obtain the SDF texture image; performs bilinear interpolation sampling on the SDF texture image to obtain the distance value from each texture pixel point to the handwriting axis after interpolation sampling, and renders the rendering buffer according to the mapping relationship between the rendering buffer and the SDF texture image, fills the color to the corresponding point whose distance value from the handwriting axis is less than or equal to the preset rendering line width, and displays the handwriting on the touch screen, and then only needs to render two triangles through the SDF texture image, the rendering overhead is small, and the rendering efficiency is improved, and the handwriting can be displayed in a timely and effective manner. Furthermore, when the handwriting remains unchanged and handwriting of different widths needs to be rendered, only one preprocessing is required to generate the SDF texture image, and the handwriting of different widths is subsequently directly rendered and displayed through the same SDF texture image. Furthermore, since the SDF texture of the present application describes distance information rather than color information, and is combined with a bilinear interpolation sampling method, it is not easy to cause edge distortion problems when a large-resolution handwriting is drawn using a small-resolution SDF texture image.
[0111] In some examples, 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 when determining the target buffer according to the size of the handwriting axis and the preset rendering line width: adding the preset rendering line width to the horizontal length of the handwriting axis and adding the preset rendering line width to the vertical length of the handwriting axis to obtain the target buffer. The target buffer is obtained by adding the preset rendering line width to the horizontal length of the handwriting axis and adding the preset rendering line width to the vertical length of the handwriting axis, so that the handwriting can be rendered and displayed completely without occlusion during rendering.
[0112] In some examples, the touch point information is a plurality of continuous sampling points collected by the touch screen according to the writing operation; the processor 301 can be used to call the application program of the touch screen response delay stored in the memory 302, execute the acquisition of touch point information in response to the writing operation on the touch screen, and acquire the handwriting axis corresponding to the writing operation according to the touch point information, including: acquiring a touch point connection line according to two adjacent sampling points; acquiring the handwriting axis corresponding to the writing operation according to the touch point connection line. By connecting two adjacent sampling points to obtain the touch point connection line, the handwriting axis can be acquired quickly and accurately.
[0113] See also Fig.11 In some examples, the SDF texture buffer includes the number of horizontal texture pixels and the number of vertical texture pixels; 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: obtain the number of horizontal texture pixels and the number of vertical texture pixels of the SDF texture buffer; divide the target buffer into a corresponding number of texture grids according to the number of horizontal texture pixels and the number of vertical texture pixels; calculate the shortest distance from the center point of each texture grid in the target buffer to the axis of the handwriting; determine the shortest distance as the value of the texture pixel of the corresponding SDF texture buffer, and obtain the SDF texture image. By dividing the target buffer into a number of texture grids corresponding to the SDF texture buffer, and then calculating the shortest distance from the center point of each texture grid to the axis of the handwriting, the shortest distance is determined as the value of the texture pixel of the corresponding SDF texture image, and the distance information of the target buffer at high resolution can be fully retained. Furthermore, the texture pixel in the SDF texture image records the distance value instead of the color value, so that the compression and stretching of the image will not greatly affect the display effect.
[0114] Example 4
[0115] The present application also provides a computer-readable storage medium on which a computer program is stored, and the instructions are suitable for being loaded by a processor and executing the method steps of the above-mentioned embodiment 1. The specific execution process can refer to the specific description shown in embodiment 1, and will not be repeated here. The device where the storage medium is located can be a personal computer, a laptop computer, a smart phone, a tablet computer and other electronic devices.
[0116] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the components described as separate parts may or may not be physically separated, and the parts displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the present application scheme. Ordinary technicians in this field can understand and implement it without paying creative work.
[0117] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0118] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the function selected in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 function selected in a box or multiple boxes.
[0119] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 steps for the function selected in a box or multiple boxes.
[0120] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0121] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0122] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules 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 disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0123] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0124] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A method for drawing handwriting, characterized in that: The steps include: Acquire touch point information in response to a writing operation on the touch screen, and acquire a handwriting axis corresponding to the writing operation according to the touch point information; Determining a target buffer according to the size of the handwriting axis and a preset rendering line width; Compressing the target buffer according to a preset texture resolution to obtain an SDF texture buffer; Calculate the shortest distance from the position corresponding to each texture pixel point of the SDF texture buffer in the target buffer to the handwriting axis, and determine the shortest distance as the value of the texture pixel point of the corresponding SDF texture buffer to obtain an SDF texture image; Allocating a rendering buffer according to the target buffer, and establishing a mapping relationship between the rendering buffer and the SDF texture image; Rendering the rendering buffer, performing bilinear interpolation sampling on the SDF texture image, obtaining the distance value from each texture pixel point to the handwriting axis after interpolation sampling, filling the rendering buffer with color to the corresponding point whose distance value from the handwriting axis is less than or equal to the preset rendering line width, and obtaining the writing handwriting; The written handwriting is displayed on the touch screen.
2. The handwriting drawing method according to claim 1, characterized in that: The SDF texture buffer includes a horizontal texture pixel number and a vertical texture pixel number; The step of calculating the shortest distance from a position corresponding to each texture pixel point of the SDF texture buffer in the target buffer to the handwriting axis, and determining the shortest distance as the value of the texture pixel point of the corresponding SDF texture buffer to obtain the SDF texture image comprises: Obtaining the number of horizontal texture pixels and the number of vertical texture pixels of the SDF texture buffer; Dividing the target buffer into a corresponding number of texture grids according to the number of horizontal texture pixel points and the number of vertical texture pixel points; Calculate the shortest distance from the center point of each texture grid in the target buffer to the handwriting axis; 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.
3. The handwriting drawing method according to claim 1, characterized in that: The texture resolution is smaller than the resolution of the target buffer.
4. The handwriting drawing method according to claim 1, characterized in that: The size of the handwriting axis includes the horizontal length of the handwriting axis and the vertical length of the handwriting axis; Determining 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 preset rendering line width to the horizontal length of the handwriting axis and adding the preset rendering line width to the vertical length of the handwriting axis.
5. The handwriting drawing method according to claim 1, characterized in that: The touch point information is a plurality of continuous sampling points collected by the touch screen according to the writing operation; The step of obtaining touch point information in response to a writing operation on the touch screen, and obtaining a handwriting axis corresponding to the writing operation according to the touch point information, comprises: obtaining a touch point connection line according to two adjacent sampling points; According to the touch point connection line, a handwriting axis corresponding to the writing operation is obtained.
6. A writing handwriting drawing device, characterized in that: include: A handwriting axis acquisition module, used to obtain touch point information in response to a writing operation on the touch screen, and to obtain a handwriting axis corresponding to the writing operation according to the touch point information; A target buffer determination module, used for determining a target buffer according to the size of the handwriting axis and a preset rendering line width; A texture buffer acquisition module, used for compressing the target buffer according to a preset texture resolution to obtain an SDF texture buffer; A texture image acquisition module, used for calculating the shortest distance from the position corresponding to each texture pixel point of the SDF texture buffer in the target buffer to the handwriting axis, and determining the shortest distance as the value of the texture pixel point of the corresponding SDF texture buffer to obtain an SDF texture image; Establishing a mapping module, used for allocating a rendering buffer according to the target buffer, and establishing a mapping relationship between the rendering buffer and the SDF texture image; A writing handwriting acquisition module is used to render the rendering buffer, perform bilinear interpolation sampling on the SDF texture image, obtain the distance value from each texture pixel point to the handwriting axis after interpolation sampling, fill the rendering buffer with color to the corresponding point whose distance value from the handwriting axis is less than or equal to the preset rendering line width, and obtain the writing handwriting; The display module is used to display the writing handwriting on the touch screen.
7. The writing handwriting drawing device according to claim 6, characterized in that: The SDF texture buffer includes a horizontal texture pixel number and a vertical texture pixel number; The texture image acquisition module comprises: A pixel number acquisition module is used to acquire the horizontal texture pixel number and the vertical texture pixel number of the SDF texture buffer; A texture grid division module, used for dividing the target buffer into a corresponding number of texture grids according to the number of horizontal texture pixel points and the number of vertical texture pixel points; A distance calculation module, used for calculating the shortest distance from the center point of each texture grid in the target buffer to the handwriting axis; The pixel value determination module is used to determine the shortest distance as the value of the texture pixel point of the corresponding SDF texture buffer to obtain an SDF texture image.
8. The writing handwriting drawing device according to claim 6, characterized in that: The texture resolution is smaller than the resolution of the target buffer.
9. An interactive tablet, comprising a touch screen, a processor and a memory; characterized in that: The memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the handwriting drawing method according to any one of claims 1 to 5.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the handwriting handwriting drawing method as claimed in any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Handwriting saving method, device, intelligent interaction equipment and readable storage medium
CN108564639A
System and method for rendering a graphical shape
US20200320779A1