Converting Image<byte> to MemoryStream without converting to WriteableBitmap first RRS feed

  • Question

  • Is there a way to directly convert Image<byte> to MemoryStream?

    The only way I know is to convert Image<byte> into a WriteableBitmap by using ImageConverter.SdkToSystem(), then use SaveJpeg to store it in a stream. However, we can only use WriteableBitmap in a UI thread. I don't want to block my UI, so I'm wondering if there are any alternative ways to bypass WriteableBitmap?

    Ways I have tried:

    1. new MemoryStream(byte[]) creates a file with the wrong format (it doesn't encode the byte array with the JPEG codec).

    2. Microsoft.FaceSdk.ImageHelper.IO.ImageWriter.SaveJpeg also needs to be done in the UI thread.

    Wednesday, August 7, 2013 3:00 AM