Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi MetaFile ist nur Schwarz (https://www.delphipraxis.net/123873-metafile-ist-nur-schwarz.html)

neolithos 10. Nov 2008 16:38


MetaFile ist nur Schwarz
 
Ich versuche aus der Zwischenablage ein MetaFile auszulesen und dieses in eine Datei zu schreiben.

Funktioniert so weit auch ganz gut, nur geht die Farbe verloren.

Wie erhalte ich das farbige EMF?

Delphi-Quellcode:
  Clipboard.Open;
  try
    img := TMetafile.Create();
    img.LoadFromClipboardFormat(0, 0, 0);

    img.SaveToFile(sFileName);

    img.Free;

    // Leere Zwischenablage
    Clipboard.Clear;
  finally
    Clipboard.Close;
  end;

neolithos 25. Dez 2008 16:43

Re: MetaFile ist nur Schwarz
 
Feststellung: Es geht nicht direkt die Farbe verloren, sondern nur die Schriftfarbe. Flächen, Linien, Bilder sind farbig.

toms 25. Dez 2008 17:57

Re: MetaFile ist nur Schwarz
 
vielleicht so? (ungetestet)

Delphi-Quellcode:
var
 img : TMetafile;
begin
  Clipboard.Open;
  try
    if IsClipboardFormatAvailable(CF_ENHMETAFILE) then
    begin
      img := TMetafile.Create();
      try
        img.LoadFromClipboardFormat(CF_ENHMETAFILE, Clipboard.GetAsHandle(CF_ENHMETAFILE), 0);
        img.SaveToFile(sFileName);
      finally
        img.Free;
      end;
    end;
  finally
    Clipboard.close;
  end;
end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 17:50 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