Pixel line drawing method and device, electronic equipment and storage medium
By performing anti-aliasing in the drawing matrix, the problem of serious jagging when drawing pixel lines in the drawing matrix is solved, and a smoother pixel line drawing effect is achieved.
Patent Information
- Application Number
- CN202411403739.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-09
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2044-10-09
AI Technical Summary
When drawing pixel lines using drawing matrix, the pixel lines generated have a severe jagged feeling, which affects the user's visual perception.
By obtaining the start coordinates, end coordinates and straight line equations of the pixel line to be drawn, multiple drawing points are determined, and anti-aliased pixel points in the preset area in the drawing matrix of N*M to ensure that the current drawing point and the previous one When the coordinates of a drawing point meet the preset conditions, save and set the corresponding pixel coordinates and pixel values.
It effectively reduces the jagged feeling of pixel lines obtained by drawing matrix drawing, and improves the user's visual experience.
Smart Images

Figure CN119478113A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image drawing, and in particular to a pixel line drawing method, device, electronic equipment and storage medium. Background Art
[0002] In some application scenarios, in order to quickly draw pixel lines, a drawing matrix is used to draw multiple pixels at one time, such as a 3*3 or 4*4 drawing matrix. Compared with drawing one pixel at a time, the drawing speed can be improved.
[0003] However, when drawing pixel lines using a drawing matrix, the drawn pixel lines have severe jaggedness, which affects the user's viewing experience. Summary of the invention
[0004] In view of the deficiencies in the prior art, the present application provides a pixel line drawing method, device, electronic device and storage medium, which are conducive to reducing the jagged feeling of the pixel line drawn by drawing the matrix.
[0005] To solve the above problems, the present invention provides the following technical solutions: In a first aspect, an embodiment of the present application provides a pixel line drawing method, the method comprising: Get the starting coordinates, ending coordinates and corresponding straight line equation of the pixel line to be drawn; Determine a plurality of drawing points according to the starting coordinates, the ending coordinates and the straight line equation; When the N*M drawing matrix moves to the current drawing point for drawing, anti-aliasing drawing is performed on the pixel points in the preset area in the N*M drawing matrix; wherein the N*M drawing matrix draws N*M pixel points each time, and N and M are both positive integers greater than one; and the current drawing point is one of the multiple drawing points; When the coordinates of the current drawing point and the coordinates of the previous drawing point meet the preset conditions, the pixel point coordinates and corresponding pixel values for anti-aliasing drawing saved when drawing the previous drawing point are determined; The pixel values of the pixel points with the same pixel point coordinates among the N*M pixel points are set to the saved pixel values based on the pixel point coordinates and pixel values for anti-aliasing drawing saved when drawing the last drawing point.
[0006] In some implementations, after performing anti-aliasing rendering on pixel points in a preset area in the N*M rendering matrix, the method further includes: Saves the pixel coordinates and corresponding pixel values of the pixel points for anti-aliasing drawing when drawing the current drawing point.
[0007] In some implementations, when the coordinates of the current drawing point and the coordinates of the previous drawing point meet a preset condition, determining the pixel point coordinates and corresponding pixel values for anti-aliasing drawing saved when drawing the previous drawing point includes: When the coordinates of the current drawing point and the coordinates of the previous drawing point meet the preset condition, calculating the number of times the drawing point continuously meets the preset condition; Determine the pixel coordinates and corresponding pixel values for anti-aliasing drawing saved when drawing the last X drawing points; wherein X is equal to the number minus one.
[0008] In some implementations, the step of setting the pixel value of the pixel point with the same pixel point coordinate among the N*M pixel points to the saved pixel value based on the pixel point coordinate and the pixel value for anti-aliasing drawing saved when drawing the last drawn point, includes: The pixel values of the pixel points with the same pixel point coordinates among the N*M pixel points are set to the saved pixel values based on the pixel point coordinates and corresponding pixel values for anti-aliasing drawing saved when drawing the previous X drawing points.
[0009] In some embodiments, the preset conditions include any one or more of the following: the number of drawing times is a preset number, the coordinates of the current drawing point and the coordinates of the previous drawing point on at least one coordinate axis are the same, and the coordinates of at least one pixel point in the N*M drawing matrix of the current drawing point are the coordinates of the pixel point in the previous drawing point that is anti-aliased.
[0010] In some implementations, determining a plurality of drawing points according to the starting coordinates, the ending coordinates, and the straight line equation includes: Calculate a first coordinate axis difference and a second coordinate axis difference according to the starting coordinate and the ending coordinate; Determine a forward coordinate axis according to the first coordinate axis difference and the second coordinate axis difference; Taking the starting coordinate as the starting point and the ending coordinate as the end point, a plurality of drawing points are obtained by advancing a preset distance along the advancing coordinate axis each time based on the straight line equation.
[0011] In some implementations, the step of advancing a preset distance along the advancing coordinate axis each time based on the straight line equation to obtain a plurality of plotted points includes: Based on the straight line equation, a plurality of initial drawing points are obtained by advancing a preset distance along the advancing coordinate axis each time; When the coordinates on the non-advanced coordinate axis of each of the initial drawing points have a decimal part, the coordinates on the non-advanced coordinate axis are rounded to obtain the multiple drawing points.
[0012] In some implementations, performing anti-aliasing rendering on pixel points in a preset area in the N*M rendering matrix includes: When there is a decimal part in the coordinates on the non-advanced coordinate axis before the current drawing point is rounded, determine the complement corresponding to the decimal; Performing anti-aliasing processing on pixel points in a first preset area among the N*M pixel points according to the decimal; Anti-aliasing processing is performed on pixel points in a second preset area among the N*M pixel points according to the complement.
[0013] In some embodiments, when the slope of the straight line equation is within a first preset range, the preset areas in the N*M drawing matrix include at least: a first preset area including a lower right pixel point and a second preset area including an upper left pixel point; When the slope of the straight line equation is within a second preset range, the preset areas in the N*M drawing matrix at least include: a first preset area including an upper right pixel point and a second preset area including a lower left pixel point.
[0014] In a second aspect, an embodiment of the present application provides a pixel line drawing device, the device comprising: An acquisition module is used to obtain the starting coordinates, the ending coordinates and the corresponding straight line equation of the pixel line to be drawn; A first determining module, used to determine a plurality of drawing points according to the starting coordinates, the ending coordinates and the straight line equation; A drawing module, configured to perform anti-aliasing drawing on pixel points in a preset area in an N*M drawing matrix when the N*M drawing matrix moves to a current drawing point for drawing; wherein the N*M drawing matrix draws N*M pixel points each time, and N and M are both positive integers greater than one; and the current drawing point is one of the multiple drawing points; A second determination module is used to determine the pixel point coordinates and corresponding pixel values for anti-aliasing drawing saved when drawing the previous drawing point when the coordinates of the current drawing point and the coordinates of the previous drawing point meet the preset conditions; The setting module is used to set the pixel value of the pixel point with the same pixel point coordinate among the N*M pixel points to the saved pixel value based on the pixel point coordinate and pixel value for anti-aliasing drawing saved when drawing the last drawing point.
[0015] In a third aspect, an embodiment of the present application provides an electronic device, including: at least one processor; and, a memory communicatively connected to at least one processor; wherein, The memory stores instructions executable by at least one processor, and the instructions are executed by at least one processor to enable the at least one processor to perform the pixel line drawing method of the first aspect.
[0016] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores an executable program, and the executable program is executed by a processor to implement the pixel line drawing method of the first aspect. In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the pixel line drawing method described in the first aspect.
[0017] The present application provides a pixel line drawing method, device, electronic device and storage medium, the method comprising: obtaining the starting coordinates, the ending coordinates and the corresponding straight line equation of the pixel line to be drawn; determining multiple drawing points according to the starting coordinates, the ending coordinates and the straight line equation; when the N*M drawing matrix moves to the current drawing point for drawing, anti-aliasing drawing is performed on the pixel points of the preset area in the N*M drawing matrix; wherein the N*M drawing matrix draws N*M pixel points each time, and N and M are both positive integers greater than one; the current drawing point is one of the multiple drawing points; when the coordinates of the current drawing point and the coordinates of the previous drawing point meet the preset conditions, the pixel point coordinates and corresponding pixel values for anti-aliasing drawing saved when drawing the previous drawing point are determined; based on the pixel point coordinates and pixel values for anti-aliasing drawing saved when drawing the previous drawing point, the pixel values of the pixel points with the same pixel point coordinates in the N*M pixel points are set to the saved pixel values. The present application can prevent the pixel values of the pixel points that have been anti-aliased from being overwritten by the subsequent drawing matrix, thereby losing the anti-aliasing effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 This is a schematic diagram of using a drawing matrix to draw pixel lines provided in an embodiment of the present application.
[0019] Figure 2 It is a flowchart of a first pixel line drawing method provided in an embodiment of the present application.
[0020] Figure 3 It is a schematic diagram of a drawing matrix provided in an embodiment of the present application.
[0021] Figure 4 This is a first schematic diagram of highlighting pixel points provided in an embodiment of the present application.
[0022] Figure 5 This is a second schematic diagram of highlighting pixels provided in an embodiment of the present application.
[0023] Figure 6 This is a first schematic diagram of pixel line drawing provided in an embodiment of the present application.
[0024] Figure 7 This is a second schematic diagram of pixel line drawing provided in an embodiment of the present application.
[0025] Figure 8 It is a flowchart of a second pixel line drawing method provided in an embodiment of the present application.
[0026] Fig. 9 This is a third schematic diagram of pixel line drawing provided in an embodiment of the present application.
[0027] Fig.10 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application.
[0028] Fig.11 It is a structural block diagram of a computer-readable storage medium provided in an embodiment of the present application. DETAILED DESCRIPTION
[0029] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0030] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0031] In order to solve the problem of severe aliasing when drawing a matrix in the prior art, the following method can be used for anti-aliasing processing.
[0032] See also Figure 1 , Figure 1 Schematic diagram of using a drawing matrix to draw pixel lines provided by an embodiment of the present application. Figure 1 As shown, when an N*M drawing matrix is used to draw pixel lines, the pixel values of all pixels are set to preset pixel values, and the drawn pixel lines are not smooth. For example, the upper left corner and the lower right corner of the drawing matrix will protrude from the continuous part, making the pixel lines severely jagged.
[0033] See also Figure 2 , Figure 2is a flow chart of the first pixel line drawing method provided in the embodiment of the present application. Figure 2 As shown, the pixel line drawing method 100 includes: steps 110 to 180.
[0034] Step 110: Obtain the starting coordinates, ending coordinates and corresponding straight line equation of the pixel line to be drawn.
[0035] In some implementations, a line of pixels to be drawn is drawn in a drawing area.
[0036] In some implementations, the pixel line to be drawn may be a pointer of a clock, an edge of a graphic, etc., and this application does not impose any limitation thereto.
[0037] In some embodiments, the pixel line may be a straight line, a curve, etc., which is not limited in the present application.
[0038] In a possible implementation manner, after the starting coordinates and the ending coordinates are acquired, the equation of the straight line can be calculated according to the starting coordinates and the ending coordinates.
[0039] In another possible implementation, the equation of the straight line can be directly obtained.
[0040] In some implementations, the drawing matrix includes N*M pixel points, and the start coordinate and the end coordinate may be the coordinates of any pixel point among the N*M pixel points.
[0041] For example, to draw the coordinates of the pixel point at the upper left corner in the matrix, the pixel point at the upper left corner in the matrix is moved to the starting coordinates during drawing.
[0042] For example, the starting coordinates (1,1) means that when drawing starts, the coordinates of the pixel point in the upper left corner of the drawing matrix are (1,1), and the coordinates of the remaining pixel points in the drawing matrix are not (1,1); the ending coordinates (2,3) means that when drawing ends, the coordinates of the pixel point in the upper left corner of the drawing matrix are (2,3), and the coordinates of the remaining points in the drawing matrix are not (2,3).
[0043] Step 120: Determine the forward coordinate axis when drawing the pixel line to be drawn according to the starting coordinate and the ending coordinate.
[0044] In some implementations, step 120 includes steps 121 to 123 .
[0045] Step 121: Calculate a first coordinate axis difference and a second coordinate axis difference according to the starting coordinate and the ending coordinate.
[0046] Step 122: When the first coordinate axis difference is greater than the second coordinate axis difference, the first coordinate axis is determined as the advancing coordinate axis when drawing the pixel line to be drawn.
[0047] Step 123: When the second coordinate axis difference is greater than the first coordinate axis difference, the second coordinate axis is determined as the advancing coordinate axis when drawing the pixel line to be drawn.
[0048] In some embodiments, the first coordinate axis difference is the absolute value of the first difference between the first coordinate axis coordinate of the starting coordinate and the first coordinate axis coordinate of the ending coordinate; the second coordinate axis difference is the absolute value of the second difference between the second coordinate axis coordinate of the starting coordinate and the second coordinate axis coordinate of the ending coordinate.
[0049] Further, the forward coordinate axis includes a positive first coordinate axis, a negative first coordinate axis, a positive second coordinate axis and a negative second coordinate axis, such as a positive X axis, a negative X axis, a positive Y axis and a negative Y axis.
[0050] At this time, step 122 includes: when the first coordinate axis difference is greater than the second coordinate axis difference, if the first difference is greater than zero, determining the positive first coordinate axis as the advancing coordinate axis when drawing the pixel line to be drawn; if the first difference is less than zero, determining the negative first coordinate axis as the advancing coordinate axis when drawing the pixel line to be drawn.
[0051] At this time, step 123 includes: when the second coordinate axis difference is greater than the first coordinate axis difference, if the second difference is greater than zero, determining the positive second coordinate axis as the advancing coordinate axis when drawing the pixel line to be drawn; if the second difference is less than zero, determining the negative second coordinate axis as the advancing coordinate axis when drawing the pixel line to be drawn.
[0052] Exemplarily, the starting coordinate is (1, 1) and the ending coordinate is (2, 3), then the difference of the first coordinate axis is 1, the difference of the second coordinate axis is 2, and the second difference 2 is greater than zero, and the forward coordinate axis is determined to be the positive Y axis.
[0053] Exemplarily, the starting coordinate is (1, 1) and the ending coordinate is (2, -1), then the first coordinate axis difference is 1, the second coordinate axis difference is 2, and the second difference is -2 which is less than zero, and the forward coordinate axis is determined to be the negative Y axis.
[0054] In this way, the forward coordinate axis of the pixel line to be drawn can be calculated. The forward coordinate axis reflects the main extension direction of the pixel line to be drawn. The effect of anti-aliasing processing based on the main extension direction is better than that based on the non-main extension direction.
[0055] Step 130: Control the N*M drawing matrix to move to the starting coordinate to draw pixel points; wherein the N*M drawing matrix draws N*M pixel points each time, and N and M are both positive integers greater than one.
[0056] Step 140: Calculate the coordinates of the N*M drawing matrix on the non-advancing coordinate axis after the N*M drawing matrix advances a preset distance along the advancing coordinate axis according to the straight line equation.
[0057] In some implementations, the preset distance is set to 1 or 2 or even more, which is not limited in this application.
[0058] For example, the starting coordinates are defined as (1,1) and the ending coordinates are defined as (2,3). At this time, the advancing coordinate axis is the positive Y axis, and the equation of the line is y=2x-1. After the drawing matrix is moved along the positive direction of the Y axis by a distance of 1, Y is equal to 2. According to the equation of the line, the coordinate of the non-advancing coordinate axis, that is, the X axis, is calculated to be equal to 1.5.
[0059] Step 150: Determine the moving distance of the N*M drawing matrix on the non-advancing coordinate axis according to the integer part of the coordinate on the non-advancing coordinate axis.
[0060] Exemplarily, when the coordinate of the non-advancing coordinate axis, i.e., the X-axis, is equal to 1.5, the integer part is 1, and the previous point is the starting point, the starting coordinates of the starting point are (1,1), and the X-axis coordinate is also 1, so the moving distance on the non-advancing coordinate axis is 0 at this time.
[0061] Step 160: Control the N*M drawing matrix to move the preset distance along the advancing coordinate axis, and to move the moving distance along the non-advancing coordinate axis.
[0062] In the above example, the drawing matrix will move from (1,1) to (1,2).
[0063] In some embodiments, the point to which the N*M drawing matrix moves along the advancing coordinate axis by the preset distance and along the non-advancing coordinate axis by the moving distance is called a drawing point, and the drawing point will be used for explanation later in the specification.
[0064] Step 170: After the movement, control the N*M drawing matrix to draw pixel points according to the decimal part of the coordinates on the non-advanced coordinate axis.
[0065] In the above example, the coordinate of the non-advanced coordinate axis, ie, the X-axis, is equal to 1.5, and the decimal part is 0.5.
[0066] In some implementations, step 170 includes steps 171 to 172 .
[0067] Step 171: When the coordinates on the non-advanced coordinate axis do not have a decimal part, control the N*M drawing matrix to be drawn according to a first preset rule.
[0068] In some embodiments, step 171 includes steps 1711 to 1712 .
[0069] Step 1711: When the coordinates on the non-advanced coordinate axis do not have a decimal part, the pixel values of the pixel points in the N*M drawing matrix are all set to preset pixel values.
[0070] Specifically, in this application, anti-aliasing processing is performed with reference to the idea of Xiaolin Wu algorithm. If there is no decimal part in the coordinates on the non-advanced coordinate axis, it is considered that the center of the drawing point is located on the straight line equation at this time, so no anti-aliasing processing is required.
[0071] Step 172: When the coordinates on the non-advanced coordinate axis have a decimal part, control the N*M drawing matrix to be drawn according to a second preset rule.
[0072] In some embodiments, step 172 includes: steps 1721 to 1726.
[0073] Step 1721: Determine the slope of the straight line according to the straight line equation.
[0074] Step 1722: Divide the pixels in the N*M drawing matrix into a first preset area, a second preset area and a common area according to the slope of the straight line.
[0075] Step 1723: Determine the complement corresponding to the decimal part.
[0076] Step 1724: Setting the pixel value of the first preset area according to the decimal part.
[0077] Step 1725: Setting the pixel value of the second preset area according to the complement.
[0078] Step 1726: Setting the pixel value of the common area to a preset pixel value.
[0079] In some embodiments, the complement of the decimal part is equal to 1-the decimal part; illustratively, if the decimal part is 0.4, the complement is 1-0.4=0.6.
[0080] In this way, the pixel values of the first preset area and the second preset area can be adjusted. Compared with setting the pixel values of all pixels in the drawing matrix to preset pixel values, such as 255, the jaggedness of the drawn pixel lines can be reduced.
[0081] Please refer to Figure 3 , Figure 3 Schematic diagram of a matrix drawing provided by an embodiment of the present application. Figure 3 As shown, the drawing matrix is a 4*4 matrix, including pixel points 1 to pixel points 16.
[0082] Specifically, Figure 3 The positive direction of the X-axis and the positive direction of the Y-axis of the coordinate system are also indicated. The positive direction of the X-axis is the right direction, and the positive direction of the Y-axis is the downward direction.
[0083] Define the drawing matrix to always be located at Figure 3 In the first quadrant of the coordinate system in, in some embodiments, step 1722 includes the following steps.
[0084] (1) When the slope is greater than zero, the first preset area is determined to be an upper right pixel point in the N*M drawing matrix, and the second preset area is determined to be a lower left pixel point in the N*M drawing matrix.
[0085] (2) When the slope is less than zero, the first preset area is determined to be a lower right pixel point in the N*M drawing matrix, and the second preset area is determined to be an upper left pixel point in the N*M drawing matrix.
[0086] In some embodiments, Figure 3 The direction of the straight line is indicated in Figure 3 The slope of the straight line is greater than 0.
[0087] In some embodiments, Figure 3 The direction of the straight line in is marked at pixel point 1, which can represent that the starting coordinates and the ending coordinates of the pixel line to be drawn obtained when executing the steps are both the coordinates of pixel point 1, that is, the coordinates of pixel point 1 at the beginning are the starting coordinates, and the coordinates of pixel point 1 at the end of drawing are the ending coordinates.
[0088] It is understandable that the pixel point in the drawing matrix to which the obtained starting coordinates and ending coordinates specifically correspond can be selected as needed, and this application does not impose any limitation.
[0089] For example, Figure 3 When the slope is greater than zero, the first preset area includes the upper right pixel point in the N*M drawing matrix, that is, pixel point 4; the second preset area includes the lower left pixel point in the N*M drawing matrix, that is, pixel point 13.
[0090] The pixel value of the upper right pixel is equal to the decimal part multiplied by the preset pixel value, and the pixel value of the lower left pixel is equal to the complement part multiplied by the preset pixel value.
[0091] For example, Figure 3 When the slope is less than zero, the first preset area includes the upper left pixel point in the N*M drawing matrix, that is, pixel point 1; the second preset area includes the lower right pixel point in the N*M drawing matrix, that is, pixel point 16.
[0092] The pixel value of the upper left pixel is equal to the decimal part multiplied by the preset pixel value, and the pixel value of the lower right pixel is equal to the complement part multiplied by the preset pixel value.
[0093] In some embodiments, the slope is judged by the positive or negative method. Figure 3 The judgment is made in the coordinate system shown in the figure. When the positive direction of one or more coordinate axes of the coordinate system changes, the above judgment method may not be applicable, because even if the direction of the slope remains unchanged, the change in the positive direction of the coordinate axis will affect the positive or negative of the slope.
[0094] In the above manner, the first preset area is set by a decimal, and the second preset area is set by a complement. In fact, anti-aliasing processing is performed according to the degree to which different pixel points deviate from the straight line corresponding to the straight line equation, which can reduce the aliasing effect.
[0095] Step 180: Determine whether to move to the terminal coordinates. If not, return to the execution step to calculate the coordinates of the N*M drawing matrix on the non-advancing coordinate axis after the N*M drawing matrix advances a preset distance along the advancing coordinate axis according to the straight line equation.
[0096] In some implementations, in order to further reduce the jagged feeling, after step 180 , the present application further includes step 190 .
[0097] Step 190: After the pixel line to be drawn is completed, the pixel values of the pixel points in the component units at both ends of the pixel line are adjusted according to the drawing direction of the pixel line.
[0098] In some implementations, because drawing is performed through a drawing matrix, a component unit of a pixel line is obtained by drawing the drawing matrix once, and the pixel line is composed of a plurality of component units.
[0099] Optionally, step 190 includes: after the pixel line to be drawn is drawn, setting the pixel values of the protruding pixel points in the component units at both ends of the pixel line to the pixel values corresponding to the background color of the drawing area where the pixel line is located according to the drawing direction of the pixel line.
[0100] Exemplarily, the preset pixel value when drawing a pixel line is 0, and the pixel value of the background color is 255.
[0101] See also Figure 4 and Figure 5 , Figure 4 is a first schematic diagram of a highlighted pixel point provided in an embodiment of the present application, Figure 5 This is a second schematic diagram of highlighting pixel points provided in an embodiment of the present application.
[0102] like Figure 4 and Figure 5As shown, when the drawing directions of the pixel line are different, the protruding pixel points in the component units at both ends of the pixel line are also different.
[0103] In some embodiments, a segmentation diagonal line is determined by a slope, and the component unit at the end is segmented into a protruding area and a non-protruding area by the segmentation diagonal line, and the pixels included in the protruding area are determined as protruding pixels.
[0104] In some implementations, the splitting diagonal line will divide a pixel into two, but a pixel is a minimum unit that cannot be further divided, so the pixels through which the splitting diagonal line passes can be directly divided into prominent pixels to maximize the anti-aliasing effect.
[0105] In some implementations, the pixels in the highlighted area may be subjected to a gradient process, where the pixel values of the pixels farther from the segmentation diagonal line are closer to the pixel values corresponding to the background color of the drawing area where the pixel line is located.
[0106] The above method can reduce the jaggedness of pixel lines, but please refer to Figure 6 and Figure 7 , Figure 6 This is a first schematic diagram of pixel line drawing provided in an embodiment of the present application. Figure 7 This is a second schematic diagram of pixel line drawing provided in an embodiment of the present application.
[0107] like Figure 6 As shown, Figure 6 The drawing matrix is a 2*2 drawing matrix. Figure 6 In the first drawing matrix, four pixels are drawn, namely pixel points 1a, 2a, 3a and 4a. In the second drawing matrix, four pixels are drawn, namely pixel points 1b, 2b, 3b and 4b. Among them, pixel point 2a and pixel point 3b are pixel points with the same coordinates, but are in different positions in the drawing matrix.
[0108] It can be seen that when the first drawing matrix of the 2*2 drawing matrix advances one pixel toward the positive X axis and one pixel toward the positive Y axis, the coordinates of the advancing coordinate axis X axis and the coordinates of the non-advancing coordinate axis Y axis change at the same time, then the anti-aliasing effect is normal, that is, Figure 6 There are pixel 1a, pixel 4a, pixel 1b and pixel 4b that have undergone anti-aliasing processing.
[0109] like Figure 7 As shown, Figure 7 The drawing matrix is a 2*2 drawing matrix. Figure 7In the first drawing matrix, four pixels are drawn, namely pixel points 1a, 2a, 3a and 4a. In the second drawing matrix, four pixels are drawn, namely pixel points 1b, 2b, 3b and 4b. Among them, pixel point 2a and pixel point 1b are pixel points with the same coordinates, pixel point 4a and pixel point 3b are pixel points with the same coordinates, but they are in different positions in the drawing matrix.
[0110] It can be seen that when the first drawing matrix of the 2*2 drawing matrix advances one pixel toward the positive X-axis but does not advance in the positive Y-axis direction, the pixel points where pixel points 4a and pixel points 3b are located are anti-aliased as pixel points of the preset area when drawn by the first drawing matrix, but are treated as pixel points of the ordinary area when drawn by the second drawing matrix, resulting in the disappearance of the anti-aliasing effect, making the anti-aliasing effect not as expected.
[0111] Right now Figure 6 There should be pixel 1a, pixel 4a, pixel 1b and pixel 4b that have been anti-aliased. However, only pixel 1a, pixel 1b and pixel 4b retain the anti-aliasing effect. The reason is that pixel 4a is a pixel in the normal area in the second drawing matrix and does not need anti-aliasing. Therefore, its pixel value is reset to the preset pixel value. Based on this, the present application provides a second pixel line drawing method, see Figure 8 , Figure 8 is a flow chart of a second pixel line drawing method provided in an embodiment of the present application, such as Figure 8 As shown, the method 200 includes: steps 210 to 250.
[0112] Step 210: Obtain the starting coordinates, ending coordinates and corresponding straight line equation of the pixel line to be drawn.
[0113] For details, please refer to the introduction in the above part of the manual, which will not be repeated here.
[0114] Step 220: Determine a plurality of drawing points according to the starting coordinates, the ending coordinates and the straight line equation.
[0115] In some implementations, step 220 includes steps 221 to 223 .
[0116] Step 221: Calculate the first coordinate axis difference and the second coordinate axis difference according to the starting coordinate and the ending coordinate.
[0117] Step 222: Determine the forward coordinate axis according to the first coordinate axis difference and the second coordinate axis difference.
[0118] Step 223: Taking the starting coordinate as the starting point and the ending coordinate as the end point, based on the straight line equation, advance a preset distance along the advancing coordinate axis each time to obtain multiple drawing points.
[0119] For details, please refer to the introduction in the above part of the manual, which will not be repeated here.
[0120] In some embodiments, the steps include steps 2231 to 2232, based on the straight line equation, advancing a preset distance along the advancing coordinate axis each time to obtain multiple drawing points.
[0121] Step 2231: Based on the straight line equation, advance a preset distance along the advancing coordinate axis each time to obtain multiple initial drawing points.
[0122] Step 2232: When the coordinates on the non-advanced coordinate axis of each of the initial drawing points have a decimal part, the coordinates on the non-advanced coordinate axis are rounded to obtain the multiple drawing points.
[0123] Specifically, a pixel is the smallest display unit in a display system, so the coordinates of each pixel in a coordinate system are usually integers. Therefore, the coordinates on the non-advancing coordinate axis need to be rounded to determine which pixel needs to be moved to.
[0124] In a possible implementation, only the integer part of the coordinates on the non-advanced coordinate axis is retained to obtain the drawing point. For example, the coordinates of the initial drawing point are (2, 2.6), and the second drawing coordinates after rounding are (2, 6). After the coordinates of the initial drawing point are rounded, the subsequent steps can perform anti-aliasing processing on the decimal part and the integer part, and even if rounding is performed, it will not affect the final display effect.
[0125] In another possible implementation method, rounding methods such as rounding off or rounding off may also be used. However, when anti-aliasing processing is performed on the pixels of the preset area based on the decimals and the complement using different rounding methods, it is necessary to make the decimal * the preset pixel value of the first preset area * the first correction coefficient, and make the complement * the preset pixel value of the second preset area * the second correction coefficient. The values of the first correction coefficient and the second correction coefficient are determined by the rounding method.
[0126] Step 230: When the N*M drawing matrix moves to the current drawing point for drawing, anti-aliasing drawing is performed on the pixel points in the preset area in the N*M drawing matrix; wherein the N*M drawing matrix draws N*M pixel points each time, and N and M are both positive integers greater than one; and the current drawing point is one of the multiple drawing points.
[0127] In some embodiments, the decimals of the coordinates on the non-advanced coordinate axis reflect the degree of deviation of the pixel point from the straight line equation, so anti-aliasing processing can be performed using the decimals of the coordinates on the non-advanced coordinate axis. In this case, step 230 includes the following steps.
[0128] (1) When the coordinates on the non-advanced coordinate axis have a decimal part before the current drawing point is rounded, determine the complement corresponding to the decimal.
[0129] (2) performing anti-aliasing processing on pixel points in a first preset area among the N*M pixel points according to the decimal.
[0130] (3) performing anti-aliasing processing on pixel points in a second preset area among the N*M pixel points according to the complement.
[0131] Among them, in the direction of the non-advancing coordinate axis, the non-advancing coordinate axis coordinate of the pixel point in the first preset area is greater than the non-advancing coordinate axis coordinate of the pixel point in the second preset area.
[0132] For example, the advancing coordinate axis is the positive X axis, and the non-advancing coordinate axis is the positive Y axis. For a 2*2 drawing matrix, the first pixel in the first column should move from (1,2) to (2,2.9), but it stays at (2,2). The second pixel in the first column should move from (1,1) to (2,1.9), but it stays at (2,1). At this time, (2,1) and (2,2) are 100% occupied.
[0133] However, originally (2, 3) should be occupied by 90%, (2, 2) by 100%, and (2, 1) by 10%. The anti-aliasing process in this application is to set (2, 2) from 100% to 0.9*100%=90%, and (2, 1) from 100% to 0.1*100%=10%. Thus, anti-aliasing is achieved when drawing an N*M matrix.
[0134] In some implementations, the method for determining the preset area is further described.
[0135] Wherein, when the slope of the straight line equation is within a first preset range, the preset area in the N*M drawing matrix at least includes: a first preset area including lower right pixels and a second preset area including upper left pixels.
[0136] Wherein, when the slope of the straight line equation is within a second preset range, the preset areas in the N*M drawing matrix at least include: a first preset area including an upper right pixel point and a second preset area including a lower left pixel point.
[0137] It can be understood that the correspondence between the slope and the first preset area and the correspondence between the slope and the second preset area will change according to the position of the origin coordinates, the positive direction of the X-axis, and the positive direction of the Y-axis. Therefore, the first preset range and the second preset range will also change with the position of the origin coordinates, the positive direction of the X-axis, and the positive direction of the Y-axis. Therefore, this application does not limit the specific values of the first preset range and the second preset range.
[0138] For example, define the drawing matrix to always be located at Figure 3 If the coordinate system is in the first quadrant of the coordinate system, the first preset range is (-∞, 0) and the second preset range is [0, +∞), or the first preset range is (-∞, 0] and the second preset range is (0, +∞).
[0139] But if Figure 3 After the positive X-axis direction and / or the positive Y-axis direction of the central coordinate system changes, the value ranges of the first preset range and the second preset range will also change accordingly, so the first preset range and the second preset range are selected according to actual conditions.
[0140] Step 240: when the coordinates of the current drawing point and the coordinates of the previous drawing point meet the preset conditions, the pixel point coordinates and corresponding pixel values for anti-aliasing drawing saved when drawing the previous drawing point are determined.
[0141] In some implementations, if the coordinates of the current drawing point and the coordinates of the previous drawing point do not meet the preset conditions, the advancing coordinate axis and the non-advancing coordinate axis move simultaneously, and no anti-aliasing failure occurs, and normal drawing is performed.
[0142] In some implementations, after step 230, the method further includes: saving pixel point coordinates and corresponding pixel values of the pixel points that are subjected to anti-aliasing rendering when rendering the current rendering point.
[0143] There are multiple pixels for anti-aliasing rendering.
[0144] Among them, when the drawing matrix does not move on the non-advanced coordinate axis, after the movement, only the first preset area or the second preset area of the pixel points in the preset area will lose the anti-aliasing effect, so there is no need to record the pixel points of all preset areas. Therefore, in a possible implementation method, the step of saving the pixel coordinates and corresponding pixel values of the pixel points for anti-aliasing drawing when drawing the current drawing point includes: determining the recorded pixel points that need to be recorded among the pixel points for anti-aliasing drawing according to the forward coordinate axis, and recording the coordinates and pixel values of the recorded pixel points.
[0145] For example, Figure 7As shown in the coordinate system and drawing matrix in, the advancing coordinate axis is the positive X-axis, and the pixel points of the preset area are the upper left and lower right pixels. However, when the drawing matrix does not move on the non-advancing coordinate axis, counting from top to bottom in the figure, the second pixel point in the second row is pixel point 4a in the first drawing matrix, which is the lower right pixel point and is anti-aliased. It is pixel point 3b in the second drawing matrix, which is a pixel point in the non-preset area. Therefore, when the second drawing matrix is drawn, the pixel value of the second pixel point in the second row is set to the preset pixel value, resulting in the disappearance of the anti-aliasing effect. Therefore, when the direction of the non-advancing coordinate axis is the positive X-axis direction, the recorded pixel points include at least the lower right pixel point, that is, the pixel point in the first preset area.
[0146] Among them, when the non-advancing coordinate axis direction is the positive X-axis direction and the positive Y-axis direction, the recorded pixel points include at least the pixel points in the first preset area; when the non-advancing coordinate axis direction is the negative X-axis direction and the negative Y-axis direction, the recorded pixel points include at least the pixel points in the second preset area.
[0147] The above method can accurately record the pixels where the anti-aliasing effect disappears, which is conducive to orderly and accurate restoration.
[0148] Based on the above implementation, step 240 includes steps 241 and 242 .
[0149] Step 241: When the coordinates of the current drawing point and the coordinates of the previous drawing point meet a preset condition, the number of times the drawing point continuously meets the preset condition is calculated.
[0150] Step 242: Determine the pixel coordinates and corresponding pixel values for anti-aliasing drawing saved when drawing the last X drawing points; wherein X is equal to the number minus one.
[0151] Among them, the preset conditions include any one or more of the following: the number of drawing times is the preset number, the coordinates of the current drawing point and the coordinates of the previous drawing point on at least one coordinate axis are the same, and the coordinates of at least one pixel point in the N*M drawing matrix of the current drawing point are the coordinates of the pixel point in the previous drawing point that is anti-aliased.
[0152] One possible implementation method is, if the preset condition includes the number of drawing times being a preset number, when determining the coordinates of multiple drawing points, calculating which number of drawing times will have an anti-aliasing effect covering the previous drawing point, and then determining the preset number.
[0153] Wherein, if the number of times that the drawing point continuously satisfies the preset condition is (X+1), then before the current drawing point, there are X continuous drawing points that satisfy the preset condition. Exemplarily, the first drawing point satisfies the preset condition, the second drawing point does not satisfy the preset condition, the third drawing point satisfies the preset condition, the fourth drawing point satisfies the preset condition, and the fifth drawing point satisfies the preset condition. Then, for the fifth drawing point, the number of times that the drawing point continuously satisfies the preset condition is three times (three, four, and five drawing points), for the fourth drawing point, the number of times that the drawing point continuously satisfies the preset condition is two times (three and four drawing points), and so on.
[0154] Step 250: based on the pixel coordinates and pixel values for anti-aliasing drawing saved when drawing the last drawing point, the pixel values of the pixel points with the same pixel coordinates among the N*M pixel points are set to the saved pixel values.
[0155] For example, Figure 6 As shown, the first drawing matrix stores the pixel coordinates and pixel values of pixel points 1a and 4a, and the second drawing matrix stores the pixel coordinates and pixel values of pixel points 1b and 4b. After executing step 250, the pixel value of pixel point 3b is set to the pixel value of pixel point 4a. Pixel point 1a is not located in the second drawing matrix, so it is not drawn.
[0156] Please refer to Fig. 9 , Fig. 9 This is a third schematic diagram of pixel line drawing provided in an embodiment of the present application. Fig. 9 The pixel value of pixel 1b is set to the pixel value of pixel 2a, so that pixel 1a, pixel 2a / 1b, pixel 4a, and pixel 4b all have anti-aliasing effects, and the anti-aliasing effect takes effect normally.
[0157] In some embodiments, step 250 includes the step of setting the pixel values of the pixel points with the same pixel point coordinates among the N*M pixel points to the saved pixel values based on the pixel point coordinates and corresponding pixel values for anti-aliasing drawing saved when drawing the previous X drawing points.
[0158] Among them, X can be equal to the number of pixels on the forward coordinate axis in the N*M drawing matrix minus one. For example, in a 2*2 drawing matrix, if the forward coordinate axis is the positive X axis, then X is equal to 1 at most. For example, in a 4*9 drawing matrix, if the forward coordinate axis is the positive X axis, then X is equal to 8 at most.
[0159] The embodiment of the present application further provides a pixel line drawing device, the pixel line drawing device comprising: The acquisition module is used to obtain the starting coordinates, ending coordinates and corresponding straight line equation of the pixel line to be drawn.
[0160] The first determining module is used to determine a plurality of drawing points according to the starting coordinates, the ending coordinates and the straight line equation.
[0161] A drawing module is used to perform anti-aliasing drawing on pixel points in a preset area in an N*M drawing matrix when the N*M drawing matrix moves to the current drawing point for drawing; wherein the N*M drawing matrix draws N*M pixel points each time, and N and M are both positive integers greater than one; and the current drawing point is one of the multiple drawing points.
[0162] The second determination module is used to determine the pixel point coordinates and corresponding pixel values for anti-aliasing drawing saved when drawing the previous drawing point when the coordinates of the current drawing point and the coordinates of the previous drawing point meet preset conditions.
[0163] The setting module is used to set the pixel value of the pixel point with the same pixel point coordinate among the N*M pixel points to the saved pixel value based on the pixel point coordinate and pixel value for anti-aliasing drawing saved when drawing the last drawing point.
[0164] Optionally, the pixel line drawing device further includes other sub-units corresponding to any of the above method embodiments, which will not be described in detail in this application.
[0165] See also Fig.10 , Fig.10 Schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Fig.10 As shown, the electronic device 300 includes: one or more processors 310 and a memory 320, Fig.10 A processor 310 is taken as an example.
[0166] In some implementations, the processor 310 and the memory 320 may be connected via a bus or other means. Fig.10 The example of connecting through bus is taken in the following.
[0167] In some embodiments, the processor 310 is used to obtain the starting coordinates, the ending coordinates and the corresponding straight line equation of the pixel line to be drawn; determine multiple drawing points according to the starting coordinates, the ending coordinates and the straight line equation; when the N*M drawing matrix moves to the current drawing point for drawing, anti-aliasing drawing is performed on the pixel points of the preset area in the N*M drawing matrix; wherein the N*M drawing matrix draws N*M pixel points each time, and N and M are both positive integers greater than one; the current drawing point is one of the multiple drawing points; when the coordinates of the current drawing point and the coordinates of the previous drawing point meet preset conditions, determine the pixel point coordinates and corresponding pixel values for anti-aliasing drawing saved when drawing the previous drawing point; based on the pixel point coordinates and pixel values for anti-aliasing drawing saved when drawing the previous drawing point, set the pixel values of the pixel points with the same pixel point coordinates among the N*M pixel points to the saved pixel values.
[0168] In some embodiments, the memory 320, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer executable programs and modules, such as program instructions / modules of the pixel line drawing method in the embodiment of the present application. The processor 310 executes various functional applications and data processing of the electronic device by running the non-volatile software programs, instructions and modules stored in the memory 320, that is, the pixel line drawing method of the above method embodiment is implemented.
[0169] In some embodiments, the memory 320 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 320 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 320 may optionally include a memory remotely arranged relative to the processor 310, and these remote memories may be connected to the controller via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0170] In some embodiments, one or more modules are stored in the memory 320, and when executed by one or more processors 310, the pixel line drawing method in any of the above method embodiments is executed, for example, the pixel line drawing method described above is executed. Figure 8 Method steps 210 to 250 in.
[0171] Please refer to Fig.11 , Fig.11The computer-readable storage medium 400 stores a program code 410, which can be called by a processor to execute the pixel line drawing method described in the above method embodiment.
[0172] The computer-readable storage medium 400 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer-readable storage medium includes a non-transitory computer-readable storage medium. The computer-readable storage medium 400 has a storage space for program codes for executing any method steps in the above control method. These program codes may be read from or written to one or more computer program products. The program code may be compressed, for example, in an appropriate form.
[0173] The embodiment of the present application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device executes the above-mentioned pixel line drawing method.
[0174] In summary, the present application provides a pixel line drawing method, device, electronic device and storage medium, the method comprising: determining multiple drawing points according to the acquired starting coordinates, ending coordinates and straight line equation; when the N*M drawing matrix moves to the current drawing point for drawing, anti-aliasing drawing is performed on the pixel points of the preset area in the N*M drawing matrix; when the coordinates of the current drawing point and the coordinates of the previous drawing point meet the preset conditions, the pixel point coordinates and corresponding pixel values saved when drawing the previous drawing point for anti-aliasing drawing are determined; based on the pixel point coordinates and pixel values saved when drawing the previous drawing point for anti-aliasing drawing, the pixel values of the pixel points with the same pixel point coordinates among the N*M pixel points are set to the saved pixel values. The present application can prevent the pixel values of the pixel points that have been subjected to anti-aliasing processing from being overwritten by the subsequent drawing matrix, thereby losing the anti-aliasing effect.
[0175] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A pixel line drawing method, characterized in that: The method comprises: Get the starting coordinates, ending coordinates and corresponding straight line equation of the pixel line to be drawn; Determine a plurality of drawing points according to the starting coordinates, the ending coordinates and the straight line equation; When the N*M drawing matrix moves to the current drawing point for drawing, anti-aliasing drawing is performed on the pixel points in the preset area in the N*M drawing matrix; wherein the N*M drawing matrix draws N*M pixel points each time, and N and M are both positive integers greater than one; and the current drawing point is one of the multiple drawing points; When the coordinates of the current drawing point and the coordinates of the previous drawing point meet the preset conditions, the pixel point coordinates and corresponding pixel values for anti-aliasing drawing saved when drawing the previous drawing point are determined; The pixel values of the pixel points with the same pixel point coordinates among the N*M pixel points are set to the saved pixel values based on the pixel point coordinates and pixel values for anti-aliasing drawing saved when drawing the last drawing point.
2. The method according to claim 1, characterized in that After performing anti-aliasing rendering on pixel points in a preset area in the N*M rendering matrix, the method further includes: Saves the pixel coordinates and corresponding pixel values of the pixel points for anti-aliasing drawing when drawing the current drawing point.
3. The method according to claim 2, characterized in that When the coordinates of the current drawing point and the coordinates of the previous drawing point meet the preset conditions, determining the pixel point coordinates and corresponding pixel values for anti-aliasing drawing saved when drawing the previous drawing point includes: When the coordinates of the current drawing point and the coordinates of the previous drawing point meet the preset condition, calculating the number of times the drawing point continuously meets the preset condition; Determine the pixel coordinates and corresponding pixel values for anti-aliasing drawing saved when drawing the last X drawing points; wherein X is equal to the number minus one.
4. The method according to claim 3, characterized in that The step of setting the pixel values of the pixel points with the same pixel point coordinates among the N*M pixel points to the saved pixel values based on the pixel point coordinates and pixel values for anti-aliasing drawing saved when drawing the last drawn point comprises: The pixel values of the pixel points with the same pixel point coordinates among the N*M pixel points are set to the saved pixel values based on the pixel point coordinates and corresponding pixel values for anti-aliasing drawing saved when drawing the previous X drawing points.
5. The method according to claim 1, characterized in that The preset conditions include any one or more of the following: the number of drawing times is a preset number, the coordinates of the current drawing point and the coordinates of the previous drawing point on at least one coordinate axis are the same, and the coordinates of at least one pixel point in the N*M drawing matrix of the current drawing point are the coordinates of the pixel point in the previous drawing point that is anti-aliased.
6. The method according to claim 1, characterized in that The determining of a plurality of drawing points according to the starting coordinates, the ending coordinates and the straight line equation includes: Calculate a first coordinate axis difference and a second coordinate axis difference according to the starting coordinate and the ending coordinate; Determine a forward coordinate axis according to the first coordinate axis difference and the second coordinate axis difference; Taking the starting coordinate as the starting point and the ending coordinate as the end point, a plurality of drawing points are obtained by advancing a preset distance along the advancing coordinate axis each time based on the straight line equation.
7. The method according to claim 6, characterized in that The step of advancing a preset distance along the advancing coordinate axis each time based on the straight line equation to obtain a plurality of drawing points includes: Based on the straight line equation, a plurality of initial drawing points are obtained by advancing a preset distance along the advancing coordinate axis each time; When the coordinates on the non-advanced coordinate axis of each of the initial drawing points have a decimal part, the coordinates on the non-advanced coordinate axis are rounded to obtain the multiple drawing points.
8. The method according to claim 7, characterized in that The performing anti-aliasing drawing on the pixel points of the preset area in the N*M drawing matrix includes: When there is a decimal part in the coordinates on the non-advanced coordinate axis before the current drawing point is rounded, determine the complement corresponding to the decimal; Performing anti-aliasing processing on pixel points in a first preset area among the N*M pixel points according to the decimal; Anti-aliasing processing is performed on pixel points in a second preset area among the N*M pixel points according to the complement.
9. The method according to claim 1, characterized in that: When the slope of the straight line equation is within a first preset range, the preset areas in the N*M drawing matrix at least include: a first preset area including a lower right pixel point and a second preset area including an upper left pixel point; When the slope of the straight line equation is within a second preset range, the preset areas in the N*M drawing matrix at least include: a first preset area including an upper right pixel point and a second preset area including a lower left pixel point.
10. A pixel line drawing device, characterized in that: The device comprises: An acquisition module is used to obtain the starting coordinates, the ending coordinates and the corresponding straight line equation of the pixel line to be drawn; A first determining module, used to determine a plurality of drawing points according to the starting coordinates, the ending coordinates and the straight line equation; A drawing module, configured to perform anti-aliasing drawing on pixel points in a preset area in an N*M drawing matrix when the N*M drawing matrix moves to a current drawing point for drawing; wherein the N*M drawing matrix draws N*M pixel points each time, and N and M are both positive integers greater than one; and the current drawing point is one of the multiple drawing points; A second determination module is used to determine the pixel point coordinates and corresponding pixel values for anti-aliasing drawing saved when drawing the previous drawing point when the coordinates of the current drawing point and the coordinates of the previous drawing point meet the preset conditions; The setting module is used to set the pixel value of the pixel point with the same pixel point coordinate among the N*M pixel points to the saved pixel value based on the pixel point coordinate and pixel value for anti-aliasing drawing saved when drawing the last drawing point.
11. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the pixel line drawing method according to any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores an executable program, and the executable program is executed by a processor to implement the pixel line drawing method according to any one of claims 1 to 9.
13. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the pixel line drawing method according to any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Image drawing method and device, electronic equipment and computer readable storage medium
CN114419193A
Image processing method and device, electronic equipment and storage medium
CN114494516A
Graph drawing method and device, electronic equipment and storage medium
CN117351112A
Graphic drawing device and graphic drawing method
US20100271382A1