Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

skin-whitening: fix the plug-in-skin-whitening procedure to let this …

…plug-in can be used in scripts.
  • Loading branch information...
commit 76ee14dc9c2de3bd090dda87ec5303036efb1aa9 1 parent cc07906
@hejiann authored
View
5 Makefile
@@ -74,7 +74,7 @@ beautify-effect.o: beautify-effect.c beautify-textures.h
beautify-textures.h: beautify-textures.list
$(GDK_PIXBUF_CSOURCE) --raw --build-list `cat beautify-textures.list` > $(@F)
-skin-whitening: skin-whitening.o
+skin-whitening: skin-whitening.o skin-whitening-effect.o
$(CC) -o $@ $^ $(LIBS)
skin-whitening.o: skin-whitening.c skin-whitening-images.h
@@ -83,6 +83,9 @@ skin-whitening.o: skin-whitening.c skin-whitening-images.h
skin-whitening-images.h: skin-whitening-images.list
$(GDK_PIXBUF_CSOURCE) --raw --build-list `cat skin-whitening-images.list` > $(@F)
+skin-whitening-effect.o: skin-whitening-effect.c skin-whitening-effect.h
+ $(CC) $(CFLAGS) -c skin-whitening-effect.c -o skin-whitening-effect.o
+
rip-border: rip-border.o
$(CC) -o $@ $^ $(LIBS)
View
1  README
@@ -40,6 +40,7 @@ CHANGELOG
2012-07-29
texture-border: add custom texures support.
skin-whitening: add reset feature.
+skin-whitening: fix skin-whitening procedure to let this plug-in can be used in scirpts.
2012-07-27
beautify: add sketch effect
View
4 beautify.c
@@ -227,8 +227,8 @@ query (void)
};
gimp_install_procedure (PLUG_IN_PROC,
- "Beautify, the easiest way to beautify photo.",
- "Beautify, the easiest way to beautify photo.",
+ "Quickly and easily beautify the photo.",
+ "Quickly and easily beautify the photo. Goto https://github.com/hejiann/beautify/wiki get more help.",
"Hejian <hejian.he@gmail.com>",
"Hejian <hejian.he@gmail.com>",
"2012",
View
83 skin-whitening-effect.c
@@ -0,0 +1,83 @@
+/**
+ * Copyright (C) 2012 hejian <hejian.he@gmail.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/>.
+ */
+
+#include <libgimp/gimp.h>
+
+#include "skin-whitening-effect.h"
+
+void
+run_effect (gint32 image_ID, WhiteningEffectType effect)
+{
+ gint32 layer = gimp_image_get_active_layer (image_ID);
+ switch (effect)
+ {
+ case WHITENING_EFFECT_LITTLE_WHITENING:
+ {
+ guint8 pts[] = {
+ 0.000000 * 255, 0.007843 * 255,
+ 0.121569 * 255, 0.160784 * 255,
+ 0.247059 * 255, 0.317647 * 255,
+ 0.372549 * 255, 0.462745 * 255,
+ 0.498039 * 255, 0.592157 * 255,
+ 0.623529 * 255, 0.713725 * 255,
+ 0.749020 * 255, 0.819608 * 255,
+ 0.874510 * 255, 0.913725 * 255,
+ 1.000000 * 255, 0.996078 * 255,
+ };
+ gimp_curves_spline (layer, GIMP_HISTOGRAM_RED, 18, pts);
+ gimp_curves_spline (layer, GIMP_HISTOGRAM_GREEN, 18, pts);
+ gimp_curves_spline (layer, GIMP_HISTOGRAM_BLUE, 18, pts);
+ break;
+ }
+ case WHITENING_EFFECT_MODERATE_WHITENING:
+ {
+ guint8 pts[] = {
+ 0.000000 * 255, 0.007843 * 255,
+ 0.121569 * 255, 0.192157 * 255,
+ 0.247059 * 255, 0.372549 * 255,
+ 0.372549 * 255, 0.529412 * 255,
+ 0.498039 * 255, 0.666667 * 255,
+ 0.623529 * 255, 0.784314 * 255,
+ 0.749020 * 255, 0.874510 * 255,
+ 0.874510 * 255, 0.945098 * 255,
+ 1.000000 * 255, 0.996078 * 255,
+ };
+ gimp_curves_spline (layer, GIMP_HISTOGRAM_RED, 18, pts);
+ gimp_curves_spline (layer, GIMP_HISTOGRAM_GREEN, 18, pts);
+ gimp_curves_spline (layer, GIMP_HISTOGRAM_BLUE, 18, pts);
+ break;
+ }
+ case WHITENING_EFFECT_HIGH_WHITENING:
+ {
+ guint8 pts[] = {
+ 0.000000 * 255, 0.007843 * 255,
+ 0.121569 * 255, 0.223529 * 255,
+ 0.247059 * 255, 0.427451 * 255,
+ 0.372549 * 255, 0.600000 * 255,
+ 0.498039 * 255, 0.741176 * 255,
+ 0.623529 * 255, 0.854902 * 255,
+ 0.749020 * 255, 0.933333 * 255,
+ 0.874510 * 255, 0.980392 * 255,
+ 1.000000 * 255, 0.996078 * 255,
+ };
+ gimp_curves_spline (layer, GIMP_HISTOGRAM_RED, 18, pts);
+ gimp_curves_spline (layer, GIMP_HISTOGRAM_GREEN, 18, pts);
+ gimp_curves_spline (layer, GIMP_HISTOGRAM_BLUE, 18, pts);
+ break;
+ }
+ }
+}
View
33 skin-whitening-effect.h
@@ -0,0 +1,33 @@
+/**
+ * Copyright (C) 2012 hejian <hejian.he@gmail.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/>.
+ */
+
+typedef enum
+{
+ WHITENING_EFFECT_NONE,
+ WHITENING_EFFECT_LITTLE_WHITENING,
+ WHITENING_EFFECT_MODERATE_WHITENING,
+ WHITENING_EFFECT_HIGH_WHITENING,
+ WHITENING_EFFECT_LITTLE_PINK, // TODO
+ WHITENING_EFFECT_MODERATE_PINK, // TODO
+ WHITENING_EFFECT_HIGH_PINK, // TODO
+ WHITENING_EFFECT_LITTLE_FLESH, // TODO
+ WHITENING_EFFECT_MODERATE_FLESH, // TODO
+ WHITENING_EFFECT_HIGH_FLESH, // TODO
+} WhiteningEffectType;
+
+void run_effect (gint32 image_ID, WhiteningEffectType effect);
+
View
104 skin-whitening.c
@@ -18,6 +18,7 @@
#include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
+#include "skin-whitening-effect.h"
#include "skin-whitening-images.h"
#define PLUG_IN_PROC "plug-in-skin-whitening"
@@ -27,12 +28,10 @@
#define PREVIEW_SIZE 480
#define THUMBNAIL_SIZE 80
-typedef enum
+typedef struct
{
- WHITENING_EFFECT_LITTLE_WHITENING,
- WHITENING_EFFECT_MODERATE_WHITENING,
- WHITENING_EFFECT_HIGH_WHITENING,
-} WhiteningEffectType;
+ WhiteningEffectType effect;
+} WhiteningValues;
static const WhiteningEffectType effects[] =
{
@@ -49,6 +48,7 @@ static void run (const gchar *name,
GimpParam **return_vals);
static void skin_whitening (GimpDrawable *drawable);
+static void skin_whitening_effect (GimpDrawable *drawable);
static gboolean skin_whitening_dialog (gint32 image_ID,
GimpDrawable *drawable);
@@ -69,6 +69,11 @@ const GimpPlugInInfo PLUG_IN_INFO =
run, /* run_proc */
};
+static WhiteningValues wvals =
+{
+ WHITENING_EFFECT_NONE, /* effect */
+};
+
static gint32 image_ID = 0;
static gint width;
static gint height;
@@ -99,11 +104,12 @@ query (void)
{ GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" },
{ GIMP_PDB_IMAGE, "image", "Input image" },
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
+ { GIMP_PDB_INT32, "effect", "The effect to apply { LITTLE_WHITENING (1), MODERATE_WHITENING (2), HIGH_WHITENING (3), LITTLE_PINK (4), MODERATE_PINK (5), HIGH_PINK (6), LITTLE_FLESH (7), MODERATE_FLESH (8), HIGH_FLESH (9) }" }
};
gimp_install_procedure (PLUG_IN_PROC,
- "the easiest way for skin whitening.",
- "the easiest way for skin whitening.",
+ "Quickly and easily whiten the skin.",
+ "Quickly and easily whiten the skin. Goto https://github.com/hejiann/beautify/wiki get more help.",
"Hejian <hejian.he@gmail.com>",
"Hejian <hejian.he@gmail.com>",
"2012",
@@ -150,9 +156,19 @@ run (const gchar *name,
break;
case GIMP_RUN_NONINTERACTIVE:
+ /* Make sure all the arguments are there! */
+ if (nparams != 4)
+ status = GIMP_PDB_CALLING_ERROR;
+
+ if (status == GIMP_PDB_SUCCESS)
+ {
+ wvals.effect = param[3].data.d_int32;
+ }
break;
case GIMP_RUN_WITH_LAST_VALS:
+ /* Possibly retrieve data */
+ gimp_get_data (PLUG_IN_PROC, &wvals);
break;
default:
@@ -165,7 +181,10 @@ run (const gchar *name,
{
/* Run! */
gimp_image_undo_group_start (image_ID);
- skin_whitening (drawable);
+ if (run_mode == GIMP_RUN_INTERACTIVE)
+ skin_whitening (drawable);
+ else
+ skin_whitening_effect (drawable);
gimp_image_undo_group_end (image_ID);
/* If run mode is interactive, flush displays */
@@ -173,8 +192,8 @@ run (const gchar *name,
gimp_displays_flush ();
/* Store data */
- /*if (run_mode == GIMP_RUN_INTERACTIVE)
- gimp_set_data (PLUG_IN_PROC, &bvals, sizeof (BeautifyValues));*/
+ if (run_mode == GIMP_RUN_INTERACTIVE)
+ gimp_set_data (PLUG_IN_PROC, &wvals, sizeof (WhiteningValues));
}
@@ -190,6 +209,12 @@ skin_whitening (GimpDrawable *drawable)
gimp_floating_sel_anchor (floating_sel);
}
+static void
+skin_whitening_effect (GimpDrawable *drawable)
+{
+ run_effect (image_ID, wvals.effect);
+}
+
static gboolean
skin_whitening_dialog (gint32 image_ID,
GimpDrawable *drawable)
@@ -367,64 +392,7 @@ effect_icon_new (WhiteningEffectType effect)
static gboolean
effect_select (GtkWidget *event_box, GdkEventButton *event, WhiteningEffectType effect)
{
- gint32 layer = gimp_image_get_active_layer (preview_image);
- switch (effect)
- {
- case WHITENING_EFFECT_LITTLE_WHITENING:
- {
- guint8 pts[] = {
- 0.000000 * 255, 0.007843 * 255,
- 0.121569 * 255, 0.160784 * 255,
- 0.247059 * 255, 0.317647 * 255,
- 0.372549 * 255, 0.462745 * 255,
- 0.498039 * 255, 0.592157 * 255,
- 0.623529 * 255, 0.713725 * 255,
- 0.749020 * 255, 0.819608 * 255,
- 0.874510 * 255, 0.913725 * 255,
- 1.000000 * 255, 0.996078 * 255,
- };
- gimp_curves_spline (layer, GIMP_HISTOGRAM_RED, 18, pts);
- gimp_curves_spline (layer, GIMP_HISTOGRAM_GREEN, 18, pts);
- gimp_curves_spline (layer, GIMP_HISTOGRAM_BLUE, 18, pts);
- break;
- }
- case WHITENING_EFFECT_MODERATE_WHITENING:
- {
- guint8 pts[] = {
- 0.000000 * 255, 0.007843 * 255,
- 0.121569 * 255, 0.192157 * 255,
- 0.247059 * 255, 0.372549 * 255,
- 0.372549 * 255, 0.529412 * 255,
- 0.498039 * 255, 0.666667 * 255,
- 0.623529 * 255, 0.784314 * 255,
- 0.749020 * 255, 0.874510 * 255,
- 0.874510 * 255, 0.945098 * 255,
- 1.000000 * 255, 0.996078 * 255,
- };
- gimp_curves_spline (layer, GIMP_HISTOGRAM_RED, 18, pts);
- gimp_curves_spline (layer, GIMP_HISTOGRAM_GREEN, 18, pts);
- gimp_curves_spline (layer, GIMP_HISTOGRAM_BLUE, 18, pts);
- break;
- }
- case WHITENING_EFFECT_HIGH_WHITENING:
- {
- guint8 pts[] = {
- 0.000000 * 255, 0.007843 * 255,
- 0.121569 * 255, 0.223529 * 255,
- 0.247059 * 255, 0.427451 * 255,
- 0.372549 * 255, 0.600000 * 255,
- 0.498039 * 255, 0.741176 * 255,
- 0.623529 * 255, 0.854902 * 255,
- 0.749020 * 255, 0.933333 * 255,
- 0.874510 * 255, 0.980392 * 255,
- 1.000000 * 255, 0.996078 * 255,
- };
- gimp_curves_spline (layer, GIMP_HISTOGRAM_RED, 18, pts);
- gimp_curves_spline (layer, GIMP_HISTOGRAM_GREEN, 18, pts);
- gimp_curves_spline (layer, GIMP_HISTOGRAM_BLUE, 18, pts);
- break;
- }
- }
+ run_effect (preview_image, effect);
preview_update (preview);
}
Please sign in to comment.
Something went wrong with that request. Please try again.