Skip to content

Instantly share code, notes, and snippets.

Created October 17, 2016 01:27
What would you like to do?
Create BitmapImage from byte array.
public static BitmapImage Create(byte[] bytes)
var result = new BitmapImage();
using (var stream = new MemoryStream(bytes))
result.CacheOption = BitmapCacheOption.OnLoad;
result.CreateOptions = BitmapCreateOptions.None;
result.StreamSource = stream;
result.Freeze(); // 非UIスレッドから作成する場合、Freezeしないとメモリリークするため注意
return result;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment