gimp/libgimpcolor/gimpcolorspace.c

774 lines
14 KiB
C
Raw Normal View History

/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
2000-01-03 06:30:20 +08:00
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
2000-01-03 06:30:20 +08:00
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
2000-01-03 06:30:20 +08:00
*/
Makefile.am configure.in added stuff for the new library below. 2001-01-23 Michael Natterer <mitch@gimp.org> * Makefile.am * configure.in * gimptool.in: added stuff for the new library below. * libgimpcolor/.cvsignore * libgimpcolor/Makefile.am * libgimpcolor/gimpcolor.h * libgimpcolor/gimpcolorspace.c * libgimpcolor/gimpcolorspace.h * libgimpcolor/gimpcolortypes.h * libgimpcolor/gimphsv.c * libgimpcolor/gimphsv.h * libgimpcolor/gimprgb.c * libgimpcolor/gimprgb.h: new shared library which both the app and plug-ins link against. The library depends only on glib. * libgimpcolor/gimpcolor.def * libgimpcolor/makefile.mingw.in * libgimpcolor/makefile.msc: added Win32 build files which definitely don't work. * libgimp/Makefile.am * libgimp/gimpcolor.[ch] * libgimp/gimpcolorspace.[ch]: removed. * libgimp/gimp.h * libgimp/gimpadaptivesupersample.c * libgimp/gimpbilinear.c * libgimp/gimppalette.c * libgimp/gimptypes.h: include the stuff from libgimpcolor. Plug-Ins don't need to include <libgimpcolor/gimpcolor.h> explicitely. LibGimp depends on libgimpcolor and thus also includes it's headers. * libgimp/gimp.def * libgimp/makefile.mingw.in: fiddled around with Win32 stuff... * app/Makefile.am: link against libgimpcolor.la * app/apptypes.h: include "libgimpcolor/gimpcolortypes.h" * app/asupsample.c * app/channels_dialog.c * app/colormap_dialog.c * app/commands.c * app/convert.c * app/devices.c * app/disp_callbacks.c * app/drawable.c * app/gimpcontext.c * app/gimpdnd.c * app/gimpimage.c * app/gimppalette.c * app/gimprc.c * app/gradient.c * app/libgimp_glue.c * app/palette.c * app/palette_import.c * app/qmask.c * app/xcf.c * app/tools/paint_core.c * app/tools/paintbrush.c * app/tools/pencil.c: include "libgimpcolor/gimpcolor.h" before all gimp includes because it's a standalone library. * plug-ins/FractalExplorer/Makefile.am * plug-ins/Lighting/Makefile.am * plug-ins/MapObject/Makefile.am * plug-ins/bmp/Makefile.am * plug-ins/common/Makefile.am * plug-ins/common/mkgen.pl * plug-ins/dbbrowser/Makefile.am * plug-ins/faxg3/Makefile.am * plug-ins/fits/Makefile.am * plug-ins/flame/Makefile.am * plug-ins/fp/Makefile.am * plug-ins/gap/Makefile.am * plug-ins/gdyntext/Makefile.am * plug-ins/gfig/Makefile.am * plug-ins/gflare/Makefile.am * plug-ins/gfli/Makefile.am * plug-ins/gimpressionist/Makefile.am * plug-ins/helpbrowser/Makefile.am * plug-ins/ifscompose/Makefile.am * plug-ins/imagemap/Makefile.am * plug-ins/maze/Makefile.am * plug-ins/mosaic/Makefile.am * plug-ins/pagecurl/Makefile.am * plug-ins/print/Makefile.am * plug-ins/rcm/Makefile.am * plug-ins/script-fu/Makefile.am * plug-ins/sel2path/Makefile.am * plug-ins/sgi/Makefile.am * plug-ins/webbrowser/Makefile.am * plug-ins/xjt/Makefile.am: add libgimpcolor.la to LDADD. * INSTALL: don't recommend to --disable-shared for development. * TODO.xml: increased some percentages, added plug-in help stuff.
2001-01-24 02:49:44 +08:00
#include "config.h"
2000-01-03 06:30:20 +08:00
#include <glib.h>
#include "libgimpmath/gimpmath.h"
Makefile.am configure.in added stuff for the new library below. 2001-01-23 Michael Natterer <mitch@gimp.org> * Makefile.am * configure.in * gimptool.in: added stuff for the new library below. * libgimpcolor/.cvsignore * libgimpcolor/Makefile.am * libgimpcolor/gimpcolor.h * libgimpcolor/gimpcolorspace.c * libgimpcolor/gimpcolorspace.h * libgimpcolor/gimpcolortypes.h * libgimpcolor/gimphsv.c * libgimpcolor/gimphsv.h * libgimpcolor/gimprgb.c * libgimpcolor/gimprgb.h: new shared library which both the app and plug-ins link against. The library depends only on glib. * libgimpcolor/gimpcolor.def * libgimpcolor/makefile.mingw.in * libgimpcolor/makefile.msc: added Win32 build files which definitely don't work. * libgimp/Makefile.am * libgimp/gimpcolor.[ch] * libgimp/gimpcolorspace.[ch]: removed. * libgimp/gimp.h * libgimp/gimpadaptivesupersample.c * libgimp/gimpbilinear.c * libgimp/gimppalette.c * libgimp/gimptypes.h: include the stuff from libgimpcolor. Plug-Ins don't need to include <libgimpcolor/gimpcolor.h> explicitely. LibGimp depends on libgimpcolor and thus also includes it's headers. * libgimp/gimp.def * libgimp/makefile.mingw.in: fiddled around with Win32 stuff... * app/Makefile.am: link against libgimpcolor.la * app/apptypes.h: include "libgimpcolor/gimpcolortypes.h" * app/asupsample.c * app/channels_dialog.c * app/colormap_dialog.c * app/commands.c * app/convert.c * app/devices.c * app/disp_callbacks.c * app/drawable.c * app/gimpcontext.c * app/gimpdnd.c * app/gimpimage.c * app/gimppalette.c * app/gimprc.c * app/gradient.c * app/libgimp_glue.c * app/palette.c * app/palette_import.c * app/qmask.c * app/xcf.c * app/tools/paint_core.c * app/tools/paintbrush.c * app/tools/pencil.c: include "libgimpcolor/gimpcolor.h" before all gimp includes because it's a standalone library. * plug-ins/FractalExplorer/Makefile.am * plug-ins/Lighting/Makefile.am * plug-ins/MapObject/Makefile.am * plug-ins/bmp/Makefile.am * plug-ins/common/Makefile.am * plug-ins/common/mkgen.pl * plug-ins/dbbrowser/Makefile.am * plug-ins/faxg3/Makefile.am * plug-ins/fits/Makefile.am * plug-ins/flame/Makefile.am * plug-ins/fp/Makefile.am * plug-ins/gap/Makefile.am * plug-ins/gdyntext/Makefile.am * plug-ins/gfig/Makefile.am * plug-ins/gflare/Makefile.am * plug-ins/gfli/Makefile.am * plug-ins/gimpressionist/Makefile.am * plug-ins/helpbrowser/Makefile.am * plug-ins/ifscompose/Makefile.am * plug-ins/imagemap/Makefile.am * plug-ins/maze/Makefile.am * plug-ins/mosaic/Makefile.am * plug-ins/pagecurl/Makefile.am * plug-ins/print/Makefile.am * plug-ins/rcm/Makefile.am * plug-ins/script-fu/Makefile.am * plug-ins/sel2path/Makefile.am * plug-ins/sgi/Makefile.am * plug-ins/webbrowser/Makefile.am * plug-ins/xjt/Makefile.am: add libgimpcolor.la to LDADD. * INSTALL: don't recommend to --disable-shared for development. * TODO.xml: increased some percentages, added plug-in help stuff.
2001-01-24 02:49:44 +08:00
#include "gimpcolortypes.h"
#include "gimpcolorspace.h"
Makefile.am configure.in added stuff for the new library below. 2001-01-23 Michael Natterer <mitch@gimp.org> * Makefile.am * configure.in * gimptool.in: added stuff for the new library below. * libgimpcolor/.cvsignore * libgimpcolor/Makefile.am * libgimpcolor/gimpcolor.h * libgimpcolor/gimpcolorspace.c * libgimpcolor/gimpcolorspace.h * libgimpcolor/gimpcolortypes.h * libgimpcolor/gimphsv.c * libgimpcolor/gimphsv.h * libgimpcolor/gimprgb.c * libgimpcolor/gimprgb.h: new shared library which both the app and plug-ins link against. The library depends only on glib. * libgimpcolor/gimpcolor.def * libgimpcolor/makefile.mingw.in * libgimpcolor/makefile.msc: added Win32 build files which definitely don't work. * libgimp/Makefile.am * libgimp/gimpcolor.[ch] * libgimp/gimpcolorspace.[ch]: removed. * libgimp/gimp.h * libgimp/gimpadaptivesupersample.c * libgimp/gimpbilinear.c * libgimp/gimppalette.c * libgimp/gimptypes.h: include the stuff from libgimpcolor. Plug-Ins don't need to include <libgimpcolor/gimpcolor.h> explicitely. LibGimp depends on libgimpcolor and thus also includes it's headers. * libgimp/gimp.def * libgimp/makefile.mingw.in: fiddled around with Win32 stuff... * app/Makefile.am: link against libgimpcolor.la * app/apptypes.h: include "libgimpcolor/gimpcolortypes.h" * app/asupsample.c * app/channels_dialog.c * app/colormap_dialog.c * app/commands.c * app/convert.c * app/devices.c * app/disp_callbacks.c * app/drawable.c * app/gimpcontext.c * app/gimpdnd.c * app/gimpimage.c * app/gimppalette.c * app/gimprc.c * app/gradient.c * app/libgimp_glue.c * app/palette.c * app/palette_import.c * app/qmask.c * app/xcf.c * app/tools/paint_core.c * app/tools/paintbrush.c * app/tools/pencil.c: include "libgimpcolor/gimpcolor.h" before all gimp includes because it's a standalone library. * plug-ins/FractalExplorer/Makefile.am * plug-ins/Lighting/Makefile.am * plug-ins/MapObject/Makefile.am * plug-ins/bmp/Makefile.am * plug-ins/common/Makefile.am * plug-ins/common/mkgen.pl * plug-ins/dbbrowser/Makefile.am * plug-ins/faxg3/Makefile.am * plug-ins/fits/Makefile.am * plug-ins/flame/Makefile.am * plug-ins/fp/Makefile.am * plug-ins/gap/Makefile.am * plug-ins/gdyntext/Makefile.am * plug-ins/gfig/Makefile.am * plug-ins/gflare/Makefile.am * plug-ins/gfli/Makefile.am * plug-ins/gimpressionist/Makefile.am * plug-ins/helpbrowser/Makefile.am * plug-ins/ifscompose/Makefile.am * plug-ins/imagemap/Makefile.am * plug-ins/maze/Makefile.am * plug-ins/mosaic/Makefile.am * plug-ins/pagecurl/Makefile.am * plug-ins/print/Makefile.am * plug-ins/rcm/Makefile.am * plug-ins/script-fu/Makefile.am * plug-ins/sel2path/Makefile.am * plug-ins/sgi/Makefile.am * plug-ins/webbrowser/Makefile.am * plug-ins/xjt/Makefile.am: add libgimpcolor.la to LDADD. * INSTALL: don't recommend to --disable-shared for development. * TODO.xml: increased some percentages, added plug-in help stuff.
2001-01-24 02:49:44 +08:00
#include "gimprgb.h"
#include "gimphsv.h"
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
2000-01-03 06:30:20 +08:00
#define GIMP_HSV_UNDEFINED -1.0
#define GIMP_HSL_UNDEFINED -1.0
2000-01-03 06:30:20 +08:00
/*********************************
* color conversion routines *
*********************************/
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
/* GimpRGB functions */
void
gimp_rgb_to_hsv (const GimpRGB *rgb,
GimpHSV *hsv)
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
{
gdouble max, min, delta;
g_return_if_fail (rgb != NULL);
g_return_if_fail (hsv != NULL);
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
max = gimp_rgb_max (rgb);
min = gimp_rgb_min (rgb);
hsv->v = max;
delta = max - min;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
if (delta > 0.0001)
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
{
hsv->s = delta / max;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
if (rgb->r == max)
{
hsv->h = (rgb->g - rgb->b) / delta;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
}
else if (rgb->g == max)
{
hsv->h = 2.0 + (rgb->b - rgb->r) / delta;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
}
else if (rgb->b == max)
{
hsv->h = 4.0 + (rgb->r - rgb->g) / delta;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
}
hsv->h /= 6.0;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
if (hsv->h < 0.0)
hsv->h += 1.0;
else if (hsv->h > 1.0)
hsv->h -= 1.0;
}
else
{
hsv->s = 0.0;
hsv->h = 0.0;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
}
hsv->a = rgb->a;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
}
void
gimp_hsv_to_rgb (const GimpHSV *hsv,
GimpRGB *rgb)
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
{
gint i;
gdouble f, w, q, t;
gdouble hue;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
g_return_if_fail (rgb != NULL);
g_return_if_fail (hsv != NULL);
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
if (hsv->s == 0.0)
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
{
rgb->r = hsv->v;
rgb->g = hsv->v;
rgb->b = hsv->v;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
}
else
{
hue = hsv->h;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
if (hue == 1.0)
hue = 0.0;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
hue *= 6.0;
i = (gint) hue;
f = hue - i;
w = hsv->v * (1.0 - hsv->s);
q = hsv->v * (1.0 - (hsv->s * f));
t = hsv->v * (1.0 - (hsv->s * (1.0 - f)));
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
switch (i)
{
case 0:
rgb->r = hsv->v;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
rgb->g = t;
rgb->b = w;
break;
case 1:
rgb->r = q;
rgb->g = hsv->v;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
rgb->b = w;
break;
case 2:
rgb->r = w;
rgb->g = hsv->v;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
rgb->b = t;
break;
case 3:
rgb->r = w;
rgb->g = q;
rgb->b = hsv->v;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
break;
case 4:
rgb->r = t;
rgb->g = w;
rgb->b = hsv->v;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
break;
case 5:
rgb->r = hsv->v;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
rgb->g = w;
rgb->b = q;
break;
}
}
rgb->a = hsv->a;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
}
void
gimp_rgb_to_hsl (const GimpRGB *rgb,
GimpHSL *hsl)
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
{
gdouble max, min, delta;
g_return_if_fail (rgb != NULL);
g_return_if_fail (hsl != NULL);
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
max = gimp_rgb_max (rgb);
min = gimp_rgb_min (rgb);
hsl->l = (max + min) / 2.0;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
if (max == min)
{
hsl->s = 0.0;
hsl->h = GIMP_HSL_UNDEFINED;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
}
else
{
if (hsl->l <= 0.5)
hsl->s = (max - min) / (max + min);
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
else
hsl->s = (max - min) / (2.0 - max - min);
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
delta = max - min;
if (delta == 0.0)
delta = 1.0;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
if (rgb->r == max)
{
hsl->h = (rgb->g - rgb->b) / delta;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
}
else if (rgb->g == max)
{
hsl->h = 2.0 + (rgb->b - rgb->r) / delta;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
}
else if (rgb->b == max)
{
hsl->h = 4.0 + (rgb->r - rgb->g) / delta;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
}
hsl->h /= 6.0;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
if (hsl->h < 0.0)
hsl->h += 1.0;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
}
hsl->a = rgb->a;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
}
static gdouble
gimp_hsl_value (gdouble n1,
gdouble n2,
gdouble hue)
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
{
gdouble val;
if (hue > 6.0)
hue -= 6.0;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
else if (hue < 0.0)
hue += 6.0;
if (hue < 1.0)
val = n1 + (n2 - n1) * hue;
else if (hue < 3.0)
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
val = n2;
else if (hue < 4.0)
val = n1 + (n2 - n1) * (4.0 - hue);
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
else
val = n1;
return val;
}
void
gimp_hsl_to_rgb (const GimpHSL *hsl,
GimpRGB *rgb)
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
{
g_return_if_fail (hsl != NULL);
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
g_return_if_fail (rgb != NULL);
if (hsl->s == 0)
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
{
/* achromatic case */
rgb->r = hsl->l;
rgb->g = hsl->l;
rgb->b = hsl->l;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
}
else
{
gdouble m1, m2;
if (hsl->l <= 0.5)
m2 = hsl->l * (1.0 + hsl->s);
else
m2 = hsl->l + hsl->s - hsl->l * hsl->s;
m1 = 2.0 * hsl->l - m2;
rgb->r = gimp_hsl_value (m1, m2, hsl->h * 6.0 + 2.0);
rgb->g = gimp_hsl_value (m1, m2, hsl->h * 6.0);
rgb->b = gimp_hsl_value (m1, m2, hsl->h * 6.0 - 2.0);
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
}
rgb->a = hsl->a;
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
}
#define GIMP_RETURN_RGB(x, y, z) { rgb->r = x; rgb->g = y; rgb->b = z; return; }
/*****************************************************************************
* Theoretically, hue 0 (pure red) is identical to hue 6 in these transforms.
* Pure red always maps to 6 in this implementation. Therefore UNDEFINED can
* be defined as 0 in situations where only unsigned numbers are desired.
*****************************************************************************/
void
gimp_rgb_to_hwb (const GimpRGB *rgb,
gdouble *hue,
gdouble *whiteness,
gdouble *blackness)
plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's 2001-01-01 Michael Natterer <mitch@gimp.org> * plug-ins/libgck/gck/gck.h * plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type and all it's functions. * libgimp/Makefile.am * libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color type and assorted functions. * libgimp/gimpcolorspace.[ch]: colorspace conversion routines for the new GimpRGB type. Also taken from LibGCK. * libgimp/gimp.h * libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include it in both files but unavoidable to follow our new "*.c" file include policy. This will go away as libgimp will be chopped up into pieces anyway. * app/apptypes.h * app/asupsample.[ch] * app/blend.c * app/color_transfer.h * app/gradient_header.h: removed "color_t" and use GimpRGB instead. * plug-ins/Lighting/lighting_apply.c * plug-ins/Lighting/lighting_image.c * plug-ins/Lighting/lighting_image.h * plug-ins/Lighting/lighting_main.c * plug-ins/Lighting/lighting_main.h * plug-ins/Lighting/lighting_preview.c * plug-ins/Lighting/lighting_shade.c * plug-ins/Lighting/lighting_shade.h * plug-ins/MapObject/mapobject_apply.c * plug-ins/MapObject/mapobject_image.c * plug-ins/MapObject/mapobject_image.h * plug-ins/MapObject/mapobject_main.c * plug-ins/MapObject/mapobject_main.h * plug-ins/MapObject/mapobject_preview.c * plug-ins/MapObject/mapobject_shade.c * plug-ins/MapObject/mapobject_shade.h * modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g * plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor version when deciding if to add a missing PDB wrapper. (All this compat cruft including libgimp/gimpcompat.h should go away ASAP)
2001-01-02 02:35:09 +08:00
{
/* RGB are each on [0, 1]. W and B are returned on [0, 1] and H is */
/* returned on [0, 6]. Exception: H is returned UNDEFINED if W == 1 - B. */
/* ====================================================================== */
gdouble R = rgb->r, G = rgb->g, B = rgb->b, w, v, b, f;
gint i;
w = gimp_rgb_min (rgb);
v = gimp_rgb_max (rgb);
b = 1.0 - v;
if (v == w)
{
*hue = GIMP_HSV_UNDEFINED;
*whiteness = w;
*blackness = b;
}
else
{
f = (R == w) ? G - B : ((G == w) ? B - R : R - G);
i = (R == w) ? 3.0 : ((G == w) ? 5.0 : 1.0);
*hue = (360.0 / 6.0) * (i - f / (v - w));
*whiteness = w;
*blackness = b;
}
}
void
gimp_hwb_to_rgb (gdouble hue,
gdouble whiteness,
gdouble blackness,
GimpRGB *rgb)
{
/* H is given on [0, 6] or UNDEFINED. whiteness and
* blackness are given on [0, 1].
* RGB are each returned on [0, 1].
*/
gdouble h = hue, w = whiteness, b = blackness, v, n, f;
gint i;
h = 6.0 * h/ 360.0;
v = 1.0 - b;
if (h == GIMP_HSV_UNDEFINED)
{
rgb->r = v;
rgb->g = v;
rgb->b = v;
}
else
{
i = floor (h);
f = h - i;
if (i & 1)
f = 1.0 - f; /* if i is odd */
n = w + f * (v - w); /* linear interpolation between w and v */
switch (i)
{
case 6:
case 0: GIMP_RETURN_RGB (v, n, w);
break;
case 1: GIMP_RETURN_RGB (n, v, w);
break;
case 2: GIMP_RETURN_RGB (w, v, n);
break;
case 3: GIMP_RETURN_RGB (w, n, v);
break;
case 4: GIMP_RETURN_RGB (n, w, v);
break;
case 5: GIMP_RETURN_RGB (v, w, n);
break;
}
}
}
/* gint functions */
2000-01-03 06:30:20 +08:00
void
gimp_rgb_to_hsv_int (gint *red,
gint *green,
gint *blue)
2000-01-03 06:30:20 +08:00
{
gint r, g, b;
gdouble h, s, v;
gint min, max;
gint delta;
2000-01-03 06:30:20 +08:00
h = 0.0;
r = *red;
g = *green;
b = *blue;
2000-01-03 06:30:20 +08:00
if (r > g)
2000-01-03 06:30:20 +08:00
{
max = MAX (r, b);
min = MIN (g, b);
2000-01-03 06:30:20 +08:00
}
else
{
max = MAX (g, b);
min = MIN (r, b);
2000-01-03 06:30:20 +08:00
}
v = max;
if (max != 0)
s = ((max - min) * 255) / (gdouble) max;
2000-01-03 06:30:20 +08:00
else
s = 0;
if (s == 0)
h = 0;
else
{
delta = max - min;
if (r == max)
h = (g - b) / (gdouble) delta;
else if (g == max)
h = 2 + (b - r) / (gdouble) delta;
else if (b == max)
h = 4 + (r - g) / (gdouble) delta;
2000-01-03 06:30:20 +08:00
h *= 42.5;
if (h < 0)
h += 255;
if (h > 255)
h -= 255;
}
*red = h;
*green = s;
*blue = v;
2000-01-03 06:30:20 +08:00
}
void
gimp_hsv_to_rgb_int (gint *hue,
gint *saturation,
gint *value)
2000-01-03 06:30:20 +08:00
{
gdouble h, s, v;
gdouble f, p, q, t;
2000-01-03 06:30:20 +08:00
if (*saturation == 0)
2000-01-03 06:30:20 +08:00
{
*hue = *value;
*saturation = *value;
*value = *value;
2000-01-03 06:30:20 +08:00
}
else
{
h = *hue * 6.0 / 255.0;
s = *saturation / 255.0;
v = *value / 255.0;
2000-01-03 06:30:20 +08:00
f = h - (gint) h;
p = v * (1.0 - s);
q = v * (1.0 - (s * f));
t = v * (1.0 - (s * (1.0 - f)));
2000-01-03 06:30:20 +08:00
switch ((gint) h)
2000-01-03 06:30:20 +08:00
{
case 0:
*hue = ROUND (v * 255.0);
*saturation = ROUND (t * 255.0);
*value = ROUND (p * 255.0);
2000-01-03 06:30:20 +08:00
break;
2000-01-03 06:30:20 +08:00
case 1:
*hue = ROUND (q * 255.0);
*saturation = ROUND (v * 255.0);
*value = ROUND (p * 255.0);
2000-01-03 06:30:20 +08:00
break;
2000-01-03 06:30:20 +08:00
case 2:
*hue = ROUND (p * 255.0);
*saturation = ROUND (v * 255.0);
*value = ROUND (t * 255.0);
2000-01-03 06:30:20 +08:00
break;
2000-01-03 06:30:20 +08:00
case 3:
*hue = ROUND (p * 255.0);
*saturation = ROUND (q * 255.0);
*value = ROUND (v * 255.0);
2000-01-03 06:30:20 +08:00
break;
2000-01-03 06:30:20 +08:00
case 4:
*hue = ROUND (t * 255.0);
*saturation = ROUND (p * 255.0);
*value = ROUND (v * 255.0);
2000-01-03 06:30:20 +08:00
break;
2000-01-03 06:30:20 +08:00
case 5:
*hue = ROUND (v * 255.0);
*saturation = ROUND (p * 255.0);
*value = ROUND (q * 255.0);
2000-01-03 06:30:20 +08:00
break;
}
}
}
void
gimp_rgb_to_hls_int (gint *red,
gint *green,
gint *blue)
2000-01-03 06:30:20 +08:00
{
gint r, g, b;
gdouble h, l, s;
gint min, max;
gint delta;
2000-01-03 06:30:20 +08:00
r = *red;
g = *green;
b = *blue;
2000-01-03 06:30:20 +08:00
if (r > g)
2000-01-03 06:30:20 +08:00
{
max = MAX (r, b);
min = MIN (g, b);
2000-01-03 06:30:20 +08:00
}
else
{
max = MAX (g, b);
min = MIN (r, b);
2000-01-03 06:30:20 +08:00
}
l = (max + min) / 2.0;
if (max == min)
{
s = 0.0;
h = 0.0;
}
else
{
delta = (max - min);
if (l < 128)
s = 255 * (gdouble) delta / (gdouble) (max + min);
2000-01-03 06:30:20 +08:00
else
s = 255 * (gdouble) delta / (gdouble) (511 - max - min);
2000-01-03 06:30:20 +08:00
if (r == max)
h = (g - b) / (gdouble) delta;
else if (g == max)
h = 2 + (b - r) / (gdouble) delta;
2000-01-03 06:30:20 +08:00
else
h = 4 + (r - g) / (gdouble) delta;
2000-01-03 06:30:20 +08:00
h = h * 42.5;
if (h < 0)
h += 255;
else if (h > 255)
h -= 255;
}
*red = h;
*green = l;
*blue = s;
2000-01-03 06:30:20 +08:00
}
gint
gimp_rgb_to_l_int (gint red,
gint green,
gint blue)
2000-01-03 06:30:20 +08:00
{
gint min, max;
2000-01-03 06:30:20 +08:00
if (red > green)
{
max = MAX (red, blue);
min = MIN (green, blue);
2000-01-03 06:30:20 +08:00
}
else
{
max = MAX (green, blue);
min = MIN (red, blue);
2000-01-03 06:30:20 +08:00
}
return (max + min) / 2.0;
}
static gint
gimp_hls_value (gdouble n1,
gdouble n2,
gdouble hue)
2000-01-03 06:30:20 +08:00
{
gdouble value;
2000-01-03 06:30:20 +08:00
if (hue > 255)
hue -= 255;
else if (hue < 0)
hue += 255;
2000-01-03 06:30:20 +08:00
if (hue < 42.5)
value = n1 + (n2 - n1) * (hue / 42.5);
else if (hue < 127.5)
value = n2;
else if (hue < 170)
value = n1 + (n2 - n1) * ((170 - hue) / 42.5);
else
value = n1;
return (gint) (value * 254.999 + 0.5);
2000-01-03 06:30:20 +08:00
}
void
gimp_hls_to_rgb_int (gint *hue,
gint *lightness,
gint *saturation)
2000-01-03 06:30:20 +08:00
{
gdouble h, l, s;
2000-01-03 06:30:20 +08:00
h = *hue;
l = *lightness;
s = *saturation;
2000-01-03 06:30:20 +08:00
if (s == 0)
2000-01-03 06:30:20 +08:00
{
/* achromatic case */
*hue = l;
*lightness = l;
*saturation = l;
2000-01-03 06:30:20 +08:00
}
else
{
gdouble m1, m2;
if (l < 128)
m2 = (l * (255 + s)) / 65025.0;
2000-01-03 06:30:20 +08:00
else
m2 = (l + s - (l * s) / 255.0) / 255.0;
2000-01-03 06:30:20 +08:00
m1 = (l / 127.5) - m2;
2000-01-03 06:30:20 +08:00
/* chromatic case */
*hue = gimp_hls_value (m1, m2, h + 85);
*lightness = gimp_hls_value (m1, m2, h);
*saturation = gimp_hls_value (m1, m2, h - 85);
2000-01-03 06:30:20 +08:00
}
}
void
gimp_rgb_to_hsv4 (guchar *rgb,
gdouble *hue,
gdouble *saturation,
gdouble *value)
2000-01-03 06:30:20 +08:00
{
gdouble red, green, blue;
gdouble h, s, v;
gdouble min, max;
gdouble delta;
2000-01-03 06:30:20 +08:00
red = rgb[0] / 255.0;
green = rgb[1] / 255.0;
blue = rgb[2] / 255.0;
h = 0.0; /* Shut up -Wall */
if (red > green)
{
max = MAX (red, blue);
min = MIN (green, blue);
2000-01-03 06:30:20 +08:00
}
else
{
max = MAX (green, blue);
min = MIN (red, blue);
2000-01-03 06:30:20 +08:00
}
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 (delta == 0.0)
delta = 1.0;
2000-01-03 06:30:20 +08:00
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;
}
*hue = h;
*saturation = s;
*value = v;
2000-01-03 06:30:20 +08:00
}
void
gimp_hsv_to_rgb4 (guchar *rgb,
gdouble hue,
gdouble saturation,
gdouble value)
2000-01-03 06:30:20 +08:00
{
gdouble h, s, v;
gdouble f, p, q, t;
2000-01-03 06:30:20 +08:00
if (saturation == 0.0)
2000-01-03 06:30:20 +08:00
{
hue = value;
saturation = value;
value = value;
2000-01-03 06:30:20 +08:00
}
else
{
h = hue * 6.0;
s = saturation;
v = value;
2000-01-03 06:30:20 +08:00
if (h == 6.0)
h = 0.0;
2000-01-03 06:30:20 +08:00
f = h - (gint) h;
p = v * (1.0 - s);
q = v * (1.0 - s * f);
t = v * (1.0 - s * (1.0 - f));
2000-01-03 06:30:20 +08:00
switch ((int) h)
2000-01-03 06:30:20 +08:00
{
case 0:
hue = v;
saturation = t;
value = p;
2000-01-03 06:30:20 +08:00
break;
case 1:
hue = q;
saturation = v;
value = p;
2000-01-03 06:30:20 +08:00
break;
case 2:
hue = p;
saturation = v;
value = t;
2000-01-03 06:30:20 +08:00
break;
case 3:
hue = p;
saturation = q;
value = v;
2000-01-03 06:30:20 +08:00
break;
case 4:
hue = t;
saturation = p;
value = v;
2000-01-03 06:30:20 +08:00
break;
case 5:
hue = v;
saturation = p;
value = q;
2000-01-03 06:30:20 +08:00
break;
}
}
rgb[0] = ROUND (hue * 255.0);
rgb[1] = ROUND (saturation * 255.0);
rgb[2] = ROUND (value * 255.0);
2000-01-03 06:30:20 +08:00
}