Create Image from Drawing

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

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

Create Image from Drawing

Post by roman » 24 Jul 2013, 16:18

Hello,

is there a possibility to set the DPI for the CADImage.Draw(graphics, rectangleF) method. I'd like to export a given CADImage to an in memory BMP and use it for a custom printing system. At the moment i just can print in low / screen resolution.

My Code:

Code: Select all

            RectangleF imageRect = cadEditorControl1.ImageRectangleF;
            Bitmap bmp = new Bitmap(cadEditorControl1.PictureBox.Size.Width, cadEditorControl1.Size.Height);
            Graphics g = Graphics.FromImage(bmp);
            g.InterpolationMode = InterpolationMode.HighQualityBicubic;
            g.SmoothingMode = SmoothingMode.HighQuality;
            g.PixelOffsetMode = PixelOffsetMode.HighQuality;
            g.CompositingQuality = CompositingQuality.HighQuality;
            g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
            cadEditorControl.Image.Draw(g, imageRect);
            
            //=> my printing system:           
            CadPrinter p = new CadPrinter(bmp);
using
bmp.SetResolution(dpi, dpi);
doesn't work because the image DPI are changed, but the real size also changes. I can fix this by changing the bmp image, but the CADIMAGE seems to be drawn in ~96DPI.

Thank you for your help,
Roman

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

Re: Create Image from Drawing

Post by support » 02 Aug 2013, 16:19

Hello roman.
Sorry, we're not sure that is the problem with printing. CADImage.Draw outputs the image with sizes in pixels, but DPI for Graphics object have specified values still. The physical sizes for printing can be calculated based on sizes in pixels and DPI.

Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply