Главная страница | назад





Article #16842: How can I place a bitmap in a Metafile?

 Question and Answer Database

FAQ1842D.txt   How can I place a bitmap in a Metafile?
Category   :VCL
Platform    :All
Product    :All 32 bit  

Question:
How can I place a bitmap in a Metafile?

Answer:
The following example demonstrates drawing a bitmap into a
metafile.

Example:

procedure TForm1.Button1Click(Sender: TObject);
 var
   m : TmetaFile;
   mc : TmetaFileCanvas;
   b : tbitmap;
begin
  m := TMetaFile.Create;
  b := TBitmap.create;
  b.LoadFromFile('C:\SomePath\SomeBitmap.BMP');
  m.Height := b.Height;
  m.Width := b.Width;
  mc := TMetafileCanvas.Create(m, 0);
  mc.Draw(0, 0, b);
  mc.Free;
  b.Free;
  m.SaveToFile('C:\SomePath\Test.emf');
  m.Free;
  Image1.Picture.LoadFromFile('C:\SomePath\Test.emf');
end;


7/16/98 4:31:28 PM
 

Last Modified: 01-SEP-99