How to export DXF to PNG?
Moderators: SDS, support, admin
-
- Posts: 8
- Joined: 20 Jan 2015, 12:46
How to export DXF to PNG?
I have DXFs that I want to convert to PNG. What's the best option to achieve this?
Re: How to export DXF to PNG?
Hello,
You should use the following approach:
You should use the following approach:
- Create a new TBitmap instance and draw CAD image graphics on the TBitmap.Canvas.
Code: Select all
function DrawToBitmap(AGraphic: TGraphic): TBitmap; begin Result := TBitmap.Create; Result.Width := AGraphic.Width; Result.Height := AGraphic.Height; Result.Canvas.StretchDraw(Rect(0, 0, AGraphic.Width, AGraphic.Height), AGraphic); end;
- Create a new TPNGImage instance and copy the contents of the created TBitmap using a TPNGImage.Assign method.
Code: Select all
var vBitmap: TBitmap; vPNGImage: TPNGImage; ... vBitmap := DrawToBitmap(CADImage); vPNGImage := TPNGImage.Create; vPNGImage.Assign(vBitmap);
- Save the PNG graphics to a file.
Code: Select all
var sFileName: string; ... vPNGImage.SaveToFile(sFileName);
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 8
- Joined: 20 Jan 2015, 12:46
Re: How to export DXF to PNG?
Thanks, Mikhail!
This works fine. I just had to make the PNG bigger than the DXF to avoid staircase effects.
Best regards,
Uli
This works fine. I just had to make the PNG bigger than the DXF to avoid staircase effects.
Best regards,
Uli
-
- Posts: 2
- Joined: 23 Mar 2020, 21:43
Re: How to export DXF to PNG?
THanks for the explanations! I did find about how to save the file as a .png myself, but couldn't find how to deal with the staircase effect. It's all good now, thanks again!