bazzinga on Fri, 14 Dec 2012 16:29:44


is there any API available to convert images on a thread other than the dispatcher/UI thread?

I need to convert image data I read from a file or from the webcam (JPG, PNG via IRandomAccessStream) to bitmap data. I used WriteableBitmap before to get the pixel data from the image stream. Now I need to run this code on a background thread and also need to create unit tests to test my code. Therefore I can't use WriteableBitmap or similar classes since they require to run on the UI thread.

Is there any WinRT API or a library I can use to accomplish this? I can't schedule the code to run on the UI thread.

Thanks for your help



bazzinga on Sun, 16 Dec 2012 20:29:53

Okay, BitmapDecoder is the answer. BitmapDecoder.CreateAsync can be used on a non-UI thread. It is now working in my unit tests and in a background worker in my application.

Note that this is different from the WPF BitmapDecoder. The WinRT version does not derive from DispatcherObject and therefore can be used in this situation luckily.