Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Use of TMemoryStream generates local loop on Nic

edited November 2003 in General
Hi,

I'm using Windows 2000, Delphi 7 Enterprise, ReportBuilder 7.03 and FireBird
SuperServer with IBX drivers.

In the database I stored several JPG photos. I use code like the snipped
below to display the photos in a report.
I noticed the use of a memory stream triggers datacom traffic flow on my PC
LAN card (seems like a local loop) where the use of the same code to display
JPG photos on a screen does not create the datacom traffic.

procedure TDataModule2.ppDetailBandSRPhotos_AllDataBeforeGenerate(Sender:
TObject);
var
ms: TMemoryStream;
Img: TJPEGImage;

procedure ShowPhoto(Field: TBlobField; var ms: TMemoryStream; var Img:
TJPEGImage);
begin
ms.Clear;
Field.SaveToStream(ms);
ms.Seek(soFromBeginning,0);
with Img do
begin
LoadFromStream(ms);
PixelFormat := jf24Bit;
Scale := jsFullSize;
Grayscale := false;
performance := jpBestQuality;
ProgressiveDisplay := true;
ProgressiveEncoding := true;
end;
end;

begin
Img := TJpegImage.Create;
ms := TMemoryStream.Create;
try
if not IBDataSetSchemePicturesPHOTO.IsNull then
begin
ShowPhoto(IBDataSetSchemePicturesPHOTO, ms, Img);
ImageSRPhotos_AllData.Picture.Graphic := Img;
end
else
ImageSRPhotos_AllData.Picture.Graphic := nil;

finally
ms.free;
Img.Free;
end;
end;


Any suggestions?



Regards,

Nols Smit

Comments

  • edited November 2003
    Hi Nols,

    The DBImage uses the same technique that you are using to load images from a
    database blob field. I'm a bit unsure what you mean my "Datacom traffic"
    but if you are talking about the network traffic between your database
    server and your application, the only place this is being done is when you
    call Field.SaveToStream. I see that you are setting your jpeg image to show
    with the best possible quality so remember that this could possibly be a
    large image since ReportBuilder converts every image to Bitmap before it is
    printed.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2003
    Hi,

    No, I use a TppImage control and in my FireBird database the field is
    declared as Blob, Subtype 0.
    In my Local Area Connection Properties, I checked the CheckBox for 'Show
    icon in taskbar when connected'
    When the sub-report (showing the images) is processes the images it hangs
    for about one minute and then traffic shows on the LAN icon. It sends a few
    hundred packets and receive more or less the same number of packets. When
    I disable the LAN card (Nic) then the report does not hang for that one
    minute while processing the images.

    My database is on the same PC and is configured as a Local Engine.

    I limit these images to 30 KB in my load statements.

    Regards,

    Nols Smit


  • edited November 2003
    Hi Nols,

    ReportBuilder does not contain any code to access your network directly.
    The only thing RB talks to is datapipelines which in turn talk to the
    dataset components you are using. If you would like to trace into our
    source and see how we load the DBImage from your database, set your library
    path to \RBuilder\Source\... and place a stop inside the TppDBImage class.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.