trying to get the separate integer rgb values of a specific pixel in a BufferedImage object

I'm trying to get the separate integer rgb values of a specific pixel in a BufferedImage object. I'm using the following, which seems to get the red value OK, however the g & b are too big: rgb = colCorBImage.getRGB(r, c); red = rgb & 255; green = rgb & 65280; blue = rgb & 16711936;

You need to learn how bitwise operators work.

Actually, the red assignment is the blue sorry

Surely what I have shoudl work no? I guess I could get the green also by shifting the lot >> 8 bits, then & that with 65535?
it isn't sufficient just to mask out the bits you need.
because the bits are still in the same position they were in before
you still have to shift them to get them in the position you want

Oh of course onlineTrafficSchool++
I was trying to simplify the simplest solution :-s
were you speeding

like a sinner
A study in 1999 found that kids' favorite TV commercial was for:
thanks for pointing out the obvious Number-6 :-)
i'm good at that.

 Tomcat Web Hosting | Tomcat Hosting

*
To prove that you're not a bot, enter this code
Anti-Spam Image

Leave a Comment

You must be logged in to post a comment.


Blog Tags:

Similar posts: