我正在使用以下代码来获取屏幕上特定像素的颜色,但由于某种原因,它总是返回黑色。这是我正在使用的代码:
Rectangle pixel = new Rectangle((int)screenPosition.X, (int)screenPosition.Y, 1, 1);
Texture2D backBufferData = new Texture2D(ScreenManager.GraphicsDevice, ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth, ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight);
Color[] waterPixel = new Color[1];
backBufferData.GetData<Color>(0, pixel, waterPixel, 0, 1);