Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Quick Report

109 views
Skip to first unread message

Paulo Hoffmann

unread,
Jun 29, 2008, 3:41:08 PM6/29/08
to
Hi, I am not sure if this is the right place, but here it goes.

I am using Delphi 7 and I have a TImage on my main form.
All I want to do is to send this image to a Quick Report page.

It works fine in my computer but in some othes a black or a
white rectangle appears where the image should be.

I have tried to set the property Picture from the TImage equals to
the TQRImage, I tried to save the picture as a BMP file and then
open it using LoadFromFile in TQRImage and at last I tried to use
TQRImage.Picture.Assign( TImage.Picture ) with no success.

Please help.

Thank you.


Joe Griffin

unread,
Jun 29, 2008, 4:42:19 PM6/29/08
to
Paulo,

I'm not sure quite what you're doing wrong, but here's some working code from one of my applications.

An image field in the SQL server database holds a graphic which needs to be printed on the report. A ADO query gets all the
fields from the database table and a DataServiceProvider is used to populate a clientdataset (cdsDivisions).

imgLogo is a TQRImage component which holds the graphic.

function Tqrf_WorkSummary.LoadStreamIntoGraphic(Graphic: TGraphic; Stream: TStream): Boolean;
begin
Result := True;
try
Stream.Position := 0;
Graphic.LoadFromStream(Stream);
except
Result := False
end;
end;

procedure Tqrf_WorkSummary.FormCreate(Sender: TObject);
var
BlobStream : TMemoryStream;
JPEGImg : TJPEGImage;
begin
inherited;
dm_Lookup.cdsDivisions.Open;
// D.P. (Joe) Griffin - Always get the Division from the Contract code
if dm_Lookup.cdsDivisions.Locate('Div_Prefix', Copy(UpperCase(dlg_JobNo.cmbContract.Text), 1, 2), [loCaseInsensitive]) then
begin
// Default settings
if Trim(dm_Lookup.cdsDivisionsPAY_COMPANY.AsString) <> '' then
begin
// Division specific payment company
lblMainCompany.Caption := dm_Lookup.cdsDivisionsPAY_COMPANY.AsString;
if NOT dm_Lookup.cdsDivisionsCOMPANY_LOGO.IsNull then
begin
BlobStream := TMemoryStream.Create;
try
dm_Lookup.cdsDivisionsCOMPANY_LOGO.SaveToStream(BlobStream);
if NOT LoadStreamIntoGraphic(imgLogo.Picture.Bitmap, BlobStream) then
begin
JPEGImg := TJPEGImage.Create;
try
{ A TPicture does not have a JPEG }
{ property, so we have to make do without }
imgLogo.Picture.Graphic := JPEGImg;
LoadStreamIntoGraphic(imgLogo.Picture.Graphic, BlobStream);
finally
JPEGImg.Free
end;
end;
finally
BlobStream.Free
end;
end;
etc ....

Hope that helps

... Joe
Member of the UK Developers Group

0 new messages