Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Optimizing grid refreshes when displaying images 1

Status
Not open for further replies.

awaresoft

Programmer
Feb 16, 2002
373
DE
I've been experimenting with using a grid to display images (digital photos).

The reason I prefer the grid approach to something like Shell.Explorer is that using a grid gives me additional flexibility for filtering and ordering images as well as an opportunity to provide additional data about each image.

My frustration with using a grid for images is that its refresh begins to slow down when there's a large number of image files being managed and one is near the bottom of the grid and navigating by up and down arrows. Specifically what I see happening is images are displayed twice while the grid's dynamic* properties are updated.

I'm wondering if there's a way for a grid to LockScreen before it starts to update itself (before it applies all its dynamic* property updates) and unlock the screen after all these dynamic* updates have been applied.

Any suggestions on what events I would use to set LockScreen to True and then restore it to False once a grid has finished all its updates?

One half-baked thought was to LockScreen = True in the grid's KeyPress and/or Scrolled events, but where to set LockScreen to False? Possibly have my dynamic* property that's updating image controls check to see if its in the last visible row of the grid and set Lockscreen to False at this point ... or start a timer with X millisecond delay to restore LockedScreen to False after some grid event occurs near the end of the grid refresh cycle?

I'm also looking for any ideas on peeking ahead in the keyboard buffer to see if a user hit the up/down or pageup/pagedown keys multiple times, performing the appropriate scrolls (WITHOUT doing a visual update after each keystroke) and THEN updating the grid control.

Any ideas appreciated,

Malcolm
 
awaresoft

If you bind the .Picture property of an image in a grid to a field in a table, VFP will render all the images in the .RecordSource of the grid with serious performance degredation where the .RecordSource has a large number of records.

An alternative is to set .Sparse = .F.and use the .DynamicCurrentControl property of the Column to call a UDF or object method which in turn assigns ALLT(TABLENAME.fieldname) to the .Picture property of the column.

Doing this means that only the visible images in the grid are rendered with an obvious performance benefit.

If you have a typical layout of a column of thumbnails and single large image displaying currently selected thumbnail on your form, you will improve performance again if you ensure the thumbnails are the same size as displayed.

It's beyond the scope of this thread as to how to achieve that, but suffice it to say you can use GDI+ or third party applications/utilities.

FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommander[sup]tm[/sup].net
PDFcommander[sup]tm[/sup].com
 

Hi Chris,

In your answer to Malcom, you suggested he "use the .DynamicCurrentControl property of the Column to call a UDF or object method".

Can you explain how to do that? I always thought DynamicCurrentControl could only return an object name.

Thanks.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike

How can I color code cells in a grid? faq184-624

is not relevant to this thread but follows the same principles.
faq184-624 said:
In the .Column(s) of the grid set .Sparse = .F. and .DynamicCurrentControl = THISFORM.mGridColours().
The code in the UDF/object method might look like
Code:
[COLOR=blue]THISFORM.gridThumbnails.Column1.Image1.Picture = ALLT(TABLENAME.fieldname)[/color]
where TABLENAME.fieldname is the path\filename.ext of the thumbnail image.

FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommander[sup]tm[/sup].net
PDFcommander[sup]tm[/sup].com
 

Chris,

Ah, I understand now.

You're simply saying that the expression in a DynamicXXX property can be a call to a UDF rather than something like an IIF(). That's true of course.

I previously thought you were talking about some clever way of having the DynamicCurrentControl expression returning a method name rather than a control name. My mistake.

On the other hand, the fact that the expression can call a UDF does open up all sorts of interesting possibilities, and is definitely worth keeping in mind.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Richard,

> An alternative is to set .Sparse = .F.and use the .DynamicCurrentControl property of the Column to call a UDF or object method which in turn assigns ALLT(TABLENAME.fieldname) to the .Picture property of the column.

This is what I'm doing now. Works great near the top of a record source with a small number of records. But as I move to the bottom of a grid with a large number of records (say 300) this technique progressively sloooooooooooows down to the point of being visually painful to watch.

> If you have a typical layout of a column of thumbnails and single large image displaying currently selected thumbnail on your form, you will improve performance again if you ensure the thumbnails are the same size as displayed.

This sounds like a great idea! I'm going to use Calvin Hsia's or Ceasar Chalom's GDI+ code to pre-create thumbnails and see how much that helps.

Create thumbnails of all your digital photos

Ceaar Chalom's GDI+ tips/example code

BTW: Do you have any thoughts on my idea of 'batching' grid navigation keystrokes and performing navigation in one step vs. updating the grid with each buffered keystroke?

Thanks!
Malcolm
 
Malcolm

Thanks for the star

If you are going to create thumbnails, I would create them in .gif format regardless of their original image format.

In thumbnail size any quality loss will not be important and the .gif format will help speed up the rendering of the images.

FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommander[sup]tm[/sup].net
PDFcommander[sup]tm[/sup].com
 
Chris,

First of all, apologies for calling you Richard (saw Chamberlain and thought of the movie star ... LOL!)

Regarding your recommendation to use GIF's for thumbnails: I thought GIF's were limited to 256 colors - won't this affect the quality of my thumbnails?

Intuitively I would have thought that BMPs might have been faster loading at the expense of being much larger on disk.

Thanks for your help on this thread!

Malcolm
 
Malcolm

I wish I had Richard's looks, women and money - ah well!

I use 120px high x 90px wide thumbnails, (aspect ratio of 4:3), with
Code:
[COLOR=blue]THISFORM.grdThumbnails.Column1.Image1.Stretch = 0[/color]
so sometimes there's whitespace top and bottom, other times whitespace left and right and occasionally no whitespace if the aspect ratio of the original image matches that of the thumbnail.

It's a question of appearance versus performance, the larger the thumbnail, the more image there is to render, (especially with more than 256 colours), and the greater chance of noticing a difference between the full size image and the thumbnail.

FAQ184-2483 - answering getting answered.​
Chris [pc2]
PDFcommander[sup]tm[/sup].net
PDFcommander[sup]tm[/sup].com
 
Chris,

One would guess that most digital photos are in 4:3 ratio (or 3:4 if taken in a portrait mode and rotated?)

I'm going to follow your suggestions,

Thank you very much,

Malcolm
 
Mike Lewis

In your answer to Malcom, you suggested he "use the .DynamicCurrentControl property of the Column to call a UDF or object method".

Can you explain how to do that? I always thought DynamicCurrentControl could only return an object name.

Take a look at faq184-2324 (paragraph 5), the call is a little different.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Awaresoft

I came across this problem regarding displaying an album of my furniture pictures. I wanted to have an album categorised and controlled via treeview and found most ways were to slow. So I used Images each in its own container inside a container 5 across and 5 deep, each image could have extra info or texttip the info with it.
I used PageUp and Down buttons in the parent container to allow paging up and down and used a treeview to select range of furniture and sub range within. I couldnt scroll the container it was to slow but pageup and down works really quickly.

Andrew
 
Andrew,

Thanks for the idea. One of the ways I'm hoping to speed up my grid is by pre-building thumbnails of photos to minimize my image sizes. I plan on pre-building the thumbnails after the user selects the folder of images to browse.

Cetin on the UT also suggested using a webbrowser control as my image browser. In other words I would generate an HTML page with image references and then use the webbrowser to show the page of my images. This is my backup plan.

Malcolm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top