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 |
|
|
IDL |
|
Send comments about this topic to Microsoft
Build date: 3/7/2012
- 5/27/2011
- Alissa Sabre
- 1/9/2011
- steveh01
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
- 5/20/2010
- barbarian
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.
- 2/6/2010
- Leo Davidson