plug-ins: remove the color-rotate plug-in

This commit is contained in:
Michael Natterer 2014-05-30 01:37:39 +02:00
parent f963f55fa4
commit 7438d5bd04
22 changed files with 0 additions and 2945 deletions

View File

@ -2203,8 +2203,6 @@ build/windows/Makefile
build/windows/gimp.rc
build/windows/gimp-plug-ins.rc
plug-ins/Makefile
plug-ins/color-rotate/Makefile
plug-ins/color-rotate/images/Makefile
plug-ins/file-bmp/Makefile
plug-ins/file-compressor/Makefile
plug-ins/file-exr/Makefile

View File

@ -37,7 +37,6 @@ endif
SUBDIRS = \
$(script_fu) \
$(pygimp) \
color-rotate \
file-bmp \
file-compressor \
$(file_exr) \

View File

@ -1,7 +0,0 @@
/Makefile.in
/Makefile
/.deps
/_libs
/.libs
/color-rotate
/color-rotate.exe

View File

@ -1,62 +0,0 @@
## Process this file with automake to produce Makefile.in
if OS_WIN32
mwindows = -mwindows
else
libm = -lm
endif
libgimpui = $(top_builddir)/libgimp/libgimpui-$(GIMP_API_VERSION).la
libgimpconfig = $(top_builddir)/libgimpconfig/libgimpconfig-$(GIMP_API_VERSION).la
libgimpwidgets = $(top_builddir)/libgimpwidgets/libgimpwidgets-$(GIMP_API_VERSION).la
libgimp = $(top_builddir)/libgimp/libgimp-$(GIMP_API_VERSION).la
libgimpcolor = $(top_builddir)/libgimpcolor/libgimpcolor-$(GIMP_API_VERSION).la
libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la
libgimpmath = $(top_builddir)/libgimpmath/libgimpmath-$(GIMP_API_VERSION).la
if HAVE_WINDRES
include $(top_srcdir)/build/windows/gimprc-plug-ins.rule
color_rotate_RC = color-rotate.rc.o
endif
AM_LDFLAGS = $(mwindows)
SUBDIRS = images
libexecdir = $(gimpplugindir)/plug-ins
libexec_PROGRAMS = color-rotate
color_rotate_SOURCES = \
color-rotate.c \
color-rotate.h \
color-rotate-callbacks.c \
color-rotate-callbacks.h \
color-rotate-dialog.c \
color-rotate-dialog.h \
color-rotate-draw.c \
color-rotate-draw.h \
color-rotate-utils.c \
color-rotate-utils.h \
color-rotate-stock.c \
color-rotate-stock.h
AM_CPPFLAGS = \
-I$(top_srcdir) \
$(GTK_CFLAGS) \
$(GEGL_CFLAGS) \
-I$(includedir)
LDADD = \
$(libm) \
$(libgimpui) \
$(libgimpwidgets) \
$(libgimpconfig) \
$(libgimpmath) \
$(libgimp) \
$(libgimpcolor) \
$(libgimpbase) \
$(GTK_LIBS) \
$(RT_LIBS) \
$(INTLLIBS) \
$(color_rotate_RC)

View File

@ -1,599 +0,0 @@
/*
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This is a plug-in for GIMP.
*
* Colormap-Rotation plug-in. Exchanges two color ranges.
*
* Copyright (C) 1999 Sven Anders (anderss@fmi.uni-passau.de)
* Based on code from Pavel Grinfeld (pavel@ml.com)
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*---------------------------------------------------------------------------
* Change log:
*
* Version 2.0, 04 April 1999.
* Nearly complete rewrite, made plug-in stable.
* (Works with GIMP 1.1 and GTK+ 1.2)
*
* Version 1.0, 27 March 1997.
* Initial (unstable) release by Pavel Grinfeld
*
*---------------------------------------------------------------------------*/
#include "config.h"
#include "libgimp/gimp.h"
#include "libgimp/gimpui.h"
#include "color-rotate.h"
#include "color-rotate-utils.h"
#include "color-rotate-draw.h"
#include "color-rotate-dialog.h"
#include "color-rotate-callbacks.h"
#include "color-rotate-stock.h"
#include "images/color-rotate-stock-pixbufs.h"
/* Misc functions */
float
rcm_units_factor (gint units)
{
switch (units)
{
case DEGREES: return 180.0 / G_PI;
case RADIANS: return 1.0;
case RADIANS_OVER_PI: return 1.0 / G_PI;
default: return -1;
}
}
const gchar *
rcm_units_string (gint units)
{
switch (units)
{
case DEGREES: return "deg";
case RADIANS: return "rad";
case RADIANS_OVER_PI: return "rad/pi";
default: return "(unknown)";
}
}
/* Circle buttons */
void
rcm_360_degrees (GtkWidget *button,
RcmCircle *circle)
{
gtk_widget_queue_draw (circle->preview);
circle->angle->beta = circle->angle->alpha-circle->angle->cw_ccw * 0.001;
rcm_render_preview (Current_c.Bna->after);
}
void
rcm_cw_ccw (GtkWidget *button,
RcmCircle *circle)
{
circle->angle->cw_ccw *= -1;
g_object_set (button,
"label",
(circle->angle->cw_ccw>0) ?
STOCK_COLOR_ROTATE_SWITCH_CLOCKWISE :
STOCK_COLOR_ROTATE_SWITCH_COUNTERCLOCKWISE,
"use_stock", TRUE,
NULL);
rcm_a_to_b (button, circle);
}
void
rcm_a_to_b (GtkWidget *button,
RcmCircle *circle)
{
gtk_widget_queue_draw (circle->preview);
SWAP (circle->angle->alpha, circle->angle->beta);
rcm_render_preview (Current_c.Bna->after);
}
/* Misc: units buttons */
static void
rcm_spinbutton_to_degrees (GtkWidget *button,
float value,
GtkWidget *label)
{
GtkAdjustment *adj;
adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (button));
gtk_adjustment_configure (adj,
value * rcm_units_factor (Current_c.Units),
gtk_adjustment_get_lower (adj), 360.0,
0.01, 1.0,
gtk_adjustment_get_page_size (adj));
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (button), 2);
gtk_label_set_text (GTK_LABEL (label), rcm_units_string (Current_c.Units));
}
void
rcm_switch_to_degrees (GtkWidget *button,
gpointer *value)
{
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
{
Current_c.Units = DEGREES;
rcm_spinbutton_to_degrees (Current_c.From->alpha_entry,
Current_c.From->angle->alpha,
Current_c.From->alpha_units_label);
rcm_spinbutton_to_degrees (Current_c.From->beta_entry,
Current_c.From->angle->beta,
Current_c.From->beta_units_label);
rcm_spinbutton_to_degrees (Current_c.To->alpha_entry,
Current_c.To->angle->alpha,
Current_c.To->alpha_units_label);
rcm_spinbutton_to_degrees (Current_c.To->beta_entry,
Current_c.To->angle->beta,
Current_c.To->beta_units_label);
rcm_spinbutton_to_degrees (Current_c.Gray->hue_entry,
Current_c.Gray->hue,
Current_c.Gray->hue_units_label);
}
}
static void
rcm_spinbutton_to_radians (GtkWidget *button,
float value,
GtkWidget *label)
{
GtkAdjustment *adj;
adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (button));
gtk_adjustment_configure (adj,
value * rcm_units_factor (Current_c.Units),
gtk_adjustment_get_lower (adj), TP,
0.0001, 0.001,
gtk_adjustment_get_page_size (adj));
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (button), 4);
gtk_label_set_text (GTK_LABEL (label), rcm_units_string (Current_c.Units));
}
void
rcm_switch_to_radians (GtkWidget *button,
gpointer *value)
{
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
{
Current_c.Units = RADIANS;
rcm_spinbutton_to_radians (Current_c.From->alpha_entry,
Current_c.From->angle->alpha,
Current_c.From->alpha_units_label);
rcm_spinbutton_to_radians (Current_c.From->beta_entry,
Current_c.From->angle->beta,
Current_c.From->beta_units_label);
rcm_spinbutton_to_radians (Current_c.To->alpha_entry,
Current_c.To->angle->alpha,
Current_c.To->alpha_units_label);
rcm_spinbutton_to_radians (Current_c.To->beta_entry,
Current_c.To->angle->beta,
Current_c.To->beta_units_label);
rcm_spinbutton_to_radians (Current_c.Gray->hue_entry,
Current_c.Gray->hue,
Current_c.Gray->hue_units_label);
}
}
static void
rcm_spinbutton_to_radians_over_PI (GtkWidget *button,
float value,
GtkWidget *label)
{
GtkAdjustment *adj;
adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (button));
gtk_adjustment_configure (adj,
value * rcm_units_factor (Current_c.Units),
gtk_adjustment_get_lower (adj), 2.0,
0.0001, 0.001,
gtk_adjustment_get_page_size (adj));
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (button), 4);
gtk_label_set_text (GTK_LABEL (label), rcm_units_string (Current_c.Units));
}
void
rcm_switch_to_radians_over_PI (GtkWidget *button,
gpointer *value)
{
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
{
Current_c.Units = RADIANS_OVER_PI;
rcm_spinbutton_to_radians_over_PI (Current_c.From->alpha_entry,
Current_c.From->angle->alpha,
Current_c.From->alpha_units_label);
rcm_spinbutton_to_radians_over_PI (Current_c.From->beta_entry,
Current_c.From->angle->beta,
Current_c.From->beta_units_label);
rcm_spinbutton_to_radians_over_PI (Current_c.To->alpha_entry,
Current_c.To->angle->alpha,
Current_c.To->alpha_units_label);
rcm_spinbutton_to_radians_over_PI (Current_c.To->beta_entry,
Current_c.To->angle->beta,
Current_c.To->beta_units_label);
rcm_spinbutton_to_radians_over_PI (Current_c.Gray->hue_entry,
Current_c.Gray->hue,
Current_c.Gray->hue_units_label);
}
}
/* Misc: Gray: mode buttons */
void
rcm_switch_to_gray_to (GtkWidget *button,
gpointer *value)
{
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
{
Current_c.Gray_to_from = GRAY_TO;
rcm_render_preview (Current_c.Bna->after);
}
}
void
rcm_switch_to_gray_from (GtkWidget *button,
gpointer *value)
{
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
{
Current_c.Gray_to_from = GRAY_FROM;
rcm_render_preview (Current_c.Bna->after);
}
}
/* Misc: Preview buttons */
void
rcm_preview_as_you_drag (GtkWidget *button,
gpointer *value)
{
Current_c.RealTime = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
}
void
rcm_combo_callback (GtkWidget *widget,
gpointer data)
{
gint value;
gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value);
Current_c.reduced = rcm_reduce_image (Current_c.drawable, Current_c.mask,
MAX_PREVIEW_SIZE, value);
gtk_widget_set_size_request (Current_c.Bna->before,
Current_c.reduced->width,
Current_c.reduced->height);
gtk_widget_set_size_request (Current_c.Bna->after,
Current_c.reduced->width,
Current_c.reduced->height);
}
/* Circle events */
gboolean
rcm_expose_event (GtkWidget *widget,
GdkEventExpose *event,
RcmCircle *circle)
{
cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
cairo_translate (cr, 0.5, 0.5);
color_rotate_draw_arrows (cr, circle->angle);
cairo_destroy (cr);
return TRUE;
}
gboolean
rcm_button_press_event (GtkWidget *widget,
GdkEventButton *event,
RcmCircle *circle)
{
float clicked_angle;
float *alpha;
float *beta;
alpha = &circle->angle->alpha;
beta = &circle->angle->beta;
clicked_angle = angle_mod_2PI (arctg (CENTER - event->y, event->x - CENTER));
circle->prev_clicked = clicked_angle;
if ((sqrt (SQR (event->y - CENTER) +
SQR (event->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);
if (*(circle->target) != clicked_angle)
{
*(circle->target) = clicked_angle;
gtk_widget_queue_draw (circle->preview);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (circle->alpha_entry),
circle->angle->alpha *
rcm_units_factor(Current_c.Units));
gtk_spin_button_set_value (GTK_SPIN_BUTTON (circle->beta_entry),
circle->angle->beta *
rcm_units_factor(Current_c.Units));
if (Current_c.RealTime)
rcm_render_preview (Current_c.Bna->after);
}
}
else
circle->mode = BOTH;
return TRUE;
}
gboolean
rcm_release_event (GtkWidget *widget,
GdkEventButton *event,
RcmCircle *circle)
{
rcm_render_preview (Current_c.Bna->after);
return TRUE;
}
gboolean
rcm_motion_notify_event (GtkWidget *widget,
GdkEventMotion *event,
RcmCircle *circle)
{
gfloat clicked_angle, delta;
clicked_angle = angle_mod_2PI (arctg (CENTER - event->y, event->x - CENTER));
delta = clicked_angle - circle->prev_clicked;
circle->prev_clicked = clicked_angle;
if (delta)
{
if (circle->mode == EACH)
{
*(circle->target) = clicked_angle;
}
else
{
circle->angle->alpha = angle_mod_2PI (circle->angle->alpha + delta);
circle->angle->beta = angle_mod_2PI (circle->angle->beta + delta);
}
gtk_widget_queue_draw (widget);
gdk_window_process_updates (gtk_widget_get_window (widget), FALSE);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (circle->alpha_entry),
circle->angle->alpha *
rcm_units_factor(Current_c.Units));
gtk_spin_button_set_value (GTK_SPIN_BUTTON (circle->beta_entry),
circle->angle->beta *
rcm_units_factor(Current_c.Units));
if (Current_c.RealTime)
rcm_render_preview (Current_c.Bna->after);
}
gdk_event_request_motions (event);
return TRUE;
}
/* Gray circle events */
gboolean
rcm_gray_expose_event (GtkWidget *widget,
GdkEventExpose *event,
RcmGray *circle)
{
cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
cairo_translate (cr, 0.5, 0.5);
color_rotate_draw_little_circle (cr, circle->hue, circle->satur);
color_rotate_draw_large_circle (cr, circle->gray_sat);
cairo_destroy (cr);
return TRUE;
}
gboolean
rcm_gray_button_press_event (GtkWidget *widget,
GdkEventButton *event,
RcmGray *circle)
{
gint x, y;
x = event->x - GRAY_CENTER - LITTLE_RADIUS;
y = GRAY_CENTER - event->y + LITTLE_RADIUS;
circle->hue = angle_mod_2PI(arctg(y, x));
circle->satur = sqrt (SQR (x) + SQR (y)) / GRAY_RADIUS;
if (circle->satur > 1.0)
circle->satur = 1;
gtk_widget_queue_draw (circle->preview);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (circle->hue_entry),
circle->hue * rcm_units_factor (Current_c.Units));
gtk_spin_button_set_value (GTK_SPIN_BUTTON (circle->satur_entry),
circle->satur);
if (Current_c.RealTime)
rcm_render_preview (Current_c.Bna->after);
return TRUE;
}
gboolean
rcm_gray_release_event (GtkWidget *widget,
GdkEventButton *event,
RcmGray *circle)
{
rcm_render_preview (Current_c.Bna->after);
return TRUE;
}
gboolean
rcm_gray_motion_notify_event (GtkWidget *widget,
GdkEventMotion *event,
RcmGray *circle)
{
gint x, y;
gtk_widget_queue_draw (circle->preview);
x = event->x - GRAY_CENTER - LITTLE_RADIUS;
y = GRAY_CENTER - event->y + LITTLE_RADIUS;
circle->hue = angle_mod_2PI (arctg (y, x));
circle->satur = sqrt (SQR (x) + SQR (y)) / GRAY_RADIUS;
if (circle->satur > 1.0)
circle->satur = 1;
gtk_spin_button_set_value (GTK_SPIN_BUTTON (circle->hue_entry),
circle->hue * rcm_units_factor(Current_c.Units));
gtk_spin_button_set_value (GTK_SPIN_BUTTON (circle->satur_entry),
circle->satur);
if (Current_c.RealTime)
rcm_render_preview (Current_c.Bna->after);
gdk_event_request_motions (event);
return TRUE;
}
/* Spinbuttons */
void
rcm_set_alpha (GtkWidget *entry,
RcmCircle *circle)
{
circle->angle->alpha = (gtk_spin_button_get_value (GTK_SPIN_BUTTON (entry)) /
rcm_units_factor (Current_c.Units));
gtk_widget_queue_draw (circle->preview);
rcm_render_preview (Current_c.Bna->after);
}
void
rcm_set_beta (GtkWidget *entry,
RcmCircle *circle)
{
circle->angle->beta = (gtk_spin_button_get_value (GTK_SPIN_BUTTON (entry)) /
rcm_units_factor(Current_c.Units));
gtk_widget_queue_draw (circle->preview);
rcm_render_preview (Current_c.Bna->after);
}
void
rcm_set_hue (GtkWidget *entry,
RcmGray *circle)
{
circle->hue = (gtk_spin_button_get_value (GTK_SPIN_BUTTON (entry)) /
rcm_units_factor(Current_c.Units));
gtk_widget_queue_draw (circle->preview);
rcm_render_preview (Current_c.Bna->after);
}
void
rcm_set_satur (GtkWidget *entry,
RcmGray *circle)
{
circle->satur = gtk_spin_button_get_value (GTK_SPIN_BUTTON (entry));
gtk_widget_queue_draw (circle->preview);
rcm_render_preview (Current_c.Bna->after);
}
void
rcm_set_gray_sat (GtkWidget *entry,
RcmGray *circle)
{
circle->gray_sat = gtk_spin_button_get_value (GTK_SPIN_BUTTON (entry));
gtk_widget_queue_draw (circle->preview);
rcm_render_preview (Current_c.Bna->after);
}

View File

@ -1,132 +0,0 @@
/*
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This is a plug-in for GIMP.
*
* Colormap-Rotation plug-in. Exchanges two color ranges.
*
* Copyright (C) 1999 Sven Anders (anderss@fmi.uni-passau.de)
* Based on code from Pavel Grinfeld (pavel@ml.com)
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*---------------------------------------------------------------------------
* Change log:
*
* Version 2.0, 04 April 1999.
* Nearly complete rewrite, made plug-in stable.
* (Works with GIMP 1.1 and GTK+ 1.2)
*
* Version 1.0, 27 March 1997.
* Initial (unstable) release by Pavel Grinfeld
*
*---------------------------------------------------------------------------*/
/* Misc functions */
float rcm_units_factor (gint units);
const gchar * rcm_units_string (gint units);
void rcm_set_pixmap (GtkWidget **widget,
GtkWidget *parent,
GtkWidget *label_box,
gchar **pixmap_data);
/* Circle buttons */
void rcm_360_degrees (GtkWidget *button,
RcmCircle *circle);
void rcm_cw_ccw (GtkWidget *button,
RcmCircle *circle);
void rcm_a_to_b (GtkWidget *button,
RcmCircle *circle);
/* Misc: units buttons */
void rcm_switch_to_degrees (GtkWidget *button,
gpointer *value);
void rcm_switch_to_radians (GtkWidget *button,
gpointer *value);
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_from (GtkWidget *button,
gpointer *value);
/* Misc: Preview buttons */
void rcm_preview_as_you_drag (GtkWidget *button,
gpointer *value);
void rcm_combo_callback (GtkWidget *widget,
gpointer data);
/* Circle events */
gboolean rcm_expose_event (GtkWidget *widget,
GdkEventExpose *event,
RcmCircle *circle);
gboolean rcm_button_press_event (GtkWidget *widget,
GdkEventButton *event,
RcmCircle *circle);
gboolean rcm_release_event (GtkWidget *widget,
GdkEventButton *event,
RcmCircle *circle);
gboolean rcm_motion_notify_event (GtkWidget *widget,
GdkEventMotion *event,
RcmCircle *circle);
/* Gray circle events */
gboolean rcm_gray_expose_event (GtkWidget *widget,
GdkEventExpose *event,
RcmGray *circle);
gboolean rcm_gray_button_press_event (GtkWidget *widget,
GdkEventButton *event,
RcmGray *circle);
gboolean rcm_gray_release_event (GtkWidget *widget,
GdkEventButton *event,
RcmGray *circle);
gboolean rcm_gray_motion_notify_event (GtkWidget *widget,
GdkEventMotion *event,
RcmGray *circle);
/* Spinbuttons */
void rcm_set_alpha (GtkWidget *entry,
RcmCircle *circle);
void rcm_set_beta (GtkWidget *entry,
RcmCircle *circle);
void rcm_set_hue (GtkWidget *entry,
RcmGray *circle);
void rcm_set_satur (GtkWidget *entry,
RcmGray *circle);
void rcm_set_gray_sat (GtkWidget *entry,
RcmGray *circle);

View File

