jpgファイルを読み取り、後で画像コントロールに表示する必要があります。以下は完全に機能します。
imgTwo.Source = FetchImage(@"C:\Image075.jpg");
public BitmapSource FetchImage(string URLlink)
{
JpegBitmapDecoder decoder = null;
BitmapSource bitmapSource = null;
decoder = new JpegBitmapDecoder(new Uri(URLlink, UriKind.Absolute), BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.OnLoad);
bitmapSource = decoder.Frames[0];
bitmapSource.Freeze();
return bitmapSource;
}
私の問題は、この画像をByte [](varbinary(MAX)としてデータベースに保持し、上記のようにファイルから直接ではなく、そこから読み取る必要があることです。したがって、入力としてByte[]を使用する必要があります。 URLlink文字列の代わりにこの関数に追加するか、BitmapSourceをByte []として保存します。これを行うにはどうすればよいですか?