PDA

View Full Version : Creating thumbnails efficiently



Luc4
25th February 2010, 06:27
Hi! Would it be possible somehow to create thumbnails for images without having to load the entire image in RAM? I would like to create a fast preview of files, is there any way to accomplish this?
Thanks!

ecanela
25th February 2010, 07:11
i think is not posible create a thumbnail of image whitout reading first the complete image. you can read (if image format allow) a portion of the image and then scale using a QImageReader.

you can read the articles for a way to create a fast thumbnail of a image.

http://labs.trolltech.com/blogs/2009/01/20/50-scaling-of-argb32-image/
http://labs.trolltech.com/blogs/2009/01/26/creating-thumbnail-preview/

i hope found this useful.

toutarrive
25th February 2010, 08:11
Keep in mind that the process of creating thumbnails is better off when done in a thread.
Depending on the number of images you're dealing with, doing so leave your interface more responsive

Luc4
1st March 2010, 21:11
I used Windows API to do this. Seems to be more efficient this way. Unfortunately this is not portable, therefore I will have to rewrite everything some other way in the future. Thanks for your answers!

chaoticbob
2nd March 2010, 00:58
You might consider using Paul Heckbert's zoom code if you can still find it. He has nearly all of the image resampling algorithms implemented in a C callable fashion. The trick is getting your data into a format that the algorithms can work on. It's a bit of code, but it's not entirely out of the question to convert his code to a template style so that you can specialize on the pixel type.

In my experience the code performs reasonably well. I'm sure if you really need to extra performance you can optimize it.

Looks like you can still download it here:
http://www.xmission.com/~legalize/zoom.html

Luc4
8th April 2010, 14:05
This is another very interesting article: http://olliwang.com/2010/01/30/creating-thumbnail-images-in-qt/. Not as fast as using the Windows API but fast, and very useful as it uses fewer memory then loading the entire image.