Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi Bitmap-->Metafile (https://www.delphipraxis.net/16384-bitmap-metafile.html)

Jörn 16. Feb 2004 12:24


Bitmap-->Metafile
 
Wie kann ich einem TMetafile den Inhalt eines TBitmaps zuweisen?
Die Klasse TMetafile hat keine Picture-Eigenschaft usw das ist das Problem.

MfG

Jörn 17. Feb 2004 15:44

Re: Bitmap-->Metafile
 
Sorry das ich das schon wieder nach oben bringen muss, aber ist das so kompliziert oder hat das nur keiner gesehen? Hab ich Infos vergessen?

MfG

Keldorn 17. Feb 2004 18:26

Re: Bitmap-->Metafile
 
Hallo,

gugg dir mal Tmetafilecanvas (ist auch ein Beipiel in der Hilfe) an und zeichne mit draw(0,0,meineBitmap) dein Bild rein.
Ob das dann allerdings Sinn macht, weiß ich nicht so recht, da für mich ein Metafile nicht unbedingt dafür da ist, ein komplette Bitmap drin zu haben.

Mfg Frank

eddy 18. Feb 2004 13:30

Re: Bitmap-->Metafile
 
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


Alle Zeitangaben in WEZ +1. Es ist jetzt 15:52 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz