graphics: ssd1306: fix crash in dithering
This commit is contained in:
@@ -38,7 +38,7 @@ impl SsdPixel {
|
||||
}
|
||||
}
|
||||
|
||||
const DITHER_MAP: [u32;15] = [
|
||||
const DITHER_MAP: [u16;15] = [
|
||||
0b1000_0000_0000_0000,
|
||||
0b1000_0000_0010_0000,
|
||||
0b1010_0000_0010_0000,
|
||||
@@ -62,9 +62,9 @@ impl AdditivePixelSink<BinaryColor> for SsdPixel {
|
||||
0 => (),
|
||||
255 => self.set_pixel(pixel),
|
||||
_ => {
|
||||
let dither_value = DITHER_MAP[opacity as usize / 16];
|
||||
let dither_value = DITHER_MAP[opacity as usize / 17];
|
||||
let dither_x = self.coords.x % 4;
|
||||
let dither_y = self.coords.x % 4;
|
||||
let dither_y = self.coords.y % 4;
|
||||
if dither_value.shr(dither_x).shr(dither_y * 4).bitand(0x01) == 1 {
|
||||
self.set_pixel(pixel);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user