[gegl] color-rotate: Update definition of gegl_rgb_to_hsv()
- From: Mukund Sivaraman <muks src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] color-rotate: Update definition of gegl_rgb_to_hsv()
- Date: Tue, 30 Aug 2011 19:44:18 +0000 (UTC)
commit 179c2ff50c5901d1564f3c75e7afffbfea618c05
Author: Mukund Sivaraman <muks banu com>
Date: Wed Aug 31 01:07:30 2011 +0530
color-rotate: Update definition of gegl_rgb_to_hsv()
operations/workshop/color-rotate.c | 64 ++++++++++++++---------------------
1 files changed, 26 insertions(+), 38 deletions(-)
---
diff --git a/operations/workshop/color-rotate.c b/operations/workshop/color-rotate.c
index b16fef0..4ee7818 100644
--- a/operations/workshop/color-rotate.c
+++ b/operations/workshop/color-rotate.c
@@ -82,50 +82,38 @@ gegl_rgb_to_hsv (gfloat r,
gfloat *s,
gfloat *v)
{
- gfloat min, max;
- gfloat delta;
+ float min;
+ float delta;
- *h = 0.0;
+ *v = MAX (MAX (r, g), b);
+ min = MIN (MIN (r, g), b);
+ delta = *v - min;
- if (r > g)
+ if (delta == 0.0f)
{
- max = MAX (r, b);
- min = MIN (g, b);
+ *h = 0.0f;
+ *s = 0.0f;
}
else
{
- max = MAX (g, b);
- min = MIN (r, b);
- }
-
- *v = max;
-
- if (max != 0.0)
- *s = (max - min) / max;
- else
- *s = 0.0;
-
- if (*s == 0.0)
- {
- *h = 0.0;
- }
- else
- {
- delta = max - min;
+ *s = delta / *v;
- if (r == max)
- *h = (g - b) / delta;
- else if (g == max)
- *h = 2 + (b - r) / delta;
- else if (b == max)
- *h = 4 + (r - g) / delta;
-
- *h /= 6.0;
+ if (r == *v)
+ {
+ *h = (g - b) / delta;
+ if (*h < 0.0f)
+ *h += 6.0f;
+ }
+ else if (g == *v)
+ {
+ *h = 2.0f + (b - r) / delta;
+ }
+ else
+ {
+ *h = 4.0f + (r - g) / delta;
+ }
- if (*h < 0.0)
- *h += 1.0;
- else if (*h > 1.0)
- *h -= 1.0;
+ *h /= 6.0f;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]