Java Utililty Methods Byte Create

List of utility methods to do Byte Create

Description

The list of methods to do Byte Create are organized into topic(s).

Method

inttoByte(double x, double gamma)
to Byte
return (int) clamp(255.0 * Math.pow(x, 1 / gamma), 0.0, 255.0);
bytetoByte(final byte[] buffer, final int offset)
to Byte
return (byte) (buffer[offset] & 0xff);
bytetoByte(final int highNibble, final int lowNibble)
Composes a byte from two nibbles.
final int result = ((highNibble & INT_BYTE_LOW_NIBBLE_MASK) << BITS_SIZE_OF_NIBBLE)
        | (lowNibble & INT_BYTE_LOW_NIBBLE_MASK);
return (byte) result;
bytetoByte(final String bitString)
Convert a bit string into an integer value.
assert (bitString.length() <= Byte.SIZE);
return (byte) toLong(bitString);
bytetoByte(final String strHexa)
Converts a hexadecimal String to a byte
return ((byte) (Short.parseShort(strHexa.toUpperCase(), 16)));
BytetoByte(final String value)
create Byte from str.
return Byte.parseByte(value);
voidtoByte(float[][] in, byte[] out, float min, float max)
to Byte
int width = in[0].length;
int height = in.length;
for (int yy = 0; yy < height; yy++) {
    for (int xx = 0; xx < width; xx++) {
        out[yy * width + xx] = (byte) (255 * (in[yy][xx] - min) / (max - min));
inttoByte(int i)
to Byte
if (i < 0)
    i = 0;
if (i > 255)
    i = 255;
return i;
bytetoByte(int n)
to Byte
if (n > Byte.MAX_VALUE)
    throw new ArithmeticException(n + " = n > Byte.MAX_VALUE = " + Byte.MAX_VALUE);
if (n < Byte.MIN_VALUE)
    throw new ArithmeticException(n + " = n < Byte.MIN_VALUE = " + Byte.MIN_VALUE);
return (byte) n;
bytetoByte(int rgb)
to Byte
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);