---
name: "hsv_to_rgb"
section: "3alleg4"
platform: "linux"
package: "allegro4-doc"
version: "2:4.4.3.1-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/hsv_to_rgb/3alleg4"
---

# hsv\_to\_rgb(3alleg4)

Converts color values between the HSV and RGB color spaces. Allegro game programming library.

## NAME

hsv\_to\_rgb, rgb\_to\_hsv - Converts color values between the HSV and RGB color spaces. Allegro game programming library.

## SYNOPSIS

**#include \<allegro.h\>**

**void hsv\_to\_rgb(float h, float s, float v, int \*r, int \*g, int \*b);**

**void rgb\_to\_hsv(int r, int g, int b, float \*h, float \*s, float \*v);**

## DESCRIPTION

Convert color values between the HSV and RGB color spaces. The RGB values  range from 0 to 255, hue is from 0 to 360, and saturation and value are  from 0 to 1. Example:

```
   int r, g, b;
   float hue, saturation, value;
   ...
   /* Convert a reddish color to HSV format. */
   rgb_to_hsv(255, 0, 128, &hue, &saturation, &value);
   /* Now put our tin foil hat, and verify that. */
   hsv_to_rgb(hue, saturation, value, &r, &g, &b);
   ASSERT(r == 255);
   ASSERT(g == 0);
   ASSERT(b == 128);
```

## SEE ALSO

**exlights**(3alleg4), **exrgbhsv**(3alleg4)
