public class Palette extends Object
Generates PAL VIC colors from first principles. The VIC colors are constructed on a YUV color wheel at certain luminance levels that depend on precise chip revision, and at certain fixed angles in the UV plane, which are fixed for all chips. Additionally, several effects observed on true PAL systems are emulated.
To implement these effects, U and V are simply averaged within each 3x2 pixel block, and Y is filtered according to a gaussian at the top row's 3x1 pixel block.
To do this, helper tables are constructed which describe the filtered colors and luminances in the 3x1 block, and another helper table that can quickly look up averages between succeeding rows to achieve the full 3x2 filter. The YUV colors are converted to RGB colors on the second conversion.
To keep table sizes small, the pal emulation works on a 128 color palette per line. Any 3 pixel block is reduced to a single color on a 128-color palette, and two such colors (from current line and preceding line) are put side by side and used as index to look up the final color.
Since odd and even rows have slightly different colors, the colors 0..127 are assigned for even rows and colors 128..255 for odd rows. They are treated independently at the color generation and quantization procedure. The highest bit of the current row's generated color is used to identify odd/even rows.
Modifier and Type | Class and Description |
---|---|
protected static class |
Palette.PaletteEntry
Simulate VIC chip colors and some common distortions to the colors.
|
protected static class |
Palette.YUVEntry |
Constructor and Description |
---|
Palette() |
Modifier and Type | Method and Description |
---|---|
static Palette.PaletteEntry[] |
buildPaletteVariant(VIC.Model model) |
void |
calculatePalette(Palette.PaletteEntry[] colors) |
float |
getBrightness() |
float |
getContrast() |
float |
getDotCreep() |
byte[] |
getEvenFiltered() |
int[] |
getEvenLines() |
float |
getGamma() |
float |
getLuminanceC() |
byte[] |
getOddFiltered() |
int[] |
getOddLines() |
float |
getOffset() |
float |
getPhaseShift() |
float |
getSaturation() |
float |
getTint() |
void |
setBrightness(float brightness) |
void |
setContrast(float contrast) |
void |
setDotCreep(float dotCreep) |
void |
setGamma(float gamma) |
void |
setLuminanceC(float luminanceC) |
void |
setOffset(float offset) |
void |
setPhaseShift(float phaseShift) |
void |
setSaturation(float saturation) |
void |
setTint(float tint) |
public void calculatePalette(Palette.PaletteEntry[] colors)
public byte[] getEvenFiltered()
public byte[] getOddFiltered()
public int[] getEvenLines()
public int[] getOddLines()
public float getGamma()
public void setGamma(float gamma)
public float getContrast()
public void setContrast(float contrast)
public float getBrightness()
public void setBrightness(float brightness)
public float getLuminanceC()
public void setLuminanceC(float luminanceC)
public float getTint()
public void setTint(float tint)
public float getPhaseShift()
public void setPhaseShift(float phaseShift)
public float getOffset()
public void setOffset(float offset)
public float getSaturation()
public void setSaturation(float saturation)
public void setDotCreep(float dotCreep)
public float getDotCreep()
public static Palette.PaletteEntry[] buildPaletteVariant(VIC.Model model)
Copyright © 2018 Ken Händel. All rights reserved.