Clean-up of filter pack plug-in

This commit is contained in:
Maurits Rijk
2004-05-06 17:59:21 +00:00
parent c4bd3139a6
commit 4549d5a902
8 changed files with 3666 additions and 2261 deletions

View File

@ -1,3 +1,15 @@
2004-05-06 Maurits Rijk <m.rijk@chello.nl>
* plug-ins/fp/fp_gdk.c
* plug-ins/fp/fp_gtk.c
* plug-ins/fp/fp_misc.c
* plug-ins/fp/fp.h: removed
* plug-ins/fp/Makefile.am: changed accordingly
* plug-ins/fp/fp.c: merged into one single file to get rid of all
global variables and functions. Major clean-up. Still more to come.
2004-05-06 Sven Neumann <sven@gimp.org>
* app/gui/about-dialog.c: center the about dialog on the monitor,
@ -1898,7 +1910,7 @@
* app/core/gimppalette-import.[ch]
* app/gui/palette-import-dialog.c: added palette import from RIFF
palette files based on a patch from ÉRDI Gergõ (bug #129788).
palette files based on a patch from <EFBFBD>ÉRDI Gerg<EFBFBD>Á<EFBFBD> (bug #129788).
2004-04-15 Michael Natterer <mitch@gimp.org>
@ -2095,7 +2107,7 @@
* app/pdb/*_cmds.c: regenerated.
2004-04-14 Raphaël Quinet <quinet@gamers.org>
2004-04-14 Rapha<EFBFBD>Á<EFBFBD>l Quinet <quinet@gamers.org>
* plug-ins/script-fu/scripts/copy-visible.scm: New version of the
script that works on a temporary copy of the image instead of
@ -2115,7 +2127,7 @@
* Made 2.0.1 release.
2004-04-13 Raphaël Quinet <quinet@gamers.org>
2004-04-13 Rapha<EFBFBD>Á<EFBFBD>l Quinet <quinet@gamers.org>
* plug-ins/common/mng.c (query, run): Workaround for bug #139947:
do not register the plug-in for INDEXED* modes and do not declare
@ -2294,11 +2306,11 @@
* configure.in (ALL_LINGUAS): revert addition of "is" until all
.po files are there.
2004-04-07 Samúel Jón Gunnarsson <sammi@techattack.nu>
2004-04-07 Sam<EFBFBD>Á<EFBFBD>el J<EFBFBD>Á<EFBFBD>n Gunnarsson <sammi@techattack.nu>
* configure.in: Added "is" to ALL_LINGUAS
2004-04-06 Iñaki Larrañaga <dooteo@euskalgnu.org>
2004-04-06 I<EFBFBD>Á<EFBFBD>aki Larra<EFBFBD>Á<EFBFBD>aga <dooteo@euskalgnu.org>
* configure.in: Added "eu" (Basque) to ALL_LINGUAS.

File diff suppressed because it is too large Load Diff

View File

@ -17,11 +17,7 @@ libexecdir = $(gimpplugindir)/plug-ins
libexec_PROGRAMS = fp
fp_SOURCES = \
fp.c \
fp.h \
fp_gdk.c \
fp_gtk.c \
fp_misc.c
fp.c
INCLUDES = \
-I$(top_srcdir) \

File diff suppressed because it is too large Load Diff

View File

@ -1,218 +0,0 @@
#define MAX_PREVIEW_SIZE 125
#define MAX_ROUGHNESS 128
#define RANGE_HEIGHT 15
#define PR_BX_BRDR 4
#define ALL 255
#define MARGIN 4
#define HELP_ID "plug-in-filter-pack"
#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
typedef struct {
gint run;
} fpInterface;
typedef struct {
gint width;
gint height;
guchar *rgb;
gdouble *hsv;
guchar *mask;
} ReducedImage;
typedef enum {
SHADOWS,
MIDTONES,
HIGHLIGHTS,
INTENSITIES
}FP_Intensity;
enum {
NONEATALL =0,
CURRENT =1,
HUE =2,
SATURATION =4,
VALUE =8
};
enum {
RED,
GREEN,
BLUE,
CYAN,
YELLOW,
MAGENTA,
ALL_PRIMARY
};
enum {
DOWN = -1,
UP = 1
};
enum {
BY_HUE,
BY_SAT,
BY_VAL,
JUDGE_BY
};
typedef struct {
GtkWidget *window;
GtkWidget *shadowsEntry;
GtkWidget *midtonesEntry;
GtkWidget *rangePreview;
GtkWidget *aliasingPreview;
GtkObject *aliasingData;
GtkWidget *aliasingGraph;
} AdvancedWindow;
typedef struct {
int Color;
float Rough;
GtkWidget *roughnessScale;
float Alias;
GtkWidget *aliasingScale;
float PreviewSize;
GtkWidget *previewSizeScale;
FP_Intensity Range;
gint ValueBy;
gint SlctnOnly;
gint RealTime;
guchar Offset;
guchar VisibleFrames;
guchar Cutoffs[INTENSITIES];
gint Touched[JUDGE_BY];
gint redAdj[JUDGE_BY][256];
gint blueAdj[JUDGE_BY][256];
gint greenAdj[JUDGE_BY][256];
gint satAdj[JUDGE_BY][256];
GtkWidget *rangeLabels[12];
}FP_Params;
GtkWidget *fp_create_bna(void);
GtkWidget *fp_create_rough(void);
GtkWidget *fp_create_range(void);
GtkWidget *fp_create_circle_palette(void);
GtkWidget *fp_create_lnd(void);
GtkWidget *fp_create_show(void);
GtkWidget *fp_create_msnls();
GtkWidget *fp_create_frame_select();
GtkWidget *fp_create_pixels_select_by();
void fp_show_hide_frame(GtkWidget *button,
GtkWidget *frame);
ReducedImage *Reduce_The_Image (GimpDrawable *,
GimpDrawable *,
gint,
gint);
void fp_render_preview (GtkWidget *,
gint,
gint );
void Update_Current_FP (gint,
gint );
void fp_Create_Nudge (gint* );
gint fp_dialog (void);
void fp_advanced_dialog (void);
void fp_advanced_call (void);
void fp_entire_image (GtkWidget *,
gpointer );
void fp_selection_only (GtkWidget *,
gpointer );
void fp_selection_in_context (GtkWidget *,
gpointer );
void selectionMade (GtkWidget *,
gpointer );
void fp_close_callback (GtkWidget *,
gpointer );
void fp_ok_callback (GtkWidget *,
gpointer );
void fp_scale_update (GtkAdjustment *,
float* );
void fp_change_current_range (GtkAdjustment*,
gint* );
void fp_change_current_pixels_by (GtkWidget *,
gint *);
void resetFilterPacks (void);
void update_range_labels (void);
void fp_create_smoothness_graph (GtkWidget* );
void fp_range_preview_spill (GtkWidget*,
gint );
void Create_A_Preview (GtkWidget **,
GtkWidget **,
int,
int );
void Create_A_Table_Entry (GtkWidget **,
GtkWidget *,
const gchar *);
GSList* Button_In_A_Box (GtkWidget *,
GSList *,
const gchar *,
GtkSignalFunc,
gpointer,
int );
void Check_Button_In_A_Box (GtkWidget *,
const gchar *label,
GtkSignalFunc func,
gpointer data,
int clicked);
void Frames_Check_Button_In_A_Box (GtkWidget *,
const gchar *label,
GtkSignalFunc func,
GtkWidget *frame,
int clicked);
void Adjust_Preview_Sizes (int width,
int height );
void refreshPreviews (int);
void initializeFilterPacks (void);
void fp (GimpDrawable *drawable);
void fp_row (const guchar *src_row,
guchar *dest_row,
gint row,
gint row_width,
gint bytes);
void draw_slider (GdkWindow *window,
GdkGC *border_gc,
GdkGC *fill_gc,
int xpos);
gint FP_Range_Change_Events (GtkWidget *,
GdkEvent *,
FP_Params *);
void As_You_Drag (GtkWidget *button);
void preview_size_scale_update (GtkAdjustment *adjustment,
float *scale_val);
void fp_advanced_ok();
gint fp_fake_transparency(gint i, gint j);

View File

@ -1,171 +0,0 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include "libgimp/gimp.h"
#include "fp.h"
extern AdvancedWindow AW;
extern FP_Params Current;
extern gint nudgeArray[256];
void
slider_erase (GdkWindow *window,
int xpos)
{
gdk_window_clear_area (window, MARGIN + xpos - (RANGE_HEIGHT - 1) / 2, 0,
RANGE_HEIGHT, RANGE_HEIGHT);
}
void
draw_slider(GdkWindow *window,
GdkGC *border_gc,
GdkGC *fill_gc,
int xpos)
{
gint i;
for (i = 0; i < RANGE_HEIGHT; i++)
gdk_draw_line (window, fill_gc, MARGIN + xpos-i/2, i, MARGIN + xpos+i/2,i);
gdk_draw_line (window, border_gc, MARGIN + xpos, 0,
MARGIN + xpos - (RANGE_HEIGHT - 1) / 2, RANGE_HEIGHT - 1);
gdk_draw_line (window, border_gc, MARGIN + xpos, 0,
MARGIN + xpos + (RANGE_HEIGHT - 1) / 2, RANGE_HEIGHT - 1);
gdk_draw_line (window, border_gc, MARGIN + xpos-(RANGE_HEIGHT-1)/2,RANGE_HEIGHT-1,
MARGIN + xpos + (RANGE_HEIGHT-1)/2, RANGE_HEIGHT-1);
}
void
draw_it (GtkWidget *widget)
{
draw_slider (AW.aliasingGraph->window,
AW.aliasingGraph->style->black_gc,
AW.aliasingGraph->style->dark_gc[GTK_STATE_NORMAL],
Current.Cutoffs[SHADOWS]);
draw_slider (AW.aliasingGraph->window,
AW.aliasingGraph->style->black_gc,
AW.aliasingGraph->style->dark_gc[GTK_STATE_NORMAL],
Current.Cutoffs[MIDTONES]);
draw_slider (AW.aliasingGraph->window,
AW.aliasingGraph->style->black_gc,
AW.aliasingGraph->style->dark_gc[GTK_STATE_SELECTED],
Current.Offset);
}
gint
FP_Range_Change_Events (GtkWidget *widget,
GdkEvent *event,
FP_Params *current)
{
GdkEventButton *bevent;
GdkEventMotion *mevent;
gint shad, mid, offset, min;
static guchar *new;
gint x;
switch (event->type)
{
case GDK_EXPOSE:
draw_it (NULL);
break;
case GDK_BUTTON_PRESS:
bevent= (GdkEventButton *) event;
shad = abs (bevent->x - Current.Cutoffs[SHADOWS]);
mid = abs (bevent->x - Current.Cutoffs[MIDTONES]);
offset = abs (bevent->x - Current.Offset);
min = MIN (MIN (shad, mid), offset);
if (bevent->x >0 && bevent->x<256)
{
if (min == shad)
new = &Current.Cutoffs[SHADOWS];
else if (min == mid)
new = &Current.Cutoffs[MIDTONES];
else
new = &Current.Offset;
slider_erase (AW.aliasingGraph->window, *new);
*new=bevent->x;
}
draw_it (NULL);
if (Current.RealTime)
{
fp_range_preview_spill (AW.rangePreview, Current.ValueBy);
update_range_labels ();
fp_create_smoothness_graph (AW.aliasingPreview);
refreshPreviews (Current.VisibleFrames);
}
break;
case GDK_BUTTON_RELEASE:
if (!Current.RealTime)
{
fp_range_preview_spill (AW.rangePreview, Current.ValueBy);
update_range_labels ();
fp_create_smoothness_graph (AW.aliasingPreview);
refreshPreviews (Current.VisibleFrames);
}
break;
case GDK_MOTION_NOTIFY:
mevent = (GdkEventMotion *) event;
gdk_window_get_pointer (widget->window, &x, NULL, NULL);
if (x >= 0 && x < 256)
{
slider_erase (AW.aliasingGraph->window, *new);
*new = x;
draw_it (NULL);
if (Current.RealTime)
{
fp_range_preview_spill (AW.rangePreview, Current.ValueBy);
update_range_labels ();
fp_create_smoothness_graph (AW.aliasingPreview);
refreshPreviews (Current.VisibleFrames);
}
}
break;
default:
break;
}
return FALSE;
}
void
update_range_labels (void)
{
gchar buffer[3];
gtk_label_set_text (GTK_LABEL(Current.rangeLabels[1]),"0");
g_snprintf (buffer, sizeof (buffer), "%d", Current.Cutoffs[SHADOWS]);
gtk_label_set_text (GTK_LABEL (Current.rangeLabels[3]), buffer);
gtk_label_set_text (GTK_LABEL (Current.rangeLabels[5]), buffer);
g_snprintf (buffer, sizeof (buffer), "%d", Current.Cutoffs[MIDTONES]);
gtk_label_set_text (GTK_LABEL (Current.rangeLabels[7]), buffer);
gtk_label_set_text (GTK_LABEL (Current.rangeLabels[9]), buffer);
gtk_label_set_text (GTK_LABEL(Current.rangeLabels[11]), "255");
}

File diff suppressed because it is too large Load Diff

View File

@ -1,447 +0,0 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#ifdef __GNUC__
#warning GTK_DISABLE_DEPRECATED
#endif
#undef GTK_DISABLE_DEPRECATED
#include <gtk/gtk.h>
#include <libgimp/gimp.h>
#include "fp.h"
extern FP_Params Current;
extern GimpDrawable *drawable, *mask;
extern ReducedImage *reduced;
extern gint nudgeArray[256];
gint colorSign[3][ALL_PRIMARY]=
{{1,-1,-1,-1,1,1},{-1,1,-1,1,1,-1},{-1,-1,1,1,-1,1}};
void initializeFilterPacks()
{
gint i, j;
for (i=0; i<256; i++)
for (j=BY_HUE; j<JUDGE_BY; j++) {
Current.redAdj [j][i]=0;
Current.greenAdj [j][i]=0;
Current.blueAdj [j][i]=0;
Current.satAdj [j][i]=0;
}
}
void resetFilterPacks()
{
initializeFilterPacks();
refreshPreviews(Current.VisibleFrames);
}
ReducedImage *Reduce_The_Image(GimpDrawable *drawable,
GimpDrawable *mask,
gint LongerSize,
gint Slctn)
{
gint RH, RW, width, height, bytes=drawable->bpp;
ReducedImage *temp = (ReducedImage *) malloc (sizeof (ReducedImage));
guchar *tempRGB, *src_row, *tempmask, *src_mask_row, R, G, B;
gint i, j, whichcol, whichrow, x1, x2, y1, y2;
GimpPixelRgn srcPR, srcMask;
gboolean NoSelectionMade=TRUE;
gdouble *tempHSV;
GimpRGB rgb;
GimpHSV hsv;
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
width = x2 - x1;
height = y2 - y1;
if (width != drawable->width && height != drawable->height)
NoSelectionMade = FALSE;
if (Slctn == 0)
{
x1 = 0;
x2 = drawable->width;
y1 = 0;
y2 = drawable->height;
}
if (Slctn == 2)
{
x1 = MAX (0, x1 - width / 2.0);
x2 = MIN (drawable->width, x2 + width / 2.0);
y1 = MAX (0, y1 - height / 2.0);
y2 = MIN (drawable->height, y2 + height / 2.0);
}
width = x2 - x1;
height = y2 - y1;
if (width > height)
{
RW = LongerSize;
RH = (gfloat) height * (gfloat) LongerSize / (gfloat) width;
}
else
{
RH = LongerSize;
RW = (gfloat) width * (gfloat) LongerSize / (gfloat) height;
}
tempRGB = (guchar *) malloc (RW * RH * bytes);
tempHSV = (gdouble *) malloc (RW * RH * bytes * sizeof (gdouble));
tempmask = (guchar *) malloc (RW * RH);
gimp_pixel_rgn_init (&srcPR, drawable, x1, y1, width, height, FALSE, FALSE);
gimp_pixel_rgn_init (&srcMask, mask, x1, y1, width, height, FALSE, FALSE);
src_row = (guchar *) malloc (width * bytes);
src_mask_row = (guchar *) malloc (width * bytes);
for (i = 0; i < RH; i++)
{
whichrow = (gfloat) i * (gfloat) height / (gfloat) RH;
gimp_pixel_rgn_get_row (&srcPR, src_row, x1, y1 + whichrow, width);
gimp_pixel_rgn_get_row (&srcMask, src_mask_row, x1, y1 + whichrow, width);
for (j = 0; j < RW; j++)
{
whichcol = (gfloat) j * (gfloat) width / (gfloat) RW;
if (NoSelectionMade)
tempmask[i * RW + j] = 255;
else
tempmask[i * RW + j] = src_mask_row[whichcol];
R = src_row[whichcol * bytes + 0];
G = src_row[whichcol * bytes + 1];
B = src_row[whichcol * bytes + 2];
gimp_rgb_set_uchar (&rgb, R, G, B);
gimp_rgb_to_hsv (&rgb, &hsv);
tempRGB[i * RW * bytes + j * bytes + 0] = R;
tempRGB[i * RW * bytes + j * bytes + 1] = G;
tempRGB[i * RW * bytes + j * bytes + 2] = B;
tempHSV[i * RW * bytes + j * bytes + 0] = hsv.h;
tempHSV[i * RW * bytes + j * bytes + 1] = hsv.s;
tempHSV[i * RW * bytes + j * bytes + 2] = hsv.v;
if (bytes == 4)
tempRGB[i * RW * bytes + j * bytes + 3] =
src_row[whichcol * bytes + 3];
}
}
temp->width = RW;
temp->height = RH;
temp->rgb = tempRGB;
temp->hsv = tempHSV;
temp->mask = tempmask;
return temp;
}
/*************************************************************/
/************** The Preview Function *************************/
void
fp_render_preview(GtkWidget *preview,
gint changewhat,
gint changewhich)
{
guchar *a;
gint Inten, bytes=drawable->bpp;
gint i, j, k, nudge, M, m, middle,JudgeBy;
float partial;
gint RW=reduced->width;
gint RH=reduced->height;
gint backupP[3], P[3], tempSat[JUDGE_BY][256];
a =(guchar *) malloc(bytes*RW);
if (changewhat==SATURATION)
for (k=0; k<256; k++) {
for (JudgeBy=BY_HUE; JudgeBy<JUDGE_BY; JudgeBy++)
tempSat[JudgeBy][k]=0;
tempSat[Current.ValueBy][k] += changewhich*nudgeArray[(k+Current.Offset)%256];
}
for (i=0; i<RH; i++) {
for (j=0; j<RW; j++) {
backupP[0] = P[0] = (int) reduced->rgb[i*RW*bytes + j*bytes + 0];
backupP[1] = P[1] = (int) reduced->rgb[i*RW*bytes + j*bytes + 1];
backupP[2] = P[2] = (int) reduced->rgb[i*RW*bytes + j*bytes + 2];
m = MIN(MIN(P[0],P[1]),P[2]);
M = MAX(MAX(P[0],P[1]),P[2]);
middle=(M+m)/2;
for (k=0; k<3; k++)
if (P[k]!=m && P[k]!=M) middle=P[k];
partial = reduced->mask[i*RW+j]/255.0;
for (JudgeBy=BY_HUE; JudgeBy<JUDGE_BY; JudgeBy++) {
if (!Current.Touched[JudgeBy]) continue;
Inten = reduced->hsv[i*RW*bytes + j*bytes + JudgeBy]*255.0;
/*DO SATURATION FIRST*/
if (changewhat != NONEATALL) {
if (M!=m) {
for (k=0; k<3; k++)
if (backupP[k] == M)
P[k] = MAX(P[k]+partial*Current.satAdj[JudgeBy][Inten],middle);
else if (backupP[k] == m)
P[k] = MIN(P[k]-partial*Current.satAdj[JudgeBy][Inten],middle);
}
P[0] += partial*Current.redAdj[JudgeBy][Inten];
P[1] += partial*Current.greenAdj[JudgeBy][Inten];
P[2] += partial*Current.blueAdj[JudgeBy][Inten];
}
}
Inten = reduced->hsv[i*RW*bytes + j*bytes + Current.ValueBy]*255.0;
nudge = partial*nudgeArray[(Inten+Current.Offset)%256];
switch (changewhat) {
case HUE:
P[0] += colorSign[RED][changewhich] * nudge;
P[1] += colorSign[GREEN][changewhich] * nudge;
P[2] += colorSign[BLUE][changewhich] * nudge;
break;
case SATURATION:
for (JudgeBy=BY_HUE; JudgeBy<JUDGE_BY; JudgeBy++)
for (k=0; k<3; k++)
if (M!=m) {
if (backupP[k] == M)
P[k] = MAX(P[k]+
partial*tempSat[JudgeBy][Inten],middle);
else if (backupP[k] == m)
P[k] = MIN(P[k]-
partial*tempSat[JudgeBy][Inten],middle);
}
break;
case VALUE:
P[0] += changewhich * nudge;
P[1] += changewhich * nudge;
P[2] += changewhich * nudge;
break;
default:
break;
}
a[j*3+0] = MAX(0,MIN(P[0], 255));
a[j*3+1] = MAX(0,MIN(P[1], 255));
a[j*3+2] = MAX(0,MIN(P[2], 255));
if (bytes==4)
for (k=0; k<3; k++) {
float transp=reduced->rgb[i*RW*bytes+j*bytes+3]/255.0;
a[3*j+k]=transp*a[3*j+k]+(1-transp)*fp_fake_transparency(i,j);
}
}
gtk_preview_draw_row( GTK_PREVIEW(preview),a,0,i,RW);
}
free(a);
gtk_widget_queue_draw (preview);
}
void
Update_Current_FP (gint changewhat,
gint changewhich)
{
int i, nudge;
for (i=0; i<256; i++) {
fp_Create_Nudge(nudgeArray);
nudge=nudgeArray[(i+Current.Offset)%256];
switch (changewhat) {
case HUE:
Current.redAdj[Current.ValueBy][i] +=
colorSign[RED][changewhich] * nudge;
Current.greenAdj[Current.ValueBy][i] +=
colorSign[GREEN][changewhich] * nudge;
Current.blueAdj[Current.ValueBy][i] +=
colorSign[BLUE][changewhich] * nudge;
break;
case SATURATION:
Current.satAdj[Current.ValueBy][i] += changewhich*nudge;
break;
case VALUE:
Current.redAdj[Current.ValueBy][i] += changewhich * nudge;
Current.greenAdj[Current.ValueBy][i] += changewhich * nudge;
Current.blueAdj[Current.ValueBy][i] += changewhich * nudge;
break;
default:
break;
} /* switch */
} /* for */
}
void
fp_create_smoothness_graph (GtkWidget *preview)
{
guchar data[256*3];
gint nArray[256];
int i, j, toBeBlack;
fp_Create_Nudge(nArray);
for (i=0; i<MAX_ROUGHNESS; i++)
{
int coor=MAX_ROUGHNESS-i;
for (j=0; j<256; j++) {
data[3*j+0]=255;
data[3*j+1]=255;
data[3*j+2]=255;
if (!(i%(MAX_ROUGHNESS/4))) {
data[3*j+0]=255;
data[3*j+1]=128;
data[3*j+2]=128;
}
if (!((j+1)%32)) {
data[3*j+0]=255;
data[3*j+1]=128;
data[3*j+2]=128;
}
toBeBlack=0;
if (nArray[j]==coor) toBeBlack=1;
if (j<255) {
int jump=abs(nArray[j]-nArray[j+1]);
if ( abs(coor-nArray[j]) < jump
&& abs(coor-nArray[j+1]) < jump)
toBeBlack=1;
}
if (toBeBlack) {
data[3*j+0]=0;
data[3*j+1]=0;
data[3*j+2]=0;
}
}
gtk_preview_draw_row( GTK_PREVIEW(preview),data,0,i,256);
}
gtk_widget_queue_draw (preview);
}
void
fp_range_preview_spill (GtkWidget *preview,
gint type)
{
guchar data[256 * 3];
gint i, j;
GimpRGB rgb;
GimpHSV hsv;
for (i = 0; i < RANGE_HEIGHT; i++)
{
for (j = 0; j < 256; j++)
{
if (! ((j + 1) % 32))
{
data[3 * j + 0] = 255;
data[3 * j + 1] = 128;
data[3 * j + 2] = 128;
}
else
{
switch (type)
{
case BY_VAL:
data[3 * j + 0] = j - Current.Offset;
data[3 * j + 1] = j - Current.Offset;
data[3 * j + 2] = j - Current.Offset;
break;
case BY_HUE:
gimp_hsv_set (&hsv,
((j - Current.Offset + 256) % 256) / 255.0,
1.0,
0.5);
gimp_hsv_to_rgb (&hsv, &rgb);
gimp_rgb_get_uchar (&rgb,
&data[3 * j + 0],
&data[3 * j + 1],
&data[3 * j + 2]);
break;
case BY_SAT:
gimp_hsv_set (&hsv,
0.5,
((j-(gint)Current.Offset+256)%256) / 255.0,
0.5);
gimp_hsv_to_rgb (&hsv, &rgb);
gimp_rgb_get_uchar (&rgb,
&data[3 * j + 0],
&data[3 * j + 1],
&data[3 * j + 2]);
break;
}
gtk_preview_draw_row (GTK_PREVIEW (preview), data, 0, i, 256);
}
}
}
gtk_widget_queue_draw (preview);
}
void fp_Create_Nudge(gint *adjArray)
{
int left, right, middle,i;
/* The following function was determined by trial and error */
double Steepness=pow(1-Current.Alias,4)*.8;
left = (Current.Range == SHADOWS) ? 0 : Current.Cutoffs[Current.Range-1];
right = Current.Cutoffs[Current.Range];
middle = (left + right)/2;
if (Current.Alias!=0)
for (i=0; i<256; i++)
if (i<=middle)
adjArray[i] = MAX_ROUGHNESS *
Current.Rough*(1+tanh(Steepness*(i-left)))/2;
else
adjArray[i] = MAX_ROUGHNESS *
Current.Rough*(1+tanh(Steepness*(right-i)))/2;
else
for (i=0; i<256; i++)
if (left<=i && i<=right)
adjArray[i] = MAX_ROUGHNESS * Current.Rough;
else
adjArray[i] = 0;
}
gint fp_fake_transparency(gint i, gint j)
{
if ( ((i%20)- 10) * ((j%20)- 10)>0 )
return 64;
else
return 196;
}