locked
BitmapSource to Bitmap to BitmapSource C# RRS feed

  • Question

  • I am writing a c# WPF app that gets images frame by frame from a camera and then does operations on them using the GetPixel and SetPixel methods from the Bitmap class. I get a System.Windows.Media.Imaging.BitmapSource from the camera. Is there any way to convert the BitmapSource to a Bitmap to do the operations and then convert it back in a way that preserves most of the frame rate?

    Thanks in advance,

    Wasabi Fan


    Wasabifan


    • Edited by Wasabi Fan Tuesday, April 10, 2012 10:21 PM
    Tuesday, April 10, 2012 10:00 PM

Answers

  • Sorry... I figured it out. I converted the BitmapSource to a byte array and operated on that, then converted it back. Thanks anyway!

    Wasabifan

    • Marked as answer by Wasabi Fan Tuesday, April 10, 2012 11:57 PM
    Tuesday, April 10, 2012 11:57 PM

All replies

  • You post isn't consistent.  "GetPixel and SetPixel" don't belong in the same post with "preserves most of the frame rate?"  If speed is important, you have to access the pixels directly from your code.
    Tuesday, April 10, 2012 10:55 PM
  • What I meant was that the very few ways I found on the internet took longer than the operation itself. Putting the conversion and the Bitmap operation together took way to long to be video. The operation on an image from the hard disk goes fairly quickly. if there is another way to get and set pixels, I would greatly appreciate knowing.


    Wasabifan



    • Edited by Wasabi Fan Tuesday, April 10, 2012 11:21 PM
    Tuesday, April 10, 2012 11:10 PM
  • Sorry... I figured it out. I converted the BitmapSource to a byte array and operated on that, then converted it back. Thanks anyway!

    Wasabifan

    • Marked as answer by Wasabi Fan Tuesday, April 10, 2012 11:57 PM
    Tuesday, April 10, 2012 11:57 PM