deadbeef.SupTools
Class Palette

java.lang.Object
  extended by deadbeef.SupTools.Palette

public class Palette
extends java.lang.Object

Palette class for mixed representation of RGB/YCbCr palettes with alpha information.

Author:
0xdeadbeef

Constructor Summary
Palette(byte[] red, byte[] green, byte[] blue, byte[] alpha)
          Ctor - construct palette from red, green blue and alpha buffers
Palette(byte[] red, byte[] green, byte[] blue, byte[] alpha, boolean use601)
          Ctor - construct palette from red, green blue and alpha buffers
Palette(int palSize)
          Ctor - initializes palette with transparent black (RGBA: 0x00000000)
Palette(int palSize, boolean use601)
          Ctor - initializes palette with transparent black (RGBA: 0x00000000)
Palette(Palette p)
          Ctor - construct new (independent) palette from existing one
 
Method Summary
 byte[] getAlpha()
          Return byte array of alpha channel components
 int getAlpha(int index)
          Get alpha channel
 int getARGB(int index)
          Return palette entry at index as Integer in ARGB format
 byte[] getB()
          Return byte array of blue components
 byte[] getCb()
          Return byte array of Cb components
 java.awt.Color getColor(int index)
          Return palette entry at index as Color
 java.awt.image.ColorModel getColorModel()
          Construct ColorModel from internal data
 java.awt.Color[] getColors()
          Return whole palette as array of Colors
 byte[] getCr()
          Return byte array of Cr components
 byte[] getG()
          Return byte array of green components
 byte[] getR()
          Return byte array of red components
 int[] getRGB(int index)
          Get Integer array containing 8bit red, green, blue components (in this order)
 int getSize()
          Get size of palette (number of entries)
 int getTransparentIndex()
          Return index of most transparent palette entry or the index of the first completely transparent color
 byte[] getY()
          Return byte array of Y components
 int[] getYCbCr(int index)
          Get Integer array containing 8bit Y, Cb, Cr components (in this order)
 void setAlpha(int index, int alpha)
          Set alpha channel
 void setARGB(int index, int c)
          Set palette index "index" to color "c" in ARGB format
 void setColor(int index, java.awt.Color c)
          Set palette index "index" to color "c"
 void setRGB(int index, int red, int green, int blue)
          Set palette entry (RGB mode)
 void setYCbCr(int index, int yn, int cbn, int crn)
          Set palette entry (YCbCr mode)
 boolean usesBT601()
          Get: use of BT.601 color model instead of BT.709
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Palette

public Palette(int palSize,
               boolean use601)
Ctor - initializes palette with transparent black (RGBA: 0x00000000)

Parameters:
palSize - Number of palette entries
use601 - Use BT.601 instead of BT.709

Palette

public Palette(int palSize)
Ctor - initializes palette with transparent black (RGBA: 0x00000000)

Parameters:
palSize - Number of palette entries

Palette

public Palette(byte[] red,
               byte[] green,
               byte[] blue,
               byte[] alpha,
               boolean use601)
Ctor - construct palette from red, green blue and alpha buffers

Parameters:
red - Byte buffer containing the red components
green - Byte buffer containing the green components
blue - Byte buffer containing the blue components
alpha - Byte buffer containing the alpha components
use601 - Use BT.601 instead of BT.709

Palette

public Palette(byte[] red,
               byte[] green,
               byte[] blue,
               byte[] alpha)
Ctor - construct palette from red, green blue and alpha buffers

Parameters:
red - Byte buffer containing the red components
green - Byte buffer containing the green components
blue - Byte buffer containing the blue components
alpha - Byte buffer containing the alpha components

Palette

public Palette(Palette p)
Ctor - construct new (independent) palette from existing one

Parameters:
p - Palette to copy values from
Method Detail

getColorModel

public java.awt.image.ColorModel getColorModel()
Construct ColorModel from internal data

Returns:
ColorModel needed to create e.g. a palette based BufferedImage

setColor

public void setColor(int index,
                     java.awt.Color c)
Set palette index "index" to color "c"

Parameters:
index - Palette index
c - Color

setARGB

public void setARGB(int index,
                    int c)
Set palette index "index" to color "c" in ARGB format

Parameters:
index - Palette index
c - Color in ARGB format

getColor

public java.awt.Color getColor(int index)
Return palette entry at index as Color

Parameters:
index - Palette index
Returns:
Palette entry at index as Color

getARGB

public int getARGB(int index)
Return palette entry at index as Integer in ARGB format

Parameters:
index - Palette index
Returns:
Palette entry at index as Integer in ARGB format

getColors

public java.awt.Color[] getColors()
Return whole palette as array of Colors

Returns:
Palette as array of Colors

setRGB

public void setRGB(int index,
                   int red,
                   int green,
                   int blue)
Set palette entry (RGB mode)

Parameters:
index - Palette index
red - 8bit red component
green - 8bit green component
blue - 8bit blue component

setYCbCr

public void setYCbCr(int index,
                     int yn,
                     int cbn,
                     int crn)
Set palette entry (YCbCr mode)

Parameters:
index - Palette index
yn - 8bit Y component
cbn - 8bit Cb component
crn - 8bit Cr component

setAlpha

public void setAlpha(int index,
                     int alpha)
Set alpha channel

Parameters:
index - Palette index
alpha - 8bit alpha channel value

getAlpha

public int getAlpha(int index)
Get alpha channel

Parameters:
index - Palette index
Returns:
8bit alpha channel value

getAlpha

public byte[] getAlpha()
Return byte array of alpha channel components

Returns:
Byte array of alpha channel components (don't modify!)

getRGB

public int[] getRGB(int index)
Get Integer array containing 8bit red, green, blue components (in this order)

Parameters:
index - Palette index
Returns:
Integer array containing 8bit red, green, blue components (in this order)

getYCbCr

public int[] getYCbCr(int index)
Get Integer array containing 8bit Y, Cb, Cr components (in this order)

Parameters:
index - Palette index
Returns:
Integer array containing 8bit Y, Cb, Cr components (in this order)

getR

public byte[] getR()
Return byte array of red components

Returns:
Byte array of red components (don't modify!)

getG

public byte[] getG()
Return byte array of green components

Returns:
Byte array of green components (don't modify!)

getB

public byte[] getB()
Return byte array of blue components

Returns:
Byte array of blue components (don't modify!)

getY

public byte[] getY()
Return byte array of Y components

Returns:
Byte array of Y components (don't modify!)

getCb

public byte[] getCb()
Return byte array of Cb components

Returns:
Byte array of Cb components (don't modify!)

getCr

public byte[] getCr()
Return byte array of Cr components

Returns:
Byte array of Cr components (don't modify!)

getSize

public int getSize()
Get size of palette (number of entries)

Returns:
Size of palette (number of entries)

getTransparentIndex

public int getTransparentIndex()
Return index of most transparent palette entry or the index of the first completely transparent color

Returns:
Index of most transparent palette entry or the index of the first completely transparent color

usesBT601

public boolean usesBT601()
Get: use of BT.601 color model instead of BT.709

Returns:
True if BT.601 is used