1 out of 1 rated this helpful - Rate this topic

IThumbnailProvider::GetThumbnail method

Applies to: desktop apps only

Gets a thumbnail image and alpha type.

Syntax

HRESULT GetThumbnail(
  [in]   UINT cx,
  [out]  HBITMAP *phbmp,
  [out]  WTS_ALPHATYPE *pdwAlpha
);

Parameters

cx [in]

Type: UINT

The maximum thumbnail size, in pixels. The Shell draws the returned bitmap at this size or smaller. The returned bitmap should fit into a square of width and height cx, though it does not need to be a square image. The Shell scales the bitmap to render at lower sizes. For example, if the image has a 6:4 aspect ratio, then the returned bitmap should also have a 6:4 aspect ratio.

phbmp [out]

Type: HBITMAP*

When this method returns, contains a pointer to the thumbnail image handle. The image must be a DIB section and 32 bits per pixel. The Shell scales down the bitmap if its width or height is larger than the size specified by cx. The Shell always respects the aspect ratio and never scales a bitmap larger than its original size.

pdwAlpha [out]

Type: WTS_ALPHATYPE*

When this method returns, contains a pointer to one of the following values from the WTS_ALPHATYPE enumeration:

WTSAT_UNKNOWN (0x0)

0x0. The bitmap is an unknown format. The Shell tries nonetheless to detect whether the image has an alpha channel.

WTSAT_RGB (0x1)

0x1. The bitmap is an RGB image without alpha. The alpha channel is invalid and the Shell ignores it.

WTSAT_ARGB (0x2)

0x2. The bitmap is an ARGB image with a valid alpha channel.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2008

Header

Thumbcache.h

IDL

Thumbcache.idl

 

 

Send comments about this topic to Microsoft

Build date: 3/7/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
E_NOTIMPL for no thumbnail
When an object has no thumbnail in it, IThumbnailProvider::GetThumbnail should return E_NOTIMPL.  The caller needs to take care of the case, e.g., by showing a placeholder image.  Explorer falls back to the file icon when it sees E_NOTIMPL.  Any other HRESULT values (other than S_OK) appears to be unexpected error and to confuse the Explorer.
F5 Washes out image for IExtractImage, too
The problem with the image washing out when F5 is hit repeately also occurs for the older IExtractImage interface (on VISTA at least; W7 seems to have fixed that problem). Does Microsoft plan to fix this anytime soon?
Confirmation WSAT_RGB issue for Windows 7 32 bit
Thank you for that! 
We confirm that this does currently occur running on Windows 7 32 bit, with all updates applied as of 5/20/2010. 
However, Vista 32, 64 and Windows 7 64 bit seem to be okay. 
We were working on this problem ourselves and your comment, Leo, helped us. 
Thank You!
-Brian
You MUST still set the alpha channel even with WTSAT_RGB
If you set WTSAT_RGB then the shell should ignore the alpha channel; however, there seems to be a bug in both Vista and Windows 7 where the alpha channel is not ignored when a cached thumbnail is scaled to a very small size.

To reproduce this bug, leave the alpha channel as all zeros and set
WTSAT_RGB, then open Windows Explorer and resize the thumbnails to a small size. One notch below "Medium Icons" seems good.

Then hit F5 a few times. Your thumbnails should turn completely black. (Sometimes the selected file is drawn okay but the others are not.)

Workaround 1: Setting WSAT_UNKNOWN seems to solve the problem.
Workaround 2: Setting the alpha channel to all 255 also seems to solve it (but then what is the point of WTSAT_RGB?)

You may also notice that, even with the workarounds, when you hit F5 the thumbnail changes and becomes fainter. It seems like the initial drawing is done via one code path but (re-)drawing the cached thumbnail is done via another, which scales a different-sized image and doesn't respect the WTSAT_RGB flag.