BExplorer.Shell.Interop.ShellThumbnail.GetBitmapSource C# (CSharp) Method

GetBitmapSource() private method

private GetBitmapSource ( System size, System.Boolean isCopyItem = false ) : System.Windows.Media.Imaging.BitmapSource
size System
isCopyItem System.Boolean
return System.Windows.Media.Imaging.BitmapSource
        private BitmapSource GetBitmapSource(System.Windows.Size size, Boolean isCopyItem = false)
        {
            //FIXME: fix the cache retrieval options
            //RetrievalOption = ShellThumbnailRetrievalOption.Default;
            IntPtr hBitmap = GetHBitmap(size, isCopyItem);

            // return a System.Media.Imaging.BitmapSource
            // Use interop to create a BitmapSource from hBitmap.
            if (hBitmap != IntPtr.Zero)
            {
                BitmapSource returnValue = Imaging.CreateBitmapSourceFromHBitmap(
                        hBitmap,
                        IntPtr.Zero,
                        System.Windows.Int32Rect.Empty,
                        BitmapSizeOptions.FromEmptyOptions()).Clone();

                // delete HBitmap to avoid memory leaks
                Gdi32.DeleteObject(hBitmap);
                return returnValue;
            }

            return null;
        }

Same methods

ShellThumbnail::GetBitmapSource ( System iconOnlySize, System thumbnailSize ) : System.Windows.Media.Imaging.BitmapSource