Tags: applies, decided, display, filter, graphical, grayscale, interface, microsoft, msdn, obtaining, pixel, programming, software, user, value, visual

Obtaining a pixel (grayscale) value from the display

On Microsoft » Microsoft Visual C#

1,651 words with 2 Comments; publish: Sun, 23 Dec 2007 11:55:00 GMT; (30093.75, « »)

Hi all,

I just got into the world of C# programming and decided to use this to make a little graphical user interface which applies a filter to an image.

Basically what I am trying to do is display an image (ie, load an image onto a picturebox) and then sample pixel (grayscale) values at various points. After obtaining these values, I wish to paint a circle per sample point, using Fillellipse() function, on a separate picturebox, where the color of the brush will match that of the grayscale value obtained.

The problem that I am faced with is obtaining the pixel values from the displayed image. Most of the questions posted here seems to be focused on accessing the pixel values directy from the bitmap file via bitmapdata construct. However, I was wondering whether it is possible to obtain the pixel value of a point on the form, and if so how would I be able to obtain the grayscale value of the pixel such that this value can be used to define the color of a solidbrush that I may use to fill in an ellipse?

If there is a simpler way of doing all this, I am more than willing to know about that too.

Thank you very much for your help in advance~

All Comments

Leave a comment...

    • The

      only way you can sample the form image is by blitting its image into a

      bitmap off the desktop. That's error prone, the form could well

      be covered by another window. And it still requires you use

      GetPixel to get the form image's pixel color value. So, stick

      with GetPixel or LockBits...

      #1; Thu, 30 Aug 2007 20:16:00 GMT
    • thanks heaps nobugz, I will do that.



      #2; Thu, 30 Aug 2007 20:17:00 GMT