Color of a screen pixel: Difference between revisions

Content added Content deleted
Line 28: Line 28:
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.
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
<lang fsharp>open System.Drawing
open System.Windows.Forms


let GetPixel x y =
let GetPixel x y =
Line 34: Line 35:
g.CopyFromScreen(new Point(x,y), new Point(0,0), new Size(1,1))
g.CopyFromScreen(new Point(x,y), new Point(0,0), new Size(1,1))
let clr = img.GetPixel(0,0)
let clr = img.GetPixel(0,0)
(clr.R, clr.G, clr.B)</lang>
(clr.R, clr.G, clr.B)

let GetPixelAtMouse () =
let pt = Cursor.Position
GetPixel pt.X pt.Y
</lang>


=={{header|Java}}==
=={{header|Java}}==