Results 1 to 2 of 2
  1. #1
    javaaspr is offline Member
    Join Date
    Apr 2012
    Posts
    1
    Rep Power
    0

    Default knowing color of a pixel in a window

    how to find the rgb values for a selected pixel in a frame window or awt window.
    Is there any method that takes position of a pixel in a frame window and return color of that pixel

  2. #2
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    340
    Rep Power
    5

    Default Re: knowing color of a pixel in a window

    I'm not sure if this is what you are looking for, but for any object that extends Component, you can call getColorModel(), which returns the instance of ColorModel used to display the component.
    With the ColorModel, you can then call getRGB(int pixel), passing in the pixel you are interested in, and it will return the color components of the pixel in the default RGB color model format.

    For example:

    Java Code:
    myJFrame.getColorModel().getRGB(400);
    Last edited by sehudson; 04-02-2012 at 09:09 PM.

Similar Threads

  1. scanning an image for a certain pixel color
    By lostsoul28 in forum New To Java
    Replies: 1
    Last Post: 02-01-2012, 01:50 PM
  2. Replies: 4
    Last Post: 11-08-2011, 05:04 AM
  3. Replies: 1
    Last Post: 11-08-2011, 05:04 AM
  4. Find Pixel With RGB Color?
    By TyCox94 in forum JDBC
    Replies: 8
    Last Post: 09-23-2011, 04:20 AM
  5. can you ask the color of one pixel?
    By liluma in forum New To Java
    Replies: 7
    Last Post: 09-06-2011, 07:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •