Skip to content

Instantly share code, notes, and snippets.

View GitMoDu's full-sized avatar

André GitMoDu

  • Lisbon
View GitHub Profile
@GitMoDu
GitMoDu / HsvToRgbInteger
Created March 19, 2025 14:21
Cpp converter of HSV to RGB888 using integer-only math.
/// <summary>
/// Converts HSV to RGB888 using integer-only math.
/// </summary>
/// <param name="hue">Hue angle [0 ; UINT16_MAX], corresponds to [0 ; 360] degrees color wheel.</param>
/// <param name="saturation">Saturation value [0 ; 255].</param>
/// <param name="value">Brightness value [0 ; 255].</param>
/// <returns>uint32 RGB888 color, where the color is represented as 0xRRGGBB.</returns>
static uint32_t HsvToRgb(const uint16_t hue, const uint8_t saturation, const uint8_t value)
{
static constexpr uint8_t Segments = 6;