Can't export DWG to big enough image
Posted: 26 Jan 2018, 15:34
Hi!
I'm trying to export dwg to tiff file. The drawing is on A0 format sheet, so to see clear text I need the dpi be quite high (more then 300).
I use this method:
CADImport.CADImage.SaveToFile(string FileName, ImageFormat ImgFormat, DRect curRect, PixelFormat pixelFormat)
But resulted images are not bigger in the bigger side then 5000 pixels, regardless of given size in curRect argument.
It turns out that there is a static field CADConst.MaxRasterImageSize that represents that limit.
By setting this field to 10000, I get exception when trying to save images with somewhat around 300 000 000 pixel.
I'm trying to export dwg to tiff file. The drawing is on A0 format sheet, so to see clear text I need the dpi be quite high (more then 300).
I use this method:
CADImport.CADImage.SaveToFile(string FileName, ImageFormat ImgFormat, DRect curRect, PixelFormat pixelFormat)
Code: Select all
public void SaveImage(string sourceFile, string filename, int resolution)
{
var cadImage = CADImage.CreateImageByExtension(sourceFile);
cadImage.IsWithoutMargins = true;
cadImage.LoadFromFile(sourceFile);
var pExtentse = cadImage.PureExtents;
DRect tmpRect = new DRect(0, 0, (pExtentse.Width / 25.4) * resolution, (pExtentse.Height / 25.4) * resolution);
cadImage.Painter.Settings.BackgroundColor = Color.White.ToArgb();
cadImage.Painter.Settings.IsShowBackground = true;
cadImage.SaveToFile(filename, ImageFormat.Tiff, tmpRect);
}
It turns out that there is a static field CADConst.MaxRasterImageSize that represents that limit.
By setting this field to 10000, I get exception when trying to save images with somewhat around 300 000 000 pixel.
Can you suggest the solution for my problem? What I need is to able to save images in maximum possible size(I know about limitation of GDI).Exception thrown: 'System.Runtime.InteropServices.ExternalException' in System.Drawing.dll
System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
в System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
в System.Drawing.Image.Save(String filename, ImageFormat format)
в CADImport.CADGraphicsGDI.SaveToFile(String FileName, ImageFormat ImgFormat, DRect curRect, PixelFormat pixelFormat, RectangleF rect, Graphics e)
в CADImport.CADGraphicsGDI.SaveToFile(String FileName, ImageFormat ImgFormat, DRect curRect, RectangleF rect, Graphics e)
в CADImport.CADImage.SaveToFile(String FileName, ImageFormat ImgFormat, DRect curRect)