Posted By

caringprogrammer on 02/06/12


Tagged

bitmap bitmapsource c#


Versions (?)

How to convert BitmapSource to Bitmap


 / Published in: C#
 

URL: http://caringprogrammer.blogspot.com/

Converting BitmapSource to Bitmap in C#

  1. private System.Drawing.Bitmap BitmapFromSource(BitmapSource bitmapsource)
  2. {
  3. System.Drawing.Bitmap bitmap;
  4. using (MemoryStream outStream = new MemoryStream())
  5. {
  6. BitmapEncoder enc = new BmpBitmapEncoder();
  7.  
  8. enc.Frames.Add(BitmapFrame.Create(bitmapsource));
  9. enc.Save(outStream);
  10. bitmap = new System.Drawing.Bitmap(outStream);
  11. }
  12. return bitmap;
  13. }

Report this snippet  

You need to login to post a comment.