From 6d88dc4f8734db3041803d384087dddde64846a8 Mon Sep 17 00:00:00 2001 From: David Hall Date: Sat, 20 Jan 2018 18:14:18 -0700 Subject: [PATCH] Added IThumbnailProvider --- PInvoke/Shell32/Thumbcache.cs | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 PInvoke/Shell32/Thumbcache.cs diff --git a/PInvoke/Shell32/Thumbcache.cs b/PInvoke/Shell32/Thumbcache.cs new file mode 100644 index 00000000..bd991640 --- /dev/null +++ b/PInvoke/Shell32/Thumbcache.cs @@ -0,0 +1,41 @@ +using System; +using System.Runtime.InteropServices; + +// ReSharper disable InconsistentNaming + +namespace Vanara.PInvoke +{ + public static partial class Shell32 + { + /// Alpha channel type information. + public enum WTS_ALPHATYPE + { + /// The bitmap is an unknown format. The Shell tries nonetheless to detect whether the image has an alpha channel. + WTSAT_UNKNOWN = 0x0, + /// The bitmap is an RGB image without alpha. The alpha channel is invalid and the Shell ignores it. + WTSAT_RGB = 0x1, + /// The bitmap is an ARGB image with a valid alpha channel. + WTSAT_ARGB = 0x2 + } + + /// Exposes a method for getting a thumbnail image. + [ComImport, Guid("e357fccd-a995-4576-b01f-234630154e96"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + public interface IThumbnailProvider + { + /// Gets a thumbnail image and alpha type. + /// + /// 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. + /// + /// + /// 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. + /// + /// When this method returns, contains a pointer to one of the following values from the WTS_ALPHATYPE enumeration. + /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + void GetThumbnail(uint cx, out IntPtr phbmp, out WTS_ALPHATYPE pdwAlpha); + } + } +} \ No newline at end of file