-
Notifications
You must be signed in to change notification settings - Fork 1
/
SierraLiteDithering.cs
44 lines (37 loc) · 1.23 KB
/
SierraLiteDithering.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
This file implements error pushing of dithering via (Frankie) Sierra Lite kernel.
This is free and unencumbered software released into the public domain.
*/
class SierraLiteDithering : DitheringBase
{
public SierraLiteDithering(FindColor colorfunc) : base(colorfunc)
{
this.methodLongName = "SierraLite";
this.fileNameAddition = "_SIEL";
}
override protected void PushError(int x, int y, short[] quantError)
{
// Push error
// X 2/4
// 1/4 1/4
int xMinusOne = x - 1;
int xPlusOne = x + 1;
int yPlusOne = y + 1;
// Current row
int currentRow = y;
if (this.IsValidCoordinate(xPlusOne, currentRow))
{
this.ModifyImageWithErrorAndMultiplier(xPlusOne, currentRow, quantError, 2.0f / 4.0f);
}
// Next row
currentRow = yPlusOne;
if (this.IsValidCoordinate(xMinusOne, currentRow))
{
this.ModifyImageWithErrorAndMultiplier(xMinusOne, currentRow, quantError, 1.0f / 4.0f);
}
if (this.IsValidCoordinate(x, currentRow))
{
this.ModifyImageWithErrorAndMultiplier(x, currentRow, quantError, 1.0f / 4.0f);
}
}
}