jjil.core
Class RgbVal

java.lang.Object
  extended by jjil.core.RgbVal

public class RgbVal
extends java.lang.Object

Helper class for manipulating RGB values. All functions are static.

Author:
webb

Constructor Summary
RgbVal()
           
 
Method Summary
static byte getB(int ARGB)
          Extracts blue byte from input ARGB word.
static byte getG(int ARGB)
          Extracts green byte from input ARGB word.
static byte getR(int ARGB)
          Extracts red byte from input ARGB word.
static int toRgb(byte R, byte G, byte B)
          Converts byte R, G, and B values to an ARGB word.
static byte toSignedByte(byte b)
          Converts from an unsigned bit field (as stored in an ARGB word to a signed byte value (that we can do computation on).
static int toUnsignedInt(byte b)
          Converts from a signed byte value (which we do computation on) to an unsigned bit field (as stored in an ARGB word).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RgbVal

public RgbVal()
Method Detail

toRgb

public static int toRgb(byte R,
                        byte G,
                        byte B)
Converts byte R, G, and B values to an ARGB word. byte is a signed data type but the ARGB word has unsigned bit fields. In other words the minimum byte value is Byte.MIN_VALUE but the color black in the ARGB word is represented as 0x00. So we must subtract Byte.MIN_VALUE to get an unsigned byte value before shifting and combining the bit fields.

Parameters:
R - input signed red byte
G - input signed green byte
B - input signed blue byte
Returns:
the color ARGB word.

getB

public static byte getB(int ARGB)
Extracts blue byte from input ARGB word. The bit fields in ARGB word are unsigned, ranging from 0x00 to 0xff. To convert these to the returned signed byte value we must add Byte.MIN_VALUE.

Parameters:
ARGB - the input color ARGB word.
Returns:
the blue byte value, converted to a signed byte

getG

public static byte getG(int ARGB)
Extracts green byte from input ARGB word. The bit fields in ARGB word are unsigned, ranging from 0x00 to 0xff. To convert these to the returned signed byte value we must add Byte.MIN_VALUE.

Parameters:
ARGB - the input color ARGB word.
Returns:
the green byte value, converted to a signed byte

getR

public static byte getR(int ARGB)
Extracts red byte from input ARGB word. The bit fields in ARGB word are unsigned, ranging from 0x00 to 0xff. To convert these to the returned signed byte value we must add Byte.MIN_VALUE.

Parameters:
ARGB - the input color ARGB word.
Returns:
the red byte value, converted to a signed byte

toSignedByte

public static byte toSignedByte(byte b)
Converts from an unsigned bit field (as stored in an ARGB word to a signed byte value (that we can do computation on).

Parameters:
b - the unsigned byte value.
Returns:
the signed byte value

toUnsignedInt

public static int toUnsignedInt(byte b)
Converts from a signed byte value (which we do computation on) to an unsigned bit field (as stored in an ARGB word). The result is returned as an int because the unsigned 8 bit value cannot be represented as a byte.

Parameters:
b - the signed byte value.
Returns:
the unsigned bit field