Page 1 of 1

Export in PNG and some transformations of entities

Posted: 07 Feb 2012, 17:58
by Chris13
Hello,

I am working on a .NET project and i have some tasks to perform from a DWG file.

First, i have to do an export to a png file in a 1920*1080 resolution.

Code: Select all

this._imageCAD = CADImage.CreateImageByExtension(pathToFile);
this._imageCAD.LoadFromFile(pathToFile);

DRect rect = new DRect();
rect.Height = 1080;
rect.Width = 1920;
   
this._imageCAD.SaveToFile("FondPlan.png", ImageFormat.Png, rect);
1/ This code works well for the png generation. But the generated file have a 1780*1080 resolution. I understand the function keeps the proportion, but can i fix it anyway with some white margin ?


2/ Then, i have to put some controls on my png file. So, i take the coordinates from my converter object.

Code: Select all

this._imageCAD.Converter.Entities
And i use the Box object, with the properties Top and Left.

Do you have some advices on how to do the transformation of the coordinate from a DWG file to PNG file ?

I already perform some transformation, but it's pretty hard to explain here, and maybe some functions do the work in the CAD import.

Thank you !

Re: Export in PNG and some transformations of entities

Posted: 13 Feb 2012, 14:48
by support
Hello.
You're correct, the resulting PNG image sizes corrected within SaveToFile method to keep the proportion. The method doesn't allow expand the output raster image by filling an additional parts.
CADImage.Converter.Entities represents a collection of entities of imported drawing. Box, Top and Left properties of an Entities member contains coordinates of this entity on drawing. CAD Import .NET doesn't provide a method for coordinates transformation between a drawing and the output raster image. However there is the CADImage.GetPoint method that transforms drawing coordinates to screen coordinates.

Alexander.