CapturePhotoToStreamAsync and CapturePhotoToStorageFileAsync strange behaviour RRS feed

  • Question

  • Good morning everyone.

     I'm writing an application that needs to access the camera on the device and continuously capture frames to recognize a qrcode. I organized the code using a timer that runs every 100ms and stops and resumes itself as first and last thing during image processing.

    To get the current preview item i use:

    using (MemoryStream ms = new MemoryStream())
                        var p = Windows.Media.MediaProperties.ImageEncodingProperties.CreateBmp();
                        await m_Camera.CapturePhotoToStreamAsync(p, ms.AsRandomAccessStream());
                        ms.Seek(0, SeekOrigin.Begin);
                        wbmp = new WriteableBitmap(1, 1);
                        await wbmp.SetSourceAsync(ms.AsRandomAccessStream());
                        wbmp = new WriteableBitmap(wbmp.PixelWidth, wbmp.PixelHeight);
                        ms.Seek(0, SeekOrigin.Begin);
                        await wbmp.SetSourceAsync(ms.AsRandomAccessStream());

    And this works like a charm on my laptop computer.

    When I try the application on my Surface 2 RT an exception is raised every time the code executes. I only have the italian error message but basically what it says is that the subtype for the imageproperties is wrong. I checked that and it is a plain "BMP".

    Do you know how to solve this problem?

    P.S: Searching the italian error message only brings out this translation page: http://www.errortoenglish.com/it/W0T9J5G4/Default.aspx

    Thanks in advance


    Thursday, July 3, 2014 12:53 PM


  • So it does not seem like a coding issue. I think this would be best as a support case so we can track down why this hardware is having a problem.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, July 3, 2014 7:24 PM