任何人都可以建议一种方法将2352x1726x8bit灰度BitmapSource
转换为Bitmap
,比3.2GHz P4上的速度大约600ms更快:
public static Bitmap toBitmap(this BitmapSource bitmapsource)
{
Bitmap bitmap;
using (MemoryStream stream = new MemoryStream())
{
// from System.Media.BitmapImage to System.Drawing.Bitmap
PngBitmapEncoder enc = new PngBitmapEncoder();
enc.Frames.Add(BitmapFrame.Create(bitmapsource));
enc.Save(stream);
bitmap = new System.Drawing.Bitmap(stream);
}
return bitmap;
}