@ -1,710 +0,0 @@
/*
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This is a plug-in for GIMP.
*
* Colormap-Rotation plug-in. Exchanges two color ranges.
*
* Copyright (C) 1999 Sven Anders (anderss@fmi.uni-passau.de)
* Based on code from Pavel Grinfeld (pavel@ml.com)
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*---------------------------------------------------------------------------
* Change log:
*
* Version 2.0, 04 April 1999.
* Nearly complete rewrite, made plug-in stable.
* (Works with GIMP 1.1 and GTK+ 1.2)
*
* Version 1.0, 27 March 1997.
* Initial (unstable) release by Pavel Grinfeld
*
*---------------------------------------------------------------------------*/
#include "config.h"
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include "color-rotate.h"
#include "color-rotate-utils.h"
#include "color-rotate-draw.h"
#include "color-rotate-callbacks.h"
#include "color-rotate-dialog.h"
#include "color-rotate-stock.h"
#include "images/color-rotate-stock-pixbufs.h"
#include "libgimp/stdplugins-intl.h"
/* Defines */
#define INITIAL_ALPHA 0.0
#define INITIAL_ALPHA_RADIANS 0.0
#define INITIAL_BETA 90.0
#define INITIAL_BETA_RADIANS ((INITIAL_BETA / 360) * 2 * G_PI)
#define INITIAL_GRAY_SAT 0.0
#define INITIAL_GRAY_RSAT 0.0
#define INITIAL_GRAY_HUE 0.0
#define RANGE_ADJUST_MASK GDK_EXPOSURE_MASK | \
GDK_ENTER_NOTIFY_MASK | \
GDK_BUTTON_PRESS_MASK | \
GDK_BUTTON_RELEASE_MASK | \
GDK_BUTTON1_MOTION_MASK | \
GDK_POINTER_MOTION_HINT_MASK
/* Previews: create one preview */
static GtkWidget *
rcm_create_one_preview (GtkWidget **preview,
gint mode,
gint width,
gint height)
{
GtkWidget *align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
GtkWidget *frame;
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_container_add (GTK_CONTAINER (align), frame);
gtk_widget_show (frame);
*preview = gimp_preview_area_new ();
gtk_widget_set_size_request (*preview, width, height);
gtk_container_add (GTK_CONTAINER (frame), *preview);
gtk_widget_show (*preview);
g_object_set_data (G_OBJECT (*preview), "mode", GINT_TO_POINTER (mode));
return align;
}
/* Previews */
static GtkWidget *
rcm_create_previews (void)
{
GtkWidget *top_vbox;
GtkWidget *vbox;
GtkWidget *frame;
GtkWidget *hbox;
GtkWidget *label;
GtkWidget *button;
GtkWidget *combo;
top_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_box_pack_start (GTK_BOX (top_vbox), vbox, TRUE, TRUE, 0);
gtk_widget_show (vbox);
label = gtk_label_new (_("Original"));
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
frame = rcm_create_one_preview (&Current_c.Bna->before, ORIGINAL,
Current_c.reduced->width,
Current_c.reduced->height);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
g_signal_connect_after (Current_c.Bna->before, "size-allocate",
G_CALLBACK (rcm_render_preview),
NULL);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_box_pack_start (GTK_BOX (top_vbox), vbox, TRUE, TRUE, 0);
gtk_widget_show (vbox);
label = gtk_label_new (_("Rotated"));
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
frame = rcm_create_one_preview (&Current_c.Bna->after, CURRENT,
Current_c.reduced->width,
Current_c.reduced->height);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
g_signal_connect_after (Current_c.Bna->after, "size-allocate",
G_CALLBACK (rcm_render_preview),
NULL);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_box_pack_start (GTK_BOX (top_vbox), vbox, FALSE, FALSE, 0);
gtk_widget_show (vbox);
button = gtk_check_button_new_with_label (_("Continuous update"));
gtk_box_pack_start(GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), Current_c.RealTime);
gtk_widget_show (button);
g_signal_connect (button, "clicked",
G_CALLBACK (rcm_preview_as_you_drag),
&(Current_c.RealTime));
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
label = gtk_label_new (_("Area:"));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
combo = gimp_int_combo_box_new (_("Entire Layer"), ENTIRE_IMAGE,
_("Selection"), SELECTION,
_("Context"), SELECTION_IN_CONTEXT,
NULL);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo), Current_c.Slctn);
gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
gtk_widget_show (combo);
g_signal_connect (combo, "changed",
G_CALLBACK (rcm_combo_callback),
NULL);
gtk_widget_show (top_vbox);
return top_vbox;
}
/* Main: One circles with values and buttons */
static RcmCircle*
rcm_create_one_circle (gint height,
const gchar *label_content)
{
GtkWidget *frame, *button_table, *legend_table;
GtkWidget *label, *button, *entry;
GtkAdjustment *adj;
RcmCircle *st;
st = g_new (RcmCircle, 1);
st->angle = g_new (RcmAngle, 1);
st->angle->alpha = INITIAL_ALPHA_RADIANS;
st->angle->beta = INITIAL_BETA_RADIANS;
st->angle->cw_ccw = 1;
/** Main: Circle: create (main) frame **/
st->frame = gimp_frame_new (label_content);
gtk_widget_show (st->frame);
/** Main: Circle: create frame & preview **/
/* create frame */
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_widget_show (frame);
/* create preview */
st->preview = gimp_preview_area_new ();
gtk_widget_set_size_request (st->preview, height, height);
gtk_container_add (GTK_CONTAINER (frame), st->preview);
gtk_widget_show (st->preview);
/* set signals */
gtk_widget_set_events (st->preview, RANGE_ADJUST_MASK);
g_signal_connect_after (st->preview, "expose-event",
G_CALLBACK (rcm_expose_event),
st);
g_signal_connect (st->preview, "button-press-event",
G_CALLBACK (rcm_button_press_event),
st);
g_signal_connect (st->preview, "button-release-event",
G_CALLBACK (rcm_release_event),
st);
g_signal_connect (st->preview, "motion-notify-event",
G_CALLBACK (rcm_motion_notify_event),
st);
/** Main: Circle: create table for buttons **/
button_table = gtk_table_new (3, 1, FALSE);
gtk_widget_show (button_table);
/** Main: Circle: Buttons **/
button = gtk_button_new_from_stock (st->angle->cw_ccw > 0 ?
STOCK_COLOR_ROTATE_SWITCH_CLOCKWISE :
STOCK_COLOR_ROTATE_SWITCH_COUNTERCLOCKWISE);
g_signal_connect (button, "clicked",
G_CALLBACK (rcm_cw_ccw),
st);
gtk_widget_show (button);
gtk_table_attach (GTK_TABLE (button_table), button,
0, 1, 0, 1,
GTK_EXPAND | GTK_FILL, GTK_FILL, 4, 2);
st->cw_ccw_pixmap = NULL;
st->cw_ccw_button = button;
st->cw_ccw_box = NULL;
st->cw_ccw_label = NULL;
button = gtk_button_new_from_stock (STOCK_COLOR_ROTATE_CHANGE_ORDER);
g_signal_connect (button, "clicked",
G_CALLBACK (rcm_a_to_b),
st);
gtk_widget_show (button);
gtk_table_attach (GTK_TABLE (button_table), button,
0, 1, 1, 2,
GTK_EXPAND | GTK_FILL, GTK_FILL, 4, 2);
st->a_b_pixmap = NULL;
st->a_b_box = NULL;
st->a_b_button = button;
button = gtk_button_new_from_stock (STOCK_COLOR_ROTATE_SELECT_ALL);
g_signal_connect (button, "clicked",
G_CALLBACK (rcm_360_degrees),
st);
gtk_widget_show (button);
gtk_table_attach (GTK_TABLE (button_table), button,
0, 1, 2, 3,
GTK_EXPAND | GTK_FILL, GTK_FILL, 4, 2);
st->f360_pixmap = NULL;
st->f360_box = NULL;
st->f360_button = button;
/** Main: Circle: Legend **/
legend_table = gtk_table_new (1, 6, FALSE);
gtk_widget_show (legend_table);
/* spinbutton 1 */
label = gtk_label_new (C_("color-range", "From:"));
gtk_widget_show (label);
gtk_table_attach (GTK_TABLE (legend_table), label, 0, 1, 0, 1,
0, GTK_EXPAND, 5, 5);
st->angle->alpha = INITIAL_ALPHA;
adj = (GtkAdjustment *) gtk_adjustment_new(st->angle->alpha,
0.0, 360.0, 0.01, 1.0, 0.0);
st->alpha_entry = entry = gtk_spin_button_new(adj, 0.01, 2);
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON(entry), TRUE);
gtk_table_attach(GTK_TABLE(legend_table), entry, 1,2, 0,1,
GTK_EXPAND|GTK_FILL, GTK_EXPAND, 2, 4);
gtk_widget_show(entry);
g_signal_connect (entry, "changed",
G_CALLBACK (rcm_set_alpha),
st);
/* label */
st->alpha_units_label = gtk_label_new (rcm_units_string (Current_c.Units));
gtk_widget_show (st->alpha_units_label);
gtk_table_attach (GTK_TABLE (legend_table),
st->alpha_units_label, 2, 3, 0, 1,
0, GTK_EXPAND, 4, 4);
/* spinbutton 2 */
label = gtk_label_new (C_("color-range", "To:"));
gtk_widget_show (label);
gtk_table_attach (GTK_TABLE (legend_table), label, 3,4, 0,1,
0, GTK_EXPAND, 4, 4);
st->angle->beta = INITIAL_BETA_RADIANS;
adj = (GtkAdjustment *) gtk_adjustment_new (INITIAL_BETA, 0.0, 360.0, 0.01, 1.0, 0.0);
st->beta_entry = entry = gtk_spin_button_new (adj, 0.01, 2);
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (entry), TRUE);
gtk_table_attach (GTK_TABLE (legend_table), entry, 4,5, 0,1,
GTK_EXPAND|GTK_FILL, GTK_EXPAND, 2, 4);
gtk_widget_show (entry);
g_signal_connect (entry, "changed",
G_CALLBACK (rcm_set_beta),
st);
/* label */
st->beta_units_label = gtk_label_new (rcm_units_string (Current_c.Units));
gtk_widget_show (st->beta_units_label);
gtk_table_attach (GTK_TABLE (legend_table), st->beta_units_label, 5,6, 0,1,
0, GTK_EXPAND, 4, 4);
/* Main: Circle: create table for Preview / Buttons / Legend */
st->table= gtk_table_new (2, 2, FALSE);
gtk_widget_show (st->table);
gtk_table_attach (GTK_TABLE (st->table), frame, 0, 1, 0, 1,
0, GTK_EXPAND, 4, 0);
gtk_table_attach (GTK_TABLE (st->table), button_table, 1, 2, 0, 1,
0, GTK_EXPAND, 2, 0);
gtk_table_attach (GTK_TABLE (st->table), legend_table, 0, 2, 1, 2,
GTK_EXPAND | GTK_FILL, GTK_EXPAND, 0, 2);
/* add table to (main) frame */
gtk_container_add (GTK_CONTAINER (st->frame), st->table);
return st;
}
/* Main */
static GtkWidget *
rcm_create_main (void)
{
GtkWidget *vbox;
Current_c.From = rcm_create_one_circle (SUM, C_("color-rotate", "From:"));
Current_c.To = rcm_create_one_circle (SUM, C_("color-rotate", "To:"));
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
gtk_widget_show (vbox);
gtk_box_pack_start (GTK_BOX (vbox), Current_c.From->frame,
FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), Current_c.To->frame,
FALSE, FALSE, 0);
return vbox;
}
/* Misc: Gray */
static GtkWidget *
rcm_create_gray (void)
{
GtkWidget *top_vbox, *vbox;
GtkWidget *frame, *preview;
GtkWidget *table;
GtkWidget *entry;
GtkWidget *radio_box;
GtkWidget *hbox;
GtkWidget *label;
GtkWidget *button;
GSList *group = NULL;
RcmGray *st;
GtkAdjustment *adj;
Current_c.Gray = st = g_new (RcmGray, 1);
st->hue = 0;
st->satur = 0;
top_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_container_set_border_width (GTK_CONTAINER (top_vbox), 12);
gtk_widget_show (top_vbox);
frame = gimp_frame_new (_("Gray"));
gtk_box_pack_start (GTK_BOX (top_vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_container_add (GTK_CONTAINER (frame), vbox);
gtk_widget_show (vbox);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
st->preview = preview = gimp_preview_area_new ();
gtk_widget_set_size_request (preview, GRAY_SUM, GRAY_SUM);
gtk_container_add (GTK_CONTAINER (frame), preview);
gtk_widget_show (preview);
gtk_widget_add_events (preview, RANGE_ADJUST_MASK);
g_signal_connect_after (preview, "expose-event",
G_CALLBACK (rcm_gray_expose_event),
st);
g_signal_connect (preview, "button-press-event",
G_CALLBACK (rcm_gray_button_press_event),
st);
g_signal_connect (preview, "button-release-event",
G_CALLBACK (rcm_gray_release_event),
st);
g_signal_connect (preview, "motion-notify-event",
G_CALLBACK (rcm_gray_motion_notify_event),
st);
/* Gray: Circle: Legend */
table = gtk_table_new (2, 3, FALSE);
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
gtk_widget_show (table);
/* Gray: Circle: Spinbutton 1 */
label = gtk_label_new(_("Hue:"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (label);
st->hue = INITIAL_GRAY_HUE;
adj = (GtkAdjustment *) gtk_adjustment_new (st->hue,
0.0, 2.0, 0.0001, 0.001, 0.0);
st->hue_entry = entry = gtk_spin_button_new (adj, 0.01, 4);
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON(entry), TRUE);
gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 0, 1,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (entry);
g_signal_connect (entry, "changed",
G_CALLBACK (rcm_set_hue),
st);
/* Gray: Circle: units label */
st->hue_units_label = gtk_label_new (rcm_units_string (Current_c.Units));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_table_attach (GTK_TABLE (table), st->hue_units_label, 2, 3, 0, 1,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (st->hue_units_label);
/* Gray: Circle: Spinbutton 2 */
label = gtk_label_new (_("Saturation:"));
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (label);
st->satur = INITIAL_GRAY_SAT;
adj = (GtkAdjustment *) gtk_adjustment_new (st->satur,
0.0, 1.0, 0.0001, 0.001, 0.0);
st->satur_entry = entry = gtk_spin_button_new (adj, 0.01, 4);
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (entry), TRUE);
gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 1, 2,
GTK_FILL, GTK_FILL, 0, 2);
gtk_widget_show (entry);
g_signal_connect (entry, "changed",
G_CALLBACK (rcm_set_satur),
st);
/** Gray: Operation-Mode **/
frame = gimp_frame_new (_("Gray Mode"));
gtk_box_pack_start (GTK_BOX (top_vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
radio_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_container_add (GTK_CONTAINER (frame), radio_box);
gtk_widget_show (radio_box);
/* Gray: Operation-Mode: two radio buttons */
button = gtk_radio_button_new_with_label(group, _("Treat as this"));
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
gtk_box_pack_start (GTK_BOX (radio_box), button, FALSE, FALSE, 0);
gtk_widget_show (button);
if (Current_c.Gray_to_from == GRAY_FROM)
gtk_button_clicked (GTK_BUTTON (button));
g_signal_connect (button, "clicked",
G_CALLBACK (rcm_switch_to_gray_from),
&(Current_c.Gray_to_from));
button = gtk_radio_button_new_with_label (group, _("Change to this"));
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
gtk_box_pack_start (GTK_BOX (radio_box), button, FALSE, FALSE, 0);
gtk_widget_show (button);
if (Current_c.Gray_to_from == GRAY_TO)
gtk_button_clicked (GTK_BUTTON (button));
g_signal_connect (button, "clicked",
G_CALLBACK (rcm_switch_to_gray_to),
&(Current_c.Gray_to_from));
/** Gray: What is gray? **/
frame = gimp_frame_new (_("Gray Threshold"));
gtk_box_pack_start (GTK_BOX (top_vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
gtk_container_add (GTK_CONTAINER (frame), hbox);
gtk_widget_show (hbox);
label = gtk_label_new (_("Saturation:"));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
st->gray_sat = INITIAL_GRAY_RSAT;
adj = (GtkAdjustment *) gtk_adjustment_new (st->gray_sat,
0.0, 1.0, 0.0001, 0.001, 0.0);
entry = gtk_spin_button_new (adj, 0.01, 4);
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (entry), TRUE);
gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0);
gtk_widget_show (entry);
g_signal_connect (entry, "changed",
G_CALLBACK (rcm_set_gray_sat),
st);
return top_vbox;
}
/* Misc */
static GtkWidget *
rcm_create_units (void)
{
GtkWidget *frame;
GtkWidget *vbox;
GtkWidget *button;
GSList *group = NULL;
/** Misc: Used unit selection **/
frame = gimp_frame_new (_("Units"));
gtk_container_set_border_width (GTK_CONTAINER (frame), 12);
gtk_widget_show (frame);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_container_add (GTK_CONTAINER (frame), vbox);
gtk_widget_show (vbox);
/* Misc: Used unit selection: 3 radio buttons */
button = gtk_radio_button_new_with_label (group, _("Radians"));
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
if (Current_c.Units == RADIANS)
gtk_button_clicked (GTK_BUTTON (button));
g_signal_connect (button, "clicked",
G_CALLBACK (rcm_switch_to_radians),
NULL);
button = gtk_radio_button_new_with_label (group, _("Radians/Pi"));
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
if (Current_c.Units == RADIANS_OVER_PI)
gtk_button_clicked (GTK_BUTTON (button));
g_signal_connect (button, "clicked",
G_CALLBACK (rcm_switch_to_radians_over_PI),
NULL);
button = gtk_radio_button_new_with_label (group, _("Degrees"));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
if (Current_c.Units == DEGREES)
gtk_button_clicked (GTK_BUTTON (button));
g_signal_connect (button, "clicked",
G_CALLBACK (rcm_switch_to_degrees),
NULL);
return frame;
}
/* create and call main dialog */
gboolean
color_rotate_dialog (void)
{
GtkWidget *dialog;
GtkWidget *hbox;
GtkWidget *notebook;
GtkWidget *previews;
gboolean run;
Current_c.Bna = g_new (RcmBna, 1);
gimp_ui_init (PLUG_IN_BINARY, TRUE);
color_rotate_stock_init ();
dialog = gimp_dialog_new (_("Rotate Colors"), PLUG_IN_ROLE,
NULL, 0,
gimp_standard_help_func, PLUG_IN_PROC,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
NULL);
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
gimp_window_set_transient (GTK_WINDOW (dialog));
Current_c.Bna->dlg = dialog;
/* Create sub-dialogs */
Current_c.reduced = rcm_reduce_image (Current_c.drawable, Current_c.mask,
MAX_PREVIEW_SIZE, Current_c.Slctn);
Current_c.Bna->bna_frame = previews = rcm_create_previews ();
/* H-Box */
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
gtk_container_set_border_width (GTK_CONTAINER (hbox), 12);
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
hbox, TRUE, TRUE, 0);
gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (hbox), previews, TRUE, TRUE, 0);
/* Notebook */
notebook = gtk_notebook_new ();
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP);
gtk_box_pack_start (GTK_BOX (hbox), notebook, TRUE, TRUE, 0);
gtk_widget_show (notebook);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), rcm_create_main (),
gtk_label_new (_("Main Options")));
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), rcm_create_gray (),
gtk_label_new (_("Gray Options")));
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), rcm_create_units (),
gtk_label_new (_("Units")));
gtk_widget_show (dialog);
rcm_render_circle (Current_c.From->preview, SUM, MARGIN);
rcm_render_circle (Current_c.To->preview, SUM, MARGIN);
rcm_render_circle (Current_c.Gray->preview, GRAY_SUM, GRAY_MARGIN);
run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
gtk_widget_destroy (dialog);
return run;
}

