Templot Club Archive 2007-2020                             

topic: 3545metafiles!
author remove search highlighting
 
posted: 6 Nov 2019 00:07

from:

Martin Wynne
 
West Of The Severn - United Kingdom

click the date to link to this post
click member name to view archived images
view images in gallery view images as slides
I have been very feeble-brained. Just because everyone tells you a thing can't be done, it doesn't mean it can't be done. :)

Just to see what happened I wrote (in Lazarus):

var
  met_rect:TRect;
  met_handle:HWND;

begin
  met_rect:=Rect(0,0,800,600);
  met_handle:=CreateEnhMetaFile(0,nil,@met_rect,nil);

                                                     
It compiled and returned a valid metafile handle!

That means I'm well on the way to replicating the Delphi TMetafile functions.

Wish me luck. :)

Martin.

posted: 6 Nov 2019 00:19

from:

Rob Manchester
 
Manchester - United Kingdom

click the date to link to this post
click member name to view archived images
view images in gallery view images as slides
Good luck Martin :)

Rob


posted: 6 Nov 2019 00:50

from:

Martin Wynne
 
West Of The Severn - United Kingdom

click the date to link to this post
click member name to view archived images
view images in gallery view images as slides
Thanks Rob. :)

Seriously it is only a start. And it is Windows only.

But if I could get it going it would put a much brighter outlook on moving everything to T3 a lot sooner.

cheers,

Martin.

posted: 6 Nov 2019 02:12

from:

Graeme
 
Bangkok - Thailand

click the date to link to this post
click member name to view archived images
view images in gallery view images as slides
Martin Wynne wrote: 
And it is Windows only. ...


A relatively minor glitch - this is still great news!

Good luck as you move on with it.

Cheers,

graeme
Last edited on 6 Nov 2019 02:13 by Graeme
posted: 7 Nov 2019 11:21

from:

Martin Wynne
 
West Of The Severn - United Kingdom

click the date to link to this post
click member name to view archived images
view images in gallery view images as slides
I'm pleased to say that after several trips round the houses I've got something working which I think we can live with. It's a bit clunky -- several things which would have worked in Delphi don't seem to work in Lazarus. That might become clearer when I've spent a lot more time on Lazarus.

But I think we have enough to provide the EMF exports (no WMF -- there are online converters if anyone wants the old WMF format), and the print-page previews.

Whether it is enough to work in the Sketchboard remains to be seen. Because of licensing issues that will have to be in a separate helper exe anyway, at least for the present.

It might even become a separate program in its own right TemplotSketch (closed-source). :)

Likewise TemplotPDF perhaps, for the PDF export, which also relies on metafiles.

cheers,

Martin.

posted: 10 Nov 2019 02:11

from:

Martin Wynne
 
West Of The Severn - United Kingdom

click the date to link to this post
click member name to view archived images
view images in gallery view images as slides
The metafile export is now working in T3 quite well. :)

Metafiles are vector files. That's great because instead of containing an actual image, they contain the instructions for drawing the image. Which means they don't have a fixed size and can be drawn crisply into a specified rectangle of any size.

What has surprised me is how few graphics programs are able to handle metafiles properly. In fact I haven't found any. Gimp and Inkscape won't load them at all. Irfanview and Microsoft Paint convert them to bitmaps on loading, which means loading is very slow, and likewise panning and scrolling. An old version of PaintShopPro which I use a lot has the wit to ask you what size to load a metafile into before doing so, but then makes a mess of the aspect ratio. All of them crash up with a layout-sized metafile.

The one shining exception is Templot's sketchboard. :) Which loads metafiles fast, and keeps them as metafiles so that panning and zooming is almost instant. (Provided that is that you don't rotate them.)

Consider for example this section of track plan in EM. It is 11ft x 2ft-6in, or 132" x 30". I exported an EMF metafile from T3 recorded at 600 DPI resolution (for best quality printing):

2_092034_260000000.png2_092034_260000000.png

If that is rendered as a bitmap at 600 DPI (dots-per-inch), it presents an image

 79200 x 18000 = 1425600000 dots or 1425 Megapixels.

A typical image from a good DSLR camera is 24 Megapixels. So it's obvious that any software which converts the EMF to a bitmap at the native recorded size is going to struggle. It's equivalent to displaying 60 such camera images simultaneously.

But as a metafile it loads quickly into the Sketchboard and zooms and pans almost instantly. This is the T2 sketchboard:

2_092043_300000000.png2_092043_300000000.png

The reason being that the sketchboard ignores the original recorded size of the metafile (other than to calculate the aspect ratio), and waits for you to drag the rectangle into which you want it to be drawn.

What does all this tech stuff mean? It means I can get the print-pages preview function into T3 for Paul. It means I can see a way forward to providing the sketchboard in T3 by means of a separate helper exe. Ditto and likewise the PDF exports.

I will get the print preview done in the next few days, and then tidy up some loose ends so that a first release of T3 can be made (version 291a), and I can post the code.

p.s. before anyone else notices it, yes the K-crossing timbering setting needs changing for EM. :)

Windows metafiles are ancient, originating in the old 16-bit Windows days. They were updated to 32-bit for Windows 95 (enhanced metafile, EMF), but apart from that they haven't changed since. The modern equivalent is SVG vector images, which are primarily for the web. If we ever wanted to port T3 to Apple Macs, we would probably have to swap to using SVG. I'm going to leave that as a project for someone else. :)
cheers,

Martin.

posted: 10 Nov 2019 15:21

from:

Martin Wynne
 
West Of The Severn - United Kingdom

click the date to link to this post
click member name to view archived images
view images in gallery view images as slides
The reason the sketchboard makes a better job of metafiles than most is that each record within the EMF file is drawn separately. That makes possible a sketchboard feature which you may not have noticed. Lines and fills in metafiles can be edited directly on the sketchboard, there is no need to go back to the output menu on the sketchboard to make such changes:

2_101012_140000000.png2_101012_140000000.png

This could be useful when creating colourful diagrams, control panels, etc.

cheers,

Martin.



about Templot Club

Templot Companion - User Guide - A-Z Index Templot Explained for beginners Please click: important information for new members and first-time visitors.
indexing link for search engines

back to top of page


Please read this important note about copyright: Unless stated otherwise, all the files submitted to this web site are copyright and the property of the respective contributor. You are welcome to use them for your own personal non-commercial purposes, and in your messages on this web site. If you want to publish any of this material elsewhere or use it commercially, you must first obtain the owner's permission to do so.
The small print: All material submitted to this web site is the responsibility of the respective contributor. By submitting material to this web site you acknowledge that you accept full responsibility for the material submitted. The owner of this web site is not responsible for any content displayed here other than his own contributions. The owner of this web site may edit, modify or remove any content at any time without giving notice or reason. Problems with this web site? Contact webmaster@templot.com.   This web site uses cookies: click for information.  
© 2020  

Powered by UltraBB - © 2009 Data 1 Systems