A pixel line drawing method and device, electronic equipment and storage medium

By obtaining the starting coordinates, ending coordinates, and equation of the pixel line from the drawing matrix, the drawing point is determined and anti-aliased drawing is performed, which solves the problem of severe jagged edges when drawing pixel lines using the drawing matrix and achieves a smoother drawing effect.

CN119478113BActive Publication Date: 2025-11-25SHENZHEN XIHUA TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411403739.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-09
Publication Date
2025-11-25
Estimated Expiration
2044-10-09

AI Technical Summary

Technical Problem

In existing technologies, pixel lines drawn using matrices exhibit severe jagged edges, negatively impacting the user experience.

Method used

By obtaining the starting coordinates, ending coordinates, and line equation of the pixel line to be drawn, multiple drawing points are determined, and anti-aliasing drawing is performed in an N*M drawing matrix. The pixel coordinates and pixel values ​​of the current drawing point are saved, and the pixel values ​​of the same pixel points are adjusted according to preset conditions to reduce the jagged edges.

Benefits of technology

It effectively reduces the jagged edges of pixel lines in the drawing matrix and improves the smoothness of the drawing effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119478113B_ABST
    Figure CN119478113B_ABST
Patent Text Reader

Abstract

The present application relates to the field of image rendering, and provides a pixel line rendering method and device, electronic equipment and storage medium, the method comprising: determining a plurality of rendering points according to the obtained starting coordinates, termination coordinates and straight line equation; when the N*M rendering matrix moves to the current rendering point for rendering, performing anti-aliasing rendering on the pixel points in the preset region of the N*M rendering matrix; when the coordinates of the current rendering point and the coordinates of the previous rendering point satisfy a preset condition, determining the pixel point coordinates and the corresponding pixel values saved during anti-aliasing rendering when the previous rendering point is rendered; and setting the pixel values of the pixel points with the same pixel point coordinates in the N*M pixel points to the saved pixel values based on the pixel point coordinates and the pixel values saved during anti-aliasing rendering when the previous rendering point is rendered. The present application can prevent the pixel values of the pixel points subjected to anti-aliasing processing from being overwritten by the subsequent rendering matrix, so that the anti-aliasing effect is not lost.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of image rendering, and in particular to a pixel line rendering method and device, electronic equipment and a storage medium. BACKGROUND

[0002] In some application scenarios, in order to quickly render a pixel line, a rendering matrix is used to render multiple pixel points at a time, for example, a 3*3 or 4*4 rendering matrix. Compared with a rendering method of rendering one pixel point at a time, the rendering speed can be improved.

[0003] However, when a rendering matrix is used to render a pixel line, the pixel line obtained by rendering has a serious jagged effect, which affects the user's visual experience. SUMMARY

[0004] To address the deficiencies of the prior art, the present application provides a pixel line rendering method, device, electronic equipment and storage medium, which can reduce the jagged effect of a pixel line obtained by rendering a rendering matrix.

[0005] To solve the above problems, the present application provides the following technical solutions:

[0006] In a first aspect, the present application provides a pixel line rendering method, which comprises:

[0007] obtaining a starting coordinate, a terminal coordinate and a corresponding straight line equation of a pixel line to be rendered;

[0008] determining a plurality of rendering points according to the starting coordinate, the terminal coordinate and the straight line equation;

[0009] performing anti-jagged rendering on pixel points in a preset region of an N*M rendering matrix when the N*M rendering matrix is moved to a current rendering point for rendering; wherein the N*M rendering matrix renders N*M pixel points each time, and N and M are positive integers greater than one; the current rendering point is one of the plurality of rendering points;

[0010] when the coordinates of the current rendering point and the coordinates of a previous rendering point satisfy a preset condition, determining pixel point coordinates and corresponding pixel values saved for anti-jagged rendering when the previous rendering point is rendered;

[0011] setting the pixel values of pixel points with the same pixel point coordinates in the N*M pixel points to the saved pixel values based on the pixel point coordinates and pixel values saved for anti-jagged rendering when the previous rendering point is rendered.

[0012] In some embodiments, after performing anti-jagged rendering on the pixel points in the preset region of the N*M rendering matrix, the method further comprises:

[0013] Save the pixel point coordinates and corresponding pixel values of the pixel points that are subjected to anti-aliasing rendering when the current drawing point is rendered.

[0014] In some embodiments, when the coordinates of the current drawing point and the coordinates of the previous drawing point satisfy a preset condition, the pixel point coordinates and corresponding pixel values subjected to anti-aliasing rendering when the previous drawing point is rendered are determined, including:

[0015] When the coordinates of the current drawing point and the coordinates of the previous drawing point satisfy a preset condition, the number of times that the drawing points successively satisfy the preset condition is calculated.

[0016] The pixel point coordinates and corresponding pixel values subjected to anti-aliasing rendering when the previous X drawing points are rendered are determined, wherein X is equal to the number of times minus one.

[0017] In some embodiments, 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 based on the pixel point coordinates and pixel values subjected to anti-aliasing rendering when the previous drawing point is rendered, including:

[0018] 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 based on the pixel point coordinates and corresponding pixel values subjected to anti-aliasing rendering when the previous X drawing points are rendered.

[0019] In some embodiments, the preset condition includes any one or more of the following: the number of times of rendering is a preset number of times, the coordinates of the current drawing point and the coordinates of the previous drawing point are the same on at least one coordinate axis, 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 points subjected to anti-aliasing rendering in the previous drawing point.

[0020] In some embodiments, determining a plurality of drawing points according to the starting coordinates, the ending coordinates, and the equation of the straight line includes:

[0021] Calculating a first coordinate axis difference value and a second coordinate axis difference value according to the starting coordinates and the ending coordinates;

[0022] Determining a forward coordinate axis according to the first coordinate axis difference value and the second coordinate axis difference value;

[0023] Based on the equation of the straight line, starting from the starting coordinates as a starting point and the ending coordinates as an ending point, and advancing a preset distance along the forward coordinate axis each time, a plurality of drawing points are obtained.

[0024] In some embodiments, based on the equation of the straight line, starting from the starting coordinates as a starting point and the ending coordinates as an ending point, and advancing a preset distance along the forward coordinate axis each time, a plurality of drawing points are obtained, including:

[0025] obtaining a plurality of initial drawing points by advancing a preset distance along the advancing coordinate axis each time based on the straight line equation;

[0026] when there is a decimal part in the coordinate on the non-advancing coordinate axis at each of the initial drawing points, rounding the coordinate on the non-advancing coordinate axis to obtain the plurality of drawing points.

[0027] In some embodiments, the anti-aliasing drawing of the pixel points in the preset region in the N*M drawing matrix comprises:

[0028] when there is a decimal part in the coordinate on the non-advancing coordinate axis before rounding the current drawing point, determining a complement corresponding to the decimal;

[0029] performing anti-aliasing processing on the pixel points in a first preset region in the N*M pixel points according to the decimal;

[0030] performing anti-aliasing processing on the pixel points in a second preset region in the N*M pixel points according to the complement.

[0031] In some embodiments, when the slope of the straight line equation is within a first preset range, the preset region in the N*M drawing matrix at least comprises a first preset region including a lower right pixel point and a second preset region including an upper left pixel point;

[0032] when the slope of the straight line equation is within a second preset range, the preset region in the N*M drawing matrix at least comprises a first preset region including an upper right pixel point and a second preset region including a lower left pixel point.

[0033] In a second aspect, an embodiment of the present application provides a pixel line drawing device, and the device comprises:

[0034] an obtaining module configured to obtain a starting coordinate, a terminal coordinate, and a corresponding straight line equation of a pixel line to be drawn;

[0035] a first determining module configured to determine a plurality of drawing points according to the starting coordinate, the terminal coordinate, and the straight line equation;

[0036] a drawing module configured to perform anti-aliasing drawing on pixel points in a preset region in an N*M drawing matrix when the N*M drawing matrix is moved to a current drawing point for drawing; wherein the N*M drawing matrix draws N*M pixel points each time, N and M are both positive integers greater than one, and the current drawing point is one of the plurality of drawing points;

[0037] a second determining module configured to determine pixel point coordinates and corresponding pixel values saved for anti-aliasing drawing when drawing a previous drawing point when the coordinates of the current drawing point and the coordinates of the previous drawing point satisfy a preset condition.

[0038] The setting module is configured to set the pixel value of the pixel point with the same pixel point coordinate in the N*M pixel points as the saved pixel value based on the saved pixel point coordinate and pixel value of the pixel point subjected to the anti-aliasing drawing when the previous drawing point is drawn.

[0039] In a third aspect, an electronic device is provided, and the electronic device comprises:

[0040] at least one processor; and

[0041] a memory in communication with the at least one processor; wherein

[0042] The memory stores instructions executable 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 perform the pixel line drawing method of the first aspect.

[0043] In a fourth aspect, a computer-readable storage medium is provided, and 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.

[0044] In a fifth aspect, a computer program product is provided, and the computer program product comprises a computer program, and the computer program is executed by a processor to implement the pixel line drawing method of the first aspect.

[0045] The pixel line drawing method, device, electronic device, and storage medium provided by the present application comprise the following steps: obtaining a starting coordinate, a terminal coordinate, and a corresponding straight line equation of a pixel line to be drawn; determining a plurality of drawing points according to the starting coordinate, the terminal coordinate, and the straight line equation; when an N*M drawing matrix moves to a current drawing point for drawing, performing anti-aliasing drawing on the pixel points in a preset region of the N*M drawing matrix; wherein the N*M drawing matrix draws N*M pixel points each time, N and M are both positive integers greater than 1; the current drawing point is one of the plurality of drawing points; when the coordinates of the current drawing point and the coordinates of a previous drawing point satisfy a preset condition, the pixel point coordinates and the corresponding pixel values subjected to the anti-aliasing drawing when the previous drawing point is drawn are determined; and the pixel value of the pixel point with the same pixel point coordinate in the N*M pixel points is set as the saved pixel value based on the saved pixel point coordinate and pixel value of the pixel point subjected to the anti-aliasing drawing when the previous drawing point is drawn. The present application can prevent the pixel value of the pixel point subjected to the anti-aliasing processing from being overwritten by the subsequent drawing matrix, so that the anti-aliasing effect is lost. BRIEF DESCRIPTION OF DRAWINGS

[0046] Figure 1 FIG. 1 is a schematic diagram of drawing a pixel line using a drawing matrix provided by an embodiment of the present application.

[0047] Figure 2 FIG. 1 is a flow diagram of a first pixel line drawing method according to an embodiment of the present application.

[0048] Figure 3 FIG. 2 is a schematic diagram of a drawing matrix according to an embodiment of the present application.

[0049] Figure 4 FIG. 3 is a first schematic diagram of highlighting pixel points according to an embodiment of the present application.

[0050] Figure 5 FIG. 4 is a second schematic diagram of highlighting pixel points according to an embodiment of the present application.

[0051] Figure 6 FIG. 5 is a first schematic diagram of pixel line drawing according to an embodiment of the present application.

[0052] Figure 7 FIG. 6 is a second schematic diagram of pixel line drawing according to an embodiment of the present application.

[0053] Figure 8 FIG. 7 is a flow diagram of a second pixel line drawing method according to an embodiment of the present application.

[0054] Figure 9 FIG. 8 is a third schematic diagram of pixel line drawing according to an embodiment of the present application.

[0055] Figure 10 FIG. 9 is a structural diagram of an electronic device according to an embodiment of the present application.

[0056] Figure 11 FIG. 10 is a structural block diagram of a computer readable storage medium according to an embodiment of the present application. DETAILED DESCRIPTION

[0057] The technical solutions in the embodiments of the present application will be clearly and completely described with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor fall within the scope of the present application.

[0058] In addition, the terms "first", "second" are used only for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined with "first", "second" can explicitly or implicitly include one or more of the features. In the description of the present application, the meaning of "multiple" is two or more, unless otherwise specifically limited.

[0059] In order to solve the problem of serious sawtooth effect in drawing a pixel line by using a drawing matrix in the prior art, the following method can be used for anti-sawtooth processing.

[0060] Referring to Figure 1 , Figure 1 is a schematic diagram of drawing a pixel line by using a drawing matrix provided by an embodiment of the present application. As shown in Figure 1 , when a pixel line is drawn by using a drawing matrix of N*M, the pixel values of all pixel points are set to a preset pixel value, and the pixel line drawn is not smooth, for example, the upper left corner and the lower right corner of the drawing matrix protrude from the continuous part, so that the pixel line has a serious sawtooth effect.

[0061] Referring to Figure 2 , Figure 2 is a flowchart of a first pixel line drawing method provided by an embodiment of the present application. As shown in Figure 2 , the pixel line drawing method 100 includes steps 110 to 180.

[0062] Step 110: Obtain the starting coordinates, the ending coordinates and the corresponding straight line equation of the pixel line to be drawn.

[0063] In some embodiments, the pixel line to be drawn is drawn in a drawing area.

[0064] In some embodiments, the pixel line to be drawn can be a pointer of a clock, an edge of a figure, etc., which is not limited in the present application.

[0065] In some embodiments, the pixel line can be a straight line, a curve, etc., which is not limited in the present application.

[0066] In one possible implementation, the straight line equation can be calculated according to the starting coordinates and the ending coordinates after the starting coordinates and the ending coordinates are obtained.

[0067] In another possible implementation, the straight line equation can be directly obtained.

[0068] In some embodiments, the drawing matrix includes N*M pixel points, and the starting coordinates and the ending coordinates can be the coordinates of any one of the N*M pixel points.

[0069] For example, the coordinates of the upper left corner pixel point in the drawing matrix are obtained, and the upper left corner pixel point in the drawing matrix is moved to the starting coordinates during drawing.

[0070] For example, the starting coordinate (1, 1) means that when the drawing starts, the coordinate of the pixel at the top-left corner of the drawing matrix is (1, 1), and the coordinates of the other pixels in the drawing matrix are not (1, 1); the ending coordinate (2, 3) means that when the drawing ends, the coordinate of the pixel at the top-left corner of the drawing matrix is (2, 3), and the coordinates of the other pixels in the drawing matrix are not (2, 3).

[0071] Step 120: determining a forward coordinate axis when drawing the pixel line to be drawn according to the starting coordinate and the ending coordinate.

[0072] In some embodiments, step 120 comprises steps 121-123.

[0073] Step 121: calculating a first coordinate axis difference value and a second coordinate axis difference value according to the starting coordinate and the ending coordinate.

[0074] Step 122: when the first coordinate axis difference value is greater than the second coordinate axis difference value, determining the first coordinate axis as the forward coordinate axis when drawing the pixel line to be drawn.

[0075] Step 123: when the second coordinate axis difference value is greater than the first coordinate axis difference value, determining the second coordinate axis as the forward coordinate axis when drawing the pixel line to be drawn.

[0076] In some embodiments, the first coordinate axis difference value 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; and the second coordinate axis difference value 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.

[0077] Further, the forward coordinate axis comprises 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.

[0078] At this time, step 122 comprises: when the first coordinate axis difference value is greater than the second coordinate axis difference value, if the first difference is greater than zero, determining the positive first coordinate axis as the forward coordinate axis when drawing the pixel line to be drawn; or if the first difference is less than zero, determining the negative first coordinate axis as the forward coordinate axis when drawing the pixel line to be drawn.

[0079] At this time, step 123 comprises: when the second coordinate axis difference value is greater than the first coordinate axis difference value, if the second difference is greater than zero, determining the positive second coordinate axis as the forward coordinate axis when drawing the pixel line to be drawn; or if the second difference is less than zero, determining the negative second coordinate axis as the forward coordinate axis when drawing the pixel line to be drawn.

[0080] For example, the starting coordinates are (1, 1) and the ending coordinates are (2, 3), the first coordinate axis difference value is 1, the second coordinate axis difference value is 2, and the second difference value is 2 greater than zero, and it is determined that the advancing coordinate axis is the positive Y axis.

[0081] For example, the starting coordinates are (1, 1) and the ending coordinates are (2, -1), the first coordinate axis difference value is 1, the second coordinate axis difference value is 2, and the second difference value is -2 less than zero, and it is determined that the advancing coordinate axis is the negative Y axis.

[0082] In the above manner, the advancing coordinate axis of the pixel line to be drawn can be calculated, and the advancing coordinate axis reflects the main extension direction of the pixel line to be drawn. The effect of performing anti-aliasing processing based on the main extension direction is better than the effect of performing anti-aliasing processing based on a non-main extension direction.

[0083] Step 130: control the N*M drawing matrix to move to the starting coordinates to draw a pixel point; wherein the N*M drawing matrix draws N*M pixel points each time, and N and M are both positive integers greater than 1.

[0084] Step 140: calculate the coordinates of the non-advancing coordinate axis of the N*M drawing matrix after advancing a preset distance along the advancing coordinate axis according to the straight line equation.

[0085] In some embodiments, the preset distance is set to 1 or 2 or even more, which is not limited in the present application.

[0086] For example, the starting coordinates are defined as (1, 1) and the ending coordinates are (2, 3), at this time the advancing coordinate axis is the positive Y axis, the straight line equation is y=2x-1, and after the drawing matrix moves 1 distance in the positive direction of the Y axis, Y is equal to 2. According to the straight line equation, the coordinates of the non-advancing coordinate axis, i.e. the X axis, are calculated to be equal to 1.5.

[0087] Step 150: determine the movement distance of the N*M drawing matrix on the non-advancing coordinate axis according to the integer part of the coordinates on the non-advancing coordinate axis.

[0088] For example, when the coordinates of the non-advancing coordinate axis, i.e. the X axis, are equal to 1.5, the integer part is 1, and the last point is the starting point, the starting coordinates of the starting point are (1, 1), and the X axis coordinates are also 1. Therefore, at this time, the movement distance on the non-advancing coordinate axis is 0.

[0089] Step 160: control the N*M drawing matrix to move the preset distance along the advancing coordinate axis and to move the movement distance along the non-advancing coordinate axis.

[0090] In the above example, the drawing matrix will move from (1, 1) to (1, 2).

[0091] In some embodiments, the drawing matrix of N*M moves along the forward coordinate axis by the preset distance, and the point to which the drawing matrix moves after moving along the non-forward coordinate axis by the movement distance is a drawing point, which will be described later in the description.

[0092] Step 170: controlling the drawing matrix of N*M to draw a pixel point according to the decimal part of the coordinate on the non-forward coordinate axis after the movement.

[0093] In the above example, the coordinate of the non-forward coordinate axis, i.e., the X axis, is equal to 1.5, and the decimal part is 0.5.

[0094] In some embodiments, step 170 includes steps 171-172.

[0095] Step 171: when the coordinate on the non-forward coordinate axis has no decimal part, controlling the drawing matrix of N*M to draw according to a first preset rule.

[0096] In some embodiments, step 171 includes steps 1711-1712.

[0097] Step 1711: when the coordinate on the non-forward coordinate axis has no decimal part, setting the pixel value of the pixel point in the drawing matrix of N*M to a preset pixel value.

[0098] Specifically, the anti-aliasing processing in the present application is performed with reference to the idea of Xiaolin Wu algorithm. If the coordinate on the non-forward coordinate axis has no decimal part, it is considered that the center of the drawing point is located on the straight line equation, and therefore, the anti-aliasing processing is not needed.

[0099] Step 172: when the coordinate on the non-forward coordinate axis has a decimal part, controlling the drawing matrix of N*M to draw according to a second preset rule.

[0100] In some embodiments, step 172 includes steps 1721-1726.

[0101] Step 1721: determining a straight line slope according to the straight line equation.

[0102] Step 1722: dividing the pixel points in the drawing matrix of N*M into a first preset area, a second preset area, and a normal area according to the straight line slope.

[0103] Step 1723: determining a complement corresponding to the decimal part.

[0104] Step 1724: setting the pixel value of the first preset area according to the decimal part.

[0105] Step 1725: setting the pixel value of the second preset area according to the complement.

[0106] Step 1726: setting the pixel value of the normal area as a preset pixel value.

[0107] In some embodiments, the complement of the decimal part is equal to 1 minus the decimal part; for example, the decimal part is 0.4, and the complement is 1-0.4=0.6.

[0108] In this way, the pixel values of the first preset area and the second preset area can be adjusted, which can reduce the sawtooth effect of the pixel line drawn by setting all pixel values in the drawing matrix as a preset pixel value, for example, all as 255.

[0109] Please refer to Figure 3 , Figure 3 is a schematic diagram of a drawing matrix provided by an embodiment of the present application. As shown in Figure 3 , the drawing matrix is a 4*4 matrix, including pixel points 1 to 16.

[0110] Specifically, Figure 3 also shows the positive direction of the X-axis and the positive direction of the Y-axis of the coordinate system, the positive direction of the X-axis is the right direction, and the positive direction of the Y-axis is the downward direction.

[0111] The drawing matrix is defined to always be located in the first quadrant of the coordinate system in Figure 3 , and in some embodiments, step 1722 includes the following steps.

[0112] (1) When the slope is greater than zero, the first preset area is determined to be the upper right pixel point in the N*M drawing matrix, and the second preset area is determined to be the lower left pixel point in the N*M drawing matrix.

[0113] (2) When the slope is less than zero, the first preset area is determined to be the lower right pixel point in the N*M drawing matrix, and the second preset area is determined to be the upper left pixel point in the N*M drawing matrix.

[0114] In some embodiments, Figure 3 shows the direction of the straight line, Figure 3 the slope of the straight line in is greater than 0.

[0115] Figure 3 In some embodiments, the direction of the straight line in

[0116] It can be understood that the starting coordinate and the ending coordinate obtained specifically correspond to which pixel point in the drawing matrix can be selected as needed, and the application does not make any limitation.

[0117] Exemplarily, 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; and the second preset area includes the lower-left pixel point in the N*M drawing matrix, that is, pixel point 13.

[0118] Wherein, the pixel value of the upper-right pixel point is equal to the decimal part multiplied by the preset pixel value, and the pixel value of the lower-left pixel point is equal to the complement part multiplied by the preset pixel value.

[0119] Exemplarily, 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; and the second preset area includes the lower-right pixel point in the N*M drawing matrix, that is, pixel point 16.

[0120] Wherein, the pixel value of the upper-left pixel point is equal to the decimal part multiplied by the preset pixel value, and the pixel value of the lower-right pixel point is equal to the complement part multiplied by the preset pixel value.

[0121] In some embodiments, the judgment by the positive and negative of the slope needs to be performed in the coordinate system as shown in the figure, and when the positive direction of one or more coordinate axes of the coordinate system changes, the above-mentioned judgment method may not be applicable because even if the direction of the slope does not change, the change of the positive direction of the coordinate axis will affect the positive and negative of the slope. Figure 3

[0122] In the above manner, the first preset area is set by the decimal, and the second preset area is set by the complement, which actually performs anti-aliasing processing according to the degree of deviation of different pixel points from the straight line corresponding to the straight line equation, and can reduce the sawtooth feeling.

[0123] Step 180: judging whether to move to the ending coordinate, and returning to perform the step of calculating the coordinates on the non-advance coordinate axis of the N*M drawing matrix after the advance preset distance of the advance coordinate axis according to the straight line equation when not moving to the ending coordinate.

[0124] In some embodiments, in order to further reduce the sawtooth feeling, after step 180, the application further includes step 190.

[0125] Step 190: adjusting the pixel values of the pixel points in the component units at both ends of the pixel line according to the drawing direction of the pixel line after the pixel line is drawn.

[0126] ​In some embodiments, because the drawing is performed by the drawing matrix, the drawing matrix draws a constituent unit of a pixel line each time the drawing is performed, and the pixel line is composed of a plurality of constituent units.

[0127] Optionally, the step 190 comprises: after the drawing of the pixel line to be drawn is completed, setting the pixel value of the protruding pixel point in the constituent unit at the end of the pixel line to the pixel value corresponding to the background color of the drawing area where the pixel line is located according to the drawing direction of the pixel line.

[0128] For example, the preset pixel value when the pixel line is drawn is 0, and the pixel value of the background color is 255.

[0129] Please refer to Figure 4 and Figure 5 , Figure 4 is a first schematic diagram of a protruding pixel point provided by an embodiment of the present application, Figure 5 is a second schematic diagram of a protruding pixel point provided by an embodiment of the present application.

[0130] As Figure 4 and Figure 5 show, when the drawing direction of the pixel line is different, the protruding pixel point in the constituent unit at the end of the pixel line is also different.

[0131] In some embodiments, the split diagonal line is determined by the slope, the constituent unit at the end is split into a protruding area and a non-protruding area by the split diagonal line, and the pixel point included in the protruding area is determined as the protruding pixel point.

[0132] In some embodiments, the split diagonal line will split a pixel point into two, but the pixel point is the smallest unit that cannot be split, so the pixel point through which the split diagonal line passes can be directly divided into the protruding pixel point, maximizing the anti-aliasing effect.

[0133] In some embodiments, the pixel points in the protruding area can be subjected to a gradient processing, and the pixel value of the pixel point farther away from the split diagonal line is closer to the pixel value corresponding to the background color of the drawing area where the pixel line is located.

[0134] The above method can reduce the aliasing of the pixel line, but please refer to Figure 6 and Figure 7 , Figure 6 is a first schematic diagram of pixel line drawing provided by an embodiment of the present application. Figure 7 is a second schematic diagram of pixel line drawing provided by an embodiment of the present application.

[0135] As Figure 6 shows, Figure 6 the drawing matrix is a 2*2 drawing matrix in the step 130, Figure 6The first drawing matrix draws four pixel points, which are pixel point 1a, 2a, 3a and 4a, and the second drawing matrix draws four pixel points, which are pixel point 1b, 2b, 3b and 4b, wherein the pixel point 2a and the pixel point 3b are pixel points with the same coordinates but in different positions in the drawing matrix.

[0136] It can be seen that when the first drawing matrix of the 2*2 drawing matrix advances one pixel point along the positive X axis and also advances one pixel point along the positive Y axis, the coordinates of the advancing coordinate axis X and the non-advancing coordinate axis Y change at the same time, and the anti-aliasing effect is normal, that is, Figure 6 The pixel points 1a, 4a, 1b and 4b are simultaneously subjected to anti-aliasing processing.

[0137] As shown in Figure 7 , Figure 7 The drawing matrix is a 2*2 drawing matrix, Figure 7 The first drawing matrix draws four pixel points, which are pixel point 1a, 2a, 3a and 4a, and the second drawing matrix draws four pixel points, which are pixel point 1b, 2b, 3b and 4b, wherein the pixel point 2a and the pixel point 1b are pixel points with the same coordinates, and the pixel point 4a and the pixel point 3b are pixel points with the same coordinates but in different positions in the drawing matrix.

[0138] It can be seen that when the first drawing matrix of the 2*2 drawing matrix advances one pixel point along the positive X axis but does not advance along the positive Y axis, the pixel points where the pixel point 4a and the pixel point 3b are located are pixel points in the preset area subjected to anti-aliasing processing when the first drawing matrix is drawn, but are treated as pixel points in the normal area when the second drawing matrix is drawn, resulting in the disappearance of the anti-aliasing effect and making the anti-aliasing effect less than expected.

[0139] That is, Figure 6 The pixel points 1a, 4a, 1b and 4b should be simultaneously subjected to anti-aliasing processing. However, finally only the pixel points 1a, 1b and 4b retain the anti-aliasing effect, and the reason is that the pixel point 4a is a pixel point in the normal area in the second drawing matrix and does not need to be subjected to anti-aliasing processing, so its pixel value is reset to the preset pixel value.

[0140] Based on this, the present application provides a second pixel line drawing method, please refer to Figure 8 , Figure 8 The flowchart of the second pixel line drawing method provided by the embodiment of the present application is shown in Figure 8 The method 200 comprises steps 210 to 250.

[0141] Step 210: obtaining a start coordinate, an end coordinate and a corresponding straight line equation of a pixel line to be drawn.

[0142] For details, refer to the above description, which will not be repeated here.

[0143] Step 220: determining a plurality of drawing points according to the start coordinate, the end coordinate and the straight line equation.

[0144] In some embodiments, step 220 includes steps 221-223.

[0145] Step 221: calculating a first coordinate axis difference value and a second coordinate axis difference value according to the start coordinate and the end coordinate.

[0146] Step 222: determining a forward coordinate axis according to the first coordinate axis difference value and the second coordinate axis difference value.

[0147] Step 223: taking the start coordinate as a starting point and the end coordinate as an ending point, and obtaining a plurality of drawing points by advancing a preset distance along the forward coordinate axis based on the straight line equation each time.

[0148] For details, refer to the above description, which will not be repeated here.

[0149] In some embodiments, step 223 includes steps 2231-2232.

[0150] Step 2231: obtaining a plurality of initial drawing points by advancing a preset distance along the forward coordinate axis based on the straight line equation each time.

[0151] Step 2232: when there is a decimal part in the coordinate on the non-forward coordinate axis at each initial drawing point, rounding the coordinate on the non-forward coordinate axis to obtain the plurality of drawing points.

[0152] Specifically, a pixel point is the smallest display unit in a display system, so the coordinate of each pixel point in a coordinate system is usually an integer, and therefore the coordinate on the non-forward coordinate axis needs to be rounded to determine which pixel point to move to.

[0153] In one possible implementation, only the integer part of the coordinate on the non-forward coordinate axis is retained to obtain a drawing point. For example, the coordinate of an initial drawing point is (2, 2.6), and the second drawing coordinate after rounding is (2, 6). After rounding the coordinate of the initial drawing point, the subsequent steps can perform anti-aliasing processing through the decimal part and the integer part, and even if rounding is performed, the final display effect will not be affected.

[0154] In another possible implementation, rounding methods such as rounding to the nearest integer or rounding to the nearest integer can also be used. However, when performing anti-aliasing processing on the pixels of the preset area based on the decimal and complement, the decimal needs to be multiplied by the preset pixel value of the first preset area and the first correction coefficient, and the complement needs to be multiplied by the preset pixel value of the second preset area and the second correction coefficient. The values ​​of the first correction coefficient and the second correction coefficient are determined by the rounding method.

[0155] Step 230: When the N*M drawing matrix moves to the current drawing point, anti-aliasing is performed on the pixels in the preset area of ​​the N*M drawing matrix; wherein, the N*M drawing matrix draws N*M pixels each time, where N and M are both positive integers greater than one; the current drawing point is one of the multiple drawing points.

[0156] In some implementations, the decimal value of the coordinates on the non-forward axes reflects the degree to which the pixel deviates from the linear equation, and therefore anti-aliasing can be performed using the decimal value of the coordinates on the non-forward axes. In this case, step 230 includes the following steps.

[0157] (1) When the coordinates on the non-forward coordinate axis before the current drawing point is rounded have a decimal part, determine the complement corresponding to the decimal.

[0158] (2) Perform anti-aliasing processing on the pixels of the first preset region among the N*M pixels according to the decimal.

[0159] (3) Perform anti-aliasing processing on the pixels in the second preset region among the N*M pixels according to the complement.

[0160] In the direction of the non-forward coordinate axis, the non-forward coordinate axis coordinate of the pixels in the first preset region is greater than the non-forward coordinate axis coordinate of the pixels in the second preset region.

[0161] For example, if the forward coordinate axis is the positive X-axis and the non-forward 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.

[0162] However, originally (2,3) should be 90% occupied, (2,2) 100% occupied, and (2,1) 10% occupied. The anti-aliasing 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%. This achieves anti-aliasing when drawing an N*M matrix.

[0163] In some implementations, the method for determining the preset area is further explained.

[0164] Wherein, when the slope of the straight line equation is within a first preset range, the preset region in the N*M drawing matrix includes at least: a first preset region including the lower right pixel and a second preset region including the upper left pixel.

[0165] Wherein, when the slope of the straight line equation is within a second preset range, the preset region in the N*M drawing matrix includes at least: a first preset region including the upper right pixel and a second preset region including the lower left pixel.

[0166] It is understandable that the correspondence between the slope and the first preset region and the correspondence between the slope and the second preset region will change depending on the position of the origin coordinates and the positive X-axis and positive Y-axis. Therefore, the first preset range and the second preset range will also change with the position of the origin coordinates and the positive X-axis and positive Y-axis. Therefore, this application does not limit the specific values ​​of the first preset range and the second preset range.

[0167] For example, the drawing matrix is ​​defined to always be located at Figure 3 Within 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, +∞).

[0168] But if Figure 3 When the positive X-axis and / or positive Y-axis of the coordinate system are changed, the value ranges of the first and second preset ranges will also change accordingly. Therefore, the first and second preset ranges should be selected according to the actual situation.

[0169] Step 240: When the coordinates of the current drawing point and the coordinates of the previous drawing point meet the preset conditions, determine the pixel coordinates and corresponding pixel values ​​saved when drawing the previous drawing point for anti-aliasing.

[0170] 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 forward coordinate axis and the non-forward coordinate axis will move simultaneously, and the anti-aliasing will not fail, and normal drawing can proceed.

[0171] In some implementations, after step 230, the method further includes: saving the pixel coordinates and corresponding pixel values ​​of the pixel points that were drawn with anti-aliasing during the drawing of the current drawing point.

[0172] The number of pixels used for anti-aliasing is multiple.

[0173] When the drawing matrix does not move on the non-advance coordinate axis, only the first preset region or the second preset region of the preset region loses the anti-aliasing effect after the movement, and thus it is not necessary to record the pixel points of all the preset regions. In one possible implementation, the step of saving the pixel point coordinates and corresponding pixel values of the pixel points subjected to the anti-aliasing drawing when the current drawing point is drawn includes: determining the recording pixel points that need to be recorded from the pixel points subjected to the anti-aliasing drawing according to the advance coordinate axis, and recording the coordinates and pixel values of the recording pixel points.

[0174] Exemplarily, as shown in the coordinate system and the drawing matrix in FIG. 1, the advance coordinate axis is the positive X axis, and the pixel points of the preset region are the left upper pixel point and the right lower pixel point. However, when the drawing matrix does not move on the non-advance coordinate axis, the second pixel point in the second row in the figure loses the anti-aliasing effect after the movement. As shown in FIG. 1, the second pixel point in the second row is the pixel point 4a when the first drawing matrix is drawn, and the pixel point 3b when the second drawing matrix is drawn. The pixel point 4a is the right lower pixel point and subjected to the anti-aliasing processing, and the pixel point 3b is not the pixel point of the preset region. Thus, the pixel value of the second pixel point in the second row is set to the preset pixel value when the second drawing matrix is drawn, resulting in the disappearance of the anti-aliasing effect. Thus, when the direction of the non-advance coordinate axis is the positive X axis direction, the recording pixel points at least include the right lower pixel point, i.e., the pixel point in the first preset region. Figure 7 When the direction of the non-advance coordinate axis is the positive X axis direction and the positive Y axis direction, the recording pixel points at least include the pixel points in the first preset region. When the direction of the non-advance coordinate axis is the negative X axis direction and the negative Y axis direction, the recording pixel points at least include the pixel points in the second preset region.

[0175] The above-described manner can accurately record the pixel points subjected to the disappearance of the anti-aliasing effect, and is beneficial to the orderly and accurate recovery.

[0176] Based on the above-described embodiment, the step 240 includes steps 241 and 242.

[0177] The step 241: when the coordinates of the current drawing point and the coordinates of the last drawing point satisfy a preset condition, calculating the number of times that the drawing point continuously satisfies the preset condition.

[0178] The step 242: determining the pixel point coordinates and corresponding pixel values of the pixel points subjected to the anti-aliasing drawing when the X drawing points are drawn, wherein X is equal to the number of times minus one.

[0179] The preset condition includes any one or more of the following: the drawing number is a preset number, the coordinates of the current drawing point and the coordinates of the last drawing point are the same on at least one coordinate axis, 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 subjected to the anti-aliasing drawing in the last drawing point.

[0180] The above-described manner can accurately record the pixel points subjected to the disappearance of the anti-aliasing effect, and is beneficial to the orderly and accurate recovery.

[0181] One possible approach is to calculate, when determining the coordinates of multiple drawing points, which drawing operations will result in the anti-aliasing effect covering the previous drawing point, if the preset conditions include a preset number of draws.

[0182] If a drawing point consecutively satisfies the preset condition a number of times, then there are X consecutive drawing points that satisfy the preset condition before the current drawing point. For example, if the first drawing point satisfies the preset condition, the second does not, the third, fourth, and fifth all satisfy the preset condition, then for the fifth drawing point, the number of times the drawing point consecutively satisfies the preset condition is three (the third, fourth, and fifth drawing points); for the fourth drawing point, the number of times the drawing point consecutively satisfies the preset condition is two (the third and fourth drawing points), and so on.

[0183] Step 250: Based on the pixel coordinates and pixel values ​​saved when drawing the previous drawing point for anti-aliasing, set the pixel values ​​of the pixels with the same pixel coordinates among the N*M pixels to the saved pixel values.

[0184] For example, such as Figure 6 As shown, the first drawing matrix stores the pixel coordinates and pixel values ​​of pixels 1a and 4a, and the second drawing matrix stores the pixel coordinates and pixel values ​​of pixels 1b and 4b. After executing step 250, the pixel value of pixel 3b is set to the pixel value of pixel 4a. Pixel 1a is not located in the second drawing matrix, so it is not drawn.

[0185] Please refer to the following: Figure 9 , Figure 9 This is a third schematic diagram of pixel line drawing provided in the embodiments of this application. Figure 9 The pixel value of pixel 1b is set to the pixel value of pixel 2a, so that pixels 1a, 2a / 1b, 4a, and 4b all have anti-aliasing effect, and the anti-aliasing effect works normally.

[0186] In some implementations, step 250 includes the step of: setting the pixel values ​​of pixels with the same pixel coordinates among the N*M pixels to the saved pixel values ​​based on the pixel coordinates and corresponding pixel values ​​of the pixels used for anti-aliasing rendering saved when drawing the X drawing points.

[0187] In this context, X can be at most equal to the number of pixels on the forward axis of an N*M drawing matrix minus one. For example, in a 2*2 drawing matrix, if the forward axis is the positive X-axis, then X can be at most equal to 1. In a 4*9 drawing matrix, if the forward axis is the positive X-axis, then X can be at most equal to 8.

[0188] This application embodiment also provides a pixel line drawing device, the pixel line drawing device comprising:

[0189] The acquisition module is used to obtain the start coordinates, end coordinates, and corresponding line equations of the pixel line to be drawn.

[0190] The first determining module is used to determine multiple drawing points based on the starting coordinates, the ending coordinates, and the equation of the straight line.

[0191] The drawing module is used to perform anti-aliasing drawing on the pixels in a preset area of ​​the N*M drawing matrix when the N*M drawing matrix moves to the current drawing point; wherein the N*M drawing matrix draws N*M pixels at a time, where N and M are both positive integers greater than one; and the current drawing point is one of the multiple drawing points.

[0192] The second determining module is used to determine the pixel coordinates and corresponding pixel values ​​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.

[0193] The setting module is used to set the pixel value of the same pixel coordinates among the N*M pixels to the saved pixel value based on the pixel coordinates and pixel value of the anti-aliased drawing saved when drawing the previous drawing point.

[0194] Optionally, the pixel line drawing device also includes other sub-units corresponding to any of the above method embodiments, which will not be described in detail in this application.

[0195] Please see Figure 10 , Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. For example... Figure 10 As shown, the electronic device 300 includes: one or more processors 310 and a memory 320. Figure 10 Take the 310 processor as an example.

[0196] In some implementations, the processor 310 and the memory 320 may be connected via a bus or other means. Figure 10 Taking the example of a connection between China and Israel via a bus.

[0197] In some embodiments, the processor 310 is configured to acquire a starting coordinate, a terminal coordinate and a corresponding straight line equation of a pixel line to be drawn; determine a plurality of drawing points according to the starting coordinate, the terminal coordinate and the straight line equation; perform anti-aliasing drawing on pixel points in a preset region 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 1; the current drawing point is one of the plurality of drawing points; when a coordinate of the current drawing point and a coordinate of a previous drawing point satisfy a preset condition, determine pixel point coordinates and corresponding pixel values saved during anti-aliasing drawing when the previous drawing point is drawn; and set pixel values of pixel points with the same pixel point coordinates in the N*M pixel points to the saved pixel values based on the pixel point coordinates and the pixel values saved during anti-aliasing drawing when the previous drawing point is drawn.

[0198] In some embodiments, the memory 320 is a non-volatile computer readable storage medium configured 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 embodiments of the present application. The processor 310 executes various functions of the electronic device and data processing by running the non-volatile software programs, instructions and modules stored in the memory 320, that is, implements the pixel line drawing method of the above method embodiments.

[0199] In some embodiments, the memory 320 can include a program storage area and a data storage area, wherein the program storage area can store an operating system and application programs required by at least one function; and the data storage area can store data created according to the use of the electronic device, etc. In addition, the memory 320 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other non-volatile solid-state memory device. In some embodiments, the memory 320 can optionally include a memory remotely arranged with respect to the processor 310, and these remote memories can be connected to the controller through a network. Examples of the above network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network and a combination thereof.

[0200] In some embodiments, one or more modules are stored in the memory 320, and when executed by the one or more processors 310, perform the pixel line drawing method in any of the above method embodiments, for example, perform the method steps 210 to 250 in the above method embodiment. Figure 8

[0201] Please refer to Figure 11 , Figure 11 ​is a structural block diagram of a computer readable storage medium provided by an embodiment of the present application. The computer readable storage medium 400 stores program code 410 therein, and the program code 410 can be invoked by a processor to execute the pixel line drawing method described in the above method embodiments.

[0202] The computer readable storage medium 400 can be an electronic storage such as a flash memory, an EEPROM (Electrically Erasable Programmable Read-Only Memory), an EPROM, a hard disk, or a ROM. Alternatively, 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 code for executing any method step in the above control method. These program codes can be read from or written into one or more computer program products. The program codes can be compressed in an appropriate form, for example.

[0203] The embodiment of the present application further 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 to enable the computer device to execute the pixel line drawing method described above.

[0204] To sum up, the present application provides a pixel line drawing method, device, electronic device, and storage medium. The method includes: determining a plurality of drawing points according to obtained starting coordinates, ending coordinates, and a straight line equation; when a N*M drawing matrix moves to a current drawing point for drawing, performing anti-aliasing drawing on pixel points in a preset region in the N*M drawing matrix; when the coordinates of the current drawing point and the coordinates of a previous drawing point satisfy a preset condition, determining pixel point coordinates and corresponding pixel values saved during anti-aliasing drawing of the previous drawing point; and setting pixel values of pixel points with the same pixel point coordinates in the N*M pixel points to the saved pixel values based on the pixel point coordinates and pixel values saved during anti-aliasing drawing of the previous drawing point. The present application can prevent pixel values of pixel points that have been subjected to anti-aliasing processing from being overwritten by a subsequent drawing matrix, thereby losing the anti-aliasing effect.

[0205] Finally, it should be noted that the above embodiments are merely used to illustrate the technical solutions of the present application, rather than limiting them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacements for some technical features therein; and 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 by, The method comprises: obtaining start coordinates, end coordinates and a corresponding straight line equation of a pixel line to be drawn; determining a plurality of drawing points according to the start coordinates, the end coordinates and the straight line equation; when an N*M drawing matrix moves to a current drawing point for drawing, performing anti-aliasing drawing on pixel points in a preset region 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 plurality of drawing points; when the coordinates of the current drawing point and the coordinates of a previous drawing point satisfy a preset condition, determining pixel point coordinates and corresponding pixel values saved during anti-aliasing drawing of the previous drawing point; based on the pixel point coordinates and the pixel values saved during anti-aliasing drawing of the previous drawing point, setting pixel values of pixel points with the same pixel point coordinates in the N*M pixel points to the saved pixel values; the preset condition comprises any one or more of the following: a drawing frequency is a preset frequency, coordinates of at least one coordinate axis of the current drawing point and the previous drawing point are the same, and coordinates of at least one pixel point in the N*M drawing matrix of the current drawing point are coordinates of pixel points subjected to anti-aliasing drawing in the previous drawing point.

2. The method of claim 1, wherein, after performing anti-aliasing drawing on the pixel points in the preset region in the N*M drawing matrix, the method further comprises: saving pixel point coordinates and corresponding pixel values of the pixel points subjected to anti-aliasing drawing when the current drawing point is drawn.

3. The method of claim 2, wherein, when the coordinates of the current drawing point and the coordinates of the previous drawing point satisfy the preset condition, determining the pixel point coordinates and the corresponding pixel values saved during anti-aliasing drawing of the previous drawing point, comprises: when the coordinates of the current drawing point and the coordinates of the previous drawing point satisfy the preset condition, calculating a frequency at which the drawing points continuously satisfy the preset condition; determining pixel point coordinates and corresponding pixel values saved during anti-aliasing drawing of X previous drawing points; wherein X is equal to the frequency minus one.

4. The method of claim 3, wherein, based on the pixel point coordinates and the pixel values saved during anti-aliasing drawing of the previous drawing point, setting pixel values of pixel points with the same pixel point coordinates in the N*M pixel points to the saved pixel values, comprises: based on the pixel point coordinates and the corresponding pixel values saved during anti-aliasing drawing of the X previous drawing points, setting pixel values of pixel points with the same pixel point coordinates in the N*M pixel points to the saved pixel values.

5. The method of claim 1, wherein, determining a plurality of drawing points according to the start coordinates, the end coordinates and the straight line equation, comprises: calculating a first coordinate axis difference value and a second coordinate axis difference value according to the start coordinates and the end coordinates; determining a forward coordinate axis according to the first coordinate axis difference value and the second coordinate axis difference value; starting from the start coordinates and ending at the end coordinates, based on the straight line equation, advancing a preset distance along the forward coordinate axis each time to obtain a plurality of drawing points.

6. The method of claim 5, wherein, based on the straight line equation, advancing a preset distance along the forward coordinate axis each time to obtain a plurality of drawing points, comprises: obtaining a plurality of initial drawing points by advancing a preset distance along the advancing coordinate axis each time based on the straight line equation; when there is a decimal part in the non-advancing coordinate axis coordinate of each initial drawing point, rounding the non-advancing coordinate axis coordinate to obtain the plurality of drawing points.

7. The method of claim 6, wherein, The anti-aliasing drawing of the pixel points in the preset region in the N*M drawing matrix comprises: when there is a decimal part in the non-advancing coordinate axis coordinate of the current drawing point before rounding, determining the complement corresponding to the decimal; performing anti-aliasing processing on the pixel points in the first preset region in the N*M pixel points according to the decimal; performing anti-aliasing processing on the pixel points in the second preset region in the N*M pixel points according to the complement.

8. The method of claim 1, wherein when the slope of the straight line equation is in a first preset range, the preset region in the N*M drawing matrix at least comprises a first preset region of a right lower pixel point and a second preset region of a left upper pixel point; when the slope of the straight line equation is in a second preset range, the preset region in the N*M drawing matrix at least comprises a first preset region of a right upper pixel point and a second preset region of a left lower pixel point.

9. A pixel line drawing apparatus characterized by comprising: The device comprises: an acquisition module configured to acquire a starting coordinate, a terminal coordinate and a corresponding straight line equation of a pixel line to be drawn; a first determination module configured to determine a plurality of drawing points according to the starting coordinate, the terminal coordinate and the straight line equation; a drawing module configured to perform anti-aliasing drawing on pixel points in a preset region in an N*M drawing matrix when the N*M drawing matrix is moved to a current drawing point for drawing; wherein the N*M drawing matrix draws N*M pixel points each time, N and M are both positive integers greater than one; the current drawing point is one of the plurality of drawing points; a second determination module configured to, when the coordinates of the current drawing point and the coordinates of a previous drawing point satisfy a preset condition, determine pixel point coordinates and corresponding pixel values saved for anti-aliasing drawing when the previous drawing point is drawn; a setting module configured to set the pixel value of the pixel point with the same pixel point coordinate in the N*M pixel points to the saved pixel value based on the pixel point coordinates and the pixel values saved for anti-aliasing drawing when the previous drawing point is drawn. The preset condition comprises any one or more of the following: the number of drawings is a preset number, the coordinates of the current drawing point and the coordinates of the previous drawing point are the same on at least one coordinate axis, 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 subjected to anti-aliasing drawing in the previous drawing point.

10. An electronic device, comprising: The electronic device comprises: at least one processor; and a memory connected in communication with the at least one processor; wherein the memory stores instructions executable 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 perform the pixel line drawing method of any one of claims 1-8.

11. A computer readable storage medium, characterized in that, The computer readable storage medium stores an executable program, and the executable program is executed by the processor to realize the pixel line drawing method in any one of claims 1-8.

12. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to realize the pixel line drawing method in any one of claims 1-8.

Citation Information

Patent Citations

  • Image drawing method and device, electronic equipment and computer readable storage medium

    CN114419193A

  • Graphic drawing device and graphic drawing method

    US20100271382A1