Commit d6766de5 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

updated status

2001-01-12  Sven Neumann  <sven@gimp.org>

	* TODO.xml: updated status

	* app/gimpcontext.c: added temporary functions to make it compile

	* app/pixel_processor.c: include tile.h when ENABLE_MP is defined

	* libgimp/gimpcolor.[ch]: added more GimpRGB functions

	* plug-ins/common/aa.c: merged fix from gimp-1-2

	* plug-ins/common/colorify.c
	* plug-ins/common/colortoalpha.c
	* plug-ins/common/exchange.c
	* plug-ins/common/film.c
	* plug-ins/common/grid.c: use GimpRGB whereever possible.
	Still work in progress.
parent 9ae4f01b
2001-01-12 Sven Neumann <sven@gimp.org>
* TODO.xml: updated status
* app/gimpcontext.c: added temporary functions to make it compile
* app/pixel_processor.c: include tile.h when ENABLE_MP is defined
* libgimp/gimpcolor.[ch]: added more GimpRGB functions
* plug-ins/common/aa.c: merged fix from gimp-1-2
* plug-ins/common/colorify.c
* plug-ins/common/colortoalpha.c
* plug-ins/common/exchange.c
* plug-ins/common/film.c
* plug-ins/common/grid.c: use GimpRGB whereever possible.
Still work in progress.
2001-01-11 Sven Neumann <sven@gimp.org>
* libgimp/gimpcolorarea.c: added antialiasing
......
......@@ -64,7 +64,7 @@
</entry>
<entry size="medium" difficulty="medium" status="20%" target="1.4">
<title>Unify Color data types</title>
<title>Unify color data types</title>
<description>
<p>
LibGimp already has a new type GimpRGB. This should be used
......@@ -83,7 +83,7 @@
<section>
<title>Objectification</title>
<entry size="small" difficulty="easy" status="0%" target="1.4">
<entry size="small" difficulty="easy" status="80%" target="1.4">
<title>Generic GimpObject</title>
<description>
<p>
......@@ -96,7 +96,7 @@
</contact>
</entry>
<entry size="medium" difficulty="medium" status="0%" target="1.4">
<entry size="medium" difficulty="medium" status="10%" target="1.4">
<title>Cleanup existing internal objects</title>
<description>
<p>
......
......@@ -39,6 +39,10 @@
#include "pixel_region.h"
#include "gimprc.h"
#ifdef ENABLE_MP
#include "tile.h"
#endif
typedef void (* p1_func) (gpointer ,
PixelRegion *);
......
......@@ -1076,14 +1076,6 @@ gimp_context_get_foreground (GimpContext *context,
*b = context->foreground[2];
}
void
gimp_palette_get_foreground (guchar *r,
guchar *g,
guchar *b)
{
gimp_context_get_foreground (NULL, r, g, b);
}
void
gimp_context_set_foreground (GimpContext *context,
gint r,
......@@ -1155,14 +1147,6 @@ gimp_context_get_background (GimpContext *context,
*b = context->background[2];
}
void
gimp_palette_get_background (guchar *r,
guchar *g,
guchar *b)
{
gimp_context_get_background (NULL, r, g, b);
}
void
gimp_context_set_background (GimpContext *context,
gint r,
......@@ -1777,8 +1761,42 @@ gimp_context_update_gradient (GimpContext *context,
}
}
/* Temporary functions */
void
gimp_context_update_gradients (gradient_t *gradient)
{
g_slist_foreach (context_list, (GFunc) gimp_context_update_gradient, gradient);
}
void
gimp_palette_get_foreground (guchar *r,
guchar *g,
guchar *b)
{
gimp_context_get_foreground (NULL, r, g, b);
}
void
gimp_palette_set_foreground (guchar r,
guchar g,
guchar b)
{
gimp_context_set_foreground (NULL, r, g, b);
}
void
gimp_palette_get_background (guchar *r,
guchar *g,
guchar *b)
{
gimp_context_get_background (NULL, r, g, b);
}
void
gimp_palette_set_background (guchar r,
guchar g,
guchar b)
{
gimp_context_set_background (NULL, r, g, b);
}
......@@ -1076,14 +1076,6 @@ gimp_context_get_foreground (GimpContext *context,
*b = context->foreground[2];
}
void
gimp_palette_get_foreground (guchar *r,
guchar *g,
guchar *b)
{
gimp_context_get_foreground (NULL, r, g, b);
}
void
gimp_context_set_foreground (GimpContext *context,
gint r,
......@@ -1155,14 +1147,6 @@ gimp_context_get_background (GimpContext *context,
*b = context->background[2];
}
void
gimp_palette_get_background (guchar *r,
guchar *g,
guchar *b)
{
gimp_context_get_background (NULL, r, g, b);
}
void
gimp_context_set_background (GimpContext *context,
gint r,
......@@ -1777,8 +1761,42 @@ gimp_context_update_gradient (GimpContext *context,
}
}
/* Temporary functions */
void
gimp_context_update_gradients (gradient_t *gradient)
{
g_slist_foreach (context_list, (GFunc) gimp_context_update_gradient, gradient);
}
void
gimp_palette_get_foreground (guchar *r,
guchar *g,
guchar *b)
{
gimp_context_get_foreground (NULL, r, g, b);
}
void
gimp_palette_set_foreground (guchar r,
guchar g,
guchar b)
{
gimp_context_set_foreground (NULL, r, g, b);
}
void
gimp_palette_get_background (guchar *r,
guchar *g,
guchar *b)
{
gimp_context_get_background (NULL, r, g, b);
}
void
gimp_palette_set_background (guchar r,
guchar g,
guchar b)
{
gimp_context_set_background (NULL, r, g, b);
}
......@@ -39,6 +39,10 @@
#include "pixel_region.h"
#include "gimprc.h"
#ifdef ENABLE_MP
#include "tile.h"
#endif
typedef void (* p1_func) (gpointer ,
PixelRegion *);
......
......@@ -22,6 +22,7 @@
#include <glib.h>
#include "gimpcolor.h"
#include "gimpcolorspace.h"
#include "gimpmath.h"
......@@ -45,6 +46,32 @@ gimp_rgb_set (GimpRGB *rgb,
rgb->b = b;
}
void
gimp_rgb_set_uchar (GimpRGB *rgb,
guchar r,
guchar g,
guchar b)
{
g_return_if_fail (rgb != NULL);
rgb->r = (gdouble) r / 255.0;
rgb->g = (gdouble) g / 255.0;
rgb->b = (gdouble) b / 255.0;
}
void
gimp_rgb_get_uchar (const GimpRGB *rgb,
guchar *r,
guchar *g,
guchar *b)
{
g_return_if_fail (rgb != NULL);
if (r) *r = rgb->r * 255.999;
if (g) *g = rgb->g * 255.999;
if (b) *b = rgb->b * 255.999;
}
void
gimp_rgb_add (GimpRGB *rgb1,
const GimpRGB *rgb2)
......@@ -136,6 +163,15 @@ gimp_rgb_gamma (GimpRGB *rgb,
rgb->b = pow (rgb->b, ig);
}
gdouble
gimp_rgb_intensity (const GimpRGB *rgb)
{
g_return_val_if_fail (rgb != NULL, 0.0);
return (INTENSITY_RED * rgb->r +
INTENSITY_GREEN * rgb->g +
INTENSITY_BLUE * rgb->b);
}
/* RGBA functions */
......@@ -154,6 +190,36 @@ gimp_rgba_set (GimpRGB *rgba,
rgba->a = a;
}
void
gimp_rgba_set_uchar (GimpRGB *rgba,
guchar r,
guchar g,
guchar b,
guchar a)
{
g_return_if_fail (rgba != NULL);
rgba->r = (gdouble) r / 255.0;
rgba->g = (gdouble) g / 255.0;
rgba->b = (gdouble) b / 255.0;
rgba->a = (gdouble) a / 255.0;
}
void
gimp_rgba_get_uchar (const GimpRGB *rgba,
guchar *r,
guchar *g,
guchar *b,
guchar *a)
{
g_return_if_fail (rgba != NULL);
if (r) *r = rgba->r * 255.999;
if (g) *g = rgba->g * 255.999;
if (b) *b = rgba->b * 255.999;
if (a) *a = rgba->a * 255.999;
}
void
gimp_rgba_add (GimpRGB *rgba1,
const GimpRGB *rgba2)
......@@ -250,3 +316,35 @@ gimp_rgba_gamma (GimpRGB *rgba,
rgba->b = pow (rgba->b, ig);
rgba->a = pow (rgba->a, ig);
}
/* These functions will become the default one day */
gboolean
gimp_palette_set_foreground_rgb (const GimpRGB *rgb)
{
guchar r, g, b;
g_return_val_if_fail (rgb != NULL, FALSE);
gimp_rgb_get_uchar (rgb, &r, &g, &b);
return gimp_palette_set_foreground (r, g, b);
}
gboolean
gimp_palette_get_foreground_rgb (GimpRGB *rgb)
{
guchar r, g, b;
g_return_val_if_fail (rgb != NULL, FALSE);
if (gimp_palette_get_foreground (&r, &g, &b))
{
gimp_rgb_set_uchar (rgb, r, g, b);
return TRUE;
}
return FALSE;
}
......@@ -37,45 +37,70 @@ struct _GimpRGB
};
void gimp_rgb_set (GimpRGB *rgb,
gdouble r,
gdouble g,
gdouble b);
void gimp_rgb_add (GimpRGB *rgb1,
const GimpRGB *rgb2);
void gimp_rgb_subtract (GimpRGB *rgb1,
const GimpRGB *rgb2);
void gimp_rgb_multiply (GimpRGB *rgb1,
gdouble factor);
gdouble gimp_rgb_distance (const GimpRGB *rgb1,
const GimpRGB *rgb2);
gdouble gimp_rgb_max (const GimpRGB *rgb);
gdouble gimp_rgb_min (const GimpRGB *rgb);
void gimp_rgb_clamp (GimpRGB *rgb);
void gimp_rgb_gamma (GimpRGB *rgb,
gdouble gamma);
void gimp_rgba_set (GimpRGB *rgba,
gdouble r,
gdouble g,
gdouble b,
gdouble a);
void gimp_rgba_add (GimpRGB *rgba1,
const GimpRGB *rgba2);
void gimp_rgba_subtract (GimpRGB *rgba1,
const GimpRGB *rgba2);
void gimp_rgba_multiply (GimpRGB *rgba,
gdouble factor);
gdouble gimp_rgba_distance (const GimpRGB *rgba1,
const GimpRGB *rgba2);
gdouble gimp_rgba_max (const GimpRGB *rgba);
gdouble gimp_rgba_min (const GimpRGB *rgba);
void gimp_rgba_clamp (GimpRGB *rgba);
void gimp_rgba_gamma (GimpRGB *rgba,
gdouble gamma);
void gimp_rgb_set (GimpRGB *rgb,
gdouble r,
gdouble g,
gdouble b);
void gimp_rgb_set_uchar (GimpRGB *rgb,
guchar r,
guchar g,
guchar b);
void gimp_rgb_get_uchar (const GimpRGB *rgb,
guchar *r,
guchar *g,
guchar *b);
void gimp_rgb_add (GimpRGB *rgb1,
const GimpRGB *rgb2);
void gimp_rgb_subtract (GimpRGB *rgb1,
const GimpRGB *rgb2);
void gimp_rgb_multiply (GimpRGB *rgb1,
gdouble factor);
gdouble gimp_rgb_distance (const GimpRGB *rgb1,
const GimpRGB *rgb2);
gdouble gimp_rgb_max (const GimpRGB *rgb);
gdouble gimp_rgb_min (const GimpRGB *rgb);
void gimp_rgb_clamp (GimpRGB *rgb);
void gimp_rgb_gamma (GimpRGB *rgb,
gdouble gamma);
gdouble gimp_rgb_intensity (const GimpRGB *rgb);
void gimp_rgba_set (GimpRGB *rgba,
gdouble r,
gdouble g,
gdouble b,
gdouble a);
void gimp_rgba_set_uchar (GimpRGB *rgba,
guchar r,
guchar g,
guchar b,
guchar a);
void gimp_rgba_get_uchar (const GimpRGB *rgba,
guchar *r,
guchar *g,
guchar *b,
guchar *a);
void gimp_rgba_add (GimpRGB *rgba1,
const GimpRGB *rgba2);
void gimp_rgba_subtract (GimpRGB *rgba1,
const GimpRGB *rgba2);
void gimp_rgba_multiply (GimpRGB *rgba,
gdouble factor);
gdouble gimp_rgba_distance (const GimpRGB *rgba1,
const GimpRGB *rgba2);
gdouble gimp_rgba_max (const GimpRGB *rgba);
gdouble gimp_rgba_min (const GimpRGB *rgba);
void gimp_rgba_clamp (GimpRGB *rgba);
void gimp_rgba_gamma (GimpRGB *rgba,
gdouble gamma);
/* These will become the default one day */
gboolean gimp_palette_set_foreground_rgb (const GimpRGB *rgb);
gboolean gimp_palette_get_foreground_rgb (GimpRGB *rgb);
#ifdef __cplusplus
......
......@@ -94,7 +94,7 @@ query (void)
save_args, NULL);
gimp_register_save_handler ("file_aa_save",
"ansi,txt,text,html",
"ansi,txt,text",
"");
}
......
......@@ -48,33 +48,31 @@
#define COLOR_SIZE 30
static void query (void);
static void run (gchar *name,
gint nparams,
GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static void colorify (GimpDrawable *drawable);
static void colorify_row (guchar *row,
gint width,
gint bpp);
static gint colorify_dialog (guchar red,
guchar green,
guchar blue);
static void colorify_ok_callback (GtkWidget *widget,
gpointer data);
static void predefined_color_callback (GtkWidget *widget,
gpointer data);
static void run (gchar *name,
gint nparams,
GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static void colorify (GimpDrawable *drawable);
static void colorify_row (guchar *row,
gint width,
gint bpp);
static gboolean colorify_dialog (GimpRGB *color);
static void colorify_ok_callback (GtkWidget *widget,
gpointer data);
static void predefined_color_callback (GtkWidget *widget,
gpointer data);
typedef struct
{
guchar color[3];
GimpRGB color;
} ColorifyVals;
typedef struct
{
gint run;
gboolean run;
} ColorifyInterface;
static ColorifyInterface cint =
......@@ -84,7 +82,7 @@ static ColorifyInterface cint =
static ColorifyVals cvals =
{
{ 255, 255, 255 }
{ 1.0, 1.0, 1.0, 1.0 }
};
static GimpRGB button_color[] =
......@@ -147,16 +145,16 @@ query (void)
}
static void
run (gchar *name,
gint nparams,
run (gchar *name,
gint nparams,
GimpParam *param,
gint *nreturn_vals,
gint *nreturn_vals,
GimpParam **return_vals)
{
GimpRunModeType run_mode;
GimpPDBStatusType status;
static GimpParam values[1];
GimpDrawable *drawable;
GimpRunModeType run_mode;
GimpPDBStatusType status;
static GimpParam values[1];
GimpDrawable *drawable;
INIT_I18N_UI();
......@@ -180,7 +178,7 @@ run (gchar *name,
{
case GIMP_RUN_INTERACTIVE:
gimp_get_data (PLUG_IN_NAME, &cvals);
if (!colorify_dialog (cvals.color[0], cvals.color[1], cvals.color[2]))
if (!colorify_dialog (&cvals.color))
return;
break;
......@@ -190,9 +188,10 @@ run (gchar *name,
if (status == GIMP_PDB_SUCCESS)
{
cvals.color[0] = param[3].data.d_color.red;
cvals.color[1] = param[3].data.d_color.green;
cvals.color[2] = param[3].data.d_color.blue;
gimp_rgb_set_uchar (&cvals.color,
param[3].data.d_color.red,
param[3].data.d_color.green,
param[3].data.d_color.blue);
}
break;
......@@ -226,21 +225,22 @@ run (gchar *name,
static void
colorify (GimpDrawable *drawable)
{
GimpPixelRgn source_region, dest_region;
GimpPixelRgn source_region;
GimpPixelRgn dest_region;
guchar *row;
gint bpp;
gint y = 0;
gint progress = 0;
gint i = 0;
gint bpp;
gint y = 0;
gint i = 0;
gint progress = 0;
for (i = 0; i < 256; i ++)
{
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;
final_red_lookup[i] = i * cvals.color.r;
final_green_lookup[i] = i * cvals.color.g;
final_blue_lookup[i] = i * cvals.color.b;
}
bpp = gimp_drawable_bpp (drawable->id);
......@@ -260,7 +260,7 @@ colorify (GimpDrawable *drawable)
colorify_row (row, sel_width, bpp);
gimp_pixel_rgn_set_row (&dest_region, row, sel_x1, y, sel_width);
gimp_progress_update ((double) ++progress / (double) sel_height);
gimp_progress_update ((gdouble) ++progress / (gdouble) sel_height);
}
g_free (row);
......@@ -275,8 +275,8 @@ colorify_row (guchar *row,
gint width,
gint bpp)
{
gint cur_x;
gint lum; /* luminosity */
gint cur_x;
gint lum; /* luminosity */
guchar *current = row;
for (cur_x = 0; cur_x < width; cur_x++)
......@@ -293,10 +293,8 @@ colorify_row (guchar *row,
}
}
static int
colorify_dialog (guchar red,
guchar green,
guchar blue)
static gboolean
colorify_dialog (GimpRGB *color)
{
GtkWidget *dialog;
GtkWidget *label;
......@@ -304,8 +302,7 @@ colorify_dialog (guchar red,
GtkWidget *frame;
GtkWidget *table;
GtkWidget *color_area;
GimpRGB color;
gint i;
gint i;
gimp_ui_init ("colorify", TRUE);
......@@ -343,16 +340,12 @@ colorify_dialog (guchar red,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (label);
gimp_rgb_set (&color,
(gdouble) cvals.color[0] / 255.0,
(gdouble) cvals.color[1] / 255.0,
(gdouble) cvals.color[2] / 255.0);
custum_color_button = gimp_color_button_new (_("Colorify Custom Color"),
COLOR_SIZE, COLOR_SIZE,
&color, FALSE);
color, FALSE);
gtk_signal_connect (GTK_OBJECT (custum_color_button), "color_changed",
GTK_SIGNAL_FUNC (gimp_color_update_uchar),
cvals.color);
GTK_SIGNAL_FUNC (gimp_color_button_get_color),
color);
gtk_table_attach (GTK_TABLE (table), custum_color_button, 6, 7, 0, 1,
GTK_FILL, GTK_FILL, 0, 0);
......@@ -360,15 +353,14 @@ colorify_dialog (guchar red,
for (i = 0; i < 7; i++)
{
/* should actually use gimp_color_button() here */
button = gtk_button_new ();
color_area = gimp_color_area_new (&button_color[i], FALSE,
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK);
color_area = gimp_color_area_new (&button_color[i], FALSE,
GDK_BUTTON2_MASK);
gtk_widget_set_usize (GTK_WIDGET (color_area), COLOR_SIZE, COLOR_SIZE);
gtk_container_add (GTK_CONTAINER (button), color_area);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) predefined_color_callback,
NULL);
color_area);
gtk_widget_show (color_area);
gtk_table_attach (GTK_TABLE (table), button, i, i + 1, 1, 2,
......@@ -399,7 +391,7 @@ predefined_color_callback (GtkWidget *widget,
{
GimpRGB color;
gimp_color_button_get_color (GIMP_COLOR_BUTTON (widget), &color);
gimp_color_area_get_color (GIMP_COLOR_AREA (data), &color);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (custum_color_button), &color);
}
......
......@@ -39,12 +39,12 @@
typedef struct
{
guchar color[3];
GimpRGB color;
} C2AValues;
typedef struct
{
gint run;
gboolean run;
} C2AInterface;
typedef struct
......@@ -55,22 +55,24 @@ typedef struct
/* Declare local functions.
*/
static void query (void);
static void run (gchar *name,
gint nparams,
GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static void toalpha (GimpDrawable *drawable);
static void toalpha_render_row (const guchar *src_row,
guchar *dest_row,
gint row_width,
const gint bytes);
static void run (gchar *name,
gint nparams,
GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static void colortoalpha (GimpRGB *src,
GimpRGB *color);
static void toalpha (GimpDrawable *drawable);
static void toalpha_render_row (const guchar *src_row,
guchar *dest_row,
gint row_width,
const gint bytes);
/* UI stuff */
static gint colortoalpha_dialog (GimpDrawable *drawable);
static void colortoalpha_ok_callback (GtkWidget *widget,
gpointer data);
static gboolean colortoalpha_dialog (GimpDrawable *drawable);
static void colortoalpha_ok_callback (GtkWidget *widget,
gpointer data);
static GimpRunModeType run_mode;