TXFormMetafileToMetafile =
class
private
FDevice: HDC;
FSource, FDest: TMetafile;
procedure ProcessMetafile;
public
property Dest: TMetafile
read FDest;
procedure LoadSourceFromFile(
const FileName:
string);
procedure SaveDestToFile(
const FileName:
string);
constructor Create(
const Device: HDC);
destructor Destroy;
override;
end;
..
function MFProc(
DC: HDC; P: Pointer; MF: TXFormMetafileToMetafile): Integer;
stdcall;
begin
Result := 1;
case PEMR(P).iType
of
// -> TXFormMetafileToMetafile Methoden;
end;
end;
constructor TXFormMetafileToMetafile.Create(
const Device: HDC);
begin
FDevice := Device;
FSource := TMetafile.Create;
FDest := TMetafile.Create;
end;
destructor TXFormMetafileToMetafile.Destroy;
begin
FSource.Free;
FDest.Free;
inherited;
end;
procedure TXFormMetafileToMetafile.LoadSourceFromFile(
const Filename:
string);
var
Stream: TStream;
begin
Stream := TFileStream.Create(Filename, fmOpenRead
or fmShareDenyWrite);
try
FSource.LoadFromStream(Stream);
finally
Stream.Free;
end;
end;
procedure TXFormMetafileToMetafile.SaveDestToFile(
const FileName:
string);
var
Stream: TStream;
begin
ProcessMetafile;
Stream := TFileStream.Create(Filename, fmCreate);
try
FDest.SaveToStream(Stream);
finally
Stream.Free;
end;
end;
procedure TXFormMetafileToMetafile.ProcessMetafile;
begin
FDest.Clear;
Windows.EnumEnhMetaFile(FDevice, FSource.Handle, @MFProc, Self, Rect(0, 0, 0, 0));
end;