Transformed one GtkPreview to a GimpPreviewArea and the other to a simple
* plug-ins/common/CML_explorer.c: Transformed one GtkPreview to a GimpPreviewArea and the other to a simple GtkDrawingArea, since this makes the code simpler.
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
2004-07-30 DindinX <david@dindinx.org>
|
||||||
|
|
||||||
|
* plug-ins/common/CML_explorer.c: Transformed one GtkPreview to a
|
||||||
|
GimpPreviewArea and the other to a simple GtkDrawingArea, since this
|
||||||
|
makes the code simpler.
|
||||||
|
|
||||||
2004-07-30 Shlomi Fish <shlomif@iglu.org.il>
|
2004-07-30 Shlomi Fish <shlomif@iglu.org.il>
|
||||||
|
|
||||||
* libgimpwidgets/gimppreviewarea.c (gimp_preview_area_draw):
|
* libgimpwidgets/gimppreviewarea.c (gimp_preview_area_draw):
|
||||||
|
@ -76,11 +76,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef __GNUC__
|
|
||||||
#warning GTK_DISABLE_DEPRECATED
|
|
||||||
#endif
|
|
||||||
#undef GTK_DISABLE_DEPRECATED
|
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#include <libgimp/gimp.h>
|
#include <libgimp/gimp.h>
|
||||||
@ -771,7 +766,6 @@ CML_main_function (gboolean preview_p)
|
|||||||
/* rendering */
|
/* rendering */
|
||||||
for (dy = 0; dy < height_by_pixel; dy += VALS.scale)
|
for (dy = 0; dy < height_by_pixel; dy += VALS.scale)
|
||||||
{
|
{
|
||||||
gint i = 0;
|
|
||||||
gint r, g, b, h, s, v;
|
gint r, g, b, h, s, v;
|
||||||
gint offset_x, offset_y, dest_offset;
|
gint offset_x, offset_y, dest_offset;
|
||||||
|
|
||||||
@ -859,10 +853,12 @@ CML_main_function (gboolean preview_p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (preview_p)
|
if (preview_p)
|
||||||
for (i = 0; i < keep_height; i++)
|
gimp_preview_area_draw (GIMP_PREVIEW_AREA (preview),
|
||||||
gtk_preview_draw_row (GTK_PREVIEW (preview),
|
0, dy,
|
||||||
dest_buffer + dest_bpl * i, 0, dy + i,
|
width_by_pixel, keep_height,
|
||||||
width_by_pixel);
|
GIMP_RGB_IMAGE,
|
||||||
|
dest_buffer,
|
||||||
|
dest_bpl);
|
||||||
else
|
else
|
||||||
gimp_pixel_rgn_set_rect (&dest_rgn, dest_buffer, x1, y1 + dy,
|
gimp_pixel_rgn_set_rect (&dest_rgn, dest_buffer, x1, y1 + dy,
|
||||||
width_by_pixel, keep_height);
|
width_by_pixel, keep_height);
|
||||||
@ -1215,8 +1211,8 @@ CML_explorer_dialog (void)
|
|||||||
gtk_container_add (GTK_CONTAINER (abox), frame);
|
gtk_container_add (GTK_CONTAINER (abox), frame);
|
||||||
gtk_widget_show (frame);
|
gtk_widget_show (frame);
|
||||||
|
|
||||||
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
preview = gimp_preview_area_new ();
|
||||||
gtk_preview_size (GTK_PREVIEW (preview),
|
gtk_widget_set_size_request (preview,
|
||||||
PREVIEW_WIDTH, PREVIEW_HEIGHT);
|
PREVIEW_WIDTH, PREVIEW_HEIGHT);
|
||||||
gtk_container_add (GTK_CONTAINER (frame), preview);
|
gtk_container_add (GTK_CONTAINER (frame), preview);
|
||||||
gtk_widget_show (preview);
|
gtk_widget_show (preview);
|
||||||
@ -1760,6 +1756,57 @@ preview_update (void)
|
|||||||
CML_main_function (TRUE);
|
CML_main_function (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
function_graph_expose (GtkWidget *widget,
|
||||||
|
GdkEventExpose *ev,
|
||||||
|
gpointer *data)
|
||||||
|
{
|
||||||
|
gint x, y, last_y;
|
||||||
|
gint rgbi[3];
|
||||||
|
guchar *buffer;
|
||||||
|
gint channel_id = GPOINTER_TO_INT (data[0]);
|
||||||
|
CML_PARAM *param = data[1];
|
||||||
|
|
||||||
|
buffer = g_new (guchar, 256*256*3);
|
||||||
|
for (x = 0; x < 256; x++)
|
||||||
|
{
|
||||||
|
/* hue */
|
||||||
|
rgbi[0] = rgbi[1] = rgbi[2] = 127;
|
||||||
|
if ((0 <= channel_id) && (channel_id <= 2))
|
||||||
|
rgbi[channel_id] = CANNONIZE ((*param), ((gdouble) x / (gdouble) 255));
|
||||||
|
gimp_hsv_to_rgb_int (rgbi, rgbi+1, rgbi+2);
|
||||||
|
for (y = 0; y < 256; y++)
|
||||||
|
{
|
||||||
|
buffer[(y*256+x)*3+0] = rgbi[0];
|
||||||
|
buffer[(y*256+x)*3+1] = rgbi[1];
|
||||||
|
buffer[(y*256+x)*3+2] = rgbi[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gdk_draw_rgb_image (widget->window, widget->style->black_gc,
|
||||||
|
0, 0, 256, 256,
|
||||||
|
GDK_RGB_DITHER_NORMAL,
|
||||||
|
buffer,
|
||||||
|
3 * 256);
|
||||||
|
|
||||||
|
g_free (buffer);
|
||||||
|
|
||||||
|
gdk_draw_line (widget->window, widget->style->white_gc, 0,255, 255, 0);
|
||||||
|
|
||||||
|
y = 255 * CLAMP (logistic_function (param, 0, param->power),
|
||||||
|
0, 1.0);
|
||||||
|
for (x = 0; x < 256; x++)
|
||||||
|
{
|
||||||
|
last_y = y;
|
||||||
|
/* curve */
|
||||||
|
y = 255 * CLAMP (logistic_function (param, x/(gdouble)255, param->power),
|
||||||
|
0, 1.0);
|
||||||
|
gdk_draw_line (widget->window, widget->style->black_gc,
|
||||||
|
x, 255-last_y, x, 255-y);
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
function_graph_new (GtkWidget *widget,
|
function_graph_new (GtkWidget *widget,
|
||||||
gpointer *data)
|
gpointer *data)
|
||||||
@ -1767,8 +1814,6 @@ function_graph_new (GtkWidget *widget,
|
|||||||
GtkWidget *dlg;
|
GtkWidget *dlg;
|
||||||
GtkWidget *frame;
|
GtkWidget *frame;
|
||||||
GtkWidget *preview;
|
GtkWidget *preview;
|
||||||
gint channel_id = GPOINTER_TO_INT (data[0]);
|
|
||||||
CML_PARAM *param = data[1];
|
|
||||||
|
|
||||||
dlg = gimp_dialog_new (_("Graph of the current settings"), "cml_explorer",
|
dlg = gimp_dialog_new (_("Graph of the current settings"), "cml_explorer",
|
||||||
gtk_widget_get_toplevel (widget), 0,
|
gtk_widget_get_toplevel (widget), 0,
|
||||||
@ -1784,54 +1829,12 @@ function_graph_new (GtkWidget *widget,
|
|||||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), frame, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (frame);
|
gtk_widget_show (frame);
|
||||||
|
|
||||||
|
preview = gtk_drawing_area_new ();
|
||||||
|
gtk_widget_set_size_request (preview, 256, 256);
|
||||||
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
|
||||||
gtk_preview_size (GTK_PREVIEW (preview), 256, 256);
|
|
||||||
gtk_container_add (GTK_CONTAINER (frame), preview);
|
gtk_container_add (GTK_CONTAINER (frame), preview);
|
||||||
gtk_widget_show (preview);
|
gtk_widget_show (preview);
|
||||||
|
g_signal_connect (preview, "expose_event",
|
||||||
{
|
G_CALLBACK (function_graph_expose), data);
|
||||||
gint x, y, last_y, yy;
|
|
||||||
guchar rgbc[3];
|
|
||||||
gint rgbi[3];
|
|
||||||
guchar black[] = { 0, 0, 0 };
|
|
||||||
guchar white[] = { 255, 255, 255 };
|
|
||||||
|
|
||||||
for (x = 0; x < 256; x++)
|
|
||||||
{
|
|
||||||
#define FAST_AND_FULLCOLOR 1
|
|
||||||
#ifdef FAST_AND_FULLCOLOR
|
|
||||||
/* hue */
|
|
||||||
rgbi[0] = rgbi[1] = rgbi[2] = 127;
|
|
||||||
if ((0 <= channel_id) && (channel_id <= 2))
|
|
||||||
rgbi[channel_id] = CANNONIZE ((*param), ((gdouble) x / (gdouble) 255));
|
|
||||||
gimp_hsv_to_rgb_int (rgbi, rgbi+1, rgbi+2);
|
|
||||||
for (y = 0; y < 3; y++)
|
|
||||||
rgbc[y] = rgbi[y];
|
|
||||||
#endif
|
|
||||||
for (y = 0; y < 256; y++)
|
|
||||||
gtk_preview_draw_row (GTK_PREVIEW (preview),
|
|
||||||
#ifdef FAST_AND_FULLCOLOR
|
|
||||||
rgbc,
|
|
||||||
#else
|
|
||||||
white,
|
|
||||||
#endif
|
|
||||||
x, y, 1);
|
|
||||||
}
|
|
||||||
y = 255 * CLAMP (logistic_function (param, x / (gdouble) 255, param->power),
|
|
||||||
0, 1.0);
|
|
||||||
for (x = 0; x < 256; x++)
|
|
||||||
{
|
|
||||||
last_y = y;
|
|
||||||
/* curve */
|
|
||||||
gtk_preview_draw_row (GTK_PREVIEW (preview), white, x, 255 - x, 1);
|
|
||||||
y = 255 * CLAMP (logistic_function (param, x/(gdouble)255, param->power),
|
|
||||||
0, 1.0);
|
|
||||||
for (yy = MIN (y, last_y); yy <= MAX (y, last_y); yy++)
|
|
||||||
gtk_preview_draw_row (GTK_PREVIEW (preview), black, x, 255 - yy, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_widget_show (dlg);
|
gtk_widget_show (dlg);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user