Page 1 of 1

save

Posted: 06 Jul 2016, 09:09
by roman
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

Re: save

Posted: 06 Jul 2016, 19:16
by support
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