C++ – explorer get image’s thumbnail really fast, how does it work

cexplorerimagethumbnails

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.....
}

Best Answer

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.