首页 > 代码库 > 在MetaFile里放图片

在MetaFile里放图片

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;

 

 

  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;

 

在MetaFile里放图片