« From the horse's mouth | Main | Danish PC license fee »

June 01, 2006

Rendering ChemDraw image as metafile in Delphi TImage control

Assume you've already set the ChemDraw control with SMILES/MOL etc and you also have a TImage on the form already called Image1 ...

procedure TForm1.ButtonRenderClick(Sender: TObject);
var
  WMFData: array of byte;
  MemStream: TMemoryStream;
begin
  WMFData:=CSChemDrawCtl1.Data['image/x-wmfs'];
  MemStream:=TMemoryStream.Create;
  MemStream.WriteBuffer(WMFData[0],Length(WMFData));
  MemStream.Seek(0,soFromBeginning);
  Image1.Picture.Metafile.LoadFromStream(MemStream);
  MemStream.Free;
end;

Posted by daen at June 1, 2006 09:04 PM

Comments

Post a comment

Thanks for signing in, . Now you can comment. (sign out)

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)


Remember me?