Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Get a pixel color on the desktop

Get a pixel color on the desktop

Scheduled Pinned Locked Moved C#
comgraphicstoolsquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Ista
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • I Ista

      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

      D Offline
      D Offline
      Dustin Metzgar
      wrote on last edited by
      #2

      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 the screenShot variable to get pixel values from the desktop.


      Logifusion[^] If not entertaining, write your Congressman.

      J 1 Reply Last reply
      0
      • D Dustin Metzgar

        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 the screenShot variable to get pixel values from the desktop.


        Logifusion[^] If not entertaining, write your Congressman.

        J Offline
        J Offline
        Jun Du
        wrote on last edited by
        #3

        Just noticed that .Net 2.0 now supports CopyFromScreen() feature, which should be quite handy for GDI+ developers. Thanks for posting, Dustin.

        Best, Jun

        L 1 Reply Last reply
        0
        • J Jun Du

          Just noticed that .Net 2.0 now supports CopyFromScreen() feature, which should be quite handy for GDI+ developers. Thanks for posting, Dustin.

          Best, Jun

          L Offline
          L Offline
          leppie
          wrote on last edited by
          #4

          Me too :-O

          **

          xacc.ide-0.2.0.57 - now with C# 2.0 parser and seamless VS2005 solution support!

          **

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups