0

New to bit manipulation here. BufferedImage.getRGB(int x, int y) returns an int containing all the RGBA values. How does one decode the bits in the int to get four 0 - 255 values for RGBA? Thanks :)

  • 1
    From [here](http://forum.lwjgl.org/index.php?topic=5901.0): `buffer.put((byte) ((pixel >> 16) & 0xFF)); // Red component buffer.put((byte) ((pixel >> 8) & 0xFF)); // Green component buffer.put((byte) (pixel & 0xFF)); // Blue component buffer.put((byte) ((pixel >> 24) & 0xFF)); // Alpha component. Only for RGBA` – Elliott Frisch Sep 23 '19 at 04:39
  • 3
    Possible duplicate of [Understanding BufferedImage.getRGB output values](https://stackoverflow.com/questions/25761438/understanding-bufferedimage-getrgb-output-values) – tevemadar Sep 23 '19 at 04:42
  • A quick search on stackoverflow gives me below, this might help https://stackoverflow.com/questions/4801366/convert-rgb-values-to-integer – Shailesh Chandra Sep 23 '19 at 05:01
  • maybe `ColorModel.getRGBDefault().getAlpha(rgb)`. `...getBlue(rgb)`, `...getGreen(rgb)` and `...getRed(rgb)` – user85421 Sep 23 '19 at 06:39

0 Answers0