Title: Exporting an TImage contents to WMF format
Question: How can I export the content of a TImage for an image in the format of Clip Galleyr of Microsoft Office?
Answer:
I used this function once and she worked.
procedure ExportBMPtoWMF(Imagem:TImage; Dest:Pchar);
//
// Export an TImage contents to WMF format (Microsoft Clippart format file)
//
var
Metafile : TMetafile;
MetafileCanvas : TMetafileCanvas;
DC : HDC;
ScreenLogPixels : Integer;
begin
Metafile := TMetafile.Create;
try
DC := GetDC(0);
ScreenLogPixels := GetDeviceCaps(DC, LOGPIXELSY);
Metafile.Inch := ScreenLogPixels;
Metafile.Width := Imagem.Picture.Bitmap.Width;
Metafile.Height := Imagem.Picture.Bitmap.Height;
MetafileCanvas := TMetafileCanvas.Create(Metafile, DC);
ReleaseDC(0, DC);
try
MetafileCanvas.Draw(0, 0, Imagem.Picture.Bitmap);
finally
MetafileCanvas.Free; end;
Metafile.Enhanced := FALSE;
Metafile.SaveToFile(Dest);
finally
Metafile.Destroy;
end;
end;