mad*_*ans 2 c# visual-studio-2013
我有一台1080P显示器.干
int j Screen.PrimaryScreen.Bounds.Width;
int k = Screen.PrimaryScreen.Bounds.Height;
_Bitmap.GetPixel(j, k).GetBrightness();
Run Code Online (Sandbox Code Playgroud)
(_Bitmap大小等于我的屏幕边界),它抛出一个异常,说"参数必须为正且<height".
Width和Height从1开始计数,GetPixel()中使用的索引从0开始.因此,当尝试以(宽度,高度)访问Pixel时,找不到任何内容
要更正错误,请将代码更改为(例如):
int width = Screen.PrimaryScreen.Bounds.Width;
int height = Screen.PrimaryScreen.Bounds.Height;
_Bitmap.GetPixel(width-1,height-1).GetBrightness();
Run Code Online (Sandbox Code Playgroud)