Results 1 to 8 of 8
  1. #1
    liluma's Avatar
    liluma is offline Member
    Join Date
    May 2011
    Location
    belgium
    Posts
    50
    Rep Power
    0

    Default can you ask the color of one pixel?

    so i'm thinking about using that for an easier way to save a map(gameboard...)

    so i would just use that as a form of database...
    so just a simple pictures, and each pixel would represent a wall, an ennemy ( each color would represent one type...) ,... and so one and one...

    so is there a way to check with if's what the hexadecimal color is

    anyone an idea if this is possible? and what API i could/should use for that?

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,267
    Rep Power
    25

    Default Re: can you ask the color of one pixel?

    Yes there are methods for getting the color of a pixel. The getRGB method of several classes would do that.

  3. #3
    liluma's Avatar
    liluma is offline Member
    Join Date
    May 2011
    Location
    belgium
    Posts
    50
    Rep Power
    0

    Default Re: can you ask the color of one pixel?

    so that would give me the hexadecimal value of the color?

    so i could write it in an if like this
    Java Code:
    int color = the method you suggested...
    
    if(color = 0xffff00)
    {
    code i want to do...
    }

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,267
    Rep Power
    25

    Default Re: can you ask the color of one pixel?

    Did you look up the getRGB method to see if it returns the value you want?

  5. #5
    liluma's Avatar
    liluma is offline Member
    Join Date
    May 2011
    Location
    belgium
    Posts
    50
    Rep Power
    0

    Default Re: can you ask the color of one pixel?

    yes

    it says this

    return type int

    methode description: getRGB(int x, int y)

    Returns an integer pixel in the default RGB color model (TYPE_INT_ARGB) and default sRGB colorspace.


    but i don't know(or should i say understand what the dutch equivalent vor colorspace is...

    so i don't get if it's the int value of the hexadecimal equivalent is that is returned...

  6. #6
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,267
    Rep Power
    25

    Default Re: can you ask the color of one pixel?

    What is the difference between an int value and a hexadecimal value?
    Everything in the computer is in binary. The value fifteen is 15 base 10 and F base 16(hex) or 1111 base 2(binary)
    What I'm saying is there is only one value and it can be represented in any number base. It is still the same number.

    Write a small program that creates a buffered image, gets its graphics content, fill it with a color and then do a getRGB and see what you get.
    Use Integer.toHexString() to show the value in hex

  7. #7
    liluma's Avatar
    liluma is offline Member
    Join Date
    May 2011
    Location
    belgium
    Posts
    50
    Rep Power
    0

    Default Re: can you ask the color of one pixel?

    realy ty... :p

    will give it a try,
    think it'll work.. :p ^^

    ty very much Norm
    Last edited by liluma; 09-06-2011 at 07:13 PM.

  8. #8
    liluma's Avatar
    liluma is offline Member
    Join Date
    May 2011
    Location
    belgium
    Posts
    50
    Rep Power
    0

    Default Re: can you ask the color of one pixel?

    it works. :p ^^

    ty for the help. ^^

Similar Threads

  1. Scanning Image Pixel by Pixel
    By the_transltr in forum Advanced Java
    Replies: 5
    Last Post: 08-28-2012, 04:01 PM
  2. Replies: 4
    Last Post: 11-08-2011, 05:04 AM
  3. compare two images pixel by pixel
    By java_bond in forum Advanced Java
    Replies: 6
    Last Post: 03-02-2010, 11:27 AM
  4. [COLOR="Navy"]execute .bat file in mysql [/COLOR]
    By msankar.ravi in forum Networking
    Replies: 0
    Last Post: 02-24-2010, 04:27 AM
  5. Pixel capture
    By Maiquelnet in forum Advanced Java
    Replies: 1
    Last Post: 11-16-2009, 08:28 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
  •