Kylix
Tips

NEW TIPS
Database (135)
Files (612)
Forms (606)
Graphic (536)
IDE (456)
Indy (433)
Internet / LAN (590)
IntraWeb (443)
Kylix (447)
Math (561)
Misc (591)
Multimedia (496)
Objects/
ActiveX (503)

OpenTools API (438)
Printing (459)
Strings (583)
System (721)
VCL (586)

Search Tip
Top15
Add new Tip

Forum

...convert a Bitamp to a emf (Enhanced Metafile)?
Author: Thomas Stutz
[ Print tip ]    

Tip Rating (4):  
     



function bmp2emf(const SourceFileName: TFileName): Boolean;
// Converts a Bitmap to a Enhanced Metafile (*.emf)
var
  
Metafile: TMetafile;
  MetaCanvas: TMetafileCanvas;
  Bitmap: TBitmap;
begin
  
Metafile := TMetaFile.Create;
  try
    
Bitmap := TBitmap.Create;
    try
      
Bitmap.LoadFromFile(SourceFileName);
      Metafile.Height := Bitmap.Height;
      Metafile.Width  := Bitmap.Width;
      MetaCanvas := TMetafileCanvas.Create(Metafile, 0);
      try
        
MetaCanvas.Draw(0, 0, Bitmap);
      finally
        
MetaCanvas.Free;
      end;
    finally
      
Bitmap.Free;
    end;
    Metafile.SaveToFile(ChangeFileExt(SourceFileName, '.emf'));
  finally
    
Metafile.Free;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  
bmp2emf('C:\TestBitmap.bmp');
end;

Rate this tip:

poor
very good


Copyright © Torry's Delphi Pages Torry's Delphi Pages Maintained by Simon Grossenbacher Notes? Comments? Feel free to send... Copyright © 1996-2001