Skip to content

Creating a thumbnail image in WPF (using worker thread and decoding for the target size)

August 20, 2007

This question just came up again.  A teammate pointed to Aaron’s post:


From → WPF

  1. Sean permalink

    Does BitmapImage make use of thumbnails from the system thumbnail cache and/or from the embedded thumbnail that may exist in the image when the DecodePixelWidth/Height is smaller than the actual image?
    Based on Aaron\’s post it seems a waste to have to read in the full file into a memory stream in order to extract a small thumbnail especially if thumbnails exist in the system thumbnail cache or are available from an embedded thumbnail.

  2. Rob permalink

    The answer from a local expert:
    We don’t use the thumbnail cache, rather .Thumbnail property returns the embedded thumbnail, .DeocdePixelWidth/Height use the native decoder scaling. If they want to use thumbnails, they should use BitmapDecoder.Frames[0].Thumbnail or use DecodePixelWidth/Height to decode the image to a smaller size 

  3. Sean permalink

    Trying to figure out the optimal strategy for implementing an Explorer/Photo Gallery style list view of thumbnail images for my WPF app in terms of performance and memory usage.
    Reading say a directory of 100 images of say 3MB each using Aaron\’s approach of reading the whole file into a memory stream to then extract the thumbnail doesn\’t sound promising in terms of paging in 300MB from disk, decompressing the jpeg and then using DecodePixelWidth/Height etc.
    Using BitmapDecoder.Frames[0].Thumbnail would surely be more effecient with maybe a fallback to DecodePixelWidth/Height if the image doesn\’t include an embedded thumbnail.
    Ideal would probably be to use the system thumbnail cache especially if the user has viewed the directory in Explorer/Photo Gallery already.
    Although it sounds like we\’d need to interop to the shell\’s IThumbnailCache or IShellItemImageFactory since BitmapImage doesn\’t do this for us.
    Do you know if the Windows Photo Gallery uses the system thumbnail cache or does it build it\’s own thumbnail cache?

  4. Rob permalink

    I\’ve been told:

    Photo Gallery will build the thumbnail cache initially and then use it subsequently through the IThumbnailProvider APIs. 

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: