Commit 14d6add3 authored by Marc Lehmann's avatar Marc Lehmann
Browse files

*** empty log message ***

parent 53bbbc22
Sun Jan 2 21:37:02 CET 2000 Marc Lehmann <pcg@goof.com>
Applied Patch by Daniel Egger, slightly modified.
* libgimp/gimpcolorspace.c, libgimp/gimpcolorspace.h,
libgimp/Makefile.am: New header & implementation for
rgb<->hsl<->hsv conversion functions.
* app/blend.c, app/paint_funcs.c, app/paint_funcs.h,
app/gradient.c, plug-ins/common/scatter_hsv.c,
plug-ins/common/vinvert.c, plug-ins/common/autostretch_hsv.c,
plug-ins/common/CML_explorer.c, plug-ins/common/sparkle.c:
Remove old rgb<->hsl<->hsv conversions and use the ones in
gimpcolorspace.[ch].
2000-01-03 Tuomas Kuosmanen <tigert@gimp.org>
 
* gimp1_1_splash.ppm: Ok. The y2k came. And the fuss is over. Time
......@@ -54,8 +69,10 @@ Sun Jan 2 16:43:46 CET 2000 Sven Neumann <sven@gimp.org>
POINTS identifier clash.
2000-01-01 Garry R. Osgood <gosgood@idt.net>
Happy New Year.
*app/disp_callbacks.c Checked RGB/GRAY/INDEXED combinations
* app/disp_callbacks.c: Checked RGB/GRAY/INDEXED combinations
RE testing #4708. added gdisplay_update_title() to gdisp_drag_drop().
so that a display endowed with dropped layers won't
continue its insistence on being empty. Nice fix, Sven.
......
......@@ -42,6 +42,7 @@
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
#include "libgimp/gimpcolorspace.h"
/* target size */
......@@ -189,9 +190,6 @@ static void gradient_fill_region (GImage *gimage, GimpDrawable *drawa
progress_func_t progress_callback,
void *progress_data);
static void calc_rgb_to_hsv (double *r, double *g, double *b);
static void calc_hsv_to_rgb (double *h, double *s, double *v);
/* functions */
......@@ -1316,7 +1314,7 @@ gradient_render_pixel (double x,
color->a = rbd->fg.a + (rbd->bg.a - rbd->fg.a) * factor;
if (rbd->blend_mode == FG_BG_HSV_MODE)
calc_hsv_to_rgb (&color->r, &color->g, &color->b);
hsv_to_rgb_double (&color->r, &color->g, &color->b);
}
}
......@@ -1411,8 +1409,8 @@ gradient_fill_region (GImage *gimage,
case FG_BG_HSV_MODE:
/* Convert to HSV */
calc_rgb_to_hsv(&rbd.fg.r, &rbd.fg.g, &rbd.fg.b);
calc_rgb_to_hsv(&rbd.bg.r, &rbd.bg.g, &rbd.bg.b);
rgb_to_hsv_double(&rbd.fg.r, &rbd.fg.g, &rbd.fg.b);
rgb_to_hsv_double(&rbd.bg.r, &rbd.bg.g, &rbd.bg.b);
break;
......@@ -1568,150 +1566,6 @@ gradient_fill_region (GImage *gimage,
}
}
static void
calc_rgb_to_hsv (double *r,
double *g,
double *b)
{
double red, green, blue;
double h, s, v;
double min, max;
double delta;
red = *r;
green = *g;
blue = *b;
h = 0.0; /* Shut up -Wall */
if (red > green)
{
if (red > blue)
max = red;
else
max = blue;
if (green < blue)
min = green;
else
min = blue;
}
else
{
if (green > blue)
max = green;
else
max = blue;
if (red < blue)
min = red;
else
min = blue;
}
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;
if (red == max)
h = (green - blue) / delta;
else if (green == max)
h = 2 + (blue - red) / delta;
else if (blue == max)
h = 4 + (red - green) / delta;
h /= 6.0;
if (h < 0.0)
h += 1.0;
else if (h > 1.0)
h -= 1.0;
}
*r = h;
*g = s;
*b = v;
}
static void
calc_hsv_to_rgb (double *h,
double *s,
double *v)
{
double hue, saturation, value;
double f, p, q, t;
if (*s == 0.0)
{
*h = *v;
*s = *v;
*v = *v; /* heh */
}
else
{
hue = *h * 6.0;
saturation = *s;
value = *v;
if (hue == 6.0)
hue = 0.0;
f = hue - (int) hue;
p = value * (1.0 - saturation);
q = value * (1.0 - saturation * f);
t = value * (1.0 - saturation * (1.0 - f));
switch ((int) hue)
{
case 0:
*h = value;
*s = t;
*v = p;
break;
case 1:
*h = q;
*s = value;
*v = p;
break;
case 2:
*h = p;
*s = value;
*v = t;
break;
case 3:
*h = p;
*s = q;
*v = value;
break;
case 4:
*h = t;
*s = p;
*v = value;
break;
case 5:
*h = value;
*s = p;
*v = q;
break;
}
}
}
/****************************/
/* Global blend functions */
/****************************/
......
......@@ -42,6 +42,7 @@
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
#include "libgimp/gimpcolorspace.h"
/* target size */
......@@ -189,9 +190,6 @@ static void gradient_fill_region (GImage *gimage, GimpDrawable *drawa
progress_func_t progress_callback,
void *progress_data);
static void calc_rgb_to_hsv (double *r, double *g, double *b);
static void calc_hsv_to_rgb (double *h, double *s, double *v);
/* functions */
......@@ -1316,7 +1314,7 @@ gradient_render_pixel (double x,
color->a = rbd->fg.a + (rbd->bg.a - rbd->fg.a) * factor;
if (rbd->blend_mode == FG_BG_HSV_MODE)
calc_hsv_to_rgb (&color->r, &color->g, &color->b);
hsv_to_rgb_double (&color->r, &color->g, &color->b);
}
}
......@@ -1411,8 +1409,8 @@ gradient_fill_region (GImage *gimage,
case FG_BG_HSV_MODE:
/* Convert to HSV */
calc_rgb_to_hsv(&rbd.fg.r, &rbd.fg.g, &rbd.fg.b);
calc_rgb_to_hsv(&rbd.bg.r, &rbd.bg.g, &rbd.bg.b);
rgb_to_hsv_double(&rbd.fg.r, &rbd.fg.g, &rbd.fg.b);
rgb_to_hsv_double(&rbd.bg.r, &rbd.bg.g, &rbd.bg.b);
break;
......@@ -1568,150 +1566,6 @@ gradient_fill_region (GImage *gimage,
}
}
static void
calc_rgb_to_hsv (double *r,
double *g,
double *b)
{
double red, green, blue;
double h, s, v;
double min, max;
double delta;
red = *r;
green = *g;
blue = *b;
h = 0.0; /* Shut up -Wall */
if (red > green)
{
if (red > blue)
max = red;
else
max = blue;
if (green < blue)
min = green;
else
min = blue;
}
else
{
if (green > blue)
max = green;
else
max = blue;
if (red < blue)
min = red;
else
min = blue;
}
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;
if (red == max)
h = (green - blue) / delta;
else if (green == max)
h = 2 + (blue - red) / delta;
else if (blue == max)
h = 4 + (red - green) / delta;
h /= 6.0;
if (h < 0.0)
h += 1.0;
else if (h > 1.0)
h -= 1.0;
}
*r = h;
*g = s;
*b = v;
}
static void
calc_hsv_to_rgb (double *h,
double *s,
double *v)
{
double hue, saturation, value;
double f, p, q, t;
if (*s == 0.0)
{
*h = *v;
*s = *v;
*v = *v; /* heh */
}
else
{
hue = *h * 6.0;
saturation = *s;
value = *v;
if (hue == 6.0)
hue = 0.0;
f = hue - (int) hue;
p = value * (1.0 - saturation);
q = value * (1.0 - saturation * f);
t = value * (1.0 - saturation * (1.0 - f));
switch ((int) hue)
{
case 0:
*h = value;
*s = t;
*v = p;
break;
case 1:
*h = q;
*s = value;
*v = p;
break;
case 2:
*h = p;
*s = value;
*v = t;
break;
case 3:
*h = p;
*s = q;
*v = value;
break;
case 4:
*h = t;
*s = p;
*v = value;
break;
case 5:
*h = value;
*s = p;
*v = q;
break;
}
}
}
/****************************/
/* Global blend functions */
/****************************/
......
......@@ -76,6 +76,7 @@
#include "libgimp/gimpintl.h"
#include "libgimp/gimplimits.h"
#include "libgimp/gimpmath.h"
#include "libgimp/gimpcolorspace.h"
#include "pixmaps/zoom_in.xpm"
#include "pixmaps/zoom_out.xpm"
......@@ -504,9 +505,6 @@ static double calc_sine_factor (double middle, double pos);
static double calc_sphere_increasing_factor (double middle, double pos);
static double calc_sphere_decreasing_factor (double middle, double pos);
static void calc_rgb_to_hsv (double *r, double *g, double *b);
static void calc_hsv_to_rgb (double *h, double *s, double *v);
/* Files and paths functions */
static gchar *build_user_filename (char *name, char *path_str);
......@@ -710,8 +708,8 @@ gradient_get_color_at (gradient_t *gradient,
s1 = seg->g1;
v1 = seg->b1;
calc_rgb_to_hsv(&h0, &s0, &v0);
calc_rgb_to_hsv(&h1, &s1, &v1);
rgb_to_hsv_double(&h0, &s0, &v0);
rgb_to_hsv_double(&h1, &s1, &v1);
s0 = s0 + (s1 - s0) * factor;
v0 = v0 + (v1 - v0) * factor;
......@@ -751,7 +749,7 @@ gradient_get_color_at (gradient_t *gradient,
*g = s0;
*b = v0;
calc_hsv_to_rgb (r, g, b);
hsv_to_rgb_double (r, g, b);
}
}
......@@ -2291,7 +2289,7 @@ prev_set_hint (gint x)
s = g;
v = b;
calc_rgb_to_hsv (&h, &s, &v);
rgb_to_hsv_double (&h, &s, &v);
g_snprintf (str, sizeof (str), _("Position: %0.6f "
"RGB (%0.3f, %0.3f, %0.3f) "
......@@ -6197,152 +6195,6 @@ calc_sphere_decreasing_factor (double middle,
return 1.0 - sqrt(1.0 - pos * pos); /* Works for convex decreasing and concave increasing */
}
/*****/
static void
calc_rgb_to_hsv (double *r,
double *g,
double *b)
{
double red, green, blue;
double h, s, v;
double min, max;
double delta;
red = *r;
green = *g;
blue = *b;
h = 0.0; /* Shut up -Wall */
if (red > green)
{
if (red > blue)
max = red;
else
max = blue;
if (green < blue)
min = green;
else
min = blue;
}
else
{
if (green > blue)
max = green;
else
max = blue;
if (red < blue)
min = red;
else
min = blue;
}
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;
if (red == max)
h = (green - blue) / delta;
else if (green == max)
h = 2 + (blue - red) / delta;
else if (blue == max)
h = 4 + (red - green) / delta;
h /= 6.0;
if (h < 0.0)
h += 1.0;
else if (h > 1.0)
h -= 1.0;
}
*r = h;
*g = s;
*b = v;
}
static void
calc_hsv_to_rgb (double *h,
double *s,
double *v)
{
double hue, saturation, value;
double f, p, q, t;
if (*s == 0.0)
{
*h = *v;
*s = *v;
*v = *v; /* heh */
}
else
{
hue = *h * 6.0;
saturation = *s;
value = *v;
if (hue == 6.0)
hue = 0.0;
f = hue - (int) hue;
p = value * (1.0 - saturation);
q = value * (1.0 - saturation * f);
t = value * (1.0 - saturation * (1.0 - f));
switch ((int) hue)
{
case 0:
*h = value;
*s = t;
*v = p;
break;
case 1:
*h = q;
*s = value;
*v = p;
break;
case 2:
*h = p;
*s = value;
*v = t;
break;
case 3:
*h = p;
*s = q;
*v = value;
break;
case 4:
*h = t;
*s = p;
*v = value;
break;
case 5:
*h = value;
*s = p;
*v = q;
break;
}
}
}
/***** Files and paths functions *****/
......
......@@ -76,6 +76,7 @@
#include "libgimp/gimpintl.h"
#include "libgimp/gimplimits.h"
#include "libgimp/gimpmath.h"
#include "libgimp/gimpcolorspace.h"
#include "pixmaps/zoom_in.xpm"
#include "pixmaps/zoom_out.xpm"
......@@ -504,9 +505,6 @@ static double calc_sine_factor (double middle, double pos);
static double calc_sphere_increasing_factor (double middle, double pos);
static double calc_sphere_decreasing_factor (double middle, double pos);
static void calc_rgb_to_hsv (double *r, double *g, double *b);
static void calc_hsv_to_rgb (double *h, double *s, double *v);
/* Files and paths functions */
static gchar *build_user_filename (char *name, char *path_str);
......@@ -710,8 +708,8 @@ gradient_get_color_at (gradient_t *gradient,