Load DWG Image and Save To EMF File
Moderators: SDS, support, admin
Load DWG Image and Save To EMF File
Hi,
I was trying to do the following, with slightly changed code to your CADViewerDemo.
The change is adding the imageFileName variable which is
used in SaveAsImage to specify the name of the image without any user interaction.
LoadFile code is unchanged.
Here is the SaveAsImage code.
Unfortunately, I cannot get this to work correctly. The created EMF is only 1K in size. Is there some requirement to load the cadImage into a PictureBox first before it is able to be saved as an image?
Regards
Andrew
I was trying to do the following, with slightly changed code to your CADViewerDemo.
The change is adding the imageFileName variable which is
used in SaveAsImage to specify the name of the image without any user interaction.
Code: Select all
CADImportNetDemos.CADViewerDemo.MainForm form = new CADImportNetDemos.CADViewerDemo.MainForm();
form.openFileName = FileName;
form.imageFileName = imageFileName;
form.LoadFile(FileName);
form.SaveAsImage();
Here is the SaveAsImage code.
Code: Select all
public void SaveAsImage()
{
if (cadImage == null)
return;
this.cadImage.DefaultColor = Color.Black;
this.cadImage.DefaultColor = CADImport.CADConst.clNone;
DRect tmpRect = new DRect(0, 0, 1000,1000);
ImageFormat imgFrm = ImageFormat.Emf;
int tmpNumberOfPartsInCircle = this.cadImage.NumberOfPartsInCircle;
this.cadImage.NumberOfPartsInCircle = CADConst.SetNumberOfPartsInCurve(tmpRect);
if ((imgFrm == ImageFormat.Emf) || (imgFrm == ImageFormat.Wmf))
cadImage.ExportToMetafile(imageFileName, tmpRect);
else
cadImage.SaveToFile(imageFileName, imgFrm, tmpRect, PixelFormat.Format24bppRgb);
this.cadImage.NumberOfPartsInCircle = tmpNumberOfPartsInCircle;
}
Regards
Andrew
Re: Load DWG Image and Save To EMF File
Hello Andrew,
Please try the following code:
Sergey.
Please try the following code:
Code: Select all
if(this.cadImage == null)
{
this.cadImage = new CADImage();
this.cadImage.InitialNewImage();
this.cadImage.UseDoubleBuffering = false;
}
cadImage.LoadFromFile(@"c:\Test.dxf");
DRect tmpRect = new DRect(0, 0, 1000,1000);
ImageFormat imgFrm = ImageFormat.Emf;
int tmpNumberOfPartsInCircle = this.cadImage.NumberOfPartsInCircle;
this.cadImage.NumberOfPartsInCircle = CADConst.SetNumberOfPartsInCurve(tmpRect);
cadImage.ExportToMetafile(@"c:\Test.emf", tmpRect);
this.cadImage.NumberOfPartsInCircle = tmpNumberOfPartsInCircle;
this.cadPictBox.Invalidate();
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support