Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Probleme mit Bildgrößen bei Konvertierung zu Wmf (https://www.delphipraxis.net/34185-probleme-mit-bildgroessen-bei-konvertierung-zu-wmf.html)

Helmi 18. Nov 2004 21:06


Probleme mit Bildgrößen bei Konvertierung zu Wmf
 
Hallo,

ich habe drei funktions, die von Bmp, Jpg oder Ico zu wmf konvertieren

gestern hat ein freund festgestellt, dass die Bilder als wmf von der skalierung kleiner sind als die originale

weiss jemand warum?

hier mal die drei funktions als Code:

Code:
procedure BmpToWmf(BitmapFile, WmfFile: TFileName);
var
  MetaFile: TMetaFile;
  MFCanvas: TMetaFileCanvas;
  Bitmap: TBitmap;

begin
  try
    Bitmap  := TBitmap.Create;
    MetaFile := TMetaFile.Create;

    with Bitmap do
      begin
        LoadFromFile(BitmapFile);

        MetaFile.Height := Height;
        MetaFile.Width := Width;
      end;

    MFCanvas := TMetafileCanvas.Create(MetaFile, 0);

    try
      MFCanvas.Draw(0, 0, Bitmap);
    finally
      MFCanvas.Free;
    end;

    MetaFile.SaveToFile(WmfFile);
  finally
    MetaFile.Free;
    Bitmap.Free;
  end;
end;

procedure JpgToWmf(JPEGFile, WmfFile: TFileName);
var
  MetaFile: TMetaFile;
  MFCanvas: TMetaFileCanvas;
  Bitmap: TBitmap;
  JpgImage: TJPEGImage;

begin
  try
    JpgImage := TJPEGImage.Create;
    Bitmap  := TBitmap.Create;
    MetaFile := TMetaFile.Create;

    with JpgImage do
      begin
        CompressionQuality := 100; {Standard-Wert}
        LoadFromFile(JPEGFile);
      end;

    with Bitmap do
      begin
        Assign(JpgImage);
        MetaFile.Height := Height;
        MetaFile.Width := Width;
      end;

    MFCanvas := TMetafileCanvas.Create(MetaFile, 0);

    try
      MFCanvas.Draw(0, 0, Bitmap);
    finally
      MFCanvas.Free;
    end;

    MetaFile.SaveToFile(WmfFile);
  finally
    MetaFile.Free;
    Bitmap.Free;
    JpgImage.Free;
  end;
end;

procedure IcoToWmf(IconFile, WmfFile: TFileName);
var
  MetaFile: TMetaFile;
  MFCanvas: TMetaFileCanvas;
  Bitmap: TBitmap;
  Icon: TIcon;

begin
  try
    Icon    := TIcon.Create;
    Bitmap  := TBitmap.Create;
    MetaFile := TMetaFile.Create;

    Icon.LoadFromFile(IconFile);

     with Bitmap do
      begin
        Height := Icon.Height;
        Width := Icon.Width;
        Canvas.Draw(0, 0, Icon);
        MetaFile.Height := Height;
        MetaFile.Width := Width;
      end;

    MFCanvas := TMetafileCanvas.Create(MetaFile, 0);

    try
      MFCanvas.Draw(0, 0, Bitmap);
    finally
      MFCanvas.Free;
    end;

    MetaFile.SaveToFile(WmfFile);
  finally
    MetaFile.Free;
    Bitmap.Free;
    Icon.Free;
  end;
end;
mfg
Helmi

Helmi 19. Nov 2004 09:42

Re: Probleme mit Bildgrößen bei Konvertierung zu Wmf
 
***Update***

weiss jemand warum das oben so ist?


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