Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
sidmorizon committed Sep 21, 2024
1 parent 50f1b78 commit e051512
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/shared/src/utils/imageUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ function convertToBlackAndWhiteImageBase64(

let whiteCount = 0;

// TODO optimize this
// https://github.com/trezor/homescreen-editor/blob/gh-pages/js/main.js#L234
for (let i = 0; i < data.length; i += 4) {
const avg = (data[i] + data[i + 1] + data[i + 2]) / 3;
if (avg > 128) {
Expand All @@ -96,7 +98,7 @@ function convertToBlackAndWhiteImageBase64(
data[i + 2] = bw;
}

// reverse color, not working
// reverse color if white part is more than half
if (whiteCount > data.length / 2) {
for (let i = 0; i < data.length; i += 4) {
data[i] = 255 - data[i];
Expand Down

0 comments on commit e051512

Please sign in to comment.