Rave - Imprimindo JPEG's |
Top Previous Next |
Tip #31 - Printing JPEG's
Category Code Based - General
Question
I need to be able to print JPEG's. How would I do that?
Solution
This can be done through the use of the PrintImageRect method and OnDecodeImage event. These allow native image format storage (such as JPG or TIFF) in the Rave file (the one created by TReportFiler) for space savings. The PrintImageRect method is called with the X1,Y1,X2,Y2 parameters like PrintBitmapRect; but instead of a bitmap object, a stream containing the image data and an optional identifier is passed. Here is some sample code from an OnPrint event.
Delphi Example: uses JPEG;
procedure TForm1.ReportSystem1Print(Sender: TObject);
var Stream: TMemoryStream; Image: TJPEGImage;
begin With Sender as TBaseReport do begin Stream := TMemoryStream.Create; Image := TJPEGImage.Create; try Image.LoadFromFile('image1.jpg'); Image.SaveToStream(Stream); Stream.Position := 0; PrintImageRect(1,1,3,3.5,Stream,'JPG'); finally Image.Free; Stream.Free; end; { tryf } end; { with } end;
|