2 つの BitmapImage オブジェクトを比較する最も簡単な方法は何ですか? 1 つは Image Source プロパティにあり、もう 1 つはコードで作成します。
新しいビットマップ イメージでイメージ ソースを設定できますが、同じイメージを何度も設定し続けるため、ちらつきが発生します。
ピクセルが Image.Source のピクセルと異なる場合にのみ、画像を設定したいと思います。
編集:
AlbumArt は、ビュー内のイメージです (MVVM に従います)。
いくつかのコード (コード ビハインド ビューで実行):
Task.Factory.StartNew(() =>
{
while (((App)Application.Current).Running)
{
Thread.Sleep(1000);
Application.Current.Dispatcher.Invoke(new Action(() =>
{
if ((this.DataContext as AudioViewModel).CurrentDevice != null)
{
if ((((this.DataContext as AudioViewModel).CurrentDevice) as AUDIO).SupportsAlbumArt)
{
BitmapImage image = new BitmapImage();
image.BeginInit();
image.UriSource = new Uri((((this.DataContext as AudioViewModel).CurrentDevice) as AUDIO).AlbumArt);
image.CacheOption = BitmapCacheOption.None;
image.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
image.EndInit();
AlbumArt.Source = image;
...