mirror of
https://github.com/jam422470459/EPD-nRF52-hema213.git
synced 2025-12-06 16:42:49 +08:00
fix SSD1619 red color
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -132,17 +132,15 @@ function canvas2bytes(canvas, type='bw', invert = false) {
|
||||
for (let y = 0; y < canvas.height; y++) {
|
||||
for (let x = 0; x < canvas.width; x++) {
|
||||
const i = (canvas.width * y + x) * 4;
|
||||
let data;
|
||||
if (type !== 'red') {
|
||||
data = imageData.data[i] === 0 && imageData.data[i+1] === 0 && imageData.data[i+2] === 0 ? 0 : 1;
|
||||
buffer.push(imageData.data[i] === 0 && imageData.data[i+1] === 0 && imageData.data[i+2] === 0 ? 0 : 1);
|
||||
} else {
|
||||
data = imageData.data[i] > 0 && imageData.data[i+1] === 0 && imageData.data[i+2] === 0 ? 0 : 1;
|
||||
buffer.push(imageData.data[i] > 0 && imageData.data[i+1] === 0 && imageData.data[i+2] === 0 ? 0 : 1);
|
||||
}
|
||||
if (invert) data = ~data;
|
||||
buffer.push(data);
|
||||
|
||||
if (buffer.length === 8) {
|
||||
arr.push(parseInt(buffer.join(''), 2));
|
||||
const data = parseInt(buffer.join(''), 2);
|
||||
arr.push(invert ? ~data : data);
|
||||
buffer = [];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user