/// <summary>
//Bitmapsource To Bitmap
/// </summary>
/// <param name="bs">需转化的Bitmapsource</param>
/// <returns>Bitmap</returns>
public static Bitmap BitmapsourceToBitmap(BitmapSource bs)
{
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(bs.PixelWidth, bs.PixelHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);
System.Drawing.Imaging.BitmapData data = bmp.LockBits(
new System.Drawing.Rectangle(System.Drawing.Point.Empty, bmp.Size),
System.Drawing.Imaging.ImageLockMode.WriteOnly,
System.Drawing.Imaging.PixelFormat.Format32bppPArgb
);
bs.CopyPixels(Int32Rect.Empty, data.Scan0, data.Height * data.Stride, data.Stride); bmp.UnlockBits(data);
return bmp;
}