Board index » delphi » Image thumbnail/TListView problem

Image thumbnail/TListView problem

How can I display image thumbnails in a TListView without screen
flickering and still have dynamic repainting (i.e. each image is
displayed as soon as the thumbnail has been created)?

The following example won't display any images until all thumbnails
have been created (too slow if there are many images in a folder).
Adding a ListView.Repaint or Application.Processmessages does the
trick -- except for some {*word*193} screen flickering.
This basic example will scan a folder for image files. For each file
found, it will be added to the ListView:

with ListView.Items.Add do
begin
   caption := PathFName;
   imageindex := 0;
end;

When done, all filename captions are neatly displayed in the Listview,
without icons or thumbnails. Now, the following will create (80x80
pixel) thumbnail images for each item in the Listview:

procedure TMainForm.GetThumbs;
var
  i : integer;
  tli : Tlistitem;
begin
  ImageListThumb.Clear;
  Application.Processmessages;

  for i := 0 to ListView.Items.Count -1 do
  try
    tli := ListView.Items[i];
    FName := tli.Caption; //complete filename

    //create thumbnail image (TBitmap) and add it to Imagelist
    ImageListThumb.add(CreatePrevThumb(FName), nil);

    //change Tlistitem imageindex to display the image we just created
    tli.imageindex := i;

    //ListView.Repaint; //screen flickering
    //ListView.Invalidate; //doesn't help
    //Application.Processmessages;  //screen flickering

  except
     showmessage('GetThumbs error'); //debug
  end;
end;

I've also played with ListViewCustomDrawItem (drawing the image
myself), but this seems to be way too slow (having added just ten or
fif{*word*249} 80x80 pixel images makes it almost impossible to scroll the
listview?)

I've also considered experimenting with a virtual listview. Could that
be a solution? If so, a simple, basic example would be great -- the
Delphi \Demos\Virtual Listview\ example is a little too messy for me
:-(

Any tips or alternative solutions would be most appreciated.

Thanks,
Jarle Aasland

 

Re:Image thumbnail/TListView problem


Does using the BeginUpdate / EndUpdate methods around the updates help?

Quote
"Jarle Aasland" <jaas...@online.no> wrote in message

news:3a597ecb.239339912@newsgroups.borland.com...
Quote
> How can I display image thumbnails in a TListView without screen
> flickering and still have dynamic repainting (i.e. each image is
> displayed as soon as the thumbnail has been created)?

[]

Re:Image thumbnail/TListView problem


On Mon, 8 Jan 2001 09:08:12 -0000, "David Taylor"

Quote
<david.j.tay...@baesystems.com> wrote:
>Does using the BeginUpdate / EndUpdate methods around the updates help?

No.

Apparently, I may be able to use ListView.Repaint (which used to cause
screen flickering), IF I first set ListView.DoubleBuffered := True.
This could be the solution I was looking for, but I'd still appreciate
other suggestions.

Thanks.

Jarle

Re:Image thumbnail/TListView problem


On Mon, 08 Jan 2001 08:52:37 GMT, jaas...@online.no (Jarle Aasland)
wrote:

Quote
>How can I display image thumbnails in a TListView without screen
>flickering and still have dynamic repainting (i.e. each image is
>displayed as soon as the thumbnail has been created)?

I wrote a quick test app to see, and i had no problems with setting
DoubleBuffered:= True
then i could scroll the view like normal and i experienced no
flickering while it loaded and displayed the thumbnails

- Asbj?rn

Re:Image thumbnail/TListView problem


before calling repaint, set a temporary variable to true and then override
the message WM_ERASEBKGND to avoid repainting all the background, but just
the items
"Lord Crc" <lord...@hotmail.com> escreveu na mensagem
news:3a59ba36.7831796@forums.inprise.com...
Quote
> On Mon, 08 Jan 2001 08:52:37 GMT, jaas...@online.no (Jarle Aasland)
> wrote:

> >How can I display image thumbnails in a TListView without screen
> >flickering and still have dynamic repainting (i.e. each image is
> >displayed as soon as the thumbnail has been created)?

> I wrote a quick test app to see, and i had no problems with setting
> DoubleBuffered:= True
> then i could scroll the view like normal and i experienced no
> flickering while it loaded and displayed the thumbnails

> - Asbj?rn

Other Threads