Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

BufferedImage and scanning pixels  RSS feed

 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what i want to do is get a bufferedImage of a certain screenshot,
which if you use.

Robot.createSreenCapture(), that returns a buffered image...

then i could use:
bufferedImage.getXTiles(); and bufferedimage.getYTiles();

but i want to "look" at each tile to look for a specific color.

how would i do that?

.getRGB(int x, int y) returns an int..

I thought that RGB values were like (100,20,30), would
it return the sum of those?

i need a way to some how get the actual color of that pixel.

Thanks,


Justin
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i appreciate the reply, but say i was looking for a "neon green" color
and evertime i was scanning and the pixel was "around" a neon green color
click, and then wait 4 seconds, and start scanning the picture from the point/pixel you just left from and continue doing this(loop).

i know how to scan each pixel and print the color.toString(), but i want the search to be more efficient, searching every pixel in a picture that is 600x800 is time consuming. what would be a better way to do this?

Justin
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but i want the search to be more efficient, searching every pixel ... what would be a
better way to do this

I would try it like this

This should run pretty fast.
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you ill try it out,


Justin
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok now when you said:

color target = neon_color;

neon_color isn't an actual predefined color right? i have to define
rgb for the neon color...

thanks,

Justin
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
neon_color isn't an actual predefined color right? i have to define
rgb for the neon color...

It is any Color, predefined or your own, eg, new Color(200,240,220).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!