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