TECH TIP: Using the JITPipeilne OnGetPicture Event to Display Images
Question: “I am using a JITPipeline to output data stored in a series of stringlists,
one of these stringlists contains the names of a graphic. How can I use the JITPipeline.OnGetPicture Event to display an image?”
Solution:
- Use JITPipeline fields editor to declare a Field with FieldType = dtGraphic. For this example, set the FieldName to ‘Graphic’. Create a second Field with FieldType = dtString and set the FieldName to ‘GraphicFile’.
- In the Report Designer, create a DBImage component and connect to the Graphic field.
- Use the Delphi code editor to declare a private variable for your form:
12privateFPicture: TPicture;
- In the FormCreate event instantiate the picture object:
123456procedure TForm1.FormCreate(Sender: TObject);beginFPicture := TPicture.Create;end;
- In the FormDestroy event, free the picture object:
123456procedure TForm1.FormDestroy(Sender: TObject);beginFPicture.Free;end;
- In the JITPipeline.OnGetPicture event, load the picture:
123456789101112131415function TForm1.ppJITPipeline1GetFieldAsPicture(aFieldName: String): TPicture;varlsFileName: String;beginif aFieldName = 'Graphic' thenbeginlsFileName := JITPipeline['GraphicFile'];FPicture.LoadFromFile(lsFileName);end;Result := FPicture;end;