This project is read-only.

GdiPlusX & Metafiles

Topics: General
Oct 29, 2008 at 10:37 AM
Dear All,
Trying to get on with new 1.20 beta version. 
I am particularly interested in metafiles; Are there any samples (demo project/elsewhere)
on creating and using metafiles.

Any other references on using metafile (NET etc) would be helpfull as well.

Oct 29, 2008 at 1:52 PM
Edited Oct 29, 2008 at 2:48 PM
Hi Sergio,

The easiest way right now is to call the new Method "DrawReport()" from the ImageCanvas object.
It returns the FULLPATH file for the EMF drawn image.

You may use it in any PictureObject, this will allow you to obtain the best resizing.

Unfortunately, we can't use PictureVal with EMFs, but using Pictures stored in the disk the result is quite good.

The EMF file is stored in the temporary folder of your machine, and is deleted when the ImageCanvas object is released.
Creating EMF files from scratch is simple as well:

LOCAL lcEMFFile, lnEMFType
LOCAL loRect as xfcRectangle
LOCAL loEMF as xfcMetafile

WITH _SCREEN.System.Drawing

lcEMFFile = ADDBS(SYS(2023))+SYS(2015)+".emf"

lnEMFType = _Screen.System.Drawing.Imaging.MetafileType.EmfPlusOnly
* The available options:
* .Imaging.MetafileType.Emf - bad quality
* .Imaging.MetafileType.EmfPlusDual - nice quality, big size
* .Imaging.MetafileType.EmfPlusOnly - returns the best quality and the smaller size

m.loRect = .Rectangle.New(0,0,m.tnWidth,m.tnHeight)

m.loEMF = .Imaging.Metafile.New(m.lcTempFile, 0, ;
   m.loRect, ;
   .Imaging.MetafileFrameUnit.Pixel, ;

m.loGFX = .Graphics.FromImage(m.loEMF)

* Then, do all the drawings normally, using all the Graphics methods and properties that you desire
* Everything that you usually do in the "BeforeDraw" method

* loGfx.SmoothingMode =
* loGfx.TextRenderingHint =
* loGfx.InterpolationMode = 
* loGfx.DrawImage(
* loGfx.DrawRectangle(



Then, just look at your EMF file, and play with it, resizing the images!
Hope this helps you to get started !



Nov 1, 2008 at 10:51 PM
Edited Nov 1, 2008 at 11:03 PM
That worked great! Thks+++

How about writing EMF inside ImageCanvas or other surface.
For instance I want to draw existing EMF (There is one great charting tool called FoxCharts...;)
onto ImageCanvas.  Is is like wrinting ordinary bitmap or there is something else needed
for Emf to be written ?