if (picture != null) { Int32 h = picture.Height; Int32 w = picture.Width; Int32 R = picture.GetPixel(e.X, e.Y).R; Int32 G = picture.GetPixel(e.X, e.Y).G; Int32 B = picture.GetPixel(e.X, e.Y).B; lbPixelValue.Text = "R:"+R+ " G:"+G+ " B:"+B; lbCoordinates.Text = String.Format("X: {0}; Y: {1}", e.X, e.Y);
使用上面的代码,我尝试从图片框上的鼠标悬停获取像素值。
有时此代码运行正常,但有时代码错误:
parameter must to be positive and < height
错误:Int32 R = picture.GetPixel(e.X, e.Y).R;
我尝试调试,问题是Y > image.height
有什么问题所以我可以得到Y > height
图片
我该如何解决?