views:

211

answers:

2

I have created a bitmap in memory, and would like to show this in rave report design time. I don't want to create a file then load. Is there a better way?

Thanks and regards, jai

A: 

Here is a code snippet I wrote for a school project some time ago. I think I put quite some research in it then and couldn't find another way.... I think the code is clear enough to see how I did it: use the clipboard. cMohr is a TChart component.

I don't have Delphi installed here right now, so I can't test it but it should work!

with Sender as TBaseReport do
begin
  SetFont('Arial', 15);
  Title := 'JTester results';
  PrintHeader('JTester results', pjCenter);

  // Mohr Circle
  bmp := TBitmap.Create;
  cMohr.Color := clWhite;
  cMohr.CopyToClipboardBitmap;
  cMohr.Color := clBtnFace;
  bmp.LoadFromClipboardFormat(cf_BitMap,ClipBoard.GetAsHandle(cf_Bitmap),0);
  PrintBitmapRect(0.2,0.5,PageWidth-0.4,(PageWidth-0.4)*bmp.Height/bmp.Width,bmp);
  ..
  ..
birger
Just for the record: TChart provides a Draw method (in D2010, don't know about the versions bundled earlier) to draw to a TCanvas of your choice, which is a much nicer solution than just destroying whatever the user has on their clipboard.
Michael Madsen
A: 

You could use a LoadFromStream into a TBitmap and then use that bitmap in RAVE.

Ritsaert Hornstra