mirror of https://github.com/GNOME/gimp.git
parent
35714bd79b
commit
07cd86c451
33
ChangeLog
33
ChangeLog
|
@ -1,3 +1,36 @@
|
|||
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;
|
||||
}
|
||||
|
|
10
app/blend.c
10
app/blend.c
|
@ -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)
|
||||
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,4 +32,13 @@ 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);
|
||||
|
||||
|
||||
/* 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
|
||||
|
|
|
@ -730,12 +730,11 @@ bumpmap_convert_row (guchar *row,
|
|||
{
|
||||
if (has_alpha)
|
||||
*p++ = lut[(int) (bmvals.waterlevel +
|
||||
(((int)
|
||||
(0.30 * row[0] + 0.59 * row[1] + 0.11 * row[2] + 0.5) -
|
||||
(((int) (INTENSITY (row[0], row[1], row[2]) + 0.5) -
|
||||
bmvals.waterlevel) *
|
||||
row[3]) / 255.0)];
|
||||
else
|
||||
*p++ = lut[(int) (0.30 * row[0] + 0.59 * row[1] + 0.11 * row[2] + 0.5)];
|
||||
*p++ = lut[(int) (INTENSITY (row[0], row[1], row[2]) + 0.5)];
|
||||
|
||||
row += 3 + has_alpha;
|
||||
}
|
||||
|
|
|
@ -246,9 +246,9 @@ colorify (GDrawable *drawable)
|
|||
|
||||
for (i = 0; i < 256; i ++)
|
||||
{
|
||||
lum_red_lookup[i] = i * 0.30;
|
||||
lum_green_lookup[i] = i * 0.59;
|
||||
lum_blue_lookup[i] = i * 0.11;
|
||||
lum_red_lookup[i] = i * INTENSITY_RED;
|
||||
lum_green_lookup[i] = i * INTENSITY_GREEN;
|
||||
lum_blue_lookup[i] = i * INTENSITY_BLUE;
|
||||
final_red_lookup[i] = i * cvals.color[0] / 255;
|
||||
final_green_lookup[i] = i * cvals.color[1] / 255;
|
||||
final_blue_lookup[i] = i * cvals.color[2] / 255;
|
||||
|
|
|
@ -86,9 +86,6 @@ static void compose_cmy (unsigned char **src, int *incr, int numpix,
|
|||
static void compose_cmyk (unsigned char **src, int *incr, int numpix,
|
||||
unsigned char *dst);
|
||||
|
||||
static void hsv_to_rgb (unsigned char *h, unsigned char *s,
|
||||
unsigned char *v, unsigned char *rgb);
|
||||
|
||||
static gint compose_dialog (char *compose_type,
|
||||
gint32 drawable_ID);
|
||||
|
||||
|
@ -670,7 +667,9 @@ compose_hsv (unsigned char **src,
|
|||
|
||||
while (count-- > 0)
|
||||
{
|
||||
hsv_to_rgb (hue_src, sat_src, val_src, rgb_dst);
|
||||
gimp_hsv_to_rgb4 (rgb_dst, (double) *hue_src / 255.0,
|
||||
(double) *sat_src / 255.0,
|
||||
(double) *val_src / 255.0);
|
||||
rgb_dst += 3;
|
||||
hue_src += hue_incr;
|
||||
sat_src += sat_incr;
|
||||
|
@ -909,93 +908,6 @@ compose_dialog (char *compose_type,
|
|||
return composeint.run;
|
||||
}
|
||||
|
||||
|
||||
/* hsv_to_rgb has been taken from the compose-plug-in of GIMP V 0.54
|
||||
* and hass been modified a little bit
|
||||
*/
|
||||
static void
|
||||
hsv_to_rgb (unsigned char *h,
|
||||
unsigned char *s,
|
||||
unsigned char *v,
|
||||
unsigned char *rgb)
|
||||
{
|
||||
double hue, sat, val;
|
||||
double f, p, q, t;
|
||||
int red, green, blue;
|
||||
|
||||
if (*s == 0)
|
||||
{
|
||||
rgb[0] = rgb[1] = rgb[2] = *v;
|
||||
}
|
||||
else
|
||||
{
|
||||
hue = *h * 6.0 / 255.0;
|
||||
sat = *s / 255.0;
|
||||
val = *v / 255.0;
|
||||
|
||||
f = hue - (int) hue;
|
||||
p = val * (1.0 - sat);
|
||||
q = val * (1.0 - (sat * f));
|
||||
t = val * (1.0 - (sat * (1.0 - f)));
|
||||
|
||||
switch ((int) hue)
|
||||
{
|
||||
case 0:
|
||||
red = (int)(val * 255.0);
|
||||
green = (int)(t * 255.0);
|
||||
blue = (int)(p * 255.0);
|
||||
break;
|
||||
case 1:
|
||||
red = (int)(q * 255.0);
|
||||
green = (int)(val * 255.0);
|
||||
blue = (int)(p * 255.0);
|
||||
break;
|
||||
case 2:
|
||||
red = (int)(p * 255.0);
|
||||
green = (int)(val * 255.0);
|
||||
blue = (int)(t * 255.0);
|
||||
break;
|
||||
case 3:
|
||||
red = (int)(p * 255.0);
|
||||
green = (int)(q * 255.0);
|
||||
blue = (int)(val * 255.0);
|
||||
break;
|
||||
case 4:
|
||||
red = (int)(t * 255.0);
|
||||
green = (int)(p * 255.0);
|
||||
blue = (int)(val * 255.0);
|
||||
break;
|
||||
case 5:
|
||||
red = (int)(val * 255.0);
|
||||
green = (int)(p * 255.0);
|
||||
blue = (int)(q * 255.0);
|
||||
break;
|
||||
default:
|
||||
red = 0;
|
||||
green = 0;
|
||||
blue = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (red < 0)
|
||||
red = 0;
|
||||
else if (red > 255)
|
||||
red = 255;
|
||||
if (green < 0)
|
||||
green = 0;
|
||||
else if (green > 255)
|
||||
green = 255;
|
||||
if (blue < 0)
|
||||
blue = 0;
|
||||
else if (blue > 255)
|
||||
blue = 255;
|
||||
|
||||
rgb[0] = (unsigned char)red;
|
||||
rgb[1] = (unsigned char)green;
|
||||
rgb[2] = (unsigned char)blue;
|
||||
}
|
||||
}
|
||||
|
||||
/* Compose interface functions */
|
||||
|
||||
static gint
|
||||
|
|
|
@ -66,8 +66,6 @@ static gint32 create_new_image (char *filename, guint width, guint height,
|
|||
|
||||
static void show_message (const char *msg);
|
||||
static int cmp_icase (char *s1, char *s2);
|
||||
static void rgb_to_hsv (unsigned char *r, unsigned char *g, unsigned char *b,
|
||||
unsigned char *h, unsigned char *s, unsigned char *v);
|
||||
|
||||
static void extract_rgb (unsigned char *src, int bpp, int numpix,
|
||||
unsigned char **dst);
|
||||
|
@ -407,15 +405,6 @@ decompose (gint32 image_ID,
|
|||
layer_ID_dst+j, drawable_dst+j, pixel_rgn_dst+j);
|
||||
dst[j] = (unsigned char *)g_malloc (tile_height * width);
|
||||
}
|
||||
if (dst[num_images-1] == NULL)
|
||||
{
|
||||
show_message ("decompose: out of memory");
|
||||
for (j = 0; j < num_images; j++)
|
||||
{
|
||||
if (dst[j] != NULL) g_free (dst[j]);
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (i < height)
|
||||
|
@ -506,81 +495,6 @@ cmp_icase (char *s1,
|
|||
}
|
||||
|
||||
|
||||
/* Convert RGB to HSV. This routine was taken from decompose plug-in
|
||||
of GIMP V 0.54 and modified a little bit.
|
||||
*/
|
||||
static void
|
||||
rgb_to_hsv (unsigned char *r,
|
||||
unsigned char *g,
|
||||
unsigned char *b,
|
||||
unsigned char *h,
|
||||
unsigned char *s,
|
||||
unsigned char *v)
|
||||
|
||||
{
|
||||
int red = (int)*r, green = (int)*g, blue = (int)*b;
|
||||
double hue;
|
||||
int min, max, delta, sat_i;
|
||||
|
||||
if (red > green)
|
||||
{
|
||||
if (red > blue)
|
||||
max = red;
|
||||
else
|
||||
max = blue;
|
||||
|
||||
if (green < blue)
|
||||
min = green;
|
||||
else
|
||||
min = blue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (green > blue)
|
||||
max = green;
|
||||
else
|
||||
max = blue;
|
||||
|
||||
if (red < blue)
|
||||
min = red;
|
||||
else
|
||||
min = blue;
|
||||
}
|
||||
|
||||
*v = (unsigned char)max;
|
||||
|
||||
if (max != 0)
|
||||
sat_i = ((max - min) * 255) / max;
|
||||
else
|
||||
sat_i = 0;
|
||||
|
||||
*s = (unsigned char)sat_i;
|
||||
|
||||
if (sat_i == 0)
|
||||
{
|
||||
*h = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
delta = max - min;
|
||||
if (red == max)
|
||||
hue = (green - blue) / (double)delta;
|
||||
else if (green == max)
|
||||
hue = 2.0 + (blue - red) / (double)delta;
|
||||
else
|
||||
hue = 4.0 + (red - green) / (double)delta;
|
||||
hue *= 42.5;
|
||||
|
||||
if (hue < 0.0)
|
||||
hue += 255.0;
|
||||
if (hue > 255.0)
|
||||
hue -= 255.0;
|
||||
|
||||
*h = (unsigned char)hue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Extract functions */
|
||||
|
||||
static void
|
||||
|
@ -710,10 +624,14 @@ extract_hsv (unsigned char *src,
|
|||
register unsigned char *sat_dst = dst[1];
|
||||
register unsigned char *val_dst = dst[2];
|
||||
register int count = numpix, offset = bpp;
|
||||
double hue, sat, val;
|
||||
|
||||
while (count-- > 0)
|
||||
{
|
||||
rgb_to_hsv (rgb_src, rgb_src+1, rgb_src+2, hue_dst++, sat_dst++, val_dst++);
|
||||
gimp_rgb_to_hsv4 (rgb_src, &hue, &sat, &val);
|
||||
*hue_dst++ = (unsigned char) (hue * 255.999);
|
||||
*sat_dst++ = (unsigned char) (sat * 255.999);
|
||||
*val_dst++ = (unsigned char) (val * 255.999);
|
||||
rgb_src += offset;
|
||||
}
|
||||
}
|
||||
|
@ -727,13 +645,13 @@ extract_hue (unsigned char *src,
|
|||
{
|
||||
register unsigned char *rgb_src = src;
|
||||
register unsigned char *hue_dst = dst[0];
|
||||
unsigned char dmy;
|
||||
unsigned char *dummy = &dmy;
|
||||
register int count = numpix, offset = bpp;
|
||||
double hue, dummy;
|
||||
|
||||
while (count-- > 0)
|
||||
{
|
||||
rgb_to_hsv (rgb_src, rgb_src+1, rgb_src+2, hue_dst++, dummy, dummy);
|
||||
gimp_rgb_to_hsv4 (rgb_src, &hue, &dummy, &dummy);
|
||||
*hue_dst++ = (unsigned char) (hue * 255.999);
|
||||
rgb_src += offset;
|
||||
}
|
||||
}
|
||||
|
@ -747,13 +665,13 @@ extract_sat (unsigned char *src,
|
|||
{
|
||||
register unsigned char *rgb_src = src;
|
||||
register unsigned char *sat_dst = dst[0];
|
||||
unsigned char dmy;
|
||||
unsigned char *dummy = &dmy;
|
||||
register int count = numpix, offset = bpp;
|
||||
double sat, dummy;
|
||||
|
||||
while (count-- > 0)
|
||||
{
|
||||
rgb_to_hsv (rgb_src, rgb_src+1, rgb_src+2, dummy, sat_dst++, dummy);
|
||||
gimp_rgb_to_hsv4 (rgb_src, &dummy, &sat, &dummy);
|
||||
*sat_dst++ = (unsigned char) (sat * 255.999);
|
||||
rgb_src += offset;
|
||||
}
|
||||
}
|
||||
|
@ -767,13 +685,13 @@ extract_val (unsigned char *src,
|
|||
{
|
||||
register unsigned char *rgb_src = src;
|
||||
register unsigned char *val_dst = dst[0];
|
||||
unsigned char dmy;
|
||||
unsigned char *dummy = &dmy;
|
||||
register int count = numpix, offset = bpp;
|
||||
double val, dummy;
|
||||
|
||||
while (count-- > 0)
|
||||
{
|
||||
rgb_to_hsv (rgb_src, rgb_src+1, rgb_src+2, dummy, dummy, val_dst++);
|
||||
gimp_rgb_to_hsv4 (rgb_src, &dummy, &dummy, &val);
|
||||
*val_dst++ = (unsigned char) (val * 255.999);
|
||||
rgb_src += offset;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -659,7 +659,7 @@ displace_map_give_value (guchar *pt,
|
|||
gdouble ret, val_alpha;
|
||||
|
||||
if (bytes >= 3)
|
||||
ret = 0.30 * pt[0] + 0.59 * pt[1] + 0.11 * pt[2];
|
||||
ret = INTENSITY (pt[0], pt[1], pt[2]);
|
||||
else
|
||||
ret = (gdouble) *pt;
|
||||
|
||||
|
|
|
@ -40,8 +40,6 @@
|
|||
#define SCALE_WIDTH 125
|
||||
#define TILE_CACHE_SIZE 16
|
||||
|
||||
#define INTENSITY(r,g,b) (r * 0.30 + g * 0.59 + b * 0.11)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gint height;
|
||||
|
|
|
@ -61,7 +61,7 @@ static char rcsid[] = "$Id$";
|
|||
|
||||
#define NSAMPLES 256
|
||||
#define TILE_CACHE_SIZE 32
|
||||
#define LUMINOSITY(X) (X[0] * 0.30 + X[1] * 0.59 + X[2] * 0.11)
|
||||
#define LUMINOSITY(X) (INTENSITY (X[0], X[1], X[2]))
|
||||
|
||||
/* Declare a local function.
|
||||
*/
|
||||
|
|
|
@ -118,9 +118,6 @@ do { \
|
|||
#define VALID_BOOL(x) ((x) == TRUE || (x) == FALSE)
|
||||
#define CLAMPED_ADD(a, b) (((a)+(b) > 0xff)? 0xff : (a) + (b))
|
||||
|
||||
/* Ideally, this would be in a common header file somewhere. This was
|
||||
* nicked from app/convert.c */
|
||||
#define INTENSITY(r,g,b) (r * 0.30 + g * 0.59 + b * 0.11 + 0.001)
|
||||
|
||||
/* Bartlett window supersampling weight function. See table 4.1, page
|
||||
* 123 of Alan Watt and Mark Watt, Advanced Animation and Rendering
|
||||
|
|
|
@ -75,7 +75,7 @@ static char rcsid[] = "$Id$";
|
|||
#endif
|
||||
|
||||
#define BOUNDS(a,x,y) ((a < x) ? x : ((a > y) ? y : a))
|
||||
#define LUMINOSITY(PIX) (PIX[0] * 0.30 + PIX[1] * 0.59 + PIX[2] * 0.11)
|
||||
#define LUMINOSITY(PIX) (INTENSITY (PIX[0], PIX[1], PIX[2]))
|
||||
#define OFFSETOF(t,f) ((int) ((char*) &((t*) 0)->f))
|
||||
|
||||
#define GRADIENT_NAME_MAX 256
|
||||
|
@ -1126,7 +1126,7 @@ plugin_put_pixel_func (int ix, int iy, color_t color, gpointer data)
|
|||
dest[2] = color.b * 255;
|
||||
}
|
||||
else
|
||||
dest[0] = (color.r * 0.30 + color.g * 0.59 + color.b * 0.11) * 255;
|
||||
dest[0] = INTENSITY (color.r, color.g, color.b) * 255;
|
||||
|
||||
if (dinfo.has_alpha)
|
||||
dest[drawable->bpp - 1] = color.a * 255;
|
||||
|
|
|
@ -46,8 +46,11 @@ void drawbox (GPixelRgn *dest_rgn,
|
|||
|
||||
|
||||
void
|
||||
get_colors (GDrawable *drawable, guint8 *fg, guint8 *bg)
|
||||
get_colors (GDrawable *drawable,
|
||||
guint8 *fg,
|
||||
guint8 *bg)
|
||||
{
|
||||
|
||||
GParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
|
||||
|
@ -57,75 +60,17 @@ get_colors (GDrawable *drawable, guint8 *fg, guint8 *bg)
|
|||
fg[3] = 255; /* area to be fully opaque. */
|
||||
bg[3] = 255;
|
||||
case RGB_IMAGE:
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_palette_get_foreground",
|
||||
&nreturn_vals,
|
||||
PARAM_END);
|
||||
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
{
|
||||
fg[0] = return_vals[1].data.d_color.red;
|
||||
fg[1] = return_vals[1].data.d_color.green;
|
||||
fg[2] = return_vals[1].data.d_color.blue;
|
||||
}
|
||||
else
|
||||
{
|
||||
fg[0] = 255;
|
||||
fg[1] = 255;
|
||||
fg[2] = 255;
|
||||
}
|
||||
return_vals = gimp_run_procedure ("gimp_palette_get_background",
|
||||
&nreturn_vals,
|
||||
PARAM_END);
|
||||
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
{
|
||||
bg[0] = return_vals[1].data.d_color.red;
|
||||
bg[1] = return_vals[1].data.d_color.green;
|
||||
bg[2] = return_vals[1].data.d_color.blue;
|
||||
}
|
||||
else
|
||||
{
|
||||
bg[0] = 0;
|
||||
bg[1] = 0;
|
||||
bg[2] = 0;
|
||||
}
|
||||
gimp_palette_get_foreground (&fg[0], &fg[1], &fg[2]);
|
||||
gimp_palette_get_background (&bg[0], &bg[1], &bg[2]);
|
||||
break;
|
||||
case GRAYA_IMAGE: /* and again */
|
||||
fg[1] = 255;
|
||||
bg[1] = 255;
|
||||
case GRAY_IMAGE:
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_palette_get_foreground",
|
||||
&nreturn_vals,
|
||||
PARAM_END);
|
||||
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
{
|
||||
fg[0] = 0.30 * return_vals[1].data.d_color.red +
|
||||
0.59 * return_vals[1].data.d_color.green +
|
||||
0.11 * return_vals[1].data.d_color.blue;
|
||||
}
|
||||
else
|
||||
{
|
||||
fg[0] = 255;
|
||||
}
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp_palette_get_background",
|
||||
&nreturn_vals,
|
||||
PARAM_END);
|
||||
|
||||
if (return_vals[0].data.d_status == STATUS_SUCCESS)
|
||||
{
|
||||
bg[0] = 0.30 * return_vals[1].data.d_color.red +
|
||||
0.59 * return_vals[1].data.d_color.green +
|
||||
0.11 * return_vals[1].data.d_color.blue;
|
||||
}
|
||||
else
|
||||
{
|
||||
bg[0] = 0;
|
||||
}
|
||||
|
||||
gimp_palette_get_foreground (&fg[0], &fg[1], &fg[2]);
|
||||
gimp_palette_get_background (&bg[0], &bg[1], &bg[2]);
|
||||
fg[0] = INTENSITY (fg[0], fg[1], fg[2]);
|
||||
bg[0] = INTENSITY (bg[0], bg[1], bg[2]);
|
||||
break;
|
||||
case INDEXEDA_IMAGE:
|
||||
case INDEXED_IMAGE: /* FIXME: Should use current fg/bg colors. */
|
||||
|
|
|
@ -73,11 +73,6 @@
|
|||
#define PLUG_IN_VERSION "May 1998, 0.9"
|
||||
#define NGRADSAMPLES 256
|
||||
|
||||
/***** Macros *****/
|
||||
|
||||
/* Convert color to Gray ala Gimp... */
|
||||
#define INTENSITY(r,g,b) (r * 0.30 + g * 0.59 + b * 0.11 + 0.001)
|
||||
|
||||
|
||||
/***** Types *****/
|
||||
|
||||
|
|
|
@ -37,241 +37,7 @@
|
|||
*
|
||||
* Revision History:
|
||||
*
|
||||
* $Log$
|
||||
* Revision 1.12 2000/01/26 16:00:48 neo
|
||||
* updated print plug-in
|
||||
*
|
||||
*
|
||||
* --Sven
|
||||
*
|
||||
* Revision 1.49.2.1 2000/01/13 23:41:29 rlk
|
||||
* Deal with null black pointer
|
||||
*
|
||||
* Revision 1.49 2000/01/08 23:30:37 rlk
|
||||
* Some tweaking
|
||||
*
|
||||
* Revision 1.48 1999/12/30 23:58:07 rlk
|
||||
* Silly little bug...
|
||||
*
|
||||
* Revision 1.47 1999/12/26 19:02:46 rlk
|
||||
* Performance stuff
|
||||
*
|
||||
* Revision 1.46 1999/12/25 17:47:17 rlk
|
||||
* Cleanup
|
||||
*
|
||||
* Revision 1.45 1999/12/25 00:41:01 rlk
|
||||
* some minor improvement
|
||||
*
|
||||
* Revision 1.44 1999/12/24 12:57:38 rlk
|
||||
* Reduce grain; improve red
|
||||
*
|
||||
* Revision 1.43 1999/12/22 03:24:34 rlk
|
||||
* round length up, not down
|
||||
*
|
||||
* Revision 1.42 1999/12/22 03:12:17 rlk
|
||||
* More constant fiddling
|
||||
*
|
||||
* Revision 1.41 1999/12/22 01:34:28 rlk
|
||||
* Reverse direction each pass
|
||||
*
|
||||
* Revision 1.40 1999/12/18 23:45:07 rlk
|
||||
* typo
|
||||
*
|
||||
* Revision 1.39 1999/12/12 20:49:01 rlk
|
||||
* Various changes
|
||||
*
|
||||
* Revision 1.38 1999/12/11 23:12:06 rlk
|
||||
* Better matching between cmy/k
|
||||
*
|
||||
* Smoother dither!
|
||||
*
|
||||
* Revision 1.37 1999/12/05 23:24:08 rlk
|
||||
* don't want PRINT_LUT in release
|
||||
*
|
||||
* Revision 1.36 1999/12/05 04:33:34 rlk
|
||||
* Good results for the night.
|
||||
*
|
||||
* Revision 1.35 1999/12/04 19:01:05 rlk
|
||||
* better use of light colors
|
||||
*
|
||||
* Revision 1.34 1999/12/02 02:09:45 rlk
|
||||
* .
|
||||
*
|
||||
* Revision 1.33 1999/11/25 00:02:03 rlk
|
||||
* Revamped many controls
|
||||
*
|
||||
* Revision 1.32 1999/11/23 02:11:37 rlk
|
||||
* Rationalize variables, pass 3
|
||||
*
|
||||
* Revision 1.31 1999/11/23 01:33:37 rlk
|
||||
* First stage of simplifying the variable stuff
|
||||
*
|
||||
* Revision 1.30 1999/11/16 00:59:00 rlk
|
||||
* More fine tuning
|
||||
*
|
||||
* Revision 1.29 1999/11/14 21:37:13 rlk
|
||||
* Revamped contrast
|
||||
*
|
||||
* Revision 1.28 1999/11/14 18:59:22 rlk
|
||||
* Final preparations for release to Olof
|
||||
*
|
||||
* Revision 1.27 1999/11/14 00:57:11 rlk
|
||||
* Mix black in sooner gives better density.
|
||||
*
|
||||
* Revision 1.26 1999/11/13 02:31:29 rlk
|
||||
* Finally! Good settings!
|
||||
*
|
||||
* Revision 1.25 1999/11/12 03:34:40 rlk
|
||||
* More tweaking
|
||||
*
|
||||
* Revision 1.24 1999/11/12 02:18:32 rlk
|
||||
* Stubs for dynamic memory allocation
|
||||
*
|
||||
* Revision 1.23 1999/11/12 01:53:37 rlk
|
||||
* Remove silly spurious stuff
|
||||
*
|
||||
* Revision 1.22 1999/11/12 01:51:47 rlk
|
||||
* Much better black
|
||||
*
|
||||
* Revision 1.21 1999/11/10 01:13:06 rlk
|
||||
* Support up to 2880 dpi
|
||||
*
|
||||
* Revision 1.20 1999/11/07 22:16:42 rlk
|
||||
* Bug fixes; try to improve dithering slightly
|
||||
*
|
||||
* Revision 1.19 1999/10/29 01:01:16 rlk
|
||||
* Smoother rendering of darker colors
|
||||
*
|
||||
* Revision 1.18 1999/10/28 02:01:15 rlk
|
||||
* One bug, two effects:
|
||||
*
|
||||
* 1) Handle 4-color correctly (it was treating the 4-color too much like the
|
||||
* 6-color).
|
||||
*
|
||||
* 2) An attempt to handle both cases with the same code path led to a
|
||||
* discontinuity that depending upon the orientation of a color gradient would
|
||||
* lead to either white or dark lines at the point that the dark version of
|
||||
* the color would kick in.
|
||||
*
|
||||
* Revision 1.17 1999/10/26 23:58:31 rlk
|
||||
* indentation
|
||||
*
|
||||
* Revision 1.16 1999/10/26 23:36:51 rlk
|
||||
* Comment out all remaining 16-bit code, and rename 16-bit functions to "standard" names
|
||||
*
|
||||
* Revision 1.15 1999/10/26 02:10:30 rlk
|
||||
* Mostly fix save/load
|
||||
*
|
||||
* Move all gimp, glib, gtk stuff into print.c (take it out of everything else).
|
||||
* This should help port it to more general purposes later.
|
||||
*
|
||||
* Revision 1.14 1999/10/25 23:31:59 rlk
|
||||
* 16-bit clean
|
||||
*
|
||||
* Revision 1.13 1999/10/25 00:14:46 rlk
|
||||
* Remove more of the 8-bit code, now that it is tested
|
||||
*
|
||||
* Revision 1.12 1999/10/23 20:26:48 rlk
|
||||
* Move LUT calculation to print-util
|
||||
*
|
||||
* Revision 1.11 1999/10/21 01:27:37 rlk
|
||||
* More progress toward full 16-bit rendering
|
||||
*
|
||||
* Revision 1.10 1999/10/19 02:04:59 rlk
|
||||
* Merge all of the single-level print_cmyk functions
|
||||
*
|
||||
* Revision 1.9 1999/10/18 01:37:02 rlk
|
||||
* Remove spurious stuff
|
||||
*
|
||||
* Revision 1.8 1999/10/17 23:44:07 rlk
|
||||
* 16-bit everything (untested)
|
||||
*
|
||||
* Revision 1.7 1999/10/17 23:01:01 rlk
|
||||
* Move various dither functions into print-utils.c
|
||||
*
|
||||
* Revision 1.6 1999/10/14 01:59:59 rlk
|
||||
* Saturation
|
||||
*
|
||||
* Revision 1.5 1999/10/03 23:57:20 rlk
|
||||
* Various improvements
|
||||
*
|
||||
* Revision 1.4 1999/09/18 15:18:47 rlk
|
||||
* A bit more random
|
||||
*
|
||||
* Revision 1.3 1999/09/14 21:43:43 rlk
|
||||
* Some hoped-for improvements
|
||||
*
|
||||
* Revision 1.2 1999/09/12 00:12:24 rlk
|
||||
* Current best stuff
|
||||
*
|
||||
* Revision 1.10 1998/05/17 07:16:49 yosh
|
||||
* 0.99.31 fun
|
||||
*
|
||||
* updated print plugin
|
||||
*
|
||||
* -Yosh
|
||||
*
|
||||
* Revision 1.14 1998/05/16 18:27:59 mike
|
||||
* Cleaned up dithering functions - unnecessary extra data in dither buffer.
|
||||
*
|
||||
* Revision 1.13 1998/05/13 17:00:36 mike
|
||||
* Minor change to CMYK generation code - now cube black difference value
|
||||
* for better colors.
|
||||
*
|
||||
* Revision 1.12 1998/05/08 19:20:50 mike
|
||||
* Updated CMYK generation code to use new method.
|
||||
* Updated dithering algorithm (slightly more uniform now, less speckling)
|
||||
* Added default media size function.
|
||||
*
|
||||
* Revision 1.11 1998/03/01 18:03:27 mike
|
||||
* Whoops - need to add 255 - alpha to the output values (transparent to white
|
||||
* and not transparent to black...)
|
||||
*
|
||||
* Revision 1.10 1998/03/01 17:20:48 mike
|
||||
* Updated alpha code to do alpha computation before gamma/brightness lut.
|
||||
*
|
||||
* Revision 1.9 1998/03/01 17:13:46 mike
|
||||
* Updated CMY/CMYK conversion code for dynamic BG and hue adjustment.
|
||||
* Added alpha channel support to color conversion functions.
|
||||
*
|
||||
* Revision 1.8 1998/01/21 21:33:47 mike
|
||||
* Replaced Burkes dither with stochastic (random) dither.
|
||||
*
|
||||
* Revision 1.7 1997/10/02 17:57:26 mike
|
||||
* Replaced ordered dither with Burkes dither (error-diffusion).
|
||||
* Now dither K separate from CMY.
|
||||
*
|
||||
* Revision 1.6 1997/07/30 20:33:05 mike
|
||||
* Final changes for 1.1 release.
|
||||
*
|
||||
* Revision 1.5 1997/07/26 18:43:04 mike
|
||||
* Fixed dither_black and dither_cmyk - wasn't clearing extra bits
|
||||
* (caused problems with A3/A4 size output).
|
||||
*
|
||||
* Revision 1.5 1997/07/26 18:43:04 mike
|
||||
* Fixed dither_black and dither_cmyk - wasn't clearing extra bits
|
||||
* (caused problems with A3/A4 size output).
|
||||
*
|
||||
* Revision 1.4 1997/07/02 18:46:26 mike
|
||||
* Fixed stupid bug in dither_black() - wasn't comparing against gray
|
||||
* pixels (comparing against the first black byte - d'oh!)
|
||||
* Changed 255 in dither matrix to 254 to shade correctly.
|
||||
*
|
||||
* Revision 1.4 1997/07/02 18:46:26 mike
|
||||
* Fixed stupid bug in dither_black() - wasn't comparing against gray
|
||||
* pixels (comparing against the first black byte - d'oh!)
|
||||
* Changed 255 in dither matrix to 254 to shade correctly.
|
||||
*
|
||||
* Revision 1.3 1997/07/02 13:51:53 mike
|
||||
* Added rgb_to_rgb and gray_to_gray conversion functions.
|
||||
* Standardized calling args to conversion functions.
|
||||
*
|
||||
* Revision 1.2 1997/07/01 19:28:44 mike
|
||||
* Updated dither matrix.
|
||||
* Fixed scaling bugs in dither_*() functions.
|
||||
*
|
||||
* Revision 1.1 1997/06/19 02:18:15 mike
|
||||
* Initial revision
|
||||
* See ChangeLog
|
||||
*/
|
||||
|
||||
/* #define PRINT_DEBUG */
|
||||
|
@ -1442,154 +1208,6 @@ dither_cmyk4(unsigned short *rgb, /* I - RGB pixels */
|
|||
}
|
||||
}
|
||||
|
||||
/* rgb/hsv conversions taken from Gimp common/autostretch_hsv.c */
|
||||
|
||||
|
||||
static void
|
||||
calc_rgb_to_hsv(unsigned short *rgb, double *hue, double *sat, double *val)
|
||||
{
|
||||
double red, green, blue;
|
||||
double h, s, v;
|
||||
double min, max;
|
||||
double delta;
|
||||
|
||||
red = rgb[0] / 65535.0;
|
||||
green = rgb[1] / 65535.0;
|
||||
blue = rgb[2] / 65535.0;
|
||||
|
||||
h = 0.0; /* Shut up -Wall */
|
||||
|
||||
if (red > green)
|
||||
{
|
||||
if (red > blue)
|
||||
max = red;
|
||||
else
|
||||
max = blue;
|
||||
|
||||
if (green < blue)
|
||||
min = green;
|
||||
else
|
||||
min = blue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (green > blue)
|
||||
max = green;
|
||||
else
|
||||
max = blue;
|
||||
|
||||
if (red < blue)
|
||||
min = red;
|
||||
else
|
||||
min = blue;
|
||||
}
|
||||
|
||||
v = max;
|
||||
|
||||
if (max != 0.0)
|
||||
s = (max - min) / max;
|
||||
else
|
||||
s = 0.0;
|
||||
|
||||
if (s == 0.0)
|
||||
h = 0.0;
|
||||
else
|
||||
{
|
||||
delta = max - min;
|
||||
|
||||
if (red == max)
|
||||
h = (green - blue) / delta;
|
||||
else if (green == max)
|
||||
h = 2 + (blue - red) / delta;
|
||||
else if (blue == max)
|
||||
h = 4 + (red - green) / delta;
|
||||
|
||||
h /= 6.0;
|
||||
|
||||
if (h < 0.0)
|
||||
h += 1.0;
|
||||
else if (h > 1.0)
|
||||
h -= 1.0;
|
||||
}
|
||||
|
||||
*hue = h;
|
||||
*sat = s;
|
||||
*val = v;
|
||||
}
|
||||
|
||||
static void
|
||||
calc_hsv_to_rgb(unsigned short *rgb, double h, double s, double v)
|
||||
{
|
||||
double hue, saturation, value;
|
||||
double f, p, q, t;
|
||||
|
||||
if (s == 0.0)
|
||||
{
|
||||
h = v;
|
||||
s = v;
|
||||
v = v; /* heh */
|
||||
}
|
||||
else
|
||||
{
|
||||
hue = h * 6.0;
|
||||
saturation = s;
|
||||
value = v;
|
||||
|
||||
if (hue == 6.0)
|
||||
hue = 0.0;
|
||||
|
||||
f = hue - (int) hue;
|
||||
p = value * (1.0 - saturation);
|
||||
q = value * (1.0 - saturation * f);
|
||||
t = value * (1.0 - saturation * (1.0 - f));
|
||||
|
||||
switch ((int) hue)
|
||||
{
|
||||
case 0:
|
||||
h = value;
|
||||
s = t;
|
||||
v = p;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
h = q;
|
||||
s = value;
|
||||
v = p;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
h = p;
|
||||
s = value;
|
||||
v = t;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
h = p;
|
||||
s = q;
|
||||
v = value;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
h = t;
|
||||
s = p;
|
||||
v = value;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
h = value;
|
||||
s = p;
|
||||
v = q;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
rgb[0] = h*65535;
|
||||
rgb[1] = s*65535;
|
||||
rgb[2] = v*65535;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 'gray_to_gray()' - Convert grayscale image data to grayscale (brightness
|
||||
* adjusted).
|
||||
|
@ -1717,9 +1335,9 @@ indexed_to_rgb(unsigned char *indexed, /* I - Indexed pixels */
|
|||
rgb[2] = lut->blue[cmap[*indexed * 3 + 2]];
|
||||
if (vars->saturation != 1.0)
|
||||
{
|
||||
calc_rgb_to_hsv(rgb, &h, &s, &v);
|
||||
gimp_rgb_to_hsv4 (rgb, &h, &s, &v);
|
||||
s = pow(s, 1.0 / vars->saturation);
|
||||
calc_hsv_to_rgb(rgb, h, s, v);
|
||||
gimp_hsv_to_rgb (rgb, h, s, v);
|
||||
}
|
||||
rgb += 3;
|
||||
indexed ++;
|
||||
|
@ -1743,9 +1361,9 @@ indexed_to_rgb(unsigned char *indexed, /* I - Indexed pixels */
|
|||
255 - indexed[1]];
|
||||
if (vars->saturation != 1.0)
|
||||
{
|
||||
calc_rgb_to_hsv(rgb, &h, &s, &v);
|
||||
gimp_rgb_to_hsv4 (rgb, &h, &s, &v);
|
||||
s = pow(s, 1.0 / vars->saturation);
|
||||
calc_hsv_to_rgb(rgb, h, s, v);
|
||||
gimp_hsv_to_rgb4 (rgb, h, s, v);
|
||||
}
|
||||
rgb += 3;
|
||||
indexed += bpp;
|
||||
|
@ -1833,7 +1451,7 @@ rgb_to_rgb(unsigned char *rgbin, /* I - RGB pixels */
|
|||
rgbout[2] = lut->blue[rgbin[2]];
|
||||
if (vars->saturation != 1.0 || vars->contrast != 100)
|
||||
{
|
||||
calc_rgb_to_hsv(rgbout, &h, &s, &v);
|
||||
gimp_rgb_to_hsv4 (rgbout, &h, &s, &v);
|
||||
if (vars->saturation != 1.0)
|
||||
s = pow(s, 1.0 / vars->saturation);
|
||||
#if 0
|
||||
|
@ -1847,7 +1465,7 @@ rgb_to_rgb(unsigned char *rgbin, /* I - RGB pixels */
|
|||
v = (tv / 2.0) + .5;
|
||||
}
|
||||
#endif
|
||||
calc_hsv_to_rgb(rgbout, h, s, v);
|
||||
gimp_hsv_to_rgb4 (rgbout, h, s, v);
|
||||
}
|
||||
if (vars->density != 1.0)
|
||||
{
|
||||
|
@ -1882,7 +1500,7 @@ rgb_to_rgb(unsigned char *rgbin, /* I - RGB pixels */
|
|||
if (vars->saturation != 1.0 || vars->contrast != 100 ||
|
||||
vars->density != 1.0)
|
||||
{
|
||||
calc_rgb_to_hsv(rgbout, &h, &s, &v);
|
||||
gimp_rgb_to_hsv4 (rgbout, &h, &s, &v);
|
||||
if (vars->saturation != 1.0)
|
||||
s = pow(s, 1.0 / vars->saturation);
|
||||
#if 0
|
||||
|
@ -1896,7 +1514,7 @@ rgb_to_rgb(unsigned char *rgbin, /* I - RGB pixels */
|
|||
v = (tv / 2.0) + .5;
|
||||
}
|
||||
#endif
|
||||
calc_hsv_to_rgb(rgbout, h, s, v);
|
||||
gimp_hsv_to_rgb4 (rgbout, h, s, v);
|
||||
}
|
||||
if (vars->density != 1.0)
|
||||
{
|
||||
|
|
|
@ -134,17 +134,18 @@ rcm_row (const guchar *src_row,
|
|||
gint bytes)
|
||||
{
|
||||
gint col, bytenum, skip;
|
||||
hsv H,S,V,R,G,B;
|
||||
gdouble H,S,V;
|
||||
guchar rgb[3];
|
||||
|
||||
for (col=0; col < row_width; col++)
|
||||
{
|
||||
skip = 0;
|
||||
|
||||
R = (float)src_row[col*bytes + 0]/255.0;
|
||||
G = (float)src_row[col*bytes + 1]/255.0;
|
||||
B = (float)src_row[col*bytes + 2]/255.0;
|
||||
rgb[0] = src_row[col*bytes + 0];
|
||||
rgb[1] = src_row[col*bytes + 1];
|
||||
rgb[2] = src_row[col*bytes + 2];
|
||||
|
||||
rgb_to_hsv(R,G,B, &H,&S,&V);
|
||||
gimp_rgb_to_hsv4 (rgb, &H, &S, &V);
|
||||
|
||||
if (rcm_is_gray(S))
|
||||
{
|
||||
|
@ -163,7 +164,7 @@ rcm_row (const guchar *src_row,
|
|||
else
|
||||
{
|
||||
skip = 1;
|
||||
hsv_to_rgb(Current.Gray->hue/TP, Current.Gray->satur, V, &R, &G, &B);
|
||||
gimp_hsv_to_rgb4 (rgb, Current.Gray->hue/TP, Current.Gray->satur, V);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,12 +177,12 @@ rcm_row (const guchar *src_row,
|
|||
H*TP);
|
||||
|
||||
H = angle_mod_2PI(H) / TP;
|
||||
hsv_to_rgb(H,S,V, &R,&G,&B);
|
||||
gimp_hsv_to_rgb4 (rgb, H, S, V);
|
||||
}
|
||||
|
||||
dest_row[col*bytes +0] = R * 255;
|
||||
dest_row[col*bytes +1] = G * 255;
|
||||
dest_row[col*bytes +2] = B * 255;
|
||||
dest_row[col * bytes + 0] = rgb[0];
|
||||
dest_row[col * bytes + 1] = rgb[1];
|
||||
dest_row[col * bytes + 2] = rgb[2];
|
||||
|
||||
if (bytes > 3)
|
||||
{
|
||||
|
|
|
@ -40,11 +40,7 @@
|
|||
/* Global defines */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef PI
|
||||
#define PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
#define TP (2*PI)
|
||||
#define TP (2*G_PI)
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/* Typedefs */
|
||||
|
@ -57,8 +53,6 @@ enum { EACH, BOTH, DEGREES, RADIANS, RADIANS_OVER_PI,
|
|||
|
||||
typedef enum { VIRGIN, DRAG_START, DRAGING, DO_NOTHING } RcmOp;
|
||||
|
||||
typedef double hsv;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float alpha;
|
||||
|
@ -71,7 +65,7 @@ typedef struct
|
|||
gint width;
|
||||
gint height;
|
||||
guchar *rgb;
|
||||
hsv *hsv;
|
||||
gdouble *hsv;
|
||||
guchar *mask;
|
||||
} ReducedImage;
|
||||
|
||||
|
|
|
@ -56,18 +56,20 @@
|
|||
/* Misc functions */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
float rcm_units_factor(gint units)
|
||||
float
|
||||
rcm_units_factor (gint units)
|
||||
{
|
||||
switch (units)
|
||||
{
|
||||
case DEGREES: return 180.0/PI;
|
||||
case DEGREES: return 180.0 / G_PI;
|
||||
case RADIANS: return 1.0;
|
||||
case RADIANS_OVER_PI: return 1.0/PI;
|
||||
case RADIANS_OVER_PI: return 1.0 / G_PI;
|
||||
default: return -1;
|
||||
}
|
||||
}
|
||||
|
||||
gchar *rcm_units_string(gint units)
|
||||
gchar *
|
||||
rcm_units_string (gint units)
|
||||
{
|
||||
switch (units)
|
||||
{
|
||||
|
@ -78,8 +80,11 @@ gchar *rcm_units_string(gint units)
|
|||
}
|
||||
}
|
||||
|
||||
void rcm_set_pixmap(GtkWidget **widget, GtkWidget *parent,
|
||||
GtkWidget *label_box, char **pixmap_data)
|
||||
void
|
||||
rcm_set_pixmap (GtkWidget **widget,
|
||||
GtkWidget *parent,
|
||||
GtkWidget *label_box,
|
||||
char **pixmap_data)
|
||||
{
|
||||
GdkPixmap *pixmap;
|
||||
GdkBitmap *mask;
|
||||
|
@ -107,7 +112,8 @@ void rcm_set_pixmap(GtkWidget **widget, GtkWidget *parent,
|
|||
/* Ok Button */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
void rcm_ok_callback (GtkWidget *widget,
|
||||
void
|
||||
rcm_ok_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
Current.Success = 1;
|
||||
|
@ -119,7 +125,9 @@ void rcm_ok_callback (GtkWidget *widget,
|
|||
/* Circle buttons */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
void rcm_360_degrees(GtkWidget *button, RcmCircle *circle)
|
||||
void
|
||||
rcm_360_degrees (GtkWidget *button,
|
||||
RcmCircle *circle)
|
||||
{
|
||||
circle->action_flag = DO_NOTHING;
|
||||
gtk_widget_draw(circle->preview, NULL);
|
||||
|
@ -129,7 +137,9 @@ void rcm_360_degrees(GtkWidget *button, RcmCircle *circle)
|
|||
rcm_render_preview(Current.Bna->after, CURRENT);
|
||||
}
|
||||
|
||||
void rcm_cw_ccw(GtkWidget *button, RcmCircle *circle)
|
||||
void
|
||||
rcm_cw_ccw (GtkWidget *button,
|
||||
RcmCircle *circle)
|
||||
{
|
||||
circle->angle->cw_ccw *= -1;
|
||||
|
||||
|
@ -142,7 +152,9 @@ void rcm_cw_ccw(GtkWidget *button, RcmCircle *circle)
|
|||
rcm_a_to_b(button, circle);
|
||||
}
|
||||
|
||||
void rcm_a_to_b(GtkWidget *button, RcmCircle *circle)
|
||||
void
|
||||
rcm_a_to_b (GtkWidget *button,
|
||||
RcmCircle *circle)
|
||||
{
|
||||
circle->action_flag = DO_NOTHING;
|
||||
gtk_widget_draw(circle->preview, NULL);
|
||||
|
@ -160,7 +172,10 @@ void rcm_a_to_b(GtkWidget *button, RcmCircle *circle)
|
|||
/* Misc: units buttons */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static void rcm_spinbutton_to_degrees(GtkWidget *button, float value, GtkWidget *label)
|
||||
static void
|
||||
rcm_spinbutton_to_degrees (GtkWidget *button,
|
||||
float value,
|
||||
GtkWidget *label)
|
||||
{
|
||||
GtkAdjustment *adj;
|
||||
|
||||
|
@ -174,7 +189,9 @@ static void rcm_spinbutton_to_degrees(GtkWidget *button, float value, GtkWidget
|
|||
gtk_label_set(GTK_LABEL(label), rcm_units_string(Current.Units));
|
||||
}
|
||||
|
||||
void rcm_switch_to_degrees(GtkWidget *button, gpointer *value)
|
||||
void
|
||||
rcm_switch_to_degrees (GtkWidget *button,
|
||||
gpointer *value)
|
||||
{
|
||||
if (GTK_TOGGLE_BUTTON(button)->active)
|
||||
{
|
||||
|
@ -208,7 +225,10 @@ void rcm_switch_to_degrees(GtkWidget *button, gpointer *value)
|
|||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static void rcm_spinbutton_to_radians(GtkWidget *button, float value, GtkWidget *label)
|
||||
static void
|
||||
rcm_spinbutton_to_radians (GtkWidget *button,
|
||||
float value,
|
||||
GtkWidget *label)
|
||||
{
|
||||
GtkAdjustment *adj;
|
||||
|
||||
|
@ -222,7 +242,9 @@ static void rcm_spinbutton_to_radians(GtkWidget *button, float value, GtkWidget
|
|||
gtk_label_set(GTK_LABEL(label), rcm_units_string(Current.Units));
|
||||
}
|
||||
|
||||
void rcm_switch_to_radians(GtkWidget *button, gpointer *value)
|
||||
void
|
||||
rcm_switch_to_radians (GtkWidget *button,
|
||||
gpointer *value)
|
||||
{
|
||||
if (GTK_TOGGLE_BUTTON(button)->active)
|
||||
{
|
||||
|
@ -256,7 +278,10 @@ void rcm_switch_to_radians(GtkWidget *button, gpointer *value)
|
|||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static void rcm_spinbutton_to_radians_over_PI(GtkWidget *button, float value, GtkWidget *label)
|
||||
static void
|
||||
rcm_spinbutton_to_radians_over_PI (GtkWidget *button,
|
||||
float value,
|
||||
GtkWidget *label)
|
||||
{
|
||||
GtkAdjustment *adj;
|
||||
|
||||
|
@ -270,7 +295,9 @@ static void rcm_spinbutton_to_radians_over_PI(GtkWidget *button, float value, Gt
|
|||
gtk_label_set(GTK_LABEL(label), rcm_units_string(Current.Units));
|
||||
}
|
||||
|
||||
void rcm_switch_to_radians_over_PI(GtkWidget *button, gpointer *value)
|
||||
void
|
||||
rcm_switch_to_radians_over_PI (GtkWidget *button,
|
||||
gpointer *value)
|
||||
{
|
||||
if (GTK_TOGGLE_BUTTON(button)->active)
|
||||
{
|
||||
|
@ -306,7 +333,9 @@ void rcm_switch_to_radians_over_PI(GtkWidget *button, gpointer *value)
|
|||
/* Misc: Gray: mode buttons */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
void rcm_switch_to_gray_to(GtkWidget *button, gpointer *value)
|
||||
void
|
||||
rcm_switch_to_gray_to (GtkWidget *button,
|
||||
gpointer *value)
|
||||
{
|
||||
if (!GTK_TOGGLE_BUTTON(button)->active) return;
|
||||
|
||||
|
@ -314,7 +343,9 @@ void rcm_switch_to_gray_to(GtkWidget *button, gpointer *value)
|
|||
rcm_render_preview(Current.Bna->after, CURRENT);
|
||||
}
|
||||
|
||||
void rcm_switch_to_gray_from(GtkWidget *button, gpointer *value)
|
||||
void
|
||||
rcm_switch_to_gray_from (GtkWidget *button,
|
||||
gpointer *value)
|
||||
{
|
||||
if (!(GTK_TOGGLE_BUTTON(button)->active)) return;
|
||||
|
||||
|
@ -326,7 +357,9 @@ void rcm_switch_to_gray_from(GtkWidget *button, gpointer *value)
|
|||
/* Misc: Preview buttons */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
void rcm_preview_as_you_drag(GtkWidget *button, gpointer *value)
|
||||
void
|
||||
rcm_preview_as_you_drag (GtkWidget *button,
|
||||
gpointer *value)
|
||||
{
|
||||
if (GTK_TOGGLE_BUTTON(button)->active)
|
||||
Current.RealTime = TRUE;
|
||||
|
@ -336,7 +369,8 @@ void rcm_preview_as_you_drag(GtkWidget *button, gpointer *value)
|
|||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static void rcm_change_preview(void)
|
||||
static void
|
||||
rcm_change_preview (void)
|
||||
{
|
||||
/* must hide and show or resize would not work ... */
|
||||
|
||||
|
@ -361,21 +395,27 @@ static void rcm_change_preview(void)
|
|||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
void rcm_selection_in_context(GtkWidget *button, gpointer *value)
|
||||
void
|
||||
rcm_selection_in_context (GtkWidget *button,
|
||||
gpointer *value)
|
||||
{
|
||||
Current.reduced = rcm_reduce_image(Current.drawable, Current.mask,
|
||||
MAX_PREVIEW_SIZE, SELECTION_IN_CONTEXT);
|
||||
rcm_change_preview();
|
||||
}
|
||||
|
||||
void rcm_selection(GtkWidget *button, gpointer *value)
|
||||
void
|
||||
rcm_selection (GtkWidget *button,
|
||||
gpointer *value)
|
||||
{
|
||||
Current.reduced = rcm_reduce_image(Current.drawable, Current.mask,
|
||||
MAX_PREVIEW_SIZE, SELECTION);
|
||||
rcm_change_preview();
|
||||
}
|
||||
|
||||
void rcm_entire_image(GtkWidget *button, gpointer *value)
|
||||
void
|
||||
rcm_entire_image (GtkWidget *button,
|
||||
gpointer *value)
|
||||
{
|
||||
Current.reduced = rcm_reduce_image(Current.drawable, Current.mask,
|
||||
MAX_PREVIEW_SIZE, ENTIRE_IMAGE);
|
||||
|
@ -387,7 +427,10 @@ void rcm_entire_image(GtkWidget *button, gpointer *value)
|
|||
/* Circle events */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
gint rcm_expose_event(GtkWidget *widget, GdkEvent *event, RcmCircle *circle)
|
||||
gint
|
||||
rcm_expose_event (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
RcmCircle *circle)
|
||||
{
|
||||
switch (circle->action_flag)
|
||||
{
|
||||
|
@ -406,7 +449,10 @@ gint rcm_expose_event(GtkWidget *widget, GdkEvent *event, RcmCircle *circle)
|
|||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
gint rcm_button_press_event(GtkWidget *widget, GdkEvent *event, RcmCircle *circle)
|
||||
gint
|
||||
rcm_button_press_event (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
RcmCircle *circle)
|
||||
{
|
||||
float clicked_angle;
|
||||
float *alpha;
|
||||
|
@ -421,8 +467,8 @@ gint rcm_button_press_event(GtkWidget *widget, GdkEvent *event, RcmCircle *circl
|
|||
clicked_angle = angle_mod_2PI(arctg(CENTER-bevent->y, bevent->x-CENTER));
|
||||
circle->prev_clicked = clicked_angle;
|
||||
|
||||
if ( (sqrt(sqr(bevent->y-CENTER) + sqr(bevent->x-CENTER)) > RADIUS * EACH_OR_BOTH) &&
|
||||
(min_prox( *alpha, *beta, clicked_angle) < PI/12) )
|
||||
if ((sqrt (SQR (bevent->y-CENTER) + SQR (bevent->x-CENTER)) > RADIUS * EACH_OR_BOTH) &&
|
||||
(min_prox (*alpha, *beta, clicked_angle) < G_PI / 12))
|
||||
{
|
||||
circle->mode = EACH;
|
||||
circle->target = closest(alpha, beta, clicked_angle);
|
||||
|
@ -451,7 +497,10 @@ gint rcm_button_press_event(GtkWidget *widget, GdkEvent *event, RcmCircle *circl
|
|||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
gint rcm_release_event(GtkWidget *widget, GdkEvent *event, RcmCircle *circle)
|
||||
gint
|
||||
rcm_release_event (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
RcmCircle *circle)
|
||||
{
|
||||
if (circle->action_flag == DRAGING)
|
||||
rcm_draw_arrows(widget->window, widget->style->black_gc, circle->angle);
|
||||
|
@ -465,7 +514,10 @@ gint rcm_release_event(GtkWidget *widget, GdkEvent *event, RcmCircle *circle)
|
|||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
gint rcm_motion_notify_event(GtkWidget *widget, GdkEvent *event, RcmCircle *circle)
|
||||
gint
|
||||
rcm_motion_notify_event (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
RcmCircle *circle)
|
||||
{
|
||||
gint x, y;
|
||||
float clicked_angle, delta;
|
||||
|
@ -525,7 +577,9 @@ gint rcm_motion_notify_event(GtkWidget *widget, GdkEvent *event, RcmCircle *circ
|
|||
/* Gray circle events */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
gint rcm_gray_expose_event(GtkWidget *widget, GdkEvent *event, RcmGray *circle)
|
||||
gint rcm_gray_expose_event (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
RcmGray *circle)
|
||||
{
|
||||
if (circle->action_flag == VIRGIN)
|
||||
{
|
||||
|
@ -542,7 +596,10 @@ gint rcm_gray_expose_event(GtkWidget *widget, GdkEvent *event, RcmGray *circle)
|
|||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
gint rcm_gray_button_press_event(GtkWidget *widget, GdkEvent *event, RcmGray *circle)
|
||||
gint
|
||||
rcm_gray_button_press_event (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
RcmGray *circle)
|
||||
{
|
||||
GdkEventButton *bevent;
|
||||
int x, y;
|
||||
|
@ -553,7 +610,7 @@ gint rcm_gray_button_press_event(GtkWidget *widget, GdkEvent *event, RcmGray *ci
|
|||
|
||||
circle->action_flag = DRAG_START;
|
||||
circle->hue = angle_mod_2PI(arctg(y, x));
|
||||
circle->satur = sqrt(sqr(x)+sqr(y)) / GRAY_RADIUS;
|
||||
circle->satur = sqrt (SQR (x) + SQR (y)) / GRAY_RADIUS;
|
||||
if (circle->satur > 1.0) circle->satur = 1;
|
||||
|
||||
gtk_widget_draw(circle->preview, NULL);
|
||||
|
@ -576,7 +633,10 @@ gint rcm_gray_button_press_event(GtkWidget *widget, GdkEvent *event, RcmGray *ci
|
|||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
gint rcm_gray_release_event(GtkWidget *widget, GdkEvent *event, RcmGray *circle)
|
||||
gint
|
||||
rcm_gray_release_event (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
RcmGray *circle)
|
||||
{
|
||||
if (circle->action_flag == DRAGING)
|
||||
rcm_draw_little_circle(widget->window,
|
||||
|
@ -593,7 +653,10 @@ gint rcm_gray_release_event(GtkWidget *widget, GdkEvent *event, RcmGray *circle)
|
|||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
gint rcm_gray_motion_notify_event(GtkWidget *widget, GdkEvent *event, RcmGray *circle)
|
||||
gint
|
||||
rcm_gray_motion_notify_event (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
RcmGray *circle)
|
||||
{
|
||||
gint x, y;
|
||||
GdkGCValues values;
|
||||
|
@ -621,7 +684,7 @@ gint rcm_gray_motion_notify_event(GtkWidget *widget, GdkEvent *event, RcmGray *c
|
|||
y = GRAY_CENTER - y + LITTLE_RADIUS;
|
||||
|
||||
circle->hue = angle_mod_2PI (arctg (y, x));
|
||||
circle->satur = sqrt(sqr(x) + sqr(y)) / GRAY_RADIUS;
|
||||
circle->satur = sqrt (SQR (x) + SQR (y)) / GRAY_RADIUS;
|
||||
if (circle->satur > 1.0) circle->satur = 1;
|
||||
|
||||
rcm_draw_little_circle(widget->window, xor_gc, circle->hue, circle->satur);
|
||||
|
@ -640,7 +703,9 @@ gint rcm_gray_motion_notify_event(GtkWidget *widget, GdkEvent *event, RcmGray *c
|
|||
/* Spinbuttons */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
void rcm_set_alpha(GtkWidget *entry, gpointer data)
|
||||
void
|
||||
rcm_set_alpha (GtkWidget *entry,
|
||||
gpointer data)
|
||||
{
|
||||
RcmCircle *circle;
|
||||
|
||||
|
@ -660,7 +725,9 @@ void rcm_set_alpha(GtkWidget *entry, gpointer data)
|
|||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
void rcm_set_beta(GtkWidget *entry, gpointer data)
|
||||
void
|
||||
rcm_set_beta (GtkWidget *entry,
|
||||
gpointer data)
|
||||
{
|
||||
RcmCircle *circle;
|
||||
|
||||
|
@ -680,7 +747,9 @@ void rcm_set_beta(GtkWidget *entry, gpointer data)
|
|||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
void rcm_set_hue(GtkWidget *entry, gpointer data)
|
||||
void
|
||||
rcm_set_hue (GtkWidget *entry,
|
||||
gpointer data)
|
||||
{
|
||||
RcmGray *circle;
|
||||
|
||||
|
@ -703,7 +772,9 @@ void rcm_set_hue(GtkWidget *entry, gpointer data)
|
|||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
void rcm_set_satur(GtkWidget *entry, gpointer data)
|
||||
void
|
||||
rcm_set_satur (GtkWidget *entry,
|
||||
gpointer data)
|
||||
{
|
||||
RcmGray *circle;
|
||||
|
||||
|
@ -724,7 +795,9 @@ void rcm_set_satur(GtkWidget *entry, gpointer data)
|
|||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
void rcm_set_gray_sat(GtkWidget *entry, gpointer data)
|
||||
void
|
||||
rcm_set_gray_sat (GtkWidget *entry,
|
||||
gpointer data)
|
||||
{
|
||||
RcmGray *circle;
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
#define INITIAL_ALPHA 0
|
||||
#define INITIAL_BETA (PI/2.0)
|
||||
#define INITIAL_BETA G_PI_2
|
||||
#define INITIAL_GRAY_SAT 0.0
|
||||
#define INITIAL_GRAY_RSAT 0.0
|
||||
#define INITIAL_GRAY_HUE 0.0
|
||||
|
|
|
@ -54,20 +54,16 @@
|
|||
|
||||
GdkGC *xor_gc;
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/* Misc functions */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
inline int R(float X)
|
||||
{
|
||||
return X + 0.5;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/* Drawing routines */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void rcm_draw_little_circle(GdkWindow *window, GdkGC *color, float hue, float satur)
|
||||
void
|
||||
rcm_draw_little_circle (GdkWindow *window,
|
||||
GdkGC *color,
|
||||
float hue,
|
||||
float satur)
|
||||
{
|
||||
int x,y;
|
||||
|
||||
|
@ -80,7 +76,10 @@ void rcm_draw_little_circle(GdkWindow *window, GdkGC *color, float hue, float sa
|
|||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void rcm_draw_large_circle(GdkWindow *window, GdkGC *color, float gray_sat)
|
||||
void
|
||||
rcm_draw_large_circle (GdkWindow *window,
|
||||
GdkGC *color,
|
||||
float gray_sat)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
|
@ -88,10 +87,10 @@ void rcm_draw_large_circle(GdkWindow *window, GdkGC *color, float gray_sat)
|
|||
y = GRAY_CENTER;
|
||||
|
||||
gdk_draw_arc(window, color, 0,
|
||||
R(x - GRAY_RADIUS * gray_sat),
|
||||
R(y - GRAY_RADIUS * gray_sat),
|
||||
R(2 * GRAY_RADIUS * gray_sat),
|
||||
R(2 * GRAY_RADIUS * gray_sat),
|
||||
ROUND (x - GRAY_RADIUS * gray_sat),
|
||||
ROUND (y - GRAY_RADIUS * gray_sat),
|
||||
ROUND (2 * GRAY_RADIUS * gray_sat),
|
||||
ROUND (2 * GRAY_RADIUS * gray_sat),
|
||||
0, 360 * 64);
|
||||
}
|
||||
|
||||
|
@ -101,7 +100,10 @@ void rcm_draw_large_circle(GdkWindow *window, GdkGC *color, float gray_sat)
|
|||
#define DEL .1
|
||||
#define TICK 10
|
||||
|
||||
void rcm_draw_arrows(GdkWindow *window, GdkGC *color, RcmAngle *angle)
|
||||
void
|
||||
rcm_draw_arrows (GdkWindow *window,
|
||||
GdkGC *color,
|
||||
RcmAngle *angle)
|
||||
{
|
||||
int dist;
|
||||
float alpha, beta, cw_ccw, delta;
|
||||
|
@ -115,49 +117,49 @@ void rcm_draw_arrows(GdkWindow *window, GdkGC *color, RcmAngle *angle)
|
|||
gdk_draw_line(window,color,
|
||||
CENTER,
|
||||
CENTER,
|
||||
R(CENTER + RADIUS * cos(alpha)),
|
||||
R(CENTER - RADIUS * sin(alpha)));
|
||||
ROUND (CENTER + RADIUS * cos(alpha)),
|
||||
ROUND (CENTER - RADIUS * sin(alpha)));
|
||||
|
||||
gdk_draw_line(window,color,
|
||||
CENTER + RADIUS * cos(alpha),
|
||||
CENTER - RADIUS * sin(alpha),
|
||||
R(CENTER + RADIUS * REL * cos(alpha - DEL)),
|
||||
R(CENTER - RADIUS * REL * sin(alpha - DEL)));
|
||||
ROUND (CENTER + RADIUS * REL * cos(alpha - DEL)),
|
||||
ROUND (CENTER - RADIUS * REL * sin(alpha - DEL)));
|
||||
|
||||
gdk_draw_line(window,color,
|
||||
CENTER + RADIUS * cos(alpha),
|
||||
CENTER - RADIUS * sin(alpha),
|
||||
R(CENTER + RADIUS * REL * cos(alpha + DEL)),
|
||||
R(CENTER - RADIUS * REL * sin(alpha + DEL)));
|
||||
ROUND (CENTER + RADIUS * REL * cos(alpha + DEL)),
|
||||
ROUND (CENTER - RADIUS * REL * sin(alpha + DEL)));
|
||||
|
||||
gdk_draw_line(window,color,
|
||||
CENTER,
|
||||
CENTER,
|
||||
R(CENTER + RADIUS * cos(beta)),
|
||||
R(CENTER - RADIUS * sin(beta)));
|
||||
ROUND (CENTER + RADIUS * cos(beta)),
|
||||
ROUND (CENTER - RADIUS * sin(beta)));
|
||||
|
||||
gdk_draw_line(window,color,
|
||||
CENTER + RADIUS * cos(beta),
|
||||
CENTER - RADIUS * sin(beta),
|
||||
R(CENTER + RADIUS * REL * cos(beta - DEL)),
|
||||
R(CENTER - RADIUS * REL * sin(beta - DEL)));
|
||||
ROUND (CENTER + RADIUS * REL * cos(beta - DEL)),
|
||||
ROUND (CENTER - RADIUS * REL * sin(beta - DEL)));
|
||||
|
||||
gdk_draw_line(window,color,
|
||||
CENTER + RADIUS * cos(beta),
|
||||
CENTER - RADIUS * sin(beta),
|
||||
R(CENTER + RADIUS * REL * cos(beta + DEL)),
|
||||
R(CENTER - RADIUS * REL * sin(beta + DEL)));
|
||||
ROUND (CENTER + RADIUS * REL * cos(beta + DEL)),
|
||||
ROUND (CENTER - RADIUS * REL * sin(beta + DEL)));
|
||||
|
||||
dist = RADIUS * EACH_OR_BOTH;
|
||||
|
||||
gdk_draw_line(window,color,
|
||||
CENTER + dist * cos(beta),
|
||||
CENTER - dist * sin(beta),
|
||||
R(CENTER + dist * cos(beta) + cw_ccw * TICK * sin(beta)),
|
||||
R(CENTER - dist * sin(beta) + cw_ccw * TICK * cos(beta)));
|
||||
ROUND (CENTER + dist * cos(beta) + cw_ccw * TICK * sin(beta)),
|
||||
ROUND (CENTER - dist * sin(beta) + cw_ccw * TICK * cos(beta)));
|
||||
|
||||
alpha *= 180*64/PI;
|
||||
delta *= 180*64/PI;
|
||||
alpha *= 180 * 64 / G_PI;
|
||||
delta *= 180 * 64 / G_PI;
|
||||
|
||||
gdk_draw_arc(window, color, 0, CENTER - dist, CENTER - dist,
|
||||
2*dist, 2*dist, alpha, delta);
|
||||
|
|
|
@ -49,20 +49,26 @@
|
|||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
float arctg(float y, float x)
|
||||
float
|
||||
arctg (float y,
|
||||
float x)
|
||||
{
|
||||
float temp = atan2(y,x);
|
||||
return (temp<0) ? (temp+TP) : temp;
|
||||
}
|
||||
|
||||
inline float sign(float x)
|
||||
inline
|
||||
float sign (float x)
|
||||
{
|
||||
return (x<0)?(-1):(1);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
float min_prox(float alpha, float beta, float angle)
|
||||
float
|
||||
min_prox (float alpha,
|
||||
float beta,
|
||||
float angle)
|
||||
{
|
||||
gfloat temp1 = MIN(angle_mod_2PI(alpha - angle),
|
||||
TP-angle_mod_2PI(alpha - angle));
|
||||
|
@ -72,7 +78,10 @@ float min_prox(float alpha, float beta, float angle)
|
|||
return MIN(temp1, temp2);
|
||||
}
|
||||
|
||||
float *closest(float *alpha, float *beta, float angle)
|
||||
float*
|
||||
closest (float *alpha,
|
||||
float *beta,
|
||||
float angle)
|
||||
{
|
||||
float temp_alpha = MIN(angle_mod_2PI(*alpha-angle),
|
||||
TP-angle_mod_2PI(*alpha-angle));
|
||||
|
@ -86,7 +95,8 @@ float *closest(float *alpha, float *beta, float angle)
|
|||
return beta;
|
||||
}
|
||||
|
||||
float angle_mod_2PI(float angle)
|
||||
float
|
||||
angle_mod_2PI (float angle)
|
||||
{
|
||||
if (angle < 0)
|
||||
return angle + TP;
|
||||
|
@ -100,7 +110,12 @@ float angle_mod_2PI(float angle)
|
|||
/* supporting routines */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
float rcm_linear(float A, float B, float C, float D, float x)
|
||||
float
|
||||
rcm_linear (float A,
|
||||
float B,
|
||||
float C,
|
||||
float D,
|
||||
float x)
|
||||
{
|
||||
if (B > A)
|
||||
if (A<=x && x<=B)
|
||||
|
@ -118,7 +133,8 @@ float rcm_linear(float A, float B, float C, float D, float x)
|
|||
return x;
|
||||
}
|
||||
|
||||
float rcm_left_end(RcmAngle *angle)
|
||||
float
|
||||
rcm_left_end (RcmAngle *angle)
|
||||
{
|
||||
gfloat alpha = angle->alpha;
|
||||
gfloat beta = angle->beta;
|
||||
|
@ -131,7 +147,8 @@ float rcm_left_end(RcmAngle *angle)
|
|||
}
|
||||
}
|
||||
|
||||
float rcm_right_end(RcmAngle *angle)
|
||||
float
|
||||
rcm_right_end (RcmAngle *angle)
|
||||
{
|
||||
gfloat alpha = angle->alpha;
|
||||
gfloat beta = angle->beta;
|
||||
|
@ -144,13 +161,16 @@ float rcm_right_end(RcmAngle *angle)
|
|||
}
|
||||
}
|
||||
|
||||
float rcm_angle_inside_slice(float angle, RcmAngle *slice)
|
||||
float
|
||||
rcm_angle_inside_slice (float angle,
|
||||
RcmAngle *slice)
|
||||
{
|
||||
return angle_mod_2PI(slice->cw_ccw * (slice->beta-angle)) /
|
||||
angle_mod_2PI(slice->cw_ccw * (slice->beta-slice->alpha));
|
||||
}
|
||||
|
||||
gint rcm_is_gray(float s)
|
||||
gint
|
||||
rcm_is_gray (float s)
|
||||
{
|
||||
if (s <= Current.Gray->gray_sat) return 1;
|
||||
return 0;
|
||||
|
@ -160,7 +180,11 @@ gint rcm_is_gray(float s)
|
|||
/* reduce image/selection for preview */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
ReducedImage *rcm_reduce_image(GDrawable *drawable, GDrawable *mask, gint LongerSize, gint Slctn)
|
||||
ReducedImage*
|
||||
rcm_reduce_image (GDrawable *drawable,
|
||||
GDrawable *mask,
|
||||
gint LongerSize,
|
||||
gint Slctn)
|
||||
{
|
||||
GPixelRgn srcPR, srcMask;
|
||||
ReducedImage *temp;
|
||||
|
@ -168,8 +192,7 @@ ReducedImage *rcm_reduce_image(GDrawable *drawable, GDrawable *mask, gint Longer
|
|||
gint i, j, whichcol, whichrow, x1, x2, y1, y2;
|
||||
gint RH, RW, width, height, bytes;
|
||||
gint NoSelectionMade;
|
||||
hsv *tempHSV, H, S, V;
|
||||
guchar R, G ,B;
|
||||
gdouble *tempHSV, H, S, V;
|
||||
|
||||
bytes = drawable->bpp;
|
||||
temp = g_new (ReducedImage, 1);
|
||||
|
@ -221,15 +244,15 @@ ReducedImage *rcm_reduce_image(GDrawable *drawable, GDrawable *mask, gint Longer
|
|||
|
||||
/* allocate memory */
|
||||
|
||||
tempRGB = (guchar *) malloc(RW * RH * bytes);
|
||||
tempHSV = (hsv *) malloc(RW * RH * bytes * sizeof(hsv));
|
||||
tempmask = (guchar *) malloc(RW * RH);
|
||||
tempRGB = g_new (guchar, RW * RH * bytes);
|
||||
tempHSV = g_new (gdouble, RW * RH * bytes);
|
||||
tempmask = g_new (guchar, RW * RH);
|
||||
|
||||
gimp_pixel_rgn_init(&srcPR, drawable, x1, y1, width, height, FALSE, FALSE);
|
||||
gimp_pixel_rgn_init(&srcMask, mask, x1, y1, width, height, FALSE, FALSE);
|
||||
|
||||
src_row = (guchar *) malloc(width * bytes);
|
||||
src_mask_row = (guchar *) malloc(width * bytes);
|
||||
src_row = g_new (guchar, width * bytes);
|
||||
src_mask_row = g_new (guchar, width * bytes);
|
||||
|
||||
/* reduce image */
|
||||
|
||||
|
@ -248,15 +271,11 @@ ReducedImage *rcm_reduce_image(GDrawable *drawable, GDrawable *mask, gint Longer
|
|||
else
|
||||
tempmask[i*RW+j] = src_mask_row[whichcol];
|
||||
|
||||
R = src_row[whichcol*bytes+0];
|
||||
G = src_row[whichcol*bytes+1];
|
||||
B = src_row[whichcol*bytes+2];
|
||||
gimp_rgb_to_hsv4 (&src_row[whichcol*bytes], &H, &S, &V);
|
||||
|
||||
rgb_to_hsv(R/255.0, G/255.0, B/255.0, &H, &S, &V);
|
||||
|
||||
tempRGB[i*RW*bytes+j*bytes+0] = R;
|
||||
tempRGB[i*RW*bytes+j*bytes+1] = G;
|
||||
tempRGB[i*RW*bytes+j*bytes+2] = B;
|
||||
tempRGB[i*RW*bytes+j*bytes+0] = src_row[whichcol*bytes+0];
|
||||
tempRGB[i*RW*bytes+j*bytes+1] = src_row[whichcol*bytes+1];
|
||||
tempRGB[i*RW*bytes+j*bytes+2] = src_row[whichcol*bytes+2];
|
||||
|
||||
tempHSV[i*RW*bytes+j*bytes+0] = H;
|
||||
tempHSV[i*RW*bytes+j*bytes+1] = S;
|
||||
|
@ -283,19 +302,26 @@ ReducedImage *rcm_reduce_image(GDrawable *drawable, GDrawable *mask, gint Longer
|
|||
/* render before/after preview */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static gint rcm_fake_transparency(gint i, gint j)
|
||||
static gint
|
||||
rcm_fake_transparency (gint i,
|
||||
gint j)
|
||||
{
|
||||
if ( ((i%20)-10)*((j%20)-10) > 0 ) return 102;
|
||||
if ( ((i%20)-10)*((j%20)-10) > 0 )
|
||||
return 102;
|
||||
|
||||
return 153;
|
||||
}
|
||||
|
||||
void rcm_render_preview(GtkWidget *preview, gint version)
|
||||
void
|
||||
rcm_render_preview (GtkWidget *preview,
|
||||
gint version)
|
||||
{
|
||||
ReducedImage *reduced;
|
||||
gint RW, RH, bytes, i, j, k, unchanged, skip;
|
||||
guchar *rgb_array, *a;
|
||||
hsv H, S, V, R, G, B;
|
||||
hsv *hsv_array;
|
||||
gdouble H, S, V;
|
||||
gdouble *hsv_array;
|
||||
guchar rgb[3];
|
||||
float degree, transp;
|
||||
|
||||
/* init some variables */
|
||||
|
@ -307,7 +333,7 @@ void rcm_render_preview(GtkWidget *preview, gint version)
|
|||
hsv_array = reduced->hsv;
|
||||
rgb_array = reduced->rgb;
|
||||
|
||||
a = (guchar *) malloc(bytes * RW);
|
||||
a = g_new (guchar, bytes * RW);
|
||||
|
||||
if (preview == NULL)
|
||||
{
|
||||
|
@ -345,7 +371,7 @@ void rcm_render_preview(GtkWidget *preview, gint version)
|
|||
case GRAY_TO:
|
||||
unchanged = 0;
|
||||
skip = 1;
|
||||
hsv_to_rgb(Current.Gray->hue/TP, Current.Gray->satur, V, &R,&G,&B);
|
||||
gimp_hsv_to_rgb4 (rgb, Current.Gray->hue/TP, Current.Gray->satur, V);
|
||||
break;
|
||||
|
||||
default: break;
|
||||
|
@ -362,17 +388,16 @@ void rcm_render_preview(GtkWidget *preview, gint version)
|
|||
H*TP);
|
||||
|
||||
H = angle_mod_2PI(H) / TP;
|
||||
hsv_to_rgb(H,S,V, &R,&G,&B);
|
||||
gimp_hsv_to_rgb4 (rgb, H,S,V);
|
||||
} /* if (!skip) */
|
||||
|
||||
if (unchanged)
|
||||
degree = 0;
|
||||
if (unchanged)degree = 0;
|
||||
else
|
||||
degree = reduced->mask[i*RW+j] / 255.0;
|
||||
|
||||
a[j*3+0] = (1-degree) * rgb_array[i*RW*bytes + j*bytes + 0] + degree * R * 255;
|
||||
a[j*3+1] = (1-degree) * rgb_array[i*RW*bytes + j*bytes + 1] + degree * G * 255;
|
||||
a[j*3+2] = (1-degree) * rgb_array[i*RW*bytes + j*bytes + 2] + degree * B * 255;
|
||||
a[j*3+0] = (1-degree) * rgb_array[i*RW*bytes + j*bytes + 0] + degree * rgb[0];
|
||||
a[j*3+1] = (1-degree) * rgb_array[i*RW*bytes + j*bytes + 1] + degree * rgb[1];
|
||||
a[j*3+2] = (1-degree) * rgb_array[i*RW*bytes + j*bytes + 2] + degree * rgb[2];
|
||||
|
||||
/* apply transparency */
|
||||
if (bytes == 4)
|
||||
|
@ -418,7 +443,7 @@ void rcm_render_preview(GtkWidget *preview, gint version)
|
|||
} /* for i */
|
||||
}
|
||||
|
||||
free(a);
|
||||
g_free (a);
|
||||
gtk_widget_draw(preview, NULL);
|
||||
gdk_flush();
|
||||
}
|
||||
|
@ -427,13 +452,17 @@ void rcm_render_preview(GtkWidget *preview, gint version)
|
|||
/* render circle */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void rcm_render_circle(GtkWidget *preview, int sum, int margin)
|
||||
void
|
||||
rcm_render_circle (GtkWidget *preview,
|
||||
int sum,
|
||||
int margin)
|
||||
{
|
||||
gint i, j;
|
||||
hsv h, s, v, r, g, b;
|
||||
gdouble h, s, v;
|
||||
guchar rgb[3];
|
||||
guchar *a;
|
||||
|
||||
a = (guchar *) malloc(3*sum);
|
||||
a = g_new (guchar, 3*sum);
|
||||
|
||||
if (preview == NULL) return;
|
||||
|
||||
|
@ -441,7 +470,7 @@ void rcm_render_circle(GtkWidget *preview, int sum, int margin)
|
|||
{
|
||||
for (i = 0; i < sum; i++)
|
||||
{
|
||||
s = sqrt((sqr(i-sum/2.0) + sqr(j-sum/2.0)) / (float)sqr(sum/2.0-margin));
|
||||
s = sqrt ((SQR (i - sum / 2.0) + SQR (j - sum / 2.0)) / (float) SQR (sum / 2.0 - margin));
|
||||
if (s > 1)
|
||||
{
|
||||
a[i*3+0] = 255;
|
||||
|
@ -450,99 +479,21 @@ void rcm_render_circle(GtkWidget *preview, int sum, int margin)
|
|||
}
|
||||
else
|
||||
{
|
||||
h = arctg(sum/2.0-j, i-sum/2.0)/(2*PI);
|
||||
h = arctg (sum / 2.0 - j, i - sum / 2.0) / (2 * G_PI);
|
||||
v = 1 - sqrt (s) / 2;
|
||||
hsv_to_rgb(h,s,v, &r, &g, &b);
|
||||
gimp_hsv_to_rgb4 (rgb, h, s, v);
|
||||
|
||||
a[i*3+0] = r*255;
|
||||
a[i*3+1] = g*255;
|
||||
a[i*3+2] = b*255;
|
||||
a[i*3+0] = rgb[0] * 255;
|
||||
a[i*3+1] = rgb[1] * 255;
|
||||
a[i*3+2] = rgb[2] * 255;
|
||||
}
|
||||
}
|
||||
gtk_preview_draw_row(GTK_PREVIEW(preview), a, 0, j, sum);
|
||||
}
|
||||
|
||||
free(a);
|
||||
g_free (a);
|
||||
gtk_widget_draw (preview, NULL);
|
||||
gdk_flush ();
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/* Conversion routines */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void rgb_to_hsv (hsv r, hsv g, hsv b, hsv *h, hsv *s, hsv *l)
|
||||
{
|
||||
hsv v;
|
||||
hsv m;
|
||||
hsv vm;
|
||||
hsv r2, g2, b2;
|
||||
|
||||
v = MAX(r,g);
|
||||
v = MAX(v,b);
|
||||
m = MIN(r,g);
|
||||
m = MIN(m,b);
|
||||
|
||||
if ((*l = (m + v) / 2.0) <= 0.0)
|
||||
{
|
||||
*s = *h = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((*s = vm = v - m) > 0.0)
|
||||
{
|
||||
*s /= (*l <= 0.5) ? (v + m ) : (2.0 - v - m);
|
||||
}
|
||||
else
|
||||
{
|
||||
*h = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
r2 = (v - r) / vm;
|
||||
g2 = (v - g) / vm;
|
||||
b2 = (v - b) / vm;
|
||||
|
||||
if (r == v)
|
||||
*h = (g == m ? 5.0 + b2 : 1.0 - g2);
|
||||
else if (g == v)
|
||||
*h = (b == m ? 1.0 + r2 : 3.0 - b2);
|
||||
else
|
||||
*h = (r == m ? 3.0 + g2 : 5.0 - r2);
|
||||
|
||||
*h /= 6;
|
||||
}
|
||||
|
||||
void hsv_to_rgb (hsv h, hsv sl, hsv l, hsv *r, hsv *g, hsv *b)
|
||||
{
|
||||
hsv v, m, sv;
|
||||
gint sextant;
|
||||
hsv fract, vsf, mid1, mid2;
|
||||
|
||||
v = (l <= 0.5) ? (l * (1.0 + sl)) : (l + sl - l * sl);
|
||||
|
||||
if (v <= 0)
|
||||
{
|
||||
*r = *g = *b = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m = l + l - v;
|
||||
sv = (v - m ) / v;
|
||||
h *= 6.0;
|
||||
sextant = h;
|
||||
fract = h - sextant;
|
||||
vsf = v * sv * fract;
|
||||
mid1 = m + vsf;
|
||||
mid2 = v - vsf;
|
||||
switch (sextant)
|
||||
{
|
||||
case 0: *r = v; *g = mid1; *b = m; break;
|
||||
case 1: *r = mid2; *g = v; *b = m; break;
|
||||
case 2: *r = m; *g = v; *b = mid1; break;
|
||||
case 3: *r = m; *g = mid2; *b = v; break;
|
||||
case 4: *r = mid1; *g = m; *b = v; break;
|
||||
case 5: *r = v; *g = m; *b = mid2; break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
/* Global defines */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
#define sqr(X) ((X)*(X))
|
||||
#define SWAP(X,Y) {float t=X; X=Y; Y=t;}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
@ -65,10 +64,6 @@ void rcm_render_circle(GtkWidget *preview, int sum, int margin);
|
|||
/* only used in 'rcm.c' (or local) */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void rgb_to_hsv (hsv r, hsv g, hsv b, hsv *h, hsv *s, hsv *l);
|
||||
|
||||
void hsv_to_rgb (hsv h, hsv sl, hsv l, hsv *r, hsv *g, hsv *b);
|
||||
|
||||
float rcm_angle_inside_slice(float angle, RcmAngle *slice);
|
||||
|
||||
gint rcm_is_gray(float s);
|
||||
|
|
Loading…
Reference in New Issue