About convert dwg to png background and line color

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
pujols
Posts: 4
Joined: 24 May 2017, 10:03

About convert dwg to png background and line color

Post by pujols » 24 May 2017, 10:58

Hi, I try convert dwg to png,
sample code:

Code: Select all

CADImage cadImage = CADImage.CreateImageByExtension(sourceFile);
cadImage.LoadFromFile(sourceFile);
DRect boundaryRectangle = new DRect(left, top, width, height);
Rectangle rect = new Rectangle(left, top, width, height);
cadImage.SaveToFile(outFileName, ImageFormat.Png, boundaryRectangle, rect);
the result show white background and black line as follows
img2.gif
img2.gif (101.12 KiB) Viewed 14525 times
dwg file in DWG TrueView show black background and white line as follows
img1.png
img1.png (252.28 KiB) Viewed 14525 times
I want to export png that all colors are same as show in DWG TrueView

I try add

Code: Select all

cadImage.BackgroundColor = Color.Black;
the result png background color is black, and line is still black.
how do I export png that all colors as same as dwg in DWG TrueView?
is CAD.NET auto change line color according to background color?

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

Re: About convert dwg to png background and line color

Post by support » 25 May 2017, 17:03

Hello,

CAD .NET doesn't change the objects color automatically, depending on the background color. You will need to adjust the default color for objects and the background color before saving to a file, as follows:

Code: Select all

cadImage.Painter.Settings.BackgroundColor = Color.Black.ToArgb();
cadImage.Painter.Settings.DefaultColor = Color.White.ToArgb();
Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply