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

Is there a limit on DBImage data size

I have a 100 page report with some 50 DBimages per page. Is there a limit on the JPEG size from the database? Some are small 50K whereas some are3MB. The program crashes randomly. Does the JPEG data get drawn on the image and effectively get compressed, and can one alter the compression? Sometimes I get "insufficient memory". Should I use a lain image and shrink the JPEG before loading it into the image?

Comments

  • plain image
  • Hi Lawrence,

    Load the report definition (if stored in file or database).

    Try setting Report.PreviewFormSettings.SinglePageOnly to True and Report.ThumbnailSettings.Enabled to False and Report.CachePages to False.

    Save the report definition.

    Test the report. If the issue persists, try shrinking the images.


    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • I will try that. But does the size of the JPG in the database make a difference? The only way I can shrink them is at run time and use a normal ppImage. I thought that the image was simply written to the image "canvas" which is small. Can I set the properties of the ppimage to help?

  • But what can I do if I have large JPG's in my database and cannot compress them? I have written my own compression routine (load a Tjpeg Image and the stretchdraw it onto a small ppImage. But how can I use a ppDBImage and make it small?

  • Hi Lawrence,

    I suggest using a TppImage and manually loading the processed image data for each record.

    1. Load the image data from your DB into a stream (using DataPipeline.GetFieldAsStream).
    2. Process the image data.
    3. Load the processed data into the TppImage.Picture
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • Can you confirm how to economically process the stream? I load a Tjpeg from the database, I create a bitmap and set the width and height to small, and then stretchdraw the jpeg into the bitmap:


    // expose the protected properties
    type
    TlbkPicture = class(TPicture)
    end;

    { get a JPG }
    oJpg := TJpegImage.Create;
    oStream := TMemoryStream.Create;
    oStream.Write(sData[1],Length(sData));
    oStream.Position := 0;
    oJpg.LoadFromStream(oStream);
    oStream.Free;

    oBmp := TBitMap.Create;
    oBmp.Width := iSize;
    oBmp.Height:= iSize;
    oBmp.Canvas.StretchDraw(oBmp.Canvas.ClipRect,oJpg);
    oJPG.Free;

    { get the bitmap stream }
    oStream := TMemoryStream.Create;
    oBmp.SavetoStream(oStream);
    oBmp.Free;

    oStream.Position := 0;
    TlbkPicture(oImage.Picture).LoadFromStream(oStream);


    Is there a faster way?

    Lawrence

  • Hi Lawrence,

    This looks fine except there is likely no need to recreate the memory stream to assign the graphic. Assigning the oBmp bitmap to the Picture.Graphic should also work.
    oBmp.Canvas.StretchDraw(oBmp.Canvas.ClipRect,oJpg);
    oJPG.Free;

    TlbkPicture(oImage.Picture).Graphic := oBmp;
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
Sign In or Register to comment.