バイト配列をに変換し、画像コントロールにSystem.Windows.Media.Imaging.BitmapImage
表示します。BitmapImage
最初のコードを使用しているとき、注意が必要です! エラーも画像も表示されません。しかし、2番目のものを使用しているときはうまくいきます! 誰が何が起こっていると言うことができますか?
最初のコードは次のとおりです。
public BitmapImage ToImage(byte[] array)
{
using (System.IO.MemoryStream ms = new System.IO.MemoryStream(array))
{
BitmapImage image = new BitmapImage();
image.BeginInit();
image.StreamSource = ms;
image.EndInit();
return image;
}
}
2番目のコードは次のとおりです。
public BitmapImage ToImage(byte[] array)
{
BitmapImage image = new BitmapImage();
image.BeginInit();
image.StreamSource = new System.IO.MemoryStream(array);
image.EndInit();
return image;
}