Large Docs with Many Pictures

General TRichView support forum. Please post your questions here
Post Reply
SiriusDG
Posts: 4
Joined: Mon Oct 31, 2005 5:41 am

Large Docs with Many Pictures

Post by SiriusDG »

Hi -- I am using trichview to create large documents with many (>150) full screen bitmaps. Psuedo code looks something like this...(apologies for poor formatting, my spacing is being deleted by the board)

Source := tjpegimage.create;
for i := 1 to numpages do
begin
PageNum := PageNum +1;
NextItem := rvReport.ItemCount;
rvReport.PageBreaksBeforeItems[rvReport.ItemCount-1]:=TRUE;
Try
Screen := tBitMap.Create;
Source.LoadFromFile(CurrentPage.Path);
Source.Scale := jsHalf;
Screen.Assign(Source);
rvReport.AddFromNewLine(' ',NORMAL);
rvReport.AddPicture(Screen);
//Screen.Dormant;
//Screen.FreeImage;
//Screen.Free;
Except on E:Exception Do
showmessage(E.Message);
End;
end

Lots of detail left out, but that is the basic idea. Note the three commented lines...this uses a ton of memory, and on larger reports, I exhuast the machine so badly it wanders off and gets lost. I would like to find a more efficient method...but I cannot do the freeing in the three commented lines, since AddPicture needs the bitmap in place until the report is done, right? Any suggestions...these reports could be in the many hundreds of bitmaps. Any ideas greatly appreciated.
Sergey Tkachenko
Site Admin
Posts: 17534
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

You cannot call Screen.Free, because this method destroys the bitmap, but it still used by rvReport.
But I think you can call Dormant or FreeImage (as far as I understand how TBitmap works, only FreeImage makes sense here)
SiriusDG
Posts: 4
Joined: Mon Oct 31, 2005 5:41 am

Converting to PDF

Post by SiriusDG »

Okay, I have cleaned that up a bit and it is working better now, and clearing the report when I am done frees the memory. Next question, I offer the user the ability to save to PDF, using RolePDF dll -- this takes a L O N G time...is there a progress indicater from within the RodePDF system that I am unaware of that I could use to let the user know how things were progressing? Thanx.

Sincerely,
David
Sergey Tkachenko
Site Admin
Posts: 17534
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

It would be better to ask RolePDF developers
SiriusDG
Posts: 4
Joined: Mon Oct 31, 2005 5:41 am

Progress for SaveRTF, and RTF File Size

Post by SiriusDG »

Sergey -- Okay, they were very helpful and that is working better now. Now is there some way to do the same for SaveRTF -- a progress indicator to let the user know how the save was going? Some of my clients are saving reports > 500 pages, and while SaveRTF is much faster than PDF, it still takes a while.

Also, the RTF files created are VERY large...I am sure this is at least partly because of the high volume of screenshots...one per page...is there anything I can do to generate smaller RTF files? I have looked at the options a little, since I am doing an assign to a tjpgimage from a Bitmap, will the SaveJpgAsJpg option buy me anything? Currently the files on disk are actually jpg, but I use TBitmap as a generic image handler, as I was considering opening the file format up later as user selectable option.

Any help greatly appreciated.

Sincerely,
David
Rob
Posts: 52
Joined: Wed Sep 07, 2005 6:47 am

Post by Rob »

Using JPEG images instead of bitmaps will help.
Sergey Tkachenko
Site Admin
Posts: 17534
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Yes, it's better to use TJpegImage, and include SaveJpgAsJpg in RTFOptions.
Images will be saved as jpegs in RTF, so it will be MUCH smaller.

I do not know a nature of your pictures. If they are photos, and especially if the source images are jpegs, storing them as jpegs is the best option.

If they are screenshots, it's better to use PNG instead:
http://www.trichview.com/forums/viewtopic.php?t=89
(but if their quality is already degraded because of saving to jpegs, it does not make sense)
Post Reply