Export in PNG and some transformations of entities

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
Chris13
Posts: 1
Joined: 07 Feb 2012, 17:31

Export in PNG and some transformations of entities

Post by Chris13 » 07 Feb 2012, 17:58

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 !

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: Export in PNG and some transformations of entities

Post by support » 13 Feb 2012, 14:48

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.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply