Commit 07cd86c4 authored by Sven Neumann's avatar Sven Neumann
Browse files

use color_conversion routines out of libgimp


--Sven
parent 35714bd7
Mon Jan 31 22:43:48 CET 2000 Sven Neumann <sven@gimp.org>
* libgimp/gimpcolorspace.c
* libgimp/gimpcolorspace.h: added INTENSITY() macro
* app/blend.c
* app/convert.c
* app/gimpimage.c
* app/temp_buf.c: use INTENSITY() from libgimp
* plug-ins/common/bumpmap.c
* plug-ins/common/colorify.c
* plug-ins/common/compose.c
* plug-ins/common/decompose.c
* plug-ins/common/displace.c
* plug-ins/common/engrave.c
* plug-ins/common/gradmap.c
* plug-ins/common/newsprint.c
* plug-ins/gflare/gflare.c
* plug-ins/maze/handy.c
* plug-ins/pagecurl/pagecurl.c
* plug-ins/print/print-util.c
* plug-ins/rcm/rcm.c
* plug-ins/rcm/rcm.h
* plug-ins/rcm/rcm_callback.c
* plug-ins/rcm/rcm_dialog.c
* plug-ins/rcm/rcm_gdk.c
* plug-ins/rcm/rcm_misc.c
* plug-ins/rcm/rcm_misc.h: use INTENSITY() and other
color_conversion_routines from libgimp. I'm not sure if I have
tested all this properly (I tried to do), so if you are bored,
please play around with the changed plug-ins.
Mon Jan 31 21:52:27 CET 2000 Stanislav Brabec <utx@penguin.cz>
 
* plug-ins/common/vinvert.c: Typo fix.
......
......@@ -42,6 +42,7 @@
#include "paint_funcs.h"
#include "temp_buf.h"
#include "libgimp/gimpcolorspace.h"
#include "libgimp/gimpintl.h"
static unsigned char * temp_buf_allocate (unsigned int);
......@@ -106,10 +107,7 @@ temp_buf_to_gray (TempBuf *src_buf,
{
*dest++ = *src++; /* alpha channel */
pix = 0.001;
pix += 0.30 * *src++;
pix += 0.59 * *src++;
pix += 0.11 * *src++;
pix = INTENSITY (*src++, *src++, *src++);
*dest++ = (unsigned char) pix;
}
......
......@@ -39,9 +39,9 @@
#include "tile.h"
#include "libgimp/gimpcolorspace.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
#include "libgimp/gimpcolorspace.h"
/* target size */
......@@ -1345,9 +1345,7 @@ gradient_put_pixel (int x,
{
/* Convert to grayscale */
*data++ = 255.0 * (0.30 * color.r +
0.59 * color.g +
0.11 * color.b);
*data++ = 255.0 * INTENSITY (color.r, color.g, color.b);
*data++ = color.a * 255.0;
}
......@@ -1553,9 +1551,7 @@ gradient_fill_region (GImage *gimage,
{
/* Convert to grayscale */
*data++ = 255.0 * (0.30 * color.r +
0.59 * color.g +
0.11 * color.b);
*data++ = 255.0 * INTENSITY (color.r, color.g, color.b);
*data++ = color.a * 255.0;
}
}
......
......@@ -102,6 +102,7 @@
#include "palette.h"
#include "palette_select.h"
#include "libgimp/gimpcolorspace.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
......@@ -126,10 +127,10 @@
#define G_SHIFT (BITS_IN_SAMPLE-PRECISION_G)
#define B_SHIFT (BITS_IN_SAMPLE-PRECISION_B)
/* this has to match the INTENSITY definition in libgimp/gimpcolorspace.h */
#define R_SCALE 30 /* scale R distances by this much */
#define G_SCALE 59 /* scale G distances by this much */
#define B_SCALE 11 /* and B by this much */
#define INTENSITY(r,g,b) (r * 0.30 + g * 0.59 + b * 0.11 + 0.001)
#define B_SCALE 11 /* and B by this much */
static const unsigned char webpal[] =
{
......
......@@ -39,9 +39,9 @@
#include "tile.h"
#include "libgimp/gimpcolorspace.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
#include "libgimp/gimpcolorspace.h"
/* target size */
......@@ -1345,9 +1345,7 @@ gradient_put_pixel (int x,
{
/* Convert to grayscale */
*data++ = 255.0 * (0.30 * color.r +
0.59 * color.g +
0.11 * color.b);
*data++ = 255.0 * INTENSITY (color.r, color.g, color.b);
*data++ = color.a * 255.0;
}
......@@ -1553,9 +1551,7 @@ gradient_fill_region (GImage *gimage,
{
/* Convert to grayscale */
*data++ = 255.0 * (0.30 * color.r +
0.59 * color.g +
0.11 * color.b);
*data++ = 255.0 * INTENSITY (color.r, color.g, color.b);
*data++ = color.a * 255.0;
}
}
......
......@@ -102,6 +102,7 @@
#include "palette.h"
#include "palette_select.h"
#include "libgimp/gimpcolorspace.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
......@@ -126,10 +127,10 @@
#define G_SHIFT (BITS_IN_SAMPLE-PRECISION_G)
#define B_SHIFT (BITS_IN_SAMPLE-PRECISION_B)
/* this has to match the INTENSITY definition in libgimp/gimpcolorspace.h */
#define R_SCALE 30 /* scale R distances by this much */
#define G_SCALE 59 /* scale G distances by this much */
#define B_SCALE 11 /* and B by this much */
#define INTENSITY(r,g,b) (r * 0.30 + g * 0.59 + b * 0.11 + 0.001)
#define B_SCALE 11 /* and B by this much */
static const unsigned char webpal[] =
{
......
......@@ -33,6 +33,7 @@
#include "pathsP.h"
#include "gimprc.h"
#include "libgimp/gimpcolorspace.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimplimits.h"
......@@ -967,7 +968,6 @@ gimp_image_transform_color (GimpImage *gimage,
guchar *dest,
GimpImageBaseType type)
{
#define INTENSITY(r,g,b) (r * 0.30 + g * 0.59 + b * 0.11 + 0.001)
GimpImageType d_type;
d_type = (drawable != NULL) ? drawable_type (drawable) :
......
......@@ -33,6 +33,7 @@
#include "pathsP.h"
#include "gimprc.h"
#include "libgimp/gimpcolorspace.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimplimits.h"
......@@ -967,7 +968,6 @@ gimp_image_transform_color (GimpImage *gimage,
guchar *dest,
GimpImageBaseType type)
{
#define INTENSITY(r,g,b) (r * 0.30 + g * 0.59 + b * 0.11 + 0.001)
GimpImageType d_type;
d_type = (drawable != NULL) ? drawable_type (drawable) :
......
......@@ -33,6 +33,7 @@
#include "pathsP.h"
#include "gimprc.h"
#include "libgimp/gimpcolorspace.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimplimits.h"
......@@ -967,7 +968,6 @@ gimp_image_transform_color (GimpImage *gimage,
guchar *dest,
GimpImageBaseType type)
{
#define INTENSITY(r,g,b) (r * 0.30 + g * 0.59 + b * 0.11 + 0.001)
GimpImageType d_type;
d_type = (drawable != NULL) ? drawable_type (drawable) :
......
......@@ -33,6 +33,7 @@
#include "pathsP.h"
#include "gimprc.h"
#include "libgimp/gimpcolorspace.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimplimits.h"
......@@ -967,7 +968,6 @@ gimp_image_transform_color (GimpImage *gimage,
guchar *dest,
GimpImageBaseType type)
{
#define INTENSITY(r,g,b) (r * 0.30 + g * 0.59 + b * 0.11 + 0.001)
GimpImageType d_type;
d_type = (drawable != NULL) ? drawable_type (drawable) :
......
......@@ -33,6 +33,7 @@
#include "pathsP.h"
#include "gimprc.h"
#include "libgimp/gimpcolorspace.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimplimits.h"
......@@ -967,7 +968,6 @@ gimp_image_transform_color (GimpImage *gimage,
guchar *dest,
GimpImageBaseType type)
{
#define INTENSITY(r,g,b) (r * 0.30 + g * 0.59 + b * 0.11 + 0.001)
GimpImageType d_type;
d_type = (drawable != NULL) ? drawable_type (drawable) :
......
......@@ -33,6 +33,7 @@
#include "pathsP.h"
#include "gimprc.h"
#include "libgimp/gimpcolorspace.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimplimits.h"
......@@ -967,7 +968,6 @@ gimp_image_transform_color (GimpImage *gimage,
guchar *dest,
GimpImageBaseType type)
{
#define INTENSITY(r,g,b) (r * 0.30 + g * 0.59 + b * 0.11 + 0.001)
GimpImageType d_type;
d_type = (drawable != NULL) ? drawable_type (drawable) :
......
......@@ -33,6 +33,7 @@
#include "pathsP.h"
#include "gimprc.h"
#include "libgimp/gimpcolorspace.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimplimits.h"
......@@ -967,7 +968,6 @@ gimp_image_transform_color (GimpImage *gimage,
guchar *dest,
GimpImageBaseType type)
{
#define INTENSITY(r,g,b) (r * 0.30 + g * 0.59 + b * 0.11 + 0.001)
GimpImageType d_type;
d_type = (drawable != NULL) ? drawable_type (drawable) :
......
......@@ -102,6 +102,7 @@
#include "palette.h"
#include "palette_select.h"
#include "libgimp/gimpcolorspace.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
......@@ -126,10 +127,10 @@
#define G_SHIFT (BITS_IN_SAMPLE-PRECISION_G)
#define B_SHIFT (BITS_IN_SAMPLE-PRECISION_B)
/* this has to match the INTENSITY definition in libgimp/gimpcolorspace.h */
#define R_SCALE 30 /* scale R distances by this much */
#define G_SCALE 59 /* scale G distances by this much */
#define B_SCALE 11 /* and B by this much */
#define INTENSITY(r,g,b) (r * 0.30 + g * 0.59 + b * 0.11 + 0.001)
#define B_SCALE 11 /* and B by this much */
static const unsigned char webpal[] =
{
......
......@@ -33,6 +33,7 @@
#include "pathsP.h"
#include "gimprc.h"
#include "libgimp/gimpcolorspace.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimplimits.h"
......@@ -967,7 +968,6 @@ gimp_image_transform_color (GimpImage *gimage,
guchar *dest,
GimpImageBaseType type)
{
#define INTENSITY(r,g,b) (r * 0.30 + g * 0.59 + b * 0.11 + 0.001)
GimpImageType d_type;
d_type = (drawable != NULL) ? drawable_type (drawable) :
......
......@@ -42,6 +42,7 @@
#include "paint_funcs.h"
#include "temp_buf.h"
#include "libgimp/gimpcolorspace.h"
#include "libgimp/gimpintl.h"
static unsigned char * temp_buf_allocate (unsigned int);
......@@ -106,10 +107,7 @@ temp_buf_to_gray (TempBuf *src_buf,
{
*dest++ = *src++; /* alpha channel */
pix = 0.001;
pix += 0.30 * *src++;
pix += 0.59 * *src++;
pix += 0.11 * *src++;
pix = INTENSITY (*src++, *src++, *src++);
*dest++ = (unsigned char) pix;
}
......
......@@ -39,9 +39,9 @@
#include "tile.h"
#include "libgimp/gimpcolorspace.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
#include "libgimp/gimpcolorspace.h"
/* target size */
......@@ -1345,9 +1345,7 @@ gradient_put_pixel (int x,
{
/* Convert to grayscale */
*data++ = 255.0 * (0.30 * color.r +
0.59 * color.g +
0.11 * color.b);
*data++ = 255.0 * INTENSITY (color.r, color.g, color.b);
*data++ = color.a * 255.0;
}
......@@ -1553,9 +1551,7 @@ gradient_fill_region (GImage *gimage,
{
/* Convert to grayscale */
*data++ = 255.0 * (0.30 * color.r +
0.59 * color.g +
0.11 * color.b);
*data++ = 255.0 * INTENSITY (color.r, color.g, color.b);
*data++ = color.a * 255.0;
}
}
......
......@@ -39,9 +39,9 @@
#include "tile.h"
#include "libgimp/gimpcolorspace.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
#include "libgimp/gimpcolorspace.h"
/* target size */
......@@ -1345,9 +1345,7 @@ gradient_put_pixel (int x,
{
/* Convert to grayscale */
*data++ = 255.0 * (0.30 * color.r +
0.59 * color.g +
0.11 * color.b);
*data++ = 255.0 * INTENSITY (color.r, color.g, color.b);
*data++ = color.a * 255.0;
}
......@@ -1553,9 +1551,7 @@ gradient_fill_region (GImage *gimage,
{
/* Convert to grayscale */
*data++ = 255.0 * (0.30 * color.r +
0.59 * color.g +
0.11 * color.b);
*data++ = 255.0 * INTENSITY (color.r, color.g, color.b);
*data++ = color.a * 255.0;
}
}
......
......@@ -615,8 +615,8 @@ gimp_hsv_to_rgb4 (guchar *rgb,
}
}
rgb[0] = h*255;
rgb[1] = s*255;
rgb[2] = v*255;
rgb[0] = h * 255;
rgb[1] = s * 255;
rgb[2] = v * 255;
}
......@@ -29,7 +29,16 @@ int gimp_rgb_to_l (int, int, int);
void gimp_hls_to_rgb (int *, int *, int *);
void gimp_rgb_to_hsv_double (double *, double *, double *);
void gimp_hsv_to_rgb_double (double *, double *, double *);
void gimp_rgb_to_hsv4 (guchar *, double *, double *, double *);
void gimp_hsv_to_rgb4 (guchar *, double, double, double);
void gimp_rgb_to_hsv4 (guchar *, double *, double *, double *);
void gimp_hsv_to_rgb4 (guchar *, double, double, double);
/* Map RGB to intensity */
#define INTENSITY_RED 0.30
#define INTENSITY_GREEN 0.59
#define INTENSITY_BLUE 0.11
#define INTENSITY(r,g,b) ((r) * INTENSITY_RED + \
(g) * INTENSITY_GREEN + \
(b) * INTENSITY_BLUE + 0.001)
#endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment