I am trying to convert Bitmap (SystemIcons.Question) to BitmapImage , so I can use it in a WPF Image control.
I have the following method for converting it to BitmapSource , but it returns InteropBitmapImage , now the problem is how to convert it to BitmapImage . The direct order does not seem to work.
Does anyone know how to do this?
CODE:
public BitmapSource ConvertToBitmapSource() { int width = SystemIcons.Question.Width; int height = SystemIcons.Question.Height; object a = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(SystemIcons.Question.ToBitmap().GetHbitmap(), IntPtr.Zero, System.Windows.Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(width, height)); return (BitmapSource)a; }
to return BitmapImage: (tied to my image control)
public BitmapImage QuestionIcon { get { return (BitmapImage)ConvertToBitmapSource(); } }
source share