天天看點

System.Drawing.Bitmap轉System.Windows.Media.ImageSource

可以用這種方法把圖檔類型轉成ImageSource類型

System.Drawing.Bitmap imageD = new System.Drawing.Bitmap(@"D:\項目\Split\bin\Debug\images\01.jpg");
IntPtr hBitmap = imageD.GetHbitmap();
image1.Source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
           

繼續閱讀