BitmapImage image = new BitmapImage(); image.BeginInit(); image.UriSource = new Uri("image.jpg", UriKind.RelativeOrAbsolute); image.EndInit();
BitmapImage image = new BitmapImage(); using (Stream stream = new MemoryStream(imageData)) { image.BeginInit(); image.StreamSource = stream; image.EndInit(); }This code creates a MemoryStream from a byte array of image data, and initializes a BitmapImage object with the MemoryStream as its source. The BeginInit and EndInit methods are called to begin and complete the initialization of the image. Package library: PresentationCore.dll