Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: select a color from a png file

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Thanked 0 Times in 0 Posts

    Default select a color from a png file


    i am working on a group project at university. we should read a map (.png file) and try to find the seas on the map. i know how i can read from a png file to an array. but i cannot find how i find the blue colors (or the colors that show seas). i googled it but i dont find anything about it (everything is about filtering, rescaling etc...) in fact i dont know how i can find it and the main sentences that i can google.

    What can i do? Any hints? i will be very glad for all supports.

  2. #2
    Junior Member
    Join Date
    Nov 2010
    Thanked 0 Times in 0 Posts

    Default Re: select a color from a png file

    hello strider,

    nice to meet another person working with java at univ
    if you want help my advice is to submit your post/problem at proper thread,
    so watch out for admin

  3. #3
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    United Kingdom
    My Mood
    Thanked 287 Times in 225 Posts
    Blog Entries

    Default Re: select a color from a png file

    Thread moved to - Java Theory & Questions - Java Programming Forums

    Welcome to the forums strider

    I have no idea if this will work but try something like:

        BufferedImage bimg = ImageIO.read(new File("map.png"));
        // get the colour of the pixel at position (x, y)
        int col = bimg.getRGB(x, y);
        // decode red, green and blue components of colour if necessary
        int r = (col >> 16) & 0xff;
        int g = (col >> 8) & 0xff;
        int b = col & 0xff;

    Source - Use Java to identify lines in a graph - Stack Overflow
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

Similar Threads

  1. Insertion and select in JDBC for two different databse
    By nrao in forum JDBC & Databases
    Replies: 1
    Last Post: November 15th, 2010, 07:14 PM
  2. Replies: 3
    Last Post: April 14th, 2010, 07:33 PM
  3. select count(*)
    By jacinto in forum JDBC & Databases
    Replies: 4
    Last Post: March 2nd, 2010, 09:30 PM
  4. Get <SELECT> tag values on other jsp page
    By nehakuls in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: November 18th, 2009, 01:29 AM