select a color from a png file
hi,
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.
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 :-"
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:
Code Java:
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