Convert dwg to jpg - Parameter is not valid

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
orenderi
Posts: 1
Joined: 05 Jul 2007, 14:49

Convert dwg to jpg - Parameter is not valid

Post by orenderi » 05 Jul 2007, 14:58

Hi,

I'm trying to convert DWG (3M) to jpg and getting Parameter is not valid exception in C# .NET 2.0.
For some DWG it works and for sone it's not. I think that it depends on the output image I request.

My code:

MemoryStream ms = new MemoryStream();
DWG.DWGImage dwgImage = new DWG.DWGImage();
dwgImage.LoadFromFile(openFileDialog1.FileName);

using (Graphics gr = this.CreateGraphics())
{
ImageFormat iFormat = ImageFormat.Jpeg;
imgName = @"C:\OUTPUT." + iFormat.ToString();
dwgImage.SaveToFile(imgName, iFormat, SetRealSize(dwgImage, gr));
}


Exception info:

dwgImage.SaveToFile method

{"Parameter is not valid."}
at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)
at CADImport.CADImage. (DRect , PixelFormat )
at CADImport.CADImage. (DRect , PixelFormat )
at CADImport.CADImage.SaveToFile(String FileName, ImageFormat ImgFormat, DRect curRect)
at AutoCADAPITester.Form1.backgroundWorker1_DoWork(Object sender, DoWorkEventArgs e) in C:\Documents and Settings\orend\Desktop\cadimportnet\AutoCADAPITester\Form1.cs:line 109
at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)

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

Post by support » 05 Jul 2007, 19:09

Hello!

Can you please send us your file which calls this exception?

Sergey.

Please post questions to the forum or write to support@cadsofttools.com

Post Reply