介绍几种常用的Image source 赋值方式: this.abc.Source = new BitmapImage(new Uri("/1.jpg", UriKind.RelativeOrAbsolute)); Uri uri = new Uri("1.jpg", UriKind.Relative); ImageSource imgSource = new System.Windows.Media.Imaging.BitmapImage(uri); this.a
bitmap to bytes Bitmap b = new Bitmap( "test.bmp "); MemoryStream ms = new MemoryStream(); b.Save(ms,System.Drawing.Imaging.ImageFormat.Bmp); byte[] bytes= ms.GetBuffer(); //byte[] bytes= ms.ToArray(); 这两句都可以,至于区别么,下面有解释 ms.Close(); bytes to bit
var imgsource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(bmp.GetHbitmap(),IntPtr.Zero,Int32Rect.Empty,BitmapSizeOptions.FromEmptyOptions()); 替换bmp