Get a pixel color on the desktop
-
Is there a function that will retrieve the pixel color on a daesktop location? Or a function that will alliow me to save the desktop as a bitmap?
-------------------------------------------------------- 1 line of code equals many bugs. So don't write any!! My mad coder blog
-
Is there a function that will retrieve the pixel color on a daesktop location? Or a function that will alliow me to save the desktop as a bitmap?
-------------------------------------------------------- 1 line of code equals many bugs. So don't write any!! My mad coder blog
There was an article of a simple screen effect not too long ago. I lost the link to it, but here's the basic code:
int screenWidth = Screen.GetBounds(new Point(0, 0)).Width;
int screenHeight = Screen.GetBounds(new Point(0, 0)).Height;
Bitmap screenShot = new Bitmap(screenWidth, screenHeight);
Graphics gfx = Graphics.FromImage((Image)screenShot);
gfx.CopyFromScreen(0, 0, 0, 0, new Size(screenWidth, screenHeight));After that, you should be able to use
GetPixel
on thescreenShot
variable to get pixel values from the desktop.
Logifusion[^] If not entertaining, write your Congressman.
-
There was an article of a simple screen effect not too long ago. I lost the link to it, but here's the basic code:
int screenWidth = Screen.GetBounds(new Point(0, 0)).Width;
int screenHeight = Screen.GetBounds(new Point(0, 0)).Height;
Bitmap screenShot = new Bitmap(screenWidth, screenHeight);
Graphics gfx = Graphics.FromImage((Image)screenShot);
gfx.CopyFromScreen(0, 0, 0, 0, new Size(screenWidth, screenHeight));After that, you should be able to use
GetPixel
on thescreenShot
variable to get pixel values from the desktop.
Logifusion[^] If not entertaining, write your Congressman.
-
Just noticed that .Net 2.0 now supports CopyFromScreen() feature, which should be quite handy for GDI+ developers. Thanks for posting, Dustin.
Best, Jun