1

ushort 配列から BitmapImage を作成することは可能ですか? もしそうなら、どのように?

現時点では、ビットマップを作成し、ビットマップ配列に変換して表示していますが、これは遅すぎます。各フレームが UI スタッドを作成している間、画像 (ライブ ビデオ フィード) を継続的に更新する必要があります。ビデオの実行中にアプリが非常に遅くなります。したがって、できるだけ早く ushort[] を BitmapImage に取得する必要があります

ありがとう、イーモン

4

2 に答える 2

2

ここに、MemoryStream を介して BitmapImage を取得する方法の例があります。

BitConverterを使用して、ushorts を MemoryStream への入力用のバイトに変換できます

于 2011-03-21T18:28:50.190 に答える
1

間の値を操作していると仮定すると0255それをバイト配列にキャストしてから、次のようにロードできますMemoryStream

// Please note that with values higher than 255 the program will throw an exception
checked
{
    ushort[] values = { 200, 100, 30/*, 256*/ };
    var bytes = (from value in values
                 select (byte)value).ToArray();

    // Taken from: http://stackoverflow.com/questions/5346727/wpf-convert-memory-stream-to-bitmapimage
    using (var stream = new MemoryStream(data))
    {
        var bitmap = new BitmapImage();
        bitmap.BeginInit();
        bitmap.StreamSource = stream;
        bitmap.CacheOption = BitmapCacheOption.OnLoad;
        bitmap.EndInit();
        bitmap.Freeze();
    }
}
于 2011-03-21T18:49:51.363 に答える