get rid of our ugly rounding code
It turns out "truncating" the last 4 bits is actually more accurate, because it divides up the palette evenly. Before: 0-7 -> 0 8-0x17 -> 1 0x18-0x27 -> 2 ... 0xd8-0xe7 -> 0xe 0xe8-0xff -> 0xf The first interval is just 8 shades, and the final interval is 24 shades.
This commit is contained in:
parent
62a2afe0d8
commit
272432ce75
9
img.mu
9
img.mu
|
@ -487,14 +487,7 @@ fn dither-pgm-unordered _src: (addr image), _dest: (addr image) {
|
|||
break-if-<=
|
||||
nearest-color <- copy 0xf0
|
||||
}
|
||||
# . round to nearest multiple of 0x10
|
||||
{
|
||||
var tmp/ecx: int <- copy nearest-color
|
||||
tmp <- and 0xf
|
||||
compare tmp, 8
|
||||
break-if-<
|
||||
nearest-color <- add 8
|
||||
}
|
||||
# . truncate last 4 bits
|
||||
nearest-color <- and 0xf0
|
||||
# error -= (nearest-color << 16)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue