Page 1 of 1

Create Image from Drawing

Posted: 24 Jul 2013, 16:18
by roman
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

Re: Create Image from Drawing

Posted: 02 Aug 2013, 16:19
by support
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.