rgb_to_hsv

Converts color values between the HSV and RGB colorspaces.

Description

void rgb_to_hsv(int r, int g, int b, float *h, float *s, float *v);
Convert color values between the HSV and RGB colorspaces. 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);
Examples using this:

Related Discussions

The following threads each have code containing this keyword: Note: You can click on the numbers to jump directly to the posts that reference this page.

Related Projects

The following projects include source code containing this keyword: