Skip to content

Commit

Permalink
Merge pull request #281 from WildernessLabs/color_cleanup
Browse files Browse the repository at this point in the history
Better color to grayscale conversions
  • Loading branch information
ctacke authored Mar 3, 2025
2 parents e9384c0 + 74774e8 commit 8984c8a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Source/Meadow.Contracts/Color.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ public struct Color
/// <summary>
/// Get the 2bpp grayscale value for current color
/// </summary>
public readonly byte Color2bppGray => (byte)((0.2989 * R + 0.5870 * G + 0.114 * B) / 85);
public readonly byte Color2bppGray => (byte)((0.299 * R + 0.587 * G + 0.114 * B) / 64);

/// <summary>
/// Get the 4bpp grayscale value for current color
/// </summary>
public readonly byte Color4bppGray => (byte)((0.2989 * R + 0.5870 * G + 0.114 * B) / 17);
public readonly byte Color4bppGray => (byte)((0.299 * R + 0.587 * G + 0.114 * B) / 16);

/// <summary>
/// Get the 8bpp grayscale value for current color
/// </summary>
public readonly byte Color8bppGray => (byte)(0.2989 * R + 0.5870 * G + 0.114 * B);
public readonly byte Color8bppGray => (byte)(0.299 * R + 0.587 * G + 0.114 * B);

/// <summary>
/// Get the 8bpp (332) color value for current color
Expand Down

0 comments on commit 8984c8a

Please sign in to comment.