public static NativeMethods.IconHandle CreateIconHandleFromImageSource(ImageSource image, Size size) { IconHelper.EnsureSystemMetrics(); bool flag = false; BitmapFrame bitmapFrame = image as BitmapFrame; bool flag2; if (bitmapFrame == null) { flag2 = (null != null); } else { BitmapDecoder decoder = bitmapFrame.Decoder; flag2 = (((decoder != null) ? decoder.Frames : null) != null); } if (flag2) { bitmapFrame = IconHelper.GetBestMatch(bitmapFrame.Decoder.Frames, size); flag = (bitmapFrame.Decoder is IconBitmapDecoder || ((double)bitmapFrame.PixelWidth == size.Width && (double)bitmapFrame.PixelHeight == size.Height)); image = bitmapFrame; } if (!flag) { bitmapFrame = BitmapFrame.Create(IconHelper.GenerateBitmapSource(image, size)); } return(IconHelper.CreateIconHandleFromBitmapFrame(bitmapFrame)); }
public static void GetIconHandlesFromImageSource(ImageSource image, out NativeMethods.IconHandle largeIconHandle, out NativeMethods.IconHandle smallIconHandle) { IconHelper.EnsureSystemMetrics(); largeIconHandle = IconHelper.CreateIconHandleFromImageSource(image, IconHelper.s_iconSize); smallIconHandle = IconHelper.CreateIconHandleFromImageSource(image, IconHelper.s_smallIconSize); }