I am creating a byte array with arbitrary values in it and want to convert it into a BitmapImage.
bi = new BitmapImage(); using (MemoryStream stream = new MemoryStream(data)) { try { bi.BeginInit(); bi.CacheOption = BitmapCacheOption.OnLoad; bi.StreamSource = stream; bi.DecodePixelWidth = width; bi.EndInit(); } catch (Exception ex) { return null; } } This code gives me a NotSupportedException all the time. How could I create a BitmapSource from any byte array?