How To…Access Image Data via the JITPipeline

Question

“How can I use a JITPipeline to provide access to a DBImage component on my report?”

Solution

The following example implements the JITPipeline GEtFieldAsPicture event to access Image data. For this example the image is loaded from a file. You could also implement a solution that loads images from other sources such a TImage on a form or a TImageList.

Download: ImageViaJIT.zip

Sample Delphi code:

procedure TForm1.FormCreate(Sender: TObject);
begin

  FPicture := TPicture.Create;

end;

procedure TForm1.FormDestroy(Sender: TObject);
begin

  FPicture.Free;

end;


function TForm1.ppJITPipeline1GetFieldAsPicture(aFieldName: String): TPicture;
begin
  if aFieldName = 'Graphic' then
    FPicture.MetaFile.LoadFromFile(TppFileUtils.GetApplicationFilePath + 'w2.wmf');

  Result := FPicture;

end;