Author Topic: XelVectors - load, save, render vector images in Pure Pascal SVG, EMF, WMF, CDR  (Read 1042 times)

Tomxe

  • Full Member
  • ***
  • Posts: 202
Reads vector formats, renders them (GDI+ on Windows, Cairo on Linux) and saves to SVG / EMF.
Reads formats:

  •     CDR
  •      CGM
  •      DWG
  •      DXF
  •      EMF
  •      MET
  •      ODG
  •      PS
  •      SVG
  •      WMF
  •      XAML

https://github.com/Xelitan/XelVectors---load-save-render-vector-images-in-Pure-Pascal


Add to your project xelvectors_pkg.lpk and XelVectors:

Code: Pascal  [Select][+][-]
  1. uses XelVectors;
  2.  
  3. var
  4.   Doc: TXVDocument;
  5.   Bmp: TBitmap;
  6. begin
  7.   Doc := TXVDocument.Create;
  8.   Bmp := TBitmap.Create;
  9.   try
  10.     Doc.LoadFromFile('rysunek.dwg');      // detect format
  11.     Bmp.SetSize(800, 600);
  12.     XVDrawToBitmap(Doc, Bmp);             // GDI+ (Windows) / Cairo (Linux)
  13.     Doc.SaveToFile('rysunek.svg');        // or .emf
  14.   finally
  15.     Bmp.Free;
  16.     Doc.Free;
  17.   end;
  18. end;
« Last Edit: October 28, 2026, 11:06:38 am by Tomxe »

zamtmn

  • Hero Member
  • *****
  • Posts: 706
Please add minimal example render file with zoom and pan?

Tomxe

  • Full Member
  • ***
  • Posts: 202
Demo added

zamtmn

  • Hero Member
  • *****
  • Posts: 706
Thanks!

Ed78z

  • Jr. Member
  • **
  • Posts: 92
Great!
Thank you.
I forgot to give you some .MET files plus my OS2MET reader/writer/renderer unit to include in your package.

I'll share them when I get back to my laptop!


[11/02/26]
https://forum.lazarus.freepascal.org/index.php/topic,75210.0.html
« Last Edit: November 03, 2026, 02:34:33 am by Ed78z »

Handoko

  • Hero Member
  • *****
  • Posts: 5569
  • My goal: build my own game engine using Lazarus
Thank you for sharing it.

I tested XelVector in my real AutoCAD projects, I found some bugs. Please see the attached picture below especially the objects that circled in green.
- The dim line markers are not rendered at the location where they should be
- Semi-transparent objects are rendered as opaque

Tomxe

  • Full Member
  • ***
  • Posts: 202
Thank you, Handoko. Could you upload a problematic AutoCad file?

Handoko

  • Hero Member
  • *****
  • Posts: 5569
  • My goal: build my own game engine using Lazarus
Here are the rendered issues:
- Dim line marker is not on the correct location
- Failed to render semi-transparent objects
- Incorrect line type and color
- Incorrect text color
- Failed to render arrow head
- Incorrect dimension's color and its line's color

Hobbit00

  • Jr. Member
  • **
  • Posts: 70
For what I know, external software (without a specific license of AutoDesk) can typically read version Autocad 2004 (or old R1.4 aka R14).

Who have implemented the ODA informations, last available format is about Autocad 2013.

Take care that no one can assert to read right a DWG file, since the format is "closed" and never public reveal.


Handoko

  • Hero Member
  • *****
  • Posts: 5569
  • My goal: build my own game engine using Lazarus
I re-saved the file as AutoCAD 2013 file format, still got the same problems.

Hobbit00

  • Jr. Member
  • **
  • Posts: 70
I re-saved the file as AutoCAD 2013 file format, still got the same problems.
My was only an explanation about historical.
I don't know how @TomXe implemented DWG reader so I don't know wich version is compatible with his works.

P.S.: one my simple DWG reader cannot read right your 2013 Dwg. This is surely about the not documented features of DWG. One of the free reader (eDrawings 2025) can read that file without issue (and the first one you posted too).

« Last Edit: November 02, 2026, 11:34:45 am by Hobbit00 »

Tomxe

  • Full Member
  • ***
  • Posts: 202
Thank you, please test it now

Handoko

  • Hero Member
  • *****
  • Posts: 5569
  • My goal: build my own game engine using Lazarus
Great job.
 ;D
 
Below is the screenshot for comparing AutoCAD 2018 format dwg file opened in XelVectors (left) and AutoCAD 2026 (right).

zamtmn

  • Hero Member
  • *****
  • Posts: 706
problem with hatchs. please check this file https://github.com/zamtmn/zcad/blob/master/environment/runtimefiles/AllCPU-AllOS/common/data/examples/test_dxf/hatches.dxf

It seems that only the first line of the pattern is drawn; there can be many lines, just like there can be many contours.
« Last Edit: November 04, 2026, 07:24:46 am by zamtmn »

Tomxe

  • Full Member
  • ***
  • Posts: 202
Thank you, fixed.

 

TinyPortal © 2005-2018