Page 1 of 1

HPGL to BMP

Posted: 10 Aug 2016, 21:15
by sugi
Hi,

I'm trying to convert an HPGL image to bitmap using your demo library.

Code: Select all

using CADImport.HPGL2;
using System.Drawing.Imaging;
//...
HPGLImage img = new HPGLImage();
img.LoadFromFile(@"C:\00006.hpgl");
img.SaveToFile(@"C:\00006.bmp", ImageFormat.Bmp, img.Extents, PixelFormat.Format24bppRgb);
However, the result is just a blank image 146x201 pixels. Why? The HPGL source file is attached.

Addionally, how can I specify the resolution when saving a bitmap (e.g. 150 DPI)?

Re: HPGL to BMP

Posted: 11 Aug 2016, 16:01
by support
Hello,

It seems that the problem is caused by using img.Extents in the SaveToFile method. Please try the following code, it produces a larger bitmap file:

Code: Select all

using CADImport;
using CADImport.HPGL2;
using System.Drawing.Imaging;
...

CADImage img = HPGLImage.CreateImageByExtension(@"C:\00006.hpgl");
img.LoadFromFile(@"C:\00006.hpgl");
DRect imageSize = new DRect(0, 0, img.AbsWidth * 5, img.AbsHeight * 5);
img.SaveToFile(@"C:\00006.bmp", ImageFormat.Bmp, imageSize, PixelFormat.Format24bppRgb);
As for setting the resolution (DPI) for the output bitmap file, I'll explain it in a separate topic. Stay tuned!


Mikhail

Re: HPGL to BMP

Posted: 11 Aug 2016, 21:05
by support
Addionally, how can I specify the resolution when saving a bitmap (e.g. 150 DPI)?
Please take a look at How to specify a DPI when saving to a BMP file topic.


Mikhail