簡體   English   中英

如何檢查Windows Phone 7和C#中兩個圖像的來源是否相同?

[英]how to check if sources of two images are same in Windows Phone 7 and C#?

如何在wp7 C#中檢查兩個圖像是否具有相同的源? 我這樣做但是沒有用。

if(image1.source.tostring()==image2.source.tostring()){}

我看不到任何簡單的方法。 ImageSource是一個抽象類,可以是任何東西,因此很難比較。 但最可能的實現是BitmapImage 所以,你可以檢查它的類型,如果是的BitmapImage或IUriContext你可以施放它和比較基本URI屬性。

您正在比較參考,比較值...

if(image1.source.ToString().Equals(image2.source.ToString())) {}

您可以在BitmapImage的幫助下比較兩個圖像

BitmapImage image1= new BitmapImage(new Uri("your first image relative path", UriKind.Relative))

BitmapImage image2= new BitmapImage(new Uri("your second image relative path", UriKind.Relative))

if(image1==image2)
{
MessageBox.show("Image matched.");
}
else
{
MessageBox.Show("Not matched.");
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM