How to convert BitmapSource to Bitmap


/ Published in: C#
Save to your folder(s)

Converting BitmapSource to Bitmap in C#


Copy this code and paste it in your HTML
  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. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.