1. Use MemeoryStream 

 1 ImageBrush backBrush = new ImageBrush();
 2 BitmapImage bi = new BitmapImage();
 3 bi.BeginInit();
 4 MemoryStream ms = new MemoryStream();
 5 iMove.app.EastOnline.Properties.Resources.Background.Save(ms, ImageFormat.Bmp); // System.Drawing.Image;
 6 ms.Seek(0, SeekOrigin.Begin);
 7 bi.StreamSource = ms;
 8 bi.EndInit();
 9 backBrush.ImageSource = Imaging.CreateBitmapSourceFromHBitmap(hBitImage, IntPtr.Zero, Int32Rect.Empty,
10                     BitmapSizeOptions.FromEmptyOptions());
11                 backBrush.Stretch = Stretch.Fill;
12                 this.Background = backBrush;

 

 

2. Use Imaging

ImageBrush backBrush = new ImageBrush();
         
IntPtr hBitImage = iMove.app.EastOnline.Properties.Resources.Background.GetHbitmap();

backBrush.ImageSource = Imaging.CreateBitmapSourceFromHBitmap(hBitImage, IntPtr.Zero, Int32Rect.Empty,
                    BitmapSizeOptions.FromEmptyOptions());
                backBrush.Stretch = Stretch.Fill;
this.Background = backBrush;

相关文章:

  • 2022-12-23
  • 2021-07-19
  • 2021-05-20
  • 2021-11-24
  • 2022-12-23
  • 2021-11-12
  • 2022-02-09
  • 2022-12-23
猜你喜欢
  • 2021-07-28
  • 2021-05-19
  • 2021-07-10
  • 2022-02-02
  • 2022-12-23
  • 2022-02-23
相关资源
相似解决方案