Im tying together two libraries. One only gives output of type System.Windows.Media.Imaging.BitmapSource
, the other only accepts input of type System.Drawing.Image
. I havent been able to find a way to convert a BitmapSource to a Image.
views:
62answers:
2
A:
I think you may find a code sample to do that here: http://stackoverflow.com/questions/2284353/is-there-a-good-way-to-convert-between-bitmapsource-and-bitmap
What do you think about it?
samy
2010-09-20 13:07:55
+1
A:
private System.Drawing.Bitmap BitmapFromSource(BitmapSource bitmapsource)
{
System.Drawing.Bitmap bitmap;
using (MemoryStream outStream = new MemoryStream())
{
BitmapEncoder enc = new BmpBitmapEncoder();
enc.Frames.Add(BitmapFrame.Create(bitmapsource));
enc.Save(outStream);
bitmap = new System.Drawing.Bitmap(outStream);
}
return bitmap;
}
John Gietzen
2010-09-20 13:08:07