2016-11-05 136 views
1
var img1 = (pictureBox1.Image = Properties.Resources.dynamite); 
    var img2 = (pictureBox2.Image = Properties.Resources.apple); 
if (img1 != img2) 
        { 
         MessageBox.Show("ok"); 
         pictureBox1.Image = Properties.Resources.empty; 

        } 
        else 
        { 
         MessageBox.Show("no"); 
         Game_Over end = new Game_Over(); 
         end.Show(); 
        } 

我想創建一個簡單的遊戲。如果我打了果果選擇器是更換一個白衣空選擇器,如果你打一個炸藥拿到比賽結束如何檢查兩個PictureBox是否具有相同的圖像?

+0

獲取位圖並比較每個像素。 –

+0

http://stackoverflow.com/a/35153895/6527049 –

+0

那麼,水果忍者? –

回答

1

將圖像轉換成字節數組,然後做字節數組的比較。

Bytearray1.SequenceEqual(bytearray2)可以是真或假。

+1

您也可以使用散列函數來比較兩個字節數組。 –

相關問題