Java Byte Create toByte(int rgb)

Here you can find the source of toByte(int rgb)

Description

to Byte

License

Apache License

Declaration

public static byte toByte(int rgb) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static byte toByte(int rgb) {
        int r = (rgb >> 16) & 0xff;
        int g = (rgb >> 8) & 0xff;
        int b = (rgb >> 0) & 0xff;
        float brightness = getBrightness(r, g, b);
        return (byte) (brightness * 255f);
    }/*from w w  w.j  a v a2  s .  c om*/

    public static float getBrightness(float r, float g, float b) {
        r /= 255f;
        g /= 255f;
        b /= 255f;
        return (r + g + b) / 3.0f;
    }
}

Related

  1. toByte(final String strHexa)
  2. toByte(final String value)
  3. toByte(float[][] in, byte[] out, float min, float max)
  4. toByte(int i)
  5. toByte(int n)
  6. toByte(long l)
  7. toByte(long l, byte[] b, int off, boolean bigEndian)
  8. toByte(Number num)
  9. toByte(Object o)