HPGL to BMP

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
sugi
Posts: 4
Joined: 10 Aug 2016, 20:33

HPGL to BMP

Post by sugi » 10 Aug 2016, 21:15

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)?
Attachments
00006.zip
(71.74 KiB) Downloaded 1268 times

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

Re: HPGL to BMP

Post by support » 11 Aug 2016, 16:01

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
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

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

Re: HPGL to BMP

Post by support » 11 Aug 2016, 21:05

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
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply