Color of a screen pixel: Difference between revisions

No edit summary
Line 25:
 
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.
<lang fsharp>open System.Drawing
 
let GetPixel x y =
use img = new Bitmap(1,1)
use g = Graphics.FromImage(img)
g.CopyFromScreen(new Point(x,y), new Point(0,0), new Size(1,1))
let clr = img.GetPixel(0,0)
(clr.R, clr.G, clr.B)</lang>
 
=={{header|Java}}==
<lang java>public static Color getColorAt(int x, int y){
Anonymous user