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