Farve på pixel ved mousepointer
Er ved at lave et program hvor jeg skal vide farven på en pixel ved en bestemt x,y position, meeeeen, det ser ikke helt ud til at virke, nogen forslag? :)[DllImport("user32.dll")]
public static extern IntPtr GetWindowDC(IntPtr hwnd);
[DllImport("user32.dll")]
public static extern IntPtr GetDC(IntPtr hwnd);
[DllImport("user32.dll")]
public static extern IntPtr WindowFromPoint(Point pt);
[DllImport("gdi32.dll")]
public static extern int GetPixel(IntPtr hdc, int x, int y);
// Dette kører i en timer
IntPtr hWnd = WindowFromPoint(Cursor.Position);
IntPtr hDc = GetDC(hWnd);
int intcolor = GetPixel(hDc, Cursor.Position.X,Cursor.Position.Y);
Color colorColor = Color.FromArgb((intColor & 0x000000FF), (intColor & 0x0000FF00) >> 8, (intColor & 0x00FF0000) >> 16);
Form1.ActiveForm.BackColor = colorColor;
