CSharp examples for System.Windows.Media.Imaging:BitmapImage
BitmapImage To Bitmap
using System.Drawing.Point; using System.Windows.Media.Imaging; using System.Windows; using System.IO;//from w ww . j a va 2 s .c om using System.Drawing.Imaging; using System.Drawing; public class Main{ public static Bitmap BitmapImageToBitmap(BitmapImage source) { var bmp = new Bitmap(source.PixelWidth, source.PixelHeight, PixelFormat.Format32bppRgb); BitmapData data = bmp.LockBits(new Rectangle(Point.Empty, bmp.Size), ImageLockMode.WriteOnly, PixelFormat.Format32bppRgb); source.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height*data.Stride, data.Stride); bmp.UnlockBits(data); return bmp; } }