View File

@ -1,46 +0,0 @@
/*
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This is a plug-in for GIMP.
*
* Colormap-Rotation plug-in. Exchanges two color ranges.
*
* Copyright (C) 1999 Sven Anders (anderss@fmi.uni-passau.de)
* Based on code from Pavel Grinfeld (pavel@ml.com)
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*----------------------------------------------------------------------------
* Change log:
*
* Version 2.0, 04 April 1999.
* Nearly complete rewrite, made plug-in stable.
* (Works with GIMP 1.1 and GTK+ 1.2)
*
* Version 1.0, 27 March 1997.
* Initial (unstable) release by Pavel Grinfeld
*
*----------------------------------------------------------------------------*/
/* Global defines */
#define MAX_PREVIEW_SIZE 150
/* Procedures */
gboolean color_rotate_dialog (void);

View File

@ -1,191 +0,0 @@
/*
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This is a plug-in for GIMP.
*
* Colormap-Rotation plug-in. Exchanges two color ranges.
*
* Copyright (C) 1999 Sven Anders (anderss@fmi.uni-passau.de)
* Based on code from Pavel Grinfeld (pavel@ml.com)
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*----------------------------------------------------------------------------
* Change log:
*
* Version 2.0, 04 April 1999.
* Nearly complete rewrite, made plug-in stable.
* (Works with GIMP 1.1 and GTK+ 1.2)
*
* Version 1.0, 27 March 1997.
* Initial (unstable) release by Pavel Grinfeld
*
*----------------------------------------------------------------------------*/
#include "config.h"
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#include "color-rotate.h"
#include "color-rotate-utils.h"
#include "color-rotate-dialog.h"
#include "color-rotate-draw.h"
/* Drawing routines */
void
color_rotate_draw_little_circle (cairo_t *cr,
gfloat hue,
gfloat satur)
{
gint x, y;
x = GRAY_CENTER + GRAY_RADIUS * satur * cos(hue);
y = GRAY_CENTER - GRAY_RADIUS * satur * sin(hue);
cairo_new_sub_path (cr);
cairo_arc (cr, x, y, LITTLE_RADIUS, 0, 2 * G_PI);
cairo_set_line_width (cr, 3.0);
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.6);
cairo_stroke_preserve (cr);
cairo_set_line_width (cr, 1.0);
cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.8);
cairo_stroke (cr);
}
void
color_rotate_draw_large_circle (cairo_t *cr,
gfloat gray_sat)
{
gint x, y;
x = GRAY_CENTER;
y = GRAY_CENTER;
cairo_new_sub_path (cr);
cairo_arc (cr, x, y, GRAY_RADIUS * gray_sat, 0, 2 * G_PI);
cairo_set_line_width (cr, 3.0);
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.6);
cairo_stroke_preserve (cr);
cairo_set_line_width (cr, 1.0);
cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.8);
cairo_stroke (cr);
}
#define REL 0.8
#define DEL 0.1
#define TICK 10
void
color_rotate_draw_arrows (cairo_t *cr,
RcmAngle *angle)
{
gint dist;
gfloat alpha, beta, cw_ccw, delta;
alpha = angle->alpha;
beta = angle->beta;
cw_ccw = angle->cw_ccw;
delta = angle_mod_2PI (beta - alpha);
if (cw_ccw == -1)
delta = delta - TP;
cairo_move_to (cr, CENTER, CENTER);
cairo_line_to (cr,
ROUND (CENTER + RADIUS * cos (alpha)),
ROUND (CENTER - RADIUS * sin (alpha)));
cairo_move_to (cr,
CENTER + RADIUS * cos (alpha),
CENTER - RADIUS * sin (alpha));
cairo_line_to (cr,
ROUND (CENTER + RADIUS * REL * cos (alpha - DEL)),
ROUND (CENTER - RADIUS * REL * sin (alpha - DEL)));
cairo_move_to (cr,
CENTER + RADIUS * cos (alpha),
CENTER - RADIUS * sin (alpha));
cairo_line_to (cr,
ROUND (CENTER + RADIUS * REL * cos (alpha + DEL)),
ROUND (CENTER - RADIUS * REL * sin (alpha + DEL)));
cairo_move_to (cr,
CENTER,
CENTER);
cairo_line_to (cr,
ROUND (CENTER + RADIUS * cos (beta)),
ROUND (CENTER - RADIUS * sin (beta)));
cairo_move_to (cr,
CENTER + RADIUS * cos (beta),
CENTER - RADIUS * sin (beta));
cairo_line_to (cr,
ROUND (CENTER + RADIUS * REL * cos (beta - DEL)),
ROUND (CENTER - RADIUS * REL * sin (beta - DEL)));
cairo_move_to (cr,
CENTER + RADIUS * cos (beta),
CENTER - RADIUS * sin (beta));
cairo_line_to (cr,
ROUND (CENTER + RADIUS * REL * cos (beta + DEL)),
ROUND (CENTER - RADIUS * REL * sin (beta + DEL)));
dist = RADIUS * EACH_OR_BOTH;
cairo_move_to (cr,
CENTER + dist * cos (beta),
CENTER - dist * sin (beta));
cairo_line_to (cr,
ROUND (CENTER + dist * cos(beta) + cw_ccw * TICK * sin (beta)),
ROUND (CENTER - dist * sin(beta) + cw_ccw * TICK * cos (beta)));
cairo_new_sub_path (cr);
if (cw_ccw > 0)
{
cairo_arc_negative (cr,
CENTER,
CENTER,
dist,
-alpha,
-beta);
}
else
{
cairo_arc (cr,
CENTER,
CENTER,
dist,
-alpha,
-beta);
}
cairo_set_line_width (cr, 3.0);
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.6);
cairo_stroke_preserve (cr);
cairo_set_line_width (cr, 1.0);
cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.8);
cairo_stroke (cr);
}

View File

@ -1,61 +0,0 @@
/*
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This is a plug-in for GIMP.
*
* Colormap-Rotation plug-in. Exchanges two color ranges.
*
* Copyright (C) 1999 Sven Anders (anderss@fmi.uni-passau.de)
* Based on code from Pavel Grinfeld (pavel@ml.com)
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*----------------------------------------------------------------------------
* Change log:
*
* Version 2.0, 04 April 1999.
* Nearly complete rewrite, made plug-in stable.
* (Works with GIMP 1.1 and GTK+ 1.2)
*
* Version 1.0, 27 March 1997.
* Initial (unstable) release by Pavel Grinfeld
*
*----------------------------------------------------------------------------*/
/* Global defines */
#define RADIUS 60
#define MARGIN 4
#define SUM (2*RADIUS + 2*MARGIN)
#define CENTER (SUM/2)
#define GRAY_RADIUS 60
#define GRAY_MARGIN 3
#define GRAY_SUM (2*GRAY_RADIUS + 2*GRAY_MARGIN)
#define GRAY_CENTER (GRAY_SUM/2)
#define LITTLE_RADIUS 3
#define EACH_OR_BOTH 0.3
void color_rotate_draw_little_circle (cairo_t *cr,
gfloat hue,
gfloat satur);
void color_rotate_draw_large_circle (cairo_t *cr,
gfloat gray_sat);
void color_rotate_draw_arrows (cairo_t *cr,
RcmAngle *angle);

View File

@ -1,98 +0,0 @@
/*
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gtk/gtk.h>
#include "color-rotate-stock.h"
#include "images/color-rotate-stock-pixbufs.h"
#include "libgimp/stdplugins-intl.h"
static GtkIconFactory *color_rotate_icon_factory = NULL;
static GtkStockItem color_rotate_stock_items[] =
{
{ STOCK_COLOR_ROTATE_SWITCH_CLOCKWISE,
N_("Switch to Clockwise"), 0, 0, NULL },
{ STOCK_COLOR_ROTATE_SWITCH_COUNTERCLOCKWISE,
N_("Switch to C/Clockwise"), 0, 0, NULL },
{ STOCK_COLOR_ROTATE_CHANGE_ORDER,
N_("Change Order of Arrows"), 0, 0, NULL },
{ STOCK_COLOR_ROTATE_SELECT_ALL,
N_("Select All"), 0, 0, NULL }
};
static void
add_stock_icon (const gchar *stock_id,
GtkIconSize size,
const guint8 *inline_data)
{
GtkIconSource *source;
GtkIconSet *set;
GdkPixbuf *pixbuf;
source = gtk_icon_source_new ();
gtk_icon_source_set_size (source, size);
gtk_icon_source_set_size_wildcarded (source, FALSE);
pixbuf = gdk_pixbuf_new_from_inline (-1, inline_data, FALSE, NULL);
gtk_icon_source_set_pixbuf (source, pixbuf);
g_object_unref (pixbuf);
set = gtk_icon_set_new ();
gtk_icon_set_add_source (set, source);
gtk_icon_source_free (source);
gtk_icon_factory_add (color_rotate_icon_factory, stock_id, set);
gtk_icon_set_unref (set);
}
void
color_rotate_stock_init (void)
{
static gboolean initialized = FALSE;
if (initialized)
return;
color_rotate_icon_factory = gtk_icon_factory_new ();
add_stock_icon (STOCK_COLOR_ROTATE_SWITCH_CLOCKWISE,
GTK_ICON_SIZE_BUTTON, color_rotate_cw);
add_stock_icon (STOCK_COLOR_ROTATE_SWITCH_COUNTERCLOCKWISE,
GTK_ICON_SIZE_BUTTON, color_rotate_ccw);
add_stock_icon (STOCK_COLOR_ROTATE_CHANGE_ORDER,
GTK_ICON_SIZE_BUTTON, color_rotate_a_b);
add_stock_icon (STOCK_COLOR_ROTATE_SELECT_ALL,
GTK_ICON_SIZE_BUTTON, color_rotate_360);
gtk_icon_factory_add_default (color_rotate_icon_factory);
gtk_stock_add_static (color_rotate_stock_items,
G_N_ELEMENTS (color_rotate_stock_items));
initialized = TRUE;
}

View File

@ -1,31 +0,0 @@
/*
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __COLOR_ROTATE_STOCK_H__
#define __COLOR_ROTATE_STOCK_H__
#define STOCK_COLOR_ROTATE_SWITCH_CLOCKWISE "color_rotate_cw"
#define STOCK_COLOR_ROTATE_SWITCH_COUNTERCLOCKWISE "color_rotate_ccw"
#define STOCK_COLOR_ROTATE_CHANGE_ORDER "color_rotate_a_b"
#define STOCK_COLOR_ROTATE_SELECT_ALL "color_rotate_360"
void color_rotate_stock_init (void);
#endif /* __COLOR_ROTATE_STOCK_H__ */

View File

@ -1,481 +0,0 @@
/*
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This is a plug-in for GIMP.
*
* Colormap-Rotation plug-in. Exchanges two color ranges.
*
* Copyright (C) 1999 Sven Anders (anderss@fmi.uni-passau.de)
* Based on code from Pavel Grinfeld (pavel@ml.com)
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*----------------------------------------------------------------------------
* Change log:
*
* Version 2.0, 04 April 1999.
* Nearly complete rewrite, made plug-in stable.
* (Works with GIMP 1.1 and GTK+ 1.2)
*
* Version 1.0, 27 March 1997.
* Initial (unstable) release by Pavel Grinfeld
*
*----------------------------------------------------------------------------*/
#include "config.h"
#include "libgimp/gimp.h"
#include "libgimp/gimpui.h"
#include "color-rotate.h"
#include "color-rotate-utils.h"
#include "color-rotate-draw.h"
float
arctg (float y,
float x)
{
float temp = atan2(y,x);
return (temp<0) ? (temp+TP) : temp;
}
float
min_prox (float alpha,
float beta,
float angle)
{
gfloat temp1 = MIN (angle_mod_2PI (alpha - angle),
TP - angle_mod_2PI (alpha - angle));
gfloat temp2 = MIN (angle_mod_2PI (beta - angle),
TP - angle_mod_2PI (beta - angle));
return MIN(temp1, temp2);
}
float*
closest (float *alpha,
float *beta,
float angle)
{
gfloat temp_alpha = MIN (angle_mod_2PI (*alpha-angle),
TP - angle_mod_2PI (*alpha-angle));
gfloat temp_beta = MIN (angle_mod_2PI (*beta -angle),
TP - angle_mod_2PI (*beta -angle));
if (temp_alpha-temp_beta < 0)
return alpha;
else
return beta;
}
float
angle_mod_2PI (float angle)
{
if (angle < 0)
return angle + TP;
else if (angle > TP)
return angle - TP;
else
return angle;
}
/* supporting routines */
float
rcm_linear (float A,
float B,
float C,
float D,
float x)
{
if (B > A)
{
if (A<=x && x<=B)
return C+(D-C)/(B-A)*(x-A);
else if (A<=x+TP && x+TP<=B)
return C+(D-C)/(B-A)*(x+TP-A);
else
return x;
}
else
{
if (B<=x && x<=A)
return C+(D-C)/(B-A)*(x-A);
else if (B<=x+TP && x+TP<=A)
return C+(D-C)/(B-A)*(x+TP-A);
else
return x;
}
}
float
rcm_left_end (RcmAngle *angle)
{
gfloat alpha = angle->alpha;
gfloat beta = angle->beta;
gint cw_ccw = angle->cw_ccw;
switch (cw_ccw)
{
case (-1):
if (alpha < beta) return alpha + TP;
default:
return alpha; /* 1 */
}
}
float
rcm_right_end (RcmAngle *angle)
{
gfloat alpha = angle->alpha;
gfloat beta = angle->beta;
gint cw_ccw = angle->cw_ccw;
switch (cw_ccw)
{
case 1:
if (beta < alpha) return beta + TP;
default:
return beta; /* -1 */
}
}
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));
}
gboolean
rcm_is_gray (float s)
{
return (s <= Current_c.Gray->gray_sat);
}
/* reduce image/selection for preview */
ReducedImage*
rcm_reduce_image (GimpDrawable *drawable,
GimpDrawable *mask,
gint LongerSize,
gint Slctn)
{
guint32 image;
GimpPixelRgn srcPR, srcMask;
ReducedImage *temp;
guchar *tempRGB, *src_row, *tempmask, *src_mask_row;
gint i, j, x1, x2, y1, y2;
gint RH, RW, width, height, bytes;
gboolean NoSelectionMade;
gint offx, offy;
gdouble *tempHSV, H, S, V;
bytes = drawable->bpp;
temp = g_new0 (ReducedImage, 1);
/* get bounds of image or selection */
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
if (((x2-x1) != drawable->width) || ((y2-y1) != drawable->height))
NoSelectionMade = FALSE;
else
NoSelectionMade = TRUE;
switch (Slctn)
{
case ENTIRE_IMAGE:
x1 = 0;
x2 = drawable->width;
y1 = 0;
y2 = drawable->height;
break;
case SELECTION_IN_CONTEXT:
x1 = MAX (0, x1 - (x2-x1) / 2.0);
x2 = MIN (drawable->width, x2 + (x2-x1) / 2.0);
y1 = MAX (0, y1 - (y2-y1) / 2.0);
y2 = MIN (drawable->height, y2 + (y2-y1) / 2.0);
break;
default:
break; /* take selection dimensions */
}
/* clamp to image size since this is the size of the mask */
gimp_drawable_offsets (drawable->drawable_id, &offx, &offy);
image = gimp_item_get_image (drawable->drawable_id);
x1 = CLAMP (x1, - offx, gimp_image_width (image) - offx);
x2 = CLAMP (x2, - offx, gimp_image_width (image) - offx);
y1 = CLAMP (y1, - offy, gimp_image_height (image) - offy);
y2 = CLAMP (y2, - offy, gimp_image_height (image) - offy);
/* calculate size of preview */
width = x2 - x1;
height = y2 - y1;
if (width < 1 || height < 1)
return temp;
if (width > height)
{
RW = LongerSize;
RH = (float) height * (float) LongerSize / (float) width;
}
else
{
RH = LongerSize;
RW = (float)width * (float) LongerSize / (float) height;
}
/* allocate memory */
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 + offx, y1 + offy, width, height, FALSE, FALSE);
src_row = g_new (guchar, width * bytes);
src_mask_row = g_new (guchar, width * bytes);
/* reduce image */
for (i = 0; i < RH; i++)
{
gint whichcol, whichrow;
whichrow = (float)i * (float)height / (float)RH;
gimp_pixel_rgn_get_row (&srcPR, src_row, x1, y1 + whichrow, width);
gimp_pixel_rgn_get_row (&srcMask, src_mask_row,
x1 + offx, y1 + offy + whichrow, width);
for (j = 0; j < RW; j++)
{
whichcol = (float)j * (float)width / (float)RW;
if (NoSelectionMade)
tempmask[i*RW+j] = 255;
else
tempmask[i*RW+j] = src_mask_row[whichcol];
gimp_rgb_to_hsv4 (&src_row[whichcol*bytes], &H, &S, &V);
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;
tempHSV[i*RW*bytes+j*bytes+2] = V;
if (bytes == 4)
tempRGB[i*RW*bytes+j*bytes+3] = src_row[whichcol*bytes+3];
}
}
/* return values */
temp->width = RW;
temp->height = RH;
temp->rgb = tempRGB;
temp->hsv = tempHSV;
temp->mask = tempmask;
return temp;
}
/* render before/after preview */
void
rcm_render_preview (GtkWidget *preview)
{
ReducedImage *reduced;
gint version;
gint RW, RH, bytes, i, j;
guchar *a;
guchar *rgb_array;
gdouble *hsv_array;
gfloat degree;
g_return_if_fail (preview != NULL);
version = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (preview), "mode"));
reduced = Current_c.reduced;
RW = reduced->width;
RH = reduced->height;
bytes = Current_c.drawable->bpp;
hsv_array = reduced->hsv;
rgb_array = reduced->rgb;
a = g_new (guchar, 4 * RW * RH);
if (version == CURRENT)
{
gdouble H, S, V;
guchar rgb[3];
for (i = 0; i < RH; i++)
{
for (j = 0; j < RW; j++)
{
gboolean unchanged = FALSE;
gboolean skip = FALSE;
H = hsv_array[i*RW*bytes + j*bytes + 0];
S = hsv_array[i*RW*bytes + j*bytes + 1];
V = hsv_array[i*RW*bytes + j*bytes + 2];
if (rcm_is_gray(S) && (reduced->mask[i*RW+j] != 0))
{
switch (Current_c.Gray_to_from)
{
case GRAY_FROM:
if (rcm_angle_inside_slice (Current_c.Gray->hue,
Current_c.From->angle) <= 1)
{
H = Current_c.Gray->hue/TP;
S = Current_c.Gray->satur;
}
else
skip = TRUE;
break;
case GRAY_TO:
unchanged = FALSE;
skip = TRUE;
gimp_hsv_to_rgb4 (rgb,
Current_c.Gray->hue/TP,
Current_c.Gray->satur,
V);
break;
default:
break;
}
}
if (!skip)
{
unchanged = FALSE;
H = rcm_linear (rcm_left_end (Current_c.From->angle),
rcm_right_end (Current_c.From->angle),
rcm_left_end (Current_c.To->angle),
rcm_right_end (Current_c.To->angle),
H * TP);
H = angle_mod_2PI(H) / TP;
gimp_hsv_to_rgb4 (rgb, H,S,V);
}
if (unchanged)
degree = 0;
else
degree = reduced->mask[i*RW+j] / 255.0;
a[(i*RW+j)*4+0] = (1-degree) * rgb_array[i*RW*bytes + j*bytes + 0] + degree * rgb[0];
a[(i*RW+j)*4+1] = (1-degree) * rgb_array[i*RW*bytes + j*bytes + 1] + degree * rgb[1];
a[(i*RW+j)*4+2] = (1-degree) * rgb_array[i*RW*bytes + j*bytes + 2] + degree * rgb[2];
/* apply transparency */
if (bytes == 4)
a[(i*RW+j)*4+3] = rgb_array[i*RW*bytes+j*bytes+3];
else
a[(i*RW+j)*4+3] = 255;
}
}
}
else /* ORIGINAL */
{
for (i = 0; i < RH; i++)
{
for (j = 0; j < RW; j++)
{
a[(i*RW+j)*4+0] = rgb_array[i*RW*bytes + j*bytes + 0];
a[(i*RW+j)*4+1] = rgb_array[i*RW*bytes + j*bytes + 1];
a[(i*RW+j)*4+2] = rgb_array[i*RW*bytes + j*bytes + 2];
if (bytes == 4)
a[(i*RW+j)*4+3] = rgb_array[i*RW*bytes+j*bytes+3];
else
a[(i*RW+j)*4+3] = 255;
}
}
}
gimp_preview_area_draw (GIMP_PREVIEW_AREA (preview),
0, 0, RW, RH,
GIMP_RGBA_IMAGE,
a,
RW * 4);
g_free (a);
}
/* render circle */
void
rcm_render_circle (GtkWidget *preview,
int sum,
int margin)
{
gint i, j;
gdouble h, s, v;
guchar *a;
if (preview == NULL) return;
a = g_new (guchar, 3*sum*sum);
for (j = 0; j < sum; j++)
{
for (i = 0; i < sum; i++)
{
s = sqrt ((SQR (i - sum / 2.0) + SQR (j - sum / 2.0)) / (float) SQR (sum / 2.0 - margin));
if (s > 1)
{
a[(j*sum+i)*3+0] = 255;
a[(j*sum+i)*3+1] = 255;
a[(j*sum+i)*3+2] = 255;
}
else
{
h = arctg (sum / 2.0 - j, i - sum / 2.0) / (2 * G_PI);
v = 1 - sqrt (s) / 4;
gimp_hsv_to_rgb4 (&a[(j*sum+i)*3], h, s, v);
}
}
}
gimp_preview_area_draw (GIMP_PREVIEW_AREA (preview),
0, 0, sum, sum,
GIMP_RGB_IMAGE,
a,
sum * 3);
g_free (a);
}

View File

@ -1,76 +0,0 @@
/*
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This is a plug-in for GIMP.
*
* Colormap-Rotation plug-in. Exchanges two color ranges.
*
* Copyright (C) 1999 Sven Anders (anderss@fmi.uni-passau.de)
* Based on code from Pavel Grinfeld (pavel@ml.com)
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*----------------------------------------------------------------------------
* Change log:
*
* Version 2.0, 04 April 1999.
* Nearly complete rewrite, made plug-in stable.
* (Works with GIMP 1.1 and GTK+ 1.2)
*
* Version 1.0, 27 March 1997.
* Initial (unstable) release by Pavel Grinfeld
*
*----------------------------------------------------------------------------*/
/* Global defines */
#define SWAP(X,Y) {float t=X; X=Y; Y=t;}
/* used in 'rcm_callback.c' and 'rcm_dialog.c' */
float arctg (gfloat y,
gfloat x);
float min_prox (gfloat alpha,
gfloat beta,
gfloat angle);
float *closest (gfloat *alpha,
gfloat *beta,
gfloat angle);
float angle_mod_2PI (gfloat angle);
ReducedImage *rcm_reduce_image (GimpDrawable *drawable,
GimpDrawable *mask,
gint longer_size,
gint selection);
void rcm_render_preview (GtkWidget *preview);
void rcm_render_circle (GtkWidget *preview,
gint sum,
gint margin);
/* only used in 'rcm.c' (or local) */
float rcm_angle_inside_slice (float angle,
RcmAngle *slice);
gint rcm_is_gray (float s);
float rcm_linear (float,
float,
float,
float,
float);
float rcm_left_end (RcmAngle *angle);
float rcm_right_end (RcmAngle *angle);

View File

@ -1,285 +0,0 @@
/*
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This is a plug-in for GIMP.
*
* Colormap-Rotation plug-in. Exchanges two color ranges.
*
* Copyright (C) 1999 Sven Anders (anderss@fmi.uni-passau.de)
* Based on code from Pavel Grinfeld (pavel@ml.com)
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*----------------------------------------------------------------------------
* Change log:
*
* Version 2.0, 04 April 1999.
* Nearly complete rewrite, made plug-in stable.
* (Works with GIMP 1.1 and GTK+ 1.2)
*
* Version 1.0, 27 March 1997.
* Initial (unstable) release by Pavel Grinfeld
*
*----------------------------------------------------------------------------*/
#include "config.h"
#include "libgimp/gimp.h"
#include "libgimp/gimpui.h"
#include "color-rotate.h"
#include "color-rotate-utils.h"
#include "color-rotate-dialog.h"
#include "color-rotate-callbacks.h"
#include "libgimp/stdplugins-intl.h"
/* Forward declarations */
static void query (void);
static void run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals);
static void color_rotate (GimpDrawable *drawable);
/* Global variables */
RcmParams Current_c =
{
SELECTION, /* SELECTION ONLY */
TRUE, /* REAL TIME */
DEGREES, /* START IN DEGREES */
GRAY_TO
};
const GimpPlugInInfo PLUG_IN_INFO =
{
NULL, /* init_proc */
NULL, /* quit_proc */
query, /* query_proc */
run, /* run_proc */
};
MAIN()
/* Query plug-in */
static void
query (void)
{
GimpParamDef args[] =
{
{ GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" },
{ GIMP_PDB_IMAGE, "image", "Input image (used for indexed images)" },
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
};
gimp_install_procedure (PLUG_IN_PROC,
N_("Replace a range of colors with another"),
"Exchanges two color ranges. "
"Based on code from Pavel Grinfeld (pavel@ml.com). "
"This version written by Sven Anders (anderss@fmi.uni-passau.de).",
"Sven Anders (anderss@fmi.uni-passau.de) and Pavel Grinfeld (pavel@ml.com)",
"Sven Anders (anderss@fmi.uni-passau.de)",
"04th April 1999",
N_("_Rotate Colors..."),
"RGB*",
GIMP_PLUGIN,
G_N_ELEMENTS (args), 0,
args, NULL);
gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/Colors/Map");
}
static void
run (const gchar *name,
gint nparams,
const GimpParam *param,
gint *nreturn_vals,
GimpParam **return_vals)
{
static GimpParam values[1];
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
*nreturn_vals = 1;
*return_vals = values;
INIT_I18N ();
values[0].type = GIMP_PDB_STATUS;
values[0].data.d_status = status;
Current_c.drawable = gimp_drawable_get (param[2].data.d_drawable);
Current_c.mask = gimp_drawable_get (gimp_image_get_selection (param[1].data.d_image));
if (gimp_drawable_is_rgb (Current_c.drawable->drawable_id))
{
if (color_rotate_dialog ())
{
gimp_progress_init (_("Rotating the colors"));
gimp_tile_cache_ntiles (2 * (Current_c.drawable->width /
gimp_tile_width () + 1));
color_rotate (Current_c.drawable);
gimp_displays_flush ();
}
else
{
status = GIMP_PDB_CANCEL;
}
}
else
{
status = GIMP_PDB_EXECUTION_ERROR;
}
values[0].data.d_status = status;
if (status == GIMP_PDB_SUCCESS)
gimp_drawable_detach (Current_c.drawable);
}
/* Rotate colors of a single row */
static void
color_rotate_row (const guchar *src_row,
guchar *dest_row,
gint row,
gint row_width,
gint bytes)
{
gint col, bytenum;
gdouble H, S, V;
guchar rgb[3];
for (col = 0; col < row_width; col++)
{
gboolean skip = FALSE;
rgb[0] = src_row[col * bytes + 0];
rgb[1] = src_row[col * bytes + 1];
rgb[2] = src_row[col * bytes + 2];
gimp_rgb_to_hsv4 (rgb, &H, &S, &V);
if (rcm_is_gray (S))
{
if (Current_c.Gray_to_from == GRAY_FROM)
{
if (rcm_angle_inside_slice (Current_c.Gray->hue,
Current_c.From->angle) <= 1)
{
H = Current_c.Gray->hue / TP;
S = Current_c.Gray->satur;
}
else
{
skip = TRUE;
}
}
else
{
skip = TRUE;
gimp_hsv_to_rgb4 (rgb, Current_c.Gray->hue / TP,
Current_c.Gray->satur, V);
}
}
if (! skip)
{
H = rcm_linear (rcm_left_end (Current_c.From->angle),
rcm_right_end (Current_c.From->angle),
rcm_left_end (Current_c.To->angle),
rcm_right_end (Current_c.To->angle),
H * TP);
H = angle_mod_2PI (H) / TP;
gimp_hsv_to_rgb4 (rgb, H, S, V);
}
dest_row[col * bytes + 0] = rgb[0];
dest_row[col * bytes + 1] = rgb[1];
dest_row[col * bytes + 2] = rgb[2];
if (bytes > 3)
{
for (bytenum = 3; bytenum < bytes; bytenum++)
dest_row[col * bytes + bytenum] = src_row[col * bytes + bytenum];
}
}
}
/* Rotate colors row by row ... */
static void
color_rotate (GimpDrawable *drawable)
{
GimpPixelRgn srcPR, destPR;
gint width, height;
gint bytes;
guchar *src_row, *dest_row;
gint row;
gint x, y;
if (! gimp_drawable_mask_intersect (drawable->drawable_id,
&x, &y, &width, &height))
{
return;
}
bytes = drawable->bpp;
src_row = g_new (guchar, width * bytes);
dest_row = g_new (guchar, width * bytes);
gimp_pixel_rgn_init (&srcPR, drawable, 0, 0,
drawable->width,
drawable->height, FALSE, FALSE);
gimp_pixel_rgn_init (&destPR, drawable, 0, 0,
drawable->width,
drawable->height, TRUE, TRUE);
for (row = y; row < (y + height); row++)
{
gimp_pixel_rgn_get_row (&srcPR, src_row, x, row, width);
color_rotate_row (src_row, dest_row, row, width, bytes);
gimp_pixel_rgn_set_row (&destPR, dest_row, x, row, width);
if ((row % 10) == 0)
gimp_progress_update ((double) row / (double) height);
}
/* update the processed region */
gimp_progress_update (1.0);
gimp_drawable_flush (drawable);
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
gimp_drawable_update (drawable->drawable_id, x, y, width, height);
g_free (src_row);
g_free (dest_row);
}

View File

@ -1,136 +0,0 @@
/*
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This is a plug-in for GIMP.
*
* Colormap-Rotation plug-in. Exchanges two color ranges.
*
* Copyright (C) 1999 Sven Anders (anderss@fmi.uni-passau.de)
* Based on code from Pavel Grinfeld (pavel@ml.com)
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*----------------------------------------------------------------------------
* Change log:
*
* Version 2.0, 04 April 1999.
* Nearly complete rewrite, made plug-in stable.
* (Works with GIMP 1.1 and GTK+ 1.2)
*
* Version 1.0, 27 March 1997.
* Initial (unstable) release by Pavel Grinfeld
*
*----------------------------------------------------------------------------*/
/* Global defines */
#define PLUG_IN_PROC "plug-in-rotate-colormap"
#define PLUG_IN_BINARY "rcm"
#define PLUG_IN_ROLE "gimp-rcm"
#define TP (2*G_PI)
/* Typedefs */
enum { ENTIRE_IMAGE, SELECTION, SELECTION_IN_CONTEXT, PREVIEW_OPTIONS };
enum { EACH, BOTH, DEGREES, RADIANS, RADIANS_OVER_PI,
GRAY_FROM, GRAY_TO, CURRENT, ORIGINAL };
typedef enum { VIRGIN, DRAG_START, DRAGING, DO_NOTHING } RcmOp;
typedef struct
{
gfloat alpha;
gfloat beta;
gint cw_ccw;
} RcmAngle;
typedef struct
{
gint width;
gint height;
guchar *rgb;
gdouble *hsv;
guchar *mask;
} ReducedImage;
typedef struct
{
GtkWidget *preview;
GtkWidget *frame;
GtkWidget *table;
GtkWidget *cw_ccw_button;
GtkWidget *cw_ccw_box;
GtkWidget *cw_ccw_label;
GtkWidget *cw_ccw_pixmap;
GtkWidget *a_b_button;
GtkWidget *a_b_box;
GtkWidget *a_b_pixmap;
GtkWidget *f360_button;
GtkWidget *f360_box;
GtkWidget *f360_pixmap;
GtkWidget *alpha_entry;
GtkWidget *alpha_units_label;
GtkWidget *beta_entry;
GtkWidget *beta_units_label;
gfloat *target;
gint mode;
RcmAngle *angle;
gfloat prev_clicked;
} RcmCircle;
typedef struct
{
GtkWidget *dlg;
GtkWidget *bna_frame;
GtkWidget *before;
GtkWidget *after;
} RcmBna;
typedef struct
{
GtkWidget *preview;
GtkWidget *frame;
gfloat gray_sat;
gfloat hue;
gfloat satur;
GtkWidget *hue_entry;
GtkWidget *hue_units_label;
GtkWidget *satur_entry;
RcmOp action_flag;
} RcmGray;
typedef struct
{
gint Slctn;
gint RealTime;
gint Units;
gint Gray_to_from;
GimpDrawable *drawable;
GimpDrawable *mask;
ReducedImage *reduced;
RcmCircle *To;
RcmCircle *From;
RcmGray *Gray;
RcmBna *Bna;
} RcmParams;
/* Global variables */
extern RcmParams Current_c;

View File

@ -1,4 +0,0 @@
/Makefile
/Makefile.in
/stock-icons.list
/color-rotate-stock-pixbufs.h

View File

@ -1,23 +0,0 @@
## Process this file with automake to produce Makefile.in
STOCK_IMAGES = \
color-rotate-360.png \
color-rotate-a-b.png \
color-rotate-ccw.png \
color-rotate-cw.png
EXTRA_DIST = $(STOCK_IMAGES)
noinst_DATA = color-rotate-stock-pixbufs.h
CLEANFILES = $(noinst_DATA) stock-icons.list
stock-icons.list: $(STOCK_IMAGES) Makefile.am
( rm -f $@; \
for image in $(STOCK_IMAGES); do \
echo $$image | \
sed -e 's|.*/||' -e 's|-|_|g' -e 's|\.png$$||' >> $@; \
echo " $(srcdir)/$$image" >> $@; \
done )
$(srcdir)/color-rotate-stock-pixbufs.h: stock-icons.list
$(GDK_PIXBUF_CSOURCE) --raw --build-list `cat stock-icons.list` > $(@F)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 240 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 233 B