views:

103

answers:

3
+1  Q: 

Convert emf to bmp

Hi,

How can convert emf to bmp with delphi 2010?

+1  A: 

Try something like:

var
  bmp: TBitmap;
  wmf: TMetafile;
bmp.SetSize(wmf.Width, wmf.Height);
bmp.Canvas.Draw(0, 0, wmf);
Ulrich Gerhardt
@Ulrich thank you !
Branko
+3  A: 

Use this code

procedure ConvertEMF2BMP(EMFFileName, BMPFileName: String) ;
var
   MetaFile : TMetafile;
   Bitmap : TBitmap;
begin
   Metafile := TMetaFile.Create;
   Bitmap := TBitmap.Create;
   try
     MetaFile.LoadFromFile(EMFFileName) ;
     with Bitmap do
     begin
       Height := Metafile.Height;
       Width := Metafile.Width;
       Canvas.Draw(0, 0, MetaFile) ;
       SaveToFile(BMPFileName) ;
     end;
   finally
     Bitmap.Free;
     MetaFile.Free;
   end;
end;
Bharat
@Bharat thank you !
Branko
+3  A: 

If you want to draw the EMF with Anti-Aliaising, you can use our freeware SynGdiPlus library:

Gdip := TGDIPlusFull.Create;
MF := TMetaFile.Create;
MF.LoadFromFile(Files[Tag]);
Bmp := Gdip.DrawAntiAliased(MF,100,100); // 100% zoom in both axis
img1.Picture.Assign(Bmp);

The drawing is done using GDI+, so the rendering will be much better than the direct Canvas.Draw direct method. You could try to use basis anti-aliaising by stretching the bitmap to a smaller size, but in this case, the font rendering will be alterated. Our native GDI+ drawing produces better rendering quality. See http://synopse.info/forum/viewtopic.php?id=10

A.Bouchez