Closed srudin closed 1 year ago
Only the information from the image is not enough. Like with any other transformation three things are required a scale, a rotation, and a translation. You need to know how the image was created:
Then you can build a transformation matrix to convert from one coordinate system to another. The only additional thing to take care is that the drawing space is continuous while an image space is discreet (a pixel is the smallest unit), but that can be easily be handled using the resolution of the image (dpi).
Ok, I will try, thx!
KNOWLEDGE: Experienced programmer but almost no experience with CAD functionality or DXF model.
GOAL: I have some DXF files and need to convert them to an image and display that image on a website. Using html/javascript I then need to add some interactive polygons (e.g. they can be clicked, change colors etc.) over the image. The polygons refer to entities ("inserts" I think?) that are defined in the DXF files already.
PROBLEM 1: I cannot export/convert the DXF files to images. I saw that there are other libraries who can do that - is it correct that netDxf does not support that?
PROBLEM 2: As I was not able to export/convert I used a free online converter and got a jpg image from there. I now tried to paint the polygons on the image but don't understand how to transform the values from the DXF coordinates to the image coordinates. Are there any helper classes or what is the formula to do that?
CODE: For better understanding here is some of the trial code I have created so far (I know the logic around the new points is totally wrong):