2

I am programming a Universal Windows App in C# and have ran into a point in my code where I wish to get a pixel array out of a BitmapImage object.

Although one can do this easily with BitmapImage.CopyPixels() if one is using the System.Windows.Media.Imaging namespace, I found the namespace was unavailable for Windows Universal Apps. Instead I used the Windows.UI.Xaml.Media.Imaging namespace to import my image, which does not have the BitmapImage.CopyPixels( ) method.

Fortunately, I can create a BitmapDecoder object with the Windows.Graphics.Imaging namespace, which does allow me to extract the pixel information using BitmapDecoder.GetPixelDataAsync( ) function. Unfortunately I cannot find a way too convert a BitmapImage to a BitmapDecoder.

Is there a way to do this, or am I going about fetching a pixel array from a BitmapImage object the complete wrong way? Any suggestions would help!

Kevin Brant
  • 141
  • 5
  • Create a temp file in local storage.
    For each image whose pixel you need write it into that temp file. Now you can read it and use BitmapDecoder to get your pixels. You can refer [this tutorial](http://www.contentmaster.com/winrt/accessing-image-pixel-data-in-a-c-windows-store-app/)
    – Jerin Feb 04 '16 at 05:03
  • 1
    You may take a look [at this answer](http://stackoverflow.com/a/34191801/2681948). – Romasz Feb 04 '16 at 06:37
  • Thanks for the help. – Kevin Brant Feb 04 '16 at 12:18

0 Answers0