Thema: Delphi Bitmap-->Metafile

Einzelnen Beitrag anzeigen

Benutzerbild von eddy
eddy

Registriert seit: 3. Jan 2003
Ort: Sachsen
573 Beiträge
 
Delphi 5 Professional
 
#4

Re: Bitmap-->Metafile

  Alt 18. Feb 2004, 13:30
Hallo Jörn,

probier' mal das:
Code:
{ ...ein Bitmap in ein emf (Enhanced Metafile) umwandeln? 
BMP --> Metafile
Quelle: http://www.swissdelphicenter.ch/de/showcode.php?id=1000}

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;
Nicht von mir getestet, aber vielleicht kommst Du ja weiter.

mfg
eddy
  Mit Zitat antworten Zitat