Skip to content

Commit

Permalink
[fb] optimize dithering for WHITE and BLACK (#73)
Browse files Browse the repository at this point in the history
These colors should never change due to dithering, and this skips the
costly conversion from remarkable_color to float and back.
  • Loading branch information
mrichards42 committed Feb 1, 2021
1 parent 0af6cac commit 1ac0cfd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/rmkit/fb/dither.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,25 @@ static const float BLUE_NOISE_MATRIX_16[32][32] = {{ 0.005338541666666667,-0.019

inline remarkable_color BAYER_2(int x, int y, remarkable_color c)
{
if (c == WHITE || c == BLACK) return c;
return color::quantize<2>(color::to_float(c) + BAYER_MATRIX_2[x%32][y%32]);
}

inline remarkable_color BAYER_16(int x, int y, remarkable_color c)
{
if (c == WHITE || c == BLACK) return c;
return color::quantize<16>(color::to_float(c) + BAYER_MATRIX_16[x%32][y%32]);
}

inline remarkable_color BLUE_NOISE_2(int x, int y, remarkable_color c)
{
if (c == WHITE || c == BLACK) return c;
return color::quantize<2>(color::to_float(c) + BLUE_NOISE_MATRIX_2[x%32][y%32]);
}

inline remarkable_color BLUE_NOISE_16(int x, int y, remarkable_color c)
{
if (c == WHITE || c == BLACK) return c;
return color::quantize<16>(color::to_float(c) + BLUE_NOISE_MATRIX_16[x%32][y%32]);
}

Expand Down

0 comments on commit 1ac0cfd

Please sign in to comment.