0
在WPF窗體上有一個System.Windows.Controls.Image,它有一個位圖。如何通過座標獲得image1.Source
的某個像素的顏色?System.Windows.Controls.Image - 嘗試獲取某個像素的顏色
在WPF窗體上有一個System.Windows.Controls.Image,它有一個位圖。如何通過座標獲得image1.Source
的某個像素的顏色?System.Windows.Controls.Image - 嘗試獲取某個像素的顏色
在Bitmap.GetPixel(x, y)方法請看:
參數
X類型:檢索像素的System.Int32的x座標。 y 類型:System.Int32要檢索的像素的y座標。
返回 值
類型:的System.Drawing.Color A顏色結構,它表示該顏色的指定像素的 。
image1.Source沒有GetPixel(x,y)方法,因爲它是ImageSource類的類型。 – Alexandre
@AlexMaslakov:你可以做的是首先將'ImageSource'轉換爲'Bitmap',然後應用我提出的方法。你可以看看這裏:http://blogs.msdn.com/b/llobo/archive/2007/03/08/bitmapsource-bitmap-interop.aspx,看看你可以從'ImageSource'轉換到'Bitmap' 。 – npinti
難道沒有更好的辦法嗎? – Alexandre