Convert RGB values into integer pixel?

I think the code is something like: int rgb = red; rgb = (rgb > 16) & 0xFF; int green = (rgb >> 8) & 0xFF; int blue = rgb & 0xFF.

I don't think you need an int on the second two lines. And the third line is supposed to be "rgb = ...", right? – Rahat Ahmed Jan 26 at 4:31 It is a single integer.An integer contains 32 bits.

The first 8 bits are for the alpha value (which is zero). The next 8 for the red, then next 8 for the green and the next 8 for the blue. Try it.

If the final output equals you initial input then you know the conversion was done correctly. – camickr Jan 26 at 4:32 Erm, I think it would depend on the color depth. Your example looks like 24-bit color to me (8 bits per channel) - is that what BufferedImage expects?

– MДΓΓ БДLL Jan 26 at 4:33 Yes, I made the assumption the buffered image is of type BufferedImage. TYPE_INT_RGB. Maybe it isn't which is why the other formula is being used.

In any case the concept is that (as far as I know) it is easier to shift bits to get the individual values instead of using the code posted. – camickr Jan 26 at 4:37.

If r, g, be = 3 integer values from 0 to 255 for each color then rgb = 65536 * r + 256 * g + b; the single rgb value is the composite value of r,g,b combined for a total of 16777216 possible shades.

Int rgb = ((r&0x0ff) 255 or >16)&0x0ff; int green=(rgb>>8) &0x0ff; int blue= (rgb) &0x0ff; No need for multipling.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions