save

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
roman
Posts: 43
Joined: 11 Aug 2011, 11:43

save

Post by roman » 06 Jul 2016, 09:09

Hello,

it is possible to draw on a CADRasterImage but it seems not to be possible to save the drawing.

Is there any possiblity to save the CadRasterImage. We need to load / save the image as "project" so the customer can save the work and then continue. (All CADEntities and Images must be on the same position inside the Image)

I found the code for saveAsDXF, but it seems to exit if it's an CadRasterImage:

Code: Select all

private void miSaveAsDXF_Click(object sender, System.EventArgs e)
		{
			if(this.cadImage == null) 
				return;
			if(this.saveDXFDlg.ShowDialog() != DialogResult.OK) 
				return;
			SaveAsDXF(this.saveDXFDlg.FileName);
		}

		private void SaveAsDXF(string fName)
		{
			#region Export
#if Export
			if(cadImage == null) return;
			if(cadImage is CADRasterImage) 
			{
				return;
			}
			CADImport.Export.DirectCADtoDXF.CADtoDXF vExp = new CADImport.Export.DirectCADtoDXF.CADtoDXF(cadImage);
			vExp.SaveToFile(fName);
#else
				MessageBox.Show("Not supported in current version!", "CAD .NET");
#endif
			#endregion Export			
		}
Is there another save method, or how can I save the Image,

Thank you,
Roman

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

Re: save

Post by support » 06 Jul 2016, 19:16

Hello Roman,

CADRasterImage object is intended for loading raster images and doesn't vectorize (convert to vector objects) the raster graphics. So, the DXF export doesn't make sense for the CADRasterImage. However, it is possible to save the CADRasterImage object to a raster format (JPEG, for example):

Code: Select all

using CADImport;
using CADImport.RasterImage;
using System.Drawing.Imaging;
...


private void miSaveAsJPEG_Click(object sender, EventArgs e)
{
    if (cadImage != null)
    {
        DRect imageSize = new DRect(0, 0, cadImage.AbsWidth, cadImage.AbsHeight);
        cadImage.SaveToFile(Path.ChangeExtension(fileName, ".jpg"), ImageFormat.Jpeg, imageSize);
    }
}
Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply