locked
Convert Windows.Storage.Streams.IBuffer to Windows.UI.Xaml.Imaging.BitMapImage RRS feed

  • Question

  • Hi

    I am developing a windows store app program for Mjpg streaming. I developed a winform app as well as wpf app for the same purpose. I will include my code here.

     public sealed partial class MainPage : Page
        {
            MjpegDecoder _mjpeg;
            public MainPage()
            {
                this.InitializeComponent();
                _mjpeg = new MjpegDecoder();
                _mjpeg.FrameReady += _mjpeg_FrameReady;
            }
            void _mjpeg_FrameReady(object sender, FrameReadyEventArgs e)
            {

               var a = e.FrameBuffer;     
           
            }

    Here the e.FrameBuffer will return  windows.storage.streams.Ibuffer. I need to take the bitmap object contained in this and assign to an image control in my xaml. How to accomplish this ?

    Please help

    Vishnu

    Thursday, November 14, 2013 11:34 AM

Answers

  • Take a look at the BitmapImage class to see how it can be initialized: from an image file or from an IRandomAccessStream. This suggests converting your buffer into one of those.

    In this case, I'd create an InMemoryRandomAccess stream, connect it to a DataWriter, and then copy the buffer in. See the Reading and writing data sample for an example.

    --Rob

    Thursday, November 14, 2013 6:33 PM
    Moderator