我有一个1080 p的显示器。正在做什么
int j Screen.PrimaryScreen.Bounds.Width;
int k = Screen.PrimaryScreen.Bounds.Height;
_Bitmap.GetPixel(j, k).GetBrightness();(_Bitmap大小等于我的屏幕边界),它抛出一个异常,说明“参数必须是正的和<高度”。
发布于 2016-03-08 21:46:10
宽度和高度从1开始计数,GetPixel()中使用的索引从0开始。因此,当试图在(宽度、高度)访问像素时,什么都找不到。
若要更正错误,请将代码更改为(例如):
int width = Screen.PrimaryScreen.Bounds.Width;
int height = Screen.PrimaryScreen.Bounds.Height;
_Bitmap.GetPixel(width-1,height-1).GetBrightness();https://stackoverflow.com/questions/35877075
复制相似问题