Anonymous user
Color of a screen pixel: Difference between revisions
Don't copy entire screen (thanks to F# example)
(Don't copy entire screen (thanks to F# example)) |
|||
Line 20:
int h = Screen.PrimaryScreen.Bounds.Height;
Bitmap img = new Bitmap(
Graphics g = Graphics.FromImage(img);
g.CopyFromScreen(new Point(
Color color = img.GetPixel(x, y);</lang>
=={{header|F_Sharp|F#}}==
The C# example copies the entire screen into our private bitmap but that's unnecessary. All we need is the single pixel. Also, it doesn't appear that the bitmap and graphics object are being disposed of there. Other than that, this is essentially identical to that solution.
|