0
votes

This is a question about picking the right Delphi components.

Using Delphi for a new app.

I'm looking to allow my user to have a list of (his own, on harddisk) pictures (just jpg for now, but should support different formats in the future), import them into my app, and then display them to him in a TListView. I was planning to tie that TListView to a TImageList (since this comes out of the box)... but when I tried, I ran into a set of weird problems about importing jpg's into a TImageList, reported here:

TImagelist not adding bitmap

So I'm wondering, am I using components for something they aren't intended for? Specifically, is the TImageList (even with some pre-formatting on import) useful for this kind of freestyle-all-sizes-and-formats-allowed stuff?

Any advice appreciated!

1
Are you planing to display a 1000×1000 jpeg in a listview? I think not...kobik
So you can store small thumbnails in the imagelist and tie it to the listview, or use custom draw to draw your graphic on the listview. imagelist is not a storage for random graphic.kobik
It could be better to spend some time and write your own ImageList which will support a lot of graphical formats. Important thing you definitely should implement in such a list is retrieving image with its original size, not the scaled copy as regular TImageList does. It might looks difficult but there are (in Internet) enough information to implement enhanced ImageList, besides... it is fun! P.S. I totally agree with Kobik - displaying large pictures within TListView is not a good idea.Josef Švejk
Yeah, obviously they won't be shown 1000x1000, user should have several list formats options like 256x256, 64x64 etc, and app should scale original sizes to the requested format in the list. I'm kind of hesitant to draw my own stuff in standard components, had a lot of problems doing that in a Stringgrid a while back, but when it has to be done, oh well...Jur
TImageList is designed for toolbar icons that all have the same size. It's the wrong component for your needs.David Heffernan

1 Answers

3
votes

TImageList is designed to contain images of stored with the same format and size. If I am understanding correctly, TImageList doesn't do what you ask for.

TListView is tied to TImageList and therefore has the same limits. In my experience, a component flexible as you ask requires a custom component and manual drawing.

If you could change the requirement and decide a fixed size, you can preprocess the images making a thumbnail of the decided sizes and store them in the image list. This way you avoid building a component specific for your needs.