static void DoSomeDithering(RGBColour current, int index, RGBColour[] InnerColour, int InnerIndex, RGBColour[] Error)
{
if (true) // Dither
{
// Calculate difference between current pixel colour and adapted pixel colour?
RGBColour diff = new RGBColour()
{
r = current.a * (byte)(current.r - InnerColour[InnerIndex].r),
g = current.a * (byte)(current.g - InnerColour[InnerIndex].g),
b = current.a * (byte)(current.b - InnerColour[InnerIndex].b)
};
// If current pixel is not at the end of a row
if ((index & 3) != 3)
{
Error[index + 1].r += diff.r * (7f / 16f);
Error[index + 1].g += diff.g * (7f / 16f);
Error[index + 1].b += diff.b * (7f / 16f);
}
// If current pixel is not in bottom row
if (index < 12)
{
// If current pixel IS at end of row
if ((index & 3) != 0)
{
Error[index + 3].r += diff.r * (3f / 16f);
Error[index + 3].g += diff.g * (3f / 16f);
Error[index + 3].b += diff.b * (3f / 16f);
}
Error[index + 4].r += diff.r * (5f / 16f);
Error[index + 4].g += diff.g * (5f / 16f);
Error[index + 4].b += diff.b * (5f / 16f);
// If current pixel is not at end of row
if ((index & 3) != 3)
{
Error[index + 5].r += diff.r * (1f / 16f);
Error[index + 5].g += diff.g * (1f / 16f);
Error[index + 5].b += diff.b * (1f / 16f);
}
}
}
}