interopbitmapimage

WPF Image: .Source = Clipboard.GetImage() is not displayed

ぃ、小莉子 提交于 2019-12-02 07:55:48
问题 This simple program does not work, the image does not appear in the Window. namespace ClipBoardTest { public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void CopyButton_Click(object sender, RoutedEventArgs e) { if (Clipboard.ContainsImage()) { ImageUIElement.Source = Clipboard.GetImage(); Console.WriteLine("Clipboard copied to UIElement"); } else { Console.WriteLine("No image in Clipboard"); } } } } Output is "Clipboard copied to UIElement", but

InteropBitmap to BitmapImage

我们两清 提交于 2019-12-01 17:49:28
I'm trying to Convert a Bitmap (SystemIcons.Question) to a BitmapImage so I can use it in a WPF Image control. I have the following method to convert it to a BitmapSource , but it returns an InteropBitmapImage , now the problem is how to convert it to a BitmapImage . A direct cast does not seem to work. Does anybody know how to do it? 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

InteropBitmap to BitmapImage

▼魔方 西西 提交于 2019-12-01 17:19:31
问题 I'm trying to Convert a Bitmap (SystemIcons.Question) to a BitmapImage so I can use it in a WPF Image control. I have the following method to convert it to a BitmapSource , but it returns an InteropBitmapImage , now the problem is how to convert it to a BitmapImage . A direct cast does not seem to work. Does anybody know how to do it? CODE: public BitmapSource ConvertToBitmapSource() { int width = SystemIcons.Question.Width; int height = SystemIcons.Question.Height; object a = System.Windows