Convert dwg to jpg - Parameter is not valid
Moderators: SDS, support, admin
Convert dwg to jpg - Parameter is not valid
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)
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)
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
Can you please send us your file which calls this exception?
Sergey.
Please post questions to the forum or write to support@cadsofttools.com