views:

344

answers:

2

I am using explorer to view image in thumbnail mode. It is really fast to get thumbnail of each image(bmp, jpg).

I am using the following code to generate thumbnails for each image. however it is much slower than the explorer, How can I write a part of code to generate thumbnail as fast as system and accurate(thumbnail generated by the following code sometimes have black band on top and bottom, or on left and right side, I don't know why...). Or can I envoke explorer's API to generate thumbnail using its function?

Bitmap sourceImg(xxx);
int nSize = sourceImg.GetPropertyItemSize(PropertyTagThumbnailData);
if(nSize > 0)
    {
    PropertyItem * pItem = (PropertyItem*)malloc(nSize);
    if (pItem != NULL)
    {
        sourceImg.GetPropertyItem(PropertyTagThumbnailData, nSize, pItem);
    }
    GenerateThumbnail from pItem.....
}
+1  A: 

Explorer is probably using the Exif embedded jpg thumbnail.

Take a look at a simple Exif Image Viewer to confirm that the images you're using contain an embedded thumbnail.

Alan
+1  A: 

For me, Explorer generates thumbnails painfully slow. My own code runs much faster for generating thumbnails. The problem I've run into is that FindFirst/FindNext are slow compared to Explorer because it uses the "file object" system instead of the "file name" system. I would like to find fast code to get the filenames in directories.

BitBank
Same here. It's only quick if it's reading the images from `thumbs.db`, otherwise it takes a very long time.
Rex M