I have a late 2013 13" macbook pro, where I've Windows 8.1 via bootcamp. The resolution is 2560×1600
There I've written a small test application which reads pixel color from the screen.
[DllImport("user32.dll")]
static extern IntPtr GetDC(IntPtr hwnd);
[DllImport("user32.dll")]
static extern Int32 ReleaseDC(IntPtr hwnd, IntPtr hdc);
[DllImport("gdi32.dll")]
static extern uint GetPixel(IntPtr hdc, int nXPos, int nYPos);
public Color GetPixelColor(int x, int y)
{
IntPtr hdc = GetDC(IntPtr.Zero);
uint pixel = GetPixel(hdc, x, y);
ReleaseDC(IntPtr.Zero, hdc);
Color color = Color.FromArgb((int)(pixel & 0x000000FF),
(int)(pixel & 0x0000FF00) >> 8,
(int)(pixel & 0x00FF0000) >> 16);
return color;
}
//And other methods which utilize this method.
The problem that is that it reads incorrect values. It appears that it gets color with some huge offset on windows explorer (e.g. if I try to get pixel from (200, 20), it seems to get color from (800, 20)), as well as it reads incorrect values if I have a game in foreground. From game window it reads greyish-black colors only from everywhere.
I've tried changing resolution to 1920x1080 as well.
Looks like I have all drivers up to date.
Also this application works flawlessly on regular desktop or laptop, I've tested it.
Any idea what could be the reason why it behaves in such odd fashion?
User contributions licensed under CC BY-SA 3.0