Coordinate conversion method and device for graphics device interface plus drawing
By establishing the conversion method of actual data, screen display and system coordinate system, the problem of low efficiency of three coordinate conversion in GDI+ drawing is solved, and efficient image drawing and operation are achieved.
Patent Information
- Application Number
- CN202011237709.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-09
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2040-11-09
AI Technical Summary
In the prior art, GDI+ cannot realize real-time conversion of three coordinates: system coordinates, screen display coordinates, and actual coordinates when drawing, resulting in inefficient drawing.
By determining the maximum and minimum values of the original drawn image, establishing the actual data coordinate system, and establishing the screen display coordinate system and the system coordinate system in turn, real-time conversion of three coordinates is realized, including the conversion of the actual coordinate data of the original drawn image to the screen display coordinate data, and the determination of the system coordinate data.
Improved drawing efficiency, especially when image enlargement, reduction and movement operations, fast coordinate conversion is achieved, simplifying the programming process of GDI+.
Smart Images

Figure CN114463467B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a coordinate conversion method and device for graphics device interface plus drawing. Background Art
[0002] This section is intended to provide a background or context to the embodiments of the invention that are recited in the claims. No statement herein is admitted to be prior art by virtue of its inclusion in this section.
[0003] GDI+ (Graphics Device Interface Plus) is part of the Windows operating system. It enables programmatic image drawing through hardware drivers. As a programming interface in the Windows system, GDI+ enables interaction with physical graphics devices. GDI+ supports a variety of graphics formats, such as JPEG, GIF, EMF, and PNG. The emergence of GDI+ has brought significant convenience to developers when programming image output, eliminating the need to consider hardware operation. GDI+ is used in various fields for mapping, such as geographic information systems and statistical analysis. GDI+ is powerful and can directly draw various basic graphics. However, when drawing images, the actual image values must be converted to corresponding system coordinates. Therefore, when drawing with GDI+, there are three coordinate dimensions: actual coordinates, display coordinates, and system coordinates. Actual coordinates are the coordinates of the actual data when displaying the graphics. Display coordinates are the coordinate system in which the data is displayed based on the screen display. System coordinates are the actual coordinates of the data in the system. When drawing images, the need to constantly consider the conversion between these three dimensions can bring certain difficulties to the practical application of GDI+. Summary of the Invention
[0004] An embodiment of the present invention provides a coordinate conversion method for a graphics device interface plus drawing, which is used to achieve real-time conversion of three coordinates: system coordinates, screen display coordinates, and actual coordinates. The method includes:
[0005] Determine the maximum and minimum values of the original drawn image;
[0006] According to the maximum and minimum values of the original drawn image, an actual data coordinate system is established, and the actual coordinate data of the original drawn image is determined;
[0007] Establish the screen display coordinate system according to the actual data coordinate system;
[0008] Establish the system coordinate system according to the screen display coordinate system;
[0009] According to the actual data coordinate system and the screen display coordinate system, the actual coordinate data of the original drawn image is converted into the screen display coordinate data; according to the actual coordinate data of the original drawn image, the screen display coordinate data, and the pre-established system coordinate data determination model, the system coordinate data of the original drawn image is determined.
[0010] An embodiment of the present invention further provides a coordinate conversion device for a graphics device interface plus drawing, for realizing real-time conversion of three coordinates: system coordinates, screen display coordinates, and actual coordinates. The device includes:
[0011] a determining unit, configured to determine a maximum value and a minimum value of the original drawn image;
[0012] An actual coordinate system establishing unit, for establishing an actual data coordinate system according to the maximum value and the minimum value of the original drawn image, and determining the actual coordinate data of the original drawn image;
[0013] A screen display coordinate system establishing unit, used for establishing a screen display coordinate system according to an actual data coordinate system;
[0014] A system coordinate system establishing unit, used for establishing a system coordinate system according to a screen display coordinate system;
[0015] The conversion unit is used to convert the actual coordinate data of the original drawn image into screen display coordinate data according to the actual data coordinate system and the screen display coordinate system; determine the system coordinate data of the original drawn image according to the actual coordinate data of the original drawn image, the screen display coordinate data, and a pre-established system coordinate data determination model.
[0016] An embodiment of the present invention further provides a computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the coordinate conversion method for graphics device interface plus drawing is implemented.
[0017] An embodiment of the present invention further provides a computer-readable storage medium storing a computer program for executing the coordinate conversion method for graphics device interface plus drawing.
[0018] In an embodiment of the present invention, a coordinate conversion scheme of a graphics device interface plus drawing is compared with the technical scheme in the prior art that cannot realize the real-time conversion of the three coordinates of system coordinates, screen display coordinates, and actual coordinates, thereby causing obstacles to drawing. By: determining the maximum and minimum values of the original drawing image; establishing an actual data coordinate system according to the maximum and minimum values of the original drawing image, and determining the actual coordinate data of the original drawing image; establishing a screen display coordinate system according to the actual data coordinate system; establishing a system coordinate system according to the screen display coordinate system; converting the actual coordinate data of the original drawing image into screen display coordinate data according to the actual data coordinate system and the screen display coordinate system; determining the system coordinate data of the original drawing image according to the actual coordinate data of the original drawing image, the screen display coordinate data, and a pre-established system coordinate data determination model, the real-time conversion of the three coordinates of system coordinates, screen display coordinates, and actual coordinates is realized, thereby improving drawing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0020] Figure 1 Schematic diagram of the flow of a coordinate conversion method for graphics device interface plus drawing in an embodiment of the present invention;
[0021] Figure 2 Schematic diagram of the coordinate conversion process when an image is zoomed in or out in an embodiment of the present invention;
[0022] Figure 3 Schematic diagram of the coordinate transformation process when moving an image in an embodiment of the present invention;
[0023] Figure 4 Schematic diagram of screen display coordinates and actual coordinate system in an embodiment of the present invention;
[0024] Figure 5 Schematic diagram of the system coordinate system in an embodiment of the present invention;
[0025] Figure 6 This is a schematic diagram of the original scale image drawing effect in an embodiment of the present invention;
[0026] Figure 7 A schematic diagram of an image magnification drawing effect in an embodiment of the present invention;
[0027] Figure 8 This is a schematic diagram of the image drawing effect before the mouse moves in an embodiment of the present invention;
[0028] Figure 9 This is a schematic diagram of the drawing effect after the mouse moves the image in an embodiment of the present invention;
[0029] Figure 10 Schematic diagram of the structure of a coordinate conversion device for graphics device interface plus drawing in an embodiment of the present invention. DETAILED DESCRIPTION
[0030] To make the purpose, technical solutions and advantages of the embodiments of the present invention more clear, the embodiments of the present invention are further described in detail below with reference to the accompanying drawings. Here, the exemplary embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.
[0031] Embodiments of the present invention generally relate to computer technology, specifically to GDI+-based programming techniques for Windows systems, and more specifically to a coordinate conversion scheme for drawing using GDI+ (Graphics Device Interface). During drawing using GDI+, each piece of image data must be converted between actual coordinates, screen display coordinates, and system coordinates, which adds a significant workload to image drawing. Embodiments of the present invention achieve real-time conversion of these three coordinates through proportional conversion. Furthermore, when zooming in, out, or moving an image, coordinate transformations are calculated by establishing a base point, enabling fast GDI+ programming. This coordinate conversion scheme for drawing using the Graphics Device Interface is described in detail below.
[0032] Figure 1 FIG. 1 is a flow chart of a coordinate conversion method for graphics device interface plus drawing according to an embodiment of the present invention. Figure 1 As shown, the method includes the following steps:
[0033] Step 101: Determine the maximum and minimum values of the original drawn image;
[0034] Step 102: establishing an actual data coordinate system based on the maximum and minimum values of the original drawn image, and determining the actual coordinate data of the original drawn image;
[0035] Step 103: Establishing a screen display coordinate system based on the actual data coordinate system;
[0036] Step 104: Establishing a system coordinate system according to the screen display coordinate system;
[0037] Step 105: Convert the actual coordinate data of the original drawn image into screen display coordinate data according to the actual data coordinate system and the screen display coordinate system; determine the system coordinate data of the original drawn image according to the actual coordinate data of the original drawn image, the screen display coordinate data, and the pre-established system coordinate data.
[0038] In one embodiment, determining the system coordinate data of the original drawn image based on the actual coordinate data of the original drawn image, the screen display coordinate data, and a pre-established system coordinate data determination model may include: determining the system coordinate data of the original drawn image based on the following system coordinate data determination model:
[0039]
[0040] Among them, SX(x), SY(y) are the system coordinates of the original drawn image, W and H are the lengths of the system coordinate axes, and P x and P y is the starting point of the coordinates displayed on the screen, XL, YL are the actual data coordinate axis lengths, O x , O y is the origin of coordinates, x and y are the actual coordinates.
[0041] In specific implementation, the above-mentioned method of determining the system coordinate data of the original drawn image realizes efficient real-time conversion of three coordinates: system coordinates, screen display coordinates, and actual coordinates, further improving drawing efficiency.
[0042] In one embodiment, Figure 2 As shown, the coordinate conversion method of the graphics device interface plus drawing may further include: when receiving an operation instruction to zoom in or out of an image, executing the following coordinate conversion steps:
[0043] Step 201: Select a coordinate in the actual data coordinate system as a base point, and determine a model based on the actual coordinate data of the base point, the coordinate data displayed on the base point screen, and the pre-established system coordinate data to determine the system coordinate data of the base point;
[0044] Step 202: Determine the initial position of the base point according to the base point system coordinate data;
[0045] Step 203: determining the displacement between the preset coordinate point after being scaled up or down and the initial position of the base point;
[0046] Step 204: Determine the system coordinate data of the enlarged or reduced preset coordinate point according to the displacement.
[0047] In a specific implementation, the coordinate conversion implementation method for zooming in and out of an image further improves the drawing efficiency.
[0048] In one embodiment, determining the system coordinate data of the preset coordinate point after enlarging or reducing the displacement may include: determining the system coordinate data of the preset coordinate point after enlarging or reducing the displacement according to the following formula:
[0049]
[0050] Among them, RX(x), RY(y) are the system coordinates of the preset coordinate point after enlargement or reduction, rate is the magnification or reduction multiple, C x , C y It is the base point system coordinate data, SX(x), SY(y) are the current system coordinates of the preset coordinate point.
[0051] In specific implementation, the above-mentioned implementation method of determining the system coordinate data of the preset coordinate point after enlargement or reduction further improves the drawing efficiency.
[0052] In one embodiment, Figure 3 As shown, the coordinate conversion method of the graphics device interface plus drawing may further include: when receiving an operation instruction to move the image, executing the following coordinate conversion steps:
[0053] Step 301: Select a coordinate in the actual data coordinate system as a base point, and determine the current base point system coordinate data based on the actual coordinate data of the base point, the base point screen display coordinate data, and the pre-established system coordinate data.
[0054] Step 302: Determine the system coordinate data of the current preset coordinate point based on the current base point system coordinate data;
[0055] Step 303: Obtain the starting position coordinates and the ending position coordinates of the mouse;
[0056] Step 304: Determine the base point system coordinate data after the image is moved based on the mouse start position coordinates and the mouse end position coordinates;
[0057] Step 305: Determine the system coordinate data of the preset coordinate point after the image is moved according to the system coordinate data of the base point after the image is moved.
[0058] In a specific implementation, the coordinate conversion method for moving an image further improves the drawing efficiency.
[0059] In one embodiment, determining the system coordinate data of the current preset coordinate point based on the current base point system coordinate data may include: determining the system coordinate data of the current preset coordinate point according to the following formula:
[0060]
[0061] Among them, X(x) and Y(y) are the system coordinate data of the current preset coordinate point, CW, CH are the length and width of the entire screen, OC x , OC y is the coordinate of the current base point system, and rate is the multiple of enlargement or reduction.
[0062] In specific implementation, the above-mentioned implementation method of determining the system coordinate data of the current preset coordinate point further improves the drawing efficiency.
[0063] In one embodiment, determining the base point system coordinate data after the image is moved based on the mouse starting position coordinates and the mouse ending position coordinates may include: determining the base point system coordinate data after the image is moved according to the following formula:
[0064] C x =OC x +X(last x )-X(new x );
[0065] C y =OC y +Y(last y )-Y(new y );
[0066] Among them C x , C y is the coordinate of the base point system after moving, OC x , OC y is the current base point system coordinate, last x ,last y Is the starting point coordinate of the mouse movement, new x ,new y The coordinate point where the mouse ends.
[0067] In specific implementation, the above-mentioned implementation method of determining the base point system coordinate data after the image is moved further improves the drawing efficiency.
[0068] In summary, the embodiments of the present invention primarily address the issue of converting the relationship between actual coordinates, screen display coordinates, and system coordinates in GDI+ drawing. They provide a system and technology for automatically calculating these three types of data coordinates, making it easier for programmers to quickly implement GDI+ programming. This technology primarily includes a module for proportionally converting actual coordinates, screen display coordinates, and system coordinates for the original image (this module can apply steps 101 to 105 above), a module for coordinate conversion when zooming in and out of an image (this module can apply steps 201 to 204 above), and a module for data conversion when moving an image (this module can apply steps 301 to 305 above).
[0069] 1. Original image system coordinates, screen display coordinates, and actual coordinate conversion technology module
[0070] When drawing graphics, it is necessary to establish a coordinate system for the actual input data to determine the displayed graphics. The origin of this coordinate is set in the lower left corner, and the coordinate axis is based on the actual data. When the system is displayed, it is necessary to establish a screen display coordinate as a conversion medium between the actual coordinates and the system coordinates. The coordinate origin of the screen display coordinates is in the same position as the origin of the actual coordinates, and the length of the coordinate system is based on the length of the screen. The system coordinates are the real coordinates of the point in the system when the image is drawn. The coordinate origin of the system coordinates is in the upper left corner, and the length of the coordinate system is the actual length of the displayed screen. When drawing graphics, the conversion of the three coordinates can be achieved through proportional conversion. The screen display coordinates and actual coordinate system are shown in the figure below. Figure 4 As shown, the system coordinate system diagram is as follows Figure 5 shown.
[0071] 2. Coordinate conversion technology module for image zooming in and out
[0072] In practical applications, GDI+ drawing graphics requires other operations besides displaying graphics. The most common one is to zoom in or out of the entire graphic. When zooming in or out, the screen display coordinates and system coordinates corresponding to the actual coordinates will change. The previously calculated correspondence cannot correctly display the image, so the correspondence needs to be recalculated. This can be achieved through the following operations:
[0073] 1. Define the base point when the image is originally displayed. The coordinates of this base point are initially set to the center of the system coordinate axis.
[0074] 2. Calculate the displacement of the coordinates of a certain point data compared with the previous coordinates after zooming in or out.
[0075] 3. Calculate the new system coordinates of the point through displacement and redraw the display image.
[0076] 3. Coordinate transformation technology module when image moves
[0077] After the drawn image is enlarged, the screen display often cannot show the entire image, so some auxiliary operations are required to browse the entire image, such as moving the image with the mouse. During the mouse movement, the system coordinates of each data point will change with the mouse movement. The system needs to display the position change through real-time drawing. In order to quickly draw the image, it is necessary to calculate the system coordinates of each data point during the mouse movement. The specific steps are as follows:
[0078] 1. Calculate the system coordinate base point to locate the displacement between the image position and the original coordinates after the transformation. The base point is initially the center position of the system coordinates, and the data will be updated as the coordinates change.
[0079] 2. Get the system coordinates of the start and stop positions of the mouse movement and calculate the distance between them.
[0080] 3. Calculate the transformation ratio of the system coordinate displacement based on the magnification ratio and base point.
[0081] 4. Substitute the actual coordinates into the calculated system coordinates corresponding to the point and draw the image.
[0082] From the above, it can be seen that the beneficial technical effects of the coordinate conversion method for graphics device interface plus drawing provided by the embodiment of the present invention are:
[0083] GDI+ enables image drawing programming on Windows systems. GDI+ is powerful and can draw a variety of graphics, and is applied in many fields. In actual applications, the real-time conversion of system coordinates, screen display coordinates, and actual coordinates is a relatively difficult problem. This technology provides a method for real-time coordinate conversion, improving drawing efficiency.
[0084] 1. Coordinate system conversion in the original image case
[0085] like Figure 6 As shown, by finding the rules among the system coordinates, screen display coordinates and actual coordinates, the direct conversion of actual data to system coordinates is achieved through proportional calculation, and images can be quickly drawn for display.
[0086] 2. Coordinate transformation when the image is enlarged or reduced
[0087] GDI+ can be applied in many fields, so in the process of drawing, it is also necessary to be able to perform various interactive operations on the output image. A very important function is to zoom in and out of the image. Figure 7 As shown, by calculating the relationship between the coordinate systems, the coordinates can be converted in real time when the image is zoomed in or out, and the image can be quickly drawn and output, which is convenient for operation.
[0088] 3. Coordinate transformation when the image moves
[0089] like Figure 8 and Figure 9 As shown, when GDI+ is used to draw images, in order to facilitate viewing of image details, it is necessary to implement the function of moving the image with the mouse. During the movement, the system coordinates corresponding to the actual data are constantly changing. By converting the coordinates of the moving data, real-time image drawing is achieved when the mouse moves.
[0090] In order to facilitate understanding of how to implement the present invention, an example is given below for illustration.
[0091] 1. Original image system coordinates, screen display coordinates, and actual coordinate conversion
[0092] In actual application, the origin of the system coordinates is in the upper left corner, and the coordinates displayed on the screen are in the lower left corner. The display coordinates of the system are set according to the actual situation. Therefore, the actual data coordinates need to be converted into screen display coordinates first, and then converted into system coordinates.
[0093]
[0094] Where SX(x), SY(y) are the converted system coordinates, W and H are the lengths of the system coordinate axes, and P x and P y is the starting point of the coordinates displayed on the screen, XL, YL are the actual data coordinate axis lengths, O x , O y is the origin of the coordinate system, and x and y are the actual coordinates of the data.
[0095] 2. Coordinate transformation when the image is enlarged or reduced
[0096] When you need to zoom in or out on an image, the relationship between the system coordinates, screen coordinates, and user coordinates will change, and you need to adjust the relationship between the three coordinates according to the magnification.
[0097] First, you need to select a coordinate as the base point, which will be used as the only base point for judgment.
[0098] C x =CW / 2
[0099] C y =CH / 2
[0100] Among them C x ,C y is the system coordinate of the base point, CW, CH are the length and width of the entire screen.
[0101] Calculate the displacement of a point's coordinates relative to the base point and calculate the new system coordinates:
[0102]
[0103] Where RX(x) and RY(y) are the system coordinate values of the point after the zoom operation, rate is the zoom or reduction multiple, and C x , C y is the base point coordinate, SX(x), SY(y) are the system coordinates of the current data.
[0104] 3. Coordinate point position when moving the layer
[0105] When applying, it is sometimes necessary to move the image, and the coordinate position of the point corresponding to the mouse must be recalculated.
[0106] First, we need to calculate the position of the current point and the base point
[0107]
[0108] Where CW, CH are the length and width of the entire screen, OC x , OC y is the current base point coordinate value, and rate is the magnification or reduction multiple.
[0109] Then calculate the new base point position of the entire coordinate after the mouse moves the layer
[0110] C x =OC x +X(last x )-X(new x )
[0111] C y =OC y +Y(last y )-Y(new y )
[0112] Among them C x , C y Is the new base point coordinate after moving the layer, OC x , OC y is the base point coordinate before moving, last x ,last y Is the starting point coordinate of the mouse movement, new x ,new y The coordinate point where the mouse ends.
[0113] Then bring the new base point into the new system coordinates calculated by RX(x) and RY(y), and draw the image according to the new coordinates.
[0114] The present invention also provides a coordinate conversion device for a graphics device interface plus drawing, as described in the following embodiments. Because the principles of this device are similar to those of the coordinate conversion method for a graphics device interface plus drawing, the implementation of this device can be referenced to the implementation of the coordinate conversion method for a graphics device interface plus drawing, and any repetitions will not be repeated.
[0115] Figure 10 FIG. 1 is a structural diagram of a coordinate conversion device for a graphics device interface plus drawing in an embodiment of the present invention. Figure 10 As shown, the device includes:
[0116] Determining unit 01, used to determine the maximum value and the minimum value of the original drawn image;
[0117] The actual coordinate system establishing unit 02 is used to establish an actual data coordinate system according to the maximum and minimum values of the original drawn image, and determine the actual coordinate data of the original drawn image;
[0118] Screen display coordinate system establishing unit 03, used to establish the screen display coordinate system according to the actual data coordinate system;
[0119] The system coordinate system establishing unit 04 is used to establish the system coordinate system according to the screen display coordinate system;
[0120] The conversion unit 05 is used to convert the actual coordinate data of the original drawn image into the screen display coordinate data according to the actual data coordinate system and the screen display coordinate system; determine the system coordinate data of the original drawn image according to the actual coordinate data of the original drawn image, the screen display coordinate data, and the pre-established system coordinate data determination model.
[0121] In a specific implementation, the conversion unit is specifically used to: determine the model according to the following system coordinate data, and determine the system coordinate data of the original drawn image:
[0122]
[0123] Among them, SX(x), SY(y) are the system coordinates of the original drawn image, W and H are the lengths of the system coordinate axes, and P x and P y is the starting point of the coordinates displayed on the screen, XL, YL are the actual data coordinate axis lengths, O x , O y is the origin of coordinates, x and y are the actual coordinates.
[0124] In a specific implementation, the coordinate conversion device for the graphics device interface plus drawing may further include: a conversion unit corresponding to zooming operations, wherein the conversion unit corresponding to zooming operations is specifically configured to:
[0125] Select a coordinate in the actual data coordinate system as the base point, and determine the model based on the actual coordinate data of the base point, the coordinate data displayed on the base point screen, and the pre-established system coordinate data to determine the system coordinate data of the base point;
[0126] Determine the initial position of the base point according to the base point system coordinate data;
[0127] Determine the displacement between the preset coordinate point after it is scaled up or down and the initial position of the base point;
[0128] According to the displacement, the system coordinate data of the enlarged or reduced preset coordinate point is determined.
[0129] In a specific implementation, determining the system coordinate data of the preset coordinate point after enlarging or reducing according to the displacement includes: determining the system coordinate data of the preset coordinate point after enlarging or reducing according to the following formula:
[0130]
[0131] Among them, RX(x), RY(y) are the system coordinates of the preset coordinate point after enlargement or reduction, rate is the magnification or reduction multiple, C x , C y It is the base point system coordinate data, SX(x), SY(y) are the current system coordinates of the preset coordinate point.
[0132] In a specific implementation, the coordinate conversion device for the graphics device interface plus drawing further includes: a conversion unit corresponding to a movement operation, wherein the conversion unit corresponding to the movement operation is specifically used to:
[0133] Select a coordinate in the actual data coordinate system as the base point, and determine the model based on the actual coordinate data of the base point, the coordinate data displayed on the base point screen, and the pre-established system coordinate data to determine the current base point system coordinate data;
[0134] Determine the system coordinate data of the current preset coordinate point according to the current base point system coordinate data;
[0135] Get the mouse start and end position coordinates;
[0136] According to the coordinates of the mouse's starting position and ending position, the coordinate data of the base point system after the image is moved is determined;
[0137] The system coordinate data of the preset coordinate point after the image is moved is determined according to the system coordinate data of the base point after the image is moved.
[0138] In a specific implementation, the system coordinate data of the current preset coordinate point is determined according to the system coordinate data of the current base point, including: determining the system coordinate data of the current preset coordinate point according to the following formula:
[0139]
[0140] Among them, X(x) and Y(y) are the system coordinate data of the current preset coordinate point, CW, CH are the length and width of the entire screen, OC x , OC y is the coordinate of the current base point system, and rate is the multiple of enlargement or reduction.
[0141] In a specific implementation, determining the base point system coordinate data after the image is moved according to the mouse starting position coordinates and the ending position coordinates includes: determining the base point system coordinate data after the image is moved according to the following formula:
[0142] C x =OC x +X(last x )-X(new x );
[0143] C y =OC y +Y(last y )-Y(new y );
[0144] Among them C x , C y is the coordinate of the base point system after moving, OC x , OC y is the current base point system coordinate, last x ,last y Is the starting point coordinate of the mouse movement, new x ,new y The coordinate point where the mouse ends.
[0145] An embodiment of the present invention further provides a computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the coordinate conversion method for graphics device interface plus drawing is implemented.
[0146] An embodiment of the present invention further provides a computer-readable storage medium storing a computer program for executing the coordinate conversion method for graphics device interface plus drawing.
[0147] In an embodiment of the present invention, a coordinate conversion scheme of a graphics device interface plus drawing is compared with the technical scheme in the prior art that cannot realize the real-time conversion of the three coordinates of system coordinates, screen display coordinates, and actual coordinates, thereby causing obstacles to drawing. By: determining the maximum and minimum values of the original drawing image; establishing an actual data coordinate system according to the maximum and minimum values of the original drawing image, and determining the actual coordinate data of the original drawing image; establishing a screen display coordinate system according to the actual data coordinate system; establishing a system coordinate system according to the screen display coordinate system; converting the actual coordinate data of the original drawing image into screen display coordinate data according to the actual data coordinate system and the screen display coordinate system; determining the system coordinate data of the original drawing image according to the actual coordinate data of the original drawing image, the screen display coordinate data, and a pre-established system coordinate data determination model, the real-time conversion of the three coordinates of system coordinates, screen display coordinates, and actual coordinates is realized, thereby improving drawing efficiency.
[0148] It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0149] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0150] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0151] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0152] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A coordinate conversion method for graphics device interface plus drawing, characterized in that: include: Determine the maximum and minimum values of the original drawn image; According to the maximum and minimum values of the original drawn image, an actual data coordinate system is established, and the actual coordinate data of the original drawn image is determined; Establish the screen display coordinate system according to the actual data coordinate system; Establish the system coordinate system according to the screen display coordinate system; According to the actual data coordinate system and the screen display coordinate system, the actual coordinate data of the original drawn image is converted into screen display coordinate data; According to the actual coordinate data of the original drawing image, the screen display coordinate data, and the pre-established system coordinate data determination model, the system coordinate data of the original drawing image is determined to achieve the relationship conversion among the actual drawing coordinates, the screen display coordinates, and the system coordinates; When an operation instruction for zooming in or out of an image is received, the following coordinate conversion steps are performed: a coordinate is selected as a base point in the actual data coordinate system, and a model is determined based on the actual coordinate data of the base point, the coordinate data displayed on the screen of the base point, and the pre-established system coordinate data to determine the system coordinate data of the base point; an initial position of the base point is determined based on the system coordinate data of the base point; and a displacement between the preset coordinate point after it is proportionally enlarged or reduced and the initial position of the base point is determined; Determining system coordinate data of the enlarged or reduced preset coordinate point according to the displacement; The coordinate conversion method for graphics device interface plus drawing further includes: when receiving an operation instruction for moving an image, performing the following coordinate conversion steps: selecting a coordinate as a base point in the actual data coordinate system, and determining the system coordinate data of the current base point based on the actual coordinate data of the base point, the coordinate data displayed on the screen of the base point, and a pre-established system coordinate data determination model; determining the system coordinate data of the current preset coordinate point based on the current system coordinate data of the base point; Obtain the coordinates of the mouse's starting position and ending position; determine the base point system coordinate data after the image moves based on the mouse's starting position and ending position coordinates; and determine the system coordinate data of the preset coordinate point after the image moves based on the base point system coordinate data after the image moves.
2. The coordinate conversion method for graphics device interface plus drawing according to claim 1, characterized in that: Determining the system coordinate data of the original drawn image according to the actual coordinate data of the original drawn image, the screen display coordinate data, and the pre-established system coordinate data determination model includes: determining the system coordinate data of the original drawn image according to the following system coordinate data determination model: Among them, SX(x), SY(y) are the system coordinates of the original drawn image, W and H are the lengths of the system coordinate axes, and P x and P y is the starting point of the coordinates displayed on the screen, XL, YL are the actual data coordinate axis lengths, O x , O y is the origin of coordinates, x and y are the actual coordinates.
3. The coordinate conversion method for graphics device interface plus drawing according to claim 1, characterized in that: Determining the system coordinate data of the preset coordinate point after enlarging or reducing the displacement includes: determining the system coordinate data of the preset coordinate point after enlarging or reducing the displacement according to the following formula: Among them, RX(x), RY(y) are the system coordinates of the preset coordinate point after enlargement or reduction, rate is the magnification or reduction multiple, C x , C y It is the base point system coordinate data, SX(x), SY(y) are the current system coordinates of the preset coordinate point, CW, CH are the length and width of the entire screen, and x, y are the actual coordinates.
4. The coordinate conversion method for graphics device interface plus drawing according to claim 1, wherein: Determining the system coordinate data of the current preset coordinate point according to the current base point system coordinate data includes: determining the system coordinate data of the current preset coordinate point according to the following formula: Among them, X(x) and Y(y) are the system coordinate data of the current preset coordinate point, CW, CH are the length and width of the entire screen, OC x , OC y is the current base point system coordinate, rate is the magnification or reduction multiple, and x and y are the actual coordinates.
5. The coordinate conversion method for graphics device interface plus drawing according to claim 4, characterized in that: Determining the base point system coordinate data after the image is moved according to the mouse starting position coordinates and the ending position coordinates includes: determining the base point system coordinate data after the image is moved according to the following formula: C x =OC x +X(last x )-X(new x ); C y =OC y +Y(last y )-Y(new y ); Among them C x , C y is the coordinate of the base point system after moving, OC x , OC y is the current base point system coordinate, last x ,last y Is the starting point coordinate of the mouse movement, new x ,new y Is the coordinate point where the mouse ends, x, y are the actual coordinates, X(last x ) and Y(last y ) is the system coordinate data of the starting point coordinates of the mouse movement, X(new x ) and Y(new y ) is the system coordinate data of the coordinate point where the mouse ends.
6. A coordinate conversion device for graphics device interface plus drawing, characterized in that: include: a determining unit, configured to determine a maximum value and a minimum value of the original drawn image; An actual coordinate system establishing unit, for establishing an actual data coordinate system according to the maximum value and the minimum value of the original drawn image, and determining the actual coordinate data of the original drawn image; A screen display coordinate system establishing unit, used for establishing a screen display coordinate system according to an actual data coordinate system; A system coordinate system establishing unit, used for establishing a system coordinate system according to a screen display coordinate system; a conversion unit for converting the actual coordinate data of the original drawn image into screen display coordinate data according to the actual data coordinate system and the screen display coordinate system; and determining the system coordinate data of the original drawn image according to the actual coordinate data of the original drawn image, the screen display coordinate data, and a pre-established system coordinate data determination model, so as to realize the relationship conversion among the actual coordinates of the drawing, the screen display coordinates, and the system coordinates; The conversion unit corresponding to the zooming operation is used to: select a coordinate in the actual data coordinate system as a base point, and determine the model based on the actual coordinate data of the base point, the coordinate data displayed on the screen of the base point, and the pre-established system coordinate data to determine the system coordinate data of the base point; determine the initial position of the base point based on the system coordinate data of the base point; determine the displacement between the preset coordinate point after being proportionally enlarged or reduced and the initial position of the base point; Determining system coordinate data of the enlarged or reduced preset coordinate point according to the displacement; The conversion unit corresponding to the move operation is used to: select a coordinate as a base point in the actual data coordinate system, and determine the system coordinate data of the current base point based on the actual coordinate data of the base point, the coordinate data displayed on the base point screen, and the pre-established system coordinate data; determine the system coordinate data of the current preset coordinate point based on the current base point system coordinate data; Obtain the coordinates of the mouse's starting position and ending position; determine the base point system coordinate data after the image moves based on the mouse's starting position and ending position coordinates; and determine the system coordinate data of the preset coordinate point after the image moves based on the base point system coordinate data after the image moves.
7. The coordinate conversion device for graphics device interface plus drawing according to claim 6, characterized in that: The conversion unit is specifically configured to determine the model according to the following system coordinate data, and determine the system coordinate data of the original drawn image: Among them, SX(x), SY(y) are the system coordinates of the original drawn image, W and H are the lengths of the system coordinate axes, and P x and P y is the starting point of the coordinates displayed on the screen, XL, YL are the actual data coordinate axis lengths, O x , O y is the origin of coordinates, x and y are the actual coordinates.
8. The coordinate conversion device for graphics device interface plus drawing according to claim 6, characterized in that: Determining the system coordinate data of the preset coordinate point after enlarging or reducing the displacement includes: determining the system coordinate data of the preset coordinate point after enlarging or reducing the displacement according to the following formula: Among them, RX(x), RY(y) are the system coordinates of the preset coordinate point after enlargement or reduction, rate is the magnification or reduction multiple, C x , C y It is the base point system coordinate data, SX(x), SY(y) are the current system coordinates of the preset coordinate point, CW, CG are the length and width of the entire screen, and x, y are the actual coordinates.
9. The coordinate conversion device for graphics device interface plus drawing according to claim 6, characterized in that: Determining the system coordinate data of the current preset coordinate point according to the current base point system coordinate data includes: determining the system coordinate data of the current preset coordinate point according to the following formula: Among them, X(x) and Y(y) are the system coordinate data of the current preset coordinate point, CW, CH are the length and width of the entire screen, OC x , OC y is the current base point system coordinate, rate is the magnification or reduction multiple, and x and y are the actual coordinates.
10. The coordinate conversion device for graphics device interface plus drawing according to claim 9, characterized in that: Determining the base point system coordinate data after the image is moved according to the mouse starting position coordinates and the ending position coordinates includes: determining the base point system coordinate data after the image is moved according to the following formula: C x =OC x +X(last x )-X(new x ); C y =OC y +Y(last y )-Y(new y ); Among them C x , C y is the coordinate of the base point system after moving, OC x , OC y is the current base point system coordinate, last x ,last y Is the starting point coordinate of the mouse movement, new x ,new y Is the coordinate point where the mouse ends, x, y are the actual coordinates, X(last x ) and Y(last y ) is the system coordinate data of the starting point coordinates of the mouse movement, X(new x ) and Y(new y ) is the system coordinate data of the coordinate point where the mouse ends.
11. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the method according to any one of claims 1 to 5 is implemented.
12. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program for executing the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Method for implementing scaling and translation of GDI electronic vector map based on mouse position
CN104898947A