diff --git a/Makefile b/Makefile index 31ec47a..226e97e 100644 --- a/Makefile +++ b/Makefile @@ -28,16 +28,25 @@ GDK_PIXBUF_CSOURCE = gdk-pixbuf-csource all: beautify rip-border skin-whitening install: beautify rip-border skin-whitening - $(GIMPTOOL) --install-admin-bin beautify - $(GIMPTOOL) --install-admin-bin rip-border - $(GIMPTOOL) --install-admin-bin skin-whitening - -beautify: beautify.o - $(CC) $(CFLAGS) -o $@ $^ $(LIBS) + # need fix: --install-admin-bin has issue in x86_64, + # it install the plug-in into /usr/lib/gimp/2.0/plug-ins/ + # but the correct directory is /usr/lib64/gimp/2.0/plug-ins/ + # $(GIMPTOOL) --install-admin-bin beautify + # $(GIMPTOOL) --install-admin-bin rip-border + # $(GIMPTOOL) --install-admin-bin skin-whitening + cp beautify /usr/lib64/gimp/2.0/plug-ins/ + cp rip-border /usr/lib64/gimp/2.0/plug-ins/ + cp skin-whitening /usr/lib64/gimp/2.0/plug-ins/ + +beautify: beautify.o beautify-effect.o + $(CC) -o $@ $^ $(LIBS) -beautify.o: beautify.c beautify-textures.h +beautify.o: beautify.c $(CC) $(CFLAGS) -c beautify.c -o beautify.o +beautify-effect.o: beautify-effect.c beautify-textures.h + $(CC) $(CFLAGS) -c beautify-effect.c -o beautify-effect.o + beautify-textures.h: beautify-textures.list $(GDK_PIXBUF_CSOURCE) --raw --build-list `cat beautify-textures.list` > $(@F) diff --git a/README b/README index ca513fa..1cc9746 100644 --- a/README +++ b/README @@ -25,9 +25,14 @@ Support: #beautify on FreeNode CHANGELOG =================== +2012-07-20 +fix make install in x86_64 +beautify refactor: split the effect code into beautify-feature.c + 2012-07-19 beautify: fix memory leak beautify: speed up dialog display +fix Makefile: install plugin into mathine directory instead of user directory 2012-07-18 beautify: add blues effect diff --git a/beautify-effect.c b/beautify-effect.c new file mode 100644 index 0000000..73dac19 --- /dev/null +++ b/beautify-effect.c @@ -0,0 +1,615 @@ +/** + * Copyright (C) 2012 hejian + * + * 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 . + */ + +#include + +#include "beautify-effect.h" +#include "beautify-textures.h" + +void +run_effect (gint32 image_ID, BeautifyEffectType effect) +{ + gimp_context_push (); + + gint32 layer = gimp_image_get_active_layer (image_ID); + gint32 effect_layer = gimp_layer_copy (layer); + gimp_image_add_layer (image_ID, effect_layer, -1); + + gint width = gimp_image_width (image_ID); + gint height = gimp_image_height (image_ID); + + switch (effect) + { + case BEAUTIFY_EFFECT_SOFT_LIGHT: + gimp_layer_set_mode (effect_layer, GIMP_SOFTLIGHT_MODE); + break; + + case BEAUTIFY_EFFECT_WARM: + { + guint8 red_pts[] = { + 0.0, 0.082031 * 255, + 0.405488 * 255, 0.621094 * 255, + 0.954268 * 255, 1.000000 * 255, + }; + guint8 green_pts[] = { + 0.0, 0.0, + 0.503049 * 255, 0.636719 * 255, + 1.000000 * 255, 1.000000 * 255, + }; + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_RED, 6, red_pts); + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_GREEN, 6, green_pts); + } + break; + + case BEAUTIFY_EFFECT_SHARPEN: + { + gint nreturn_vals; + GimpParam *return_vals = gimp_run_procedure ("plug-in-sharpen", + &nreturn_vals, + GIMP_PDB_INT32, 1, + GIMP_PDB_IMAGE, image_ID, + GIMP_PDB_DRAWABLE, effect_layer, + GIMP_PDB_INT32, 50, + GIMP_PDB_END); + gimp_destroy_params (return_vals, nreturn_vals); + } + break; + case BEAUTIFY_EFFECT_STRONG_CONTRAST: + { + guint8 red_pts[] = { + 0.000000 * 255, 0.003922 * 255, + 0.121569 * 255, 0.039216 * 255, + 0.247059 * 255, 0.105882 * 255, + 0.372549 * 255, 0.235294 * 255, + 0.498039 * 255, 0.537255 * 255, + 0.623529 * 255, 0.768627 * 255, + 0.749020 * 255, 0.858824 * 255, + 0.874510 * 255, 0.929412 * 255, + 1.000000 * 255, 1.000000 * 255, + }; + guint8 green_pts[] = { + 0.000000 * 255, 0.003922 * 255, + 0.121569 * 255, 0.027451 * 255, + 0.247059 * 255, 0.117647 * 255, + 0.372549 * 255, 0.286275 * 255, + 0.498039 * 255, 0.576471 * 255, + 0.623529 * 255, 0.780392 * 255, + 0.749020 * 255, 0.890196 * 255, + 0.874510 * 255, 0.952941 * 255, + 1.000000 * 255, 1.000000 * 255, + }; + guint8 blue_pts[] = { + 0.000000 * 255, 0.003922 * 255, + 0.121569 * 255, 0.050980 * 255, + 0.247059 * 255, 0.133333 * 255, + 0.372549 * 255, 0.294118 * 255, + 0.498039 * 255, 0.568627 * 255, + 0.623529 * 255, 0.772549 * 255, + 0.749020 * 255, 0.874510 * 255, + 0.874510 * 255, 0.941176 * 255, + 1.000000 * 255, 1.000000 * 255, + }; + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_RED, 18, red_pts); + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_GREEN, 18, green_pts); + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts); + break; + } + case BEAUTIFY_EFFECT_SMART_COLOR: + { + guint8 red_pts[] = { + 0.0, 0.001012 * 255, 0.121569 * 255, 0.126695 * 255, + 0.247059 * 255, 0.279821 * 255, 0.372549 * 255, 0.428038 * 255, + 0.498039 * 255, 0.567700 * 255, 0.623529 * 255, 0.699439 * 255, + 0.749020 * 255, 0.821423 * 255, 0.874510 * 255, 0.953474 * 255, + 1.000000 * 255, 0.997988 * 255, + }; + guint8 green_pts[] = { + 0.0, 0.004278 * 255, 0.121569 * 255, 0.107139 * 255, + 0.247059 * 255, 0.225961 * 255, 0.372549 * 255, 0.346578 * 255, + 0.498039 * 255, 0.472647 * 255, 0.623529 * 255, 0.602136 * 255, + 0.749020 * 255, 0.730046 * 255, 0.874510 * 255, 0.873495 * 255, + 1.000000 * 255, 0.996787 * 255, + }; + guint8 blue_pts[] = { + 0.0, 0.000105 * 255, 0.121569 * 255, 0.060601 * 255, + 0.247059 * 255, 0.146772 * 255, 0.372549 * 255, 0.262680 * 255, + 0.498039 * 255, 0.408053 * 255, 0.623529 * 255, 0.566459 * 255, + 0.749020 * 255, 0.691468 * 255, 0.874510 * 255, 0.847356 * 255, + 1.000000 * 255, 0.999226 * 255, + }; + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_RED, 18, red_pts); + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_GREEN, 18, green_pts); + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts); + } + break; + case BEAUTIFY_EFFECT_INVERT: + gimp_invert (effect_layer); + break; + case BEAUTIFY_EFFECT_GOTHIC_STYLE: + { + guint8 red_pts[] = { + 0.0, 0.003922 * 255, 0.121569 * 255, 0.011765 * 255, + 0.247059 * 255, 0.074510 * 255, 0.372549 * 255, 0.200000 * 255, + 0.498039 * 255, 0.380392 * 255, 0.623529 * 255, 0.584314 * 255, + 0.749020 * 255, 0.784314 * 255, 0.874510 * 255, 0.933333 * 255, + 1.000000 * 255, 1.000000 * 255, + }; + guint8 green_pts[] = { + 0.0, 0.003922 * 255, 0.121569 * 255, 0.039216 * 255, + 0.247059 * 255, 0.160784 * 255, 0.372549 * 255, 0.317647 * 255, + 0.498039 * 255, 0.501961 * 255, 0.623529 * 255, 0.682353 * 255, + 0.749020 * 255, 0.843137 * 255, 0.874510 * 255, 0.952941 * 255, + 1.000000 * 255, 1.000000 * 255, + }; + guint8 blue_pts[] = { + 0.0, 0.003922 * 255, 0.121569 * 255, 0.007843 * 255, + 0.247059 * 255, 0.058824 * 255, 0.372549 * 255, 0.172549 * 255, + 0.498039 * 255, 0.349020 * 255, 0.623529 * 255, 0.556863 * 255, + 0.749020 * 255, 0.768627 * 255, 0.874510 * 255, 0.929412 * 255, + 1.000000 * 255, 1.000000 * 255, + }; + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_RED, 18, red_pts); + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_GREEN, 18, green_pts); + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts); + } + break; + case BEAUTIFY_EFFECT_CLASSIC_HDR: + { + guint8 red_pts[] = { + 0.0, 0.054902 * 255, 0.121569 * 255, 0.070588 * 255, + 0.247059 * 255, 0.243137 * 255, 0.372549 * 255, 0.407843 * 255, + 0.498039 * 255, 0.552941 * 255, 0.623529 * 255, 0.678431 * 255, + 0.749020 * 255, 0.780392 * 255, 0.874510 * 255, 0.866667 * 255, + 1.000000 * 255, 0.949020 * 255, + }; + guint8 green_pts[] = { + 0.0, 0.007843 * 255, 0.121569 * 255, 0.023529 * 255, + 0.247059 * 255, 0.207843 * 255, 0.372549 * 255, 0.388235 * 255, + 0.498039 * 255, 0.541176 * 255, 0.623529 * 255, 0.682353 * 255, + 0.749020 * 255, 0.796078 * 255, 0.874510 * 255, 0.898039 * 255, + 1.000000 * 255, 0.996078 * 255, + }; + guint8 blue_pts[] = { + 0.0, 0.258824 * 255, 0.121569 * 255, 0.294118 * 255, + 0.247059 * 255, 0.372549 * 255, 0.372549 * 255, 0.450980 * 255, + 0.498039 * 255, 0.521569 * 255, 0.623529 * 255, 0.592157 * 255, + 0.749020 * 255, 0.654902 * 255, 0.874510 * 255, 0.717647 * 255, + 1.000000 * 255, 0.776471 * 255, + }; + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_RED, 18, red_pts); + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_GREEN, 18, green_pts); + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts); + } + break; + case BEAUTIFY_EFFECT_IMPRESSION: + { + guint8 red_pts[] = { + 0.000000 * 255, 0.113725 * 255, + 0.121569 * 255, 0.213975 * 255, + 0.247059 * 255, 0.323494 * 255, + 0.372549 * 255, 0.460137 * 255, + 0.498039 * 255, 0.621504 * 255, + 0.623529 * 255, 0.716847 * 255, + 0.749020 * 255, 0.766909 * 255, + 0.874510 * 255, 0.817666 * 255, + 1.000000 * 255, 0.862745 * 255, + }; + guint8 green_pts[] = { + 0.000000 * 255, 0.200000 * 255, + 0.121569 * 255, 0.317329 * 255, + 0.247059 * 255, 0.407881 * 255, + 0.372549 * 255, 0.535429 * 255, + 0.498039 * 255, 0.682828 * 255, + 0.623529 * 255, 0.770688 * 255, + 0.749020 * 255, 0.813005 * 255, + 0.874510 * 255, 0.852891 * 255, + 1.000000 * 255, 0.902716 * 255, + }; + guint8 blue_pts[] = { + 0.000000 * 255, 0.317714 * 255, + 0.121569 * 255, 0.364205 * 255, + 0.247059 * 255, 0.417294 * 255, + 0.372549 * 255, 0.495841 * 255, + 0.498039 * 255, 0.612710 * 255, + 0.623529 * 255, 0.719834 * 255, + 0.749020 * 255, 0.795937 * 255, + 0.874510 * 255, 0.845977 * 255, + 1.000000 * 255, 0.883024 * 255, + }; + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_RED, 18, red_pts); + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_GREEN, 18, green_pts); + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts); + break; + } + case BEAUTIFY_EFFECT_LITTLE_FRESH: + { + guint8 red_pts[] = { + 0.0, 0.002975 * 255, 0.121569 * 255, 0.135413 * 255, + 0.247059 * 255, 0.271797 * 255, 0.372549 * 255, 0.420642 * 255, + 0.498039 * 255, 0.587088 * 255, 0.623529 * 255, 0.672206 * 255, + 0.749020 * 255, 0.781208 * 255, 0.874510 * 255, 0.881668 * 255, + 1.000000 * 255, 0.993149 * 255, + }; + guint8 green_pts[] = { + 0.0, 0.001070 * 255, 0.121569 * 255, 0.123393 * 255, + 0.247059 * 255, 0.254300 * 255, 0.372549 * 255, 0.377336 * 255, + 0.498039 * 255, 0.486582 * 255, 0.623529 * 255, 0.607331 * 255, + 0.749020 * 255, 0.722174 * 255, 0.874510 * 255, 0.858206 * 255, + 1.000000 * 255, 0.992154 * 255, + }; + guint8 blue_pts[] = { + 0.0, 0.003917 * 255, 0.121569 * 255, 0.098807 * 255, + 0.247059 * 255, 0.234746 * 255, 0.372549 * 255, 0.378388 * 255, + 0.498039 * 255, 0.520273 * 255, 0.623529 * 255, 0.633239 * 255, + 0.749020 * 255, 0.748242 * 255, 0.874510 * 255, 0.862234 * 255, + 1.000000 * 255, 0.964176 * 255, + }; + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_RED, 18, red_pts); + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_GREEN, 18, green_pts); + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts); + } + break; + case BEAUTIFY_EFFECT_PINK_LADY: + { + guint8 red_pts[] = { + 0.000000 * 255, 0.003922 * 255, + 0.121569 * 255, 0.196078 * 255, + 0.247059 * 255, 0.356863 * 255, + 0.372549 * 255, 0.509804 * 255, + 0.498039 * 255, 0.647059 * 255, + 0.623529 * 255, 0.760784 * 255, + 0.749020 * 255, 0.858824 * 255, + 0.874510 * 255, 0.937255 * 255, + 1.000000 * 255, 1.000000 * 255, + }; + guint8 green_pts[] = { + 0.000000 * 255, 0.003922 * 255, + 0.121569 * 255, 0.180392 * 255, + 0.247059 * 255, 0.329412 * 255, + 0.372549 * 255, 0.478431 * 255, + 0.498039 * 255, 0.611765 * 255, + 0.623529 * 255, 0.729412 * 255, + 0.749020 * 255, 0.831373 * 255, + 0.874510 * 255, 0.921569 * 255, + 1.000000 * 255, 1.000000 * 255, + }; + guint8 blue_pts[] = { + 0.000000 * 255, 0.003922 * 255, + 0.121569 * 255, 0.168627 * 255, + 0.247059 * 255, 0.317647 * 255, + 0.372549 * 255, 0.458824 * 255, + 0.498039 * 255, 0.592157 * 255, + 0.623529 * 255, 0.709804 * 255, + 0.749020 * 255, 0.819608 * 255, + 0.874510 * 255, 0.913725 * 255, + 1.000000 * 255, 1.000000 * 255, + }; + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_RED, 18, red_pts); + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_GREEN, 18, green_pts); + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts); + break; + } + case BEAUTIFY_EFFECT_ABAO: + /* TODO */ + break; + case BEAUTIFY_EFFECT_ICE_SPIRIT: + { + guint8 red_pts[] = { + 0.0, 0.007843 * 255, 0.121569 * 255, 0.141176 * 255, + 0.247059 * 255, 0.286275 * 255, 0.372549 * 255, 0.423529 * 255, + 0.498039 * 255, 0.552941 * 255, 0.623529 * 255, 0.674510 * 255, + 0.749020 * 255, 0.792157 * 255, 0.874510 * 255, 0.898039 * 255, + 1.000000 * 255, 1.000000 * 255, + }; + guint8 green_pts[] = { + 0.0, 0.007843 * 255, 0.121569 * 255, 0.184314 * 255, + 0.247059 * 255, 0.360784 * 255, 0.372549 * 255, 0.517647 * 255, + 0.498039 * 255, 0.654902 * 255, 0.623529 * 255, 0.768627 * 255, + 0.749020 * 255, 0.866667 * 255, 0.874510 * 255, 0.945098 * 255, + 1.000000 * 255, 1.000000 * 255, + }; + guint8 blue_pts[] = { + 0.0, 0.007843 * 255, 0.121569 * 255, 0.211765 * 255, + 0.247059 * 255, 0.407843 * 255, 0.372549 * 255, 0.576471 * 255, + 0.498039 * 255, 0.717647 * 255, 0.623529 * 255, 0.827451 * 255, + 0.749020 * 255, 0.913725 * 255, 0.874510 * 255, 0.972549 * 255, + 1.000000 * 255, 1.000000 * 255, + }; + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_RED, 18, red_pts); + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_GREEN, 18, green_pts); + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts); + } + break; + case BEAUTIFY_EFFECT_JAPANESE: + { + guint8 red_pts[] = { + 0.0, 0.098039 * 255, 0.121569 * 255, 0.188479 * 255, + 0.247059 * 255, 0.329761 * 255, 0.372549 * 255, 0.496682 * 255, + 0.498039 * 255, 0.657383 * 255, 0.623529 * 255, 0.787002 * 255, + 0.749020 * 255, 0.864444 * 255, 0.874510 * 255, 0.900704 * 255, + 1.000000 * 255, 0.917552 * 255, + }; + guint8 green_pts[] = { + 0.0, 0.103431 * 255, 0.121569 * 255, 0.224676 * 255, + 0.247059 * 255, 0.394142 * 255, 0.372549 * 255, 0.541888 * 255, + 0.498039 * 255, 0.675963 * 255, 0.623529 * 255, 0.785613 * 255, + 0.749020 * 255, 0.893224 * 255, 0.874510 * 255, 0.943625 * 255, + 1.000000 * 255, 0.972720 * 255, + }; + guint8 blue_pts[] = { + 0.0, 0.412025 * 255, 0.121569 * 255, 0.469119 * 255, + 0.247059 * 255, 0.615777 * 255, 0.372549 * 255, 0.751174 * 255, + 0.498039 * 255, 0.862955 * 255, 0.623529 * 255, 0.954468 * 255, + 0.749020 * 255, 0.995760 * 255, 0.874510 * 255, 1.000000 * 255, + 1.000000 * 255, 1.000000 * 255, + }; + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_RED, 18, red_pts); + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_GREEN, 18, green_pts); + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts); + } + break; + case BEAUTIFY_EFFECT_NEW_JAPANESE: + { + guint8 red_pts[] = { + 0.0, 0.042969 * 255, + 0.350610 * 255, 0.320312 * 255, + 0.621951 * 255, 0.566406 * 255, + 0.847561 * 255, 0.632812 * 255, + 1.000000 * 255, 0.769531 * 255, + }; + guint8 green_pts[] = { + 0.0, 0.031250 * 255, + 0.125000 * 255, 0.144531 * 255, + 0.500000 * 255, 0.523438 * 255, + 0.881098 * 255, 0.738281 * 255, + 1.000000 * 255, 0.882812 * 255, + }; + guint8 blue_pts[] = { + 0.0, 0.0, + 0.121951 * 255, 0.039062 * 255, + 1.000000 * 255, 0.972656 * 255, + }; + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_RED, 10, red_pts); + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_GREEN, 10, green_pts); + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_BLUE, 6, blue_pts); + } + break; + case BEAUTIFY_EFFECT_WARM_YELLOW: + { + guint8 red_pts[] = { + 0.0, 0.000980 * 255, 0.121569 * 255, 0.065574 * 255, + 0.247059 * 255, 0.213677 * 255, 0.372549 * 255, 0.383298 * 255, + 0.498039 * 255, 0.556855 * 255, 0.623529 * 255, 0.726149 * 255, + 0.749020 * 255, 0.864046 * 255, 0.874510 * 255, 0.958157 * 255, + 1.000000 * 255, 0.996641 * 255, + }; + guint8 green_pts[] = { + 0.0, 0.005882 * 255, 0.121569 * 255, 0.107837 * 255, + 0.247059 * 255, 0.276792 * 255, 0.372549 * 255, 0.452811 * 255, + 0.498039 * 255, 0.617782 * 255, 0.623529 * 255, 0.763782 * 255, + 0.749020 * 255, 0.886822 * 255, 0.874510 * 255, 0.965223 * 255, + 1.000000 * 255, 0.996993 * 255, + }; + guint8 blue_pts[] = { + 0.0, 0.000495 * 255, 0.121569 * 255, 0.035825 * 255, + 0.247059 * 255, 0.149480 * 255, 0.372549 * 255, 0.305398 * 255, + 0.498039 * 255, 0.491352 * 255, 0.623529 * 255, 0.670305 * 255, + 0.749020 * 255, 0.838898 * 255, 0.874510 * 255, 0.951301 * 255, + 1.000000 * 255, 0.994118 * 255, + }; + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_RED, 18, red_pts); + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_GREEN, 18, green_pts); + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts); + } + break; + case BEAUTIFY_EFFECT_BLUES: + { + guint8 red_pts[] = { + 0.000000 * 255, 0.003922 * 255, + 0.121569 * 255, 0.321569 * 255, + 0.247059 * 255, 0.541176 * 255, + 0.372549 * 255, 0.713725 * 255, + 0.498039 * 255, 0.831373 * 255, + 0.623529 * 255, 0.905882 * 255, + 0.749020 * 255, 0.952941 * 255, + 0.874510 * 255, 0.980392 * 255, + 1.000000 * 255, 1.000000 * 255, + }; + guint8 green_pts[] = { + 0.000000 * 255, 0.003922 * 255, + 0.121569 * 255, 0.266667 * 255, + 0.247059 * 255, 0.466667 * 255, + 0.372549 * 255, 0.627451 * 255, + 0.498039 * 255, 0.756863 * 255, + 0.623529 * 255, 0.847059 * 255, + 0.749020 * 255, 0.917647 * 255, + 0.874510 * 255, 0.964706 * 255, + 1.000000 * 255, 1.000000 * 255, + }; + guint8 blue_pts[] = { + 0.000000 * 255, 0.007843 * 255, + 0.121569 * 255, 0.286275 * 255, + 0.247059 * 255, 0.505882 * 255, + 0.372549 * 255, 0.682353 * 255, + 0.498039 * 255, 0.811765 * 255, + 0.623529 * 255, 0.901961 * 255, + 0.749020 * 255, 0.960784 * 255, + 0.874510 * 255, 0.988235 * 255, + 1.000000 * 255, 0.996078 * 255, + }; + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_RED, 18, red_pts); + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_GREEN, 18, green_pts); + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts); + break; + } + case BEAUTIFY_EFFECT_PURPLE_FANTASY: + { + guint8 red_pts[] = { + 0.000000 * 255, 0.003922 * 255, + 0.121569 * 255, 0.184314 * 255, + 0.247059 * 255, 0.376471 * 255, + 0.372549 * 255, 0.533333 * 255, + 0.498039 * 255, 0.662745 * 255, + 0.623529 * 255, 0.788235 * 255, + 0.749020 * 255, 0.878431 * 255, + 0.874510 * 255, 0.941176 * 255, + 1.000000 * 255, 1.000000 * 255, + }; + guint8 green_pts[] = { + 0.000000 * 255, 0.003922 * 255, + 0.121569 * 255, 0.113725 * 255, + 0.247059 * 255, 0.243137 * 255, + 0.372549 * 255, 0.407843 * 255, + 0.498039 * 255, 0.623529 * 255, + 0.623529 * 255, 0.760784 * 255, + 0.749020 * 255, 0.847059 * 255, + 0.874510 * 255, 0.925490 * 255, + 1.000000 * 255, 1.000000 * 255, + }; + guint8 blue_pts[] = { + 0.000000 * 255, 0.007843 * 255, + 0.121569 * 255, 0.309804 * 255, + 0.247059 * 255, 0.505882 * 255, + 0.372549 * 255, 0.603922 * 255, + 0.498039 * 255, 0.709804 * 255, + 0.623529 * 255, 0.784314 * 255, + 0.749020 * 255, 0.854902 * 255, + 0.874510 * 255, 0.929412 * 255, + 1.000000 * 255, 1.000000 * 255, + }; + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_RED, 18, red_pts); + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_GREEN, 18, green_pts); + gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts); + break; + } + case BEAUTIFY_EFFECT_BRIGHT_RED: + { + gint32 layer; + GdkPixbuf *pixbuf; + + pixbuf = gdk_pixbuf_new_from_inline (-1, texture_bright_red, FALSE, NULL); + layer = gimp_layer_new_from_pixbuf (image_ID, "texture", pixbuf, 100, GIMP_SCREEN_MODE, 0, 0); + gimp_image_insert_layer (image_ID, layer, -1, 0); + gimp_layer_scale (layer, width, height, FALSE); + gimp_image_merge_down (image_ID, layer, GIMP_CLIP_TO_BOTTOM_LAYER); + + guint8 red_pts[] = { + 0.000000 * 255, 0.001183 * 255, + 0.121569 * 255, 0.131140 * 255, + 0.247059 * 255, 0.353431 * 255, + 0.372549 * 255, 0.538498 * 255, + 0.498039 * 255, 0.690185 * 255, + 0.623529 * 255, 0.804008 * 255, + 0.749020 * 255, 0.900806 * 255, + 0.874510 * 255, 0.988271 * 255, + 1.000000 * 255, 1.000000 * 255, + }; + guint8 green_pts[] = { + 0.000000 * 255, 0.000098 * 255, + 0.121569 * 255, 0.097098 * 255, + 0.247059 * 255, 0.286323 * 255, + 0.372549 * 255, 0.458654 * 255, + 0.498039 * 255, 0.611045 * 255, + 0.623529 * 255, 0.744221 * 255, + 0.749020 * 255, 0.858522 * 255, + 0.874510 * 255, 0.968540 * 255, + 1.000000 * 255, 1.000000 * 255, + }; + guint8 blue_pts[] = { + 0.000000 * 255, 0.000369 * 255, + 0.121569 * 255, 0.100320 * 255, + 0.247059 * 255, 0.285806 * 255, + 0.372549 * 255, 0.459693 * 255, + 0.498039 * 255, 0.612676 * 255, + 0.623529 * 255, 0.745027 * 255, + 0.749020 * 255, 0.860280 * 255, + 0.874510 * 255, 0.967918 * 255, + 1.000000 * 255, 1.000000 * 255, + }; + layer = gimp_image_get_active_layer (image_ID); + gimp_curves_spline (layer, GIMP_HISTOGRAM_RED, 18, red_pts); + gimp_curves_spline (layer, GIMP_HISTOGRAM_GREEN, 18, green_pts); + gimp_curves_spline (layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts); + break; + } + case BEAUTIFY_EFFECT_CHRISTMAS_EVE: + { + gint32 layer = gimp_layer_new (image_ID, "color", width, height, GIMP_RGB_IMAGE, 100, GIMP_OVERLAY_MODE); + gimp_image_insert_layer (image_ID, layer, -1, 0); + GimpRGB color = + { + (gdouble) 156.0 / 255.0, + (gdouble) 208.0 / 255.0, + (gdouble) 240.0 / 255.0, + 1.0, + }; + gimp_context_set_foreground (&color); + gimp_edit_fill (layer, GIMP_FOREGROUND_FILL); + gimp_image_merge_down (image_ID, layer, GIMP_CLIP_TO_BOTTOM_LAYER); + + GdkPixbuf *pixbuf = gdk_pixbuf_new_from_inline (-1, texture_christmas_eve, FALSE, NULL); + gint32 texture_layer = gimp_layer_new_from_pixbuf (image_ID, "texture", pixbuf, 100, GIMP_SCREEN_MODE, 0, 0); + gimp_image_insert_layer (image_ID, texture_layer, -1, 0); + gimp_layer_scale (texture_layer, width, height, FALSE); + gimp_image_merge_down (image_ID, texture_layer, GIMP_CLIP_TO_BOTTOM_LAYER); + break; + } + case BEAUTIFY_EFFECT_ASTRAL: + { + GdkPixbuf *pixbuf = gdk_pixbuf_new_from_inline (-1, texture_astral, FALSE, NULL); + gint32 texture_layer = gimp_layer_new_from_pixbuf (image_ID, "texture", pixbuf, 100, GIMP_SOFTLIGHT_MODE, 0, 0); + gimp_image_insert_layer (image_ID, texture_layer, -1, 0); + gimp_layer_scale (texture_layer, width, height, FALSE); + gimp_image_merge_down (image_ID, texture_layer, GIMP_CLIP_TO_BOTTOM_LAYER); + } + break; + case BEAUTIFY_EFFECT_PICK_LIGHT: + { + gint32 layer; + GdkPixbuf *pixbuf; + + layer = gimp_layer_new (image_ID, "color", width, height, GIMP_RGB_IMAGE, 100, GIMP_SCREEN_MODE); + gimp_image_insert_layer (image_ID, layer, -1, 0); + GimpRGB color = + { + (gdouble) 62.0 / 255.0, + (gdouble) 62.0 / 255.0, + (gdouble) 62.0 / 255.0, + 1.0, + }; + gimp_context_set_foreground (&color); + gimp_edit_fill (layer, GIMP_FOREGROUND_FILL); + gimp_image_merge_down (image_ID, layer, GIMP_CLIP_TO_BOTTOM_LAYER); + + pixbuf = gdk_pixbuf_new_from_inline (-1, texture_pick_light_1, FALSE, NULL); + layer = gimp_layer_new_from_pixbuf (image_ID, "texture 1", pixbuf, 100, GIMP_SCREEN_MODE, 0, 0); + gimp_image_insert_layer (image_ID, layer, -1, 0); + gimp_layer_scale (layer, width, height, FALSE); + gimp_image_merge_down (image_ID, layer, GIMP_CLIP_TO_BOTTOM_LAYER); + + pixbuf = gdk_pixbuf_new_from_inline (-1, texture_pick_light_2, FALSE, NULL); + layer = gimp_layer_new_from_pixbuf (image_ID, "texture 2", pixbuf, 100, GIMP_SCREEN_MODE, 0, 0); + gimp_image_insert_layer (image_ID, layer, -1, 0); + gimp_layer_scale (layer, width, height, FALSE); + gimp_image_merge_down (image_ID, layer, GIMP_CLIP_TO_BOTTOM_LAYER); + break; + } + } + + gimp_context_pop (); +} + diff --git a/beautify-effect.h b/beautify-effect.h new file mode 100644 index 0000000..5b891d1 --- /dev/null +++ b/beautify-effect.h @@ -0,0 +1,48 @@ +/** + * Copyright (C) 2012 hejian + * + * 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 . + */ + +typedef enum +{ + BEAUTIFY_EFFECT_NONE, + BEAUTIFY_EFFECT_SOFT_LIGHT, + BEAUTIFY_EFFECT_WARM, + BEAUTIFY_EFFECT_SHARPEN, + BEAUTIFY_EFFECT_STRONG_CONTRAST, + BEAUTIFY_EFFECT_SMART_COLOR, + BEAUTIFY_EFFECT_INVERT, + + BEAUTIFY_EFFECT_GOTHIC_STYLE, + BEAUTIFY_EFFECT_CLASSIC_HDR, + BEAUTIFY_EFFECT_IMPRESSION, + + BEAUTIFY_EFFECT_LITTLE_FRESH, + BEAUTIFY_EFFECT_PINK_LADY, + BEAUTIFY_EFFECT_ABAO, + BEAUTIFY_EFFECT_ICE_SPIRIT, + BEAUTIFY_EFFECT_JAPANESE, + BEAUTIFY_EFFECT_NEW_JAPANESE, + BEAUTIFY_EFFECT_WARM_YELLOW, + BEAUTIFY_EFFECT_BLUES, + BEAUTIFY_EFFECT_PURPLE_FANTASY, + + BEAUTIFY_EFFECT_BRIGHT_RED, + BEAUTIFY_EFFECT_CHRISTMAS_EVE, + BEAUTIFY_EFFECT_ASTRAL, + BEAUTIFY_EFFECT_PICK_LIGHT, +} BeautifyEffectType; + +void run_effect (gint32 image_ID, BeautifyEffectType effect); diff --git a/beautify.c b/beautify.c index b1a63bb..83fd9ee 100644 --- a/beautify.c +++ b/beautify.c @@ -18,14 +18,12 @@ #include #include -#include "beautify-textures.h" +#include "beautify-effect.h" #define PLUG_IN_PROC "plug-in-beautify" #define PLUG_IN_BINARY "beautify" #define PLUG_IN_ROLE "gimp-beautify" -#define TEXTURE_PATH "textures/effects" - #define PREVIEW_SIZE 480 #define THUMBNAIL_SIZE 80 @@ -41,36 +39,6 @@ typedef struct gdouble yellow_blue; } BeautifyValues; -typedef enum -{ - BEAUTIFY_EFFECT_NONE, - BEAUTIFY_EFFECT_SOFT_LIGHT, - BEAUTIFY_EFFECT_WARM, - BEAUTIFY_EFFECT_SHARPEN, - BEAUTIFY_EFFECT_STRONG_CONTRAST, - BEAUTIFY_EFFECT_SMART_COLOR, - BEAUTIFY_EFFECT_INVERT, - - BEAUTIFY_EFFECT_GOTHIC_STYLE, - BEAUTIFY_EFFECT_CLASSIC_HDR, - BEAUTIFY_EFFECT_IMPRESSION, - - BEAUTIFY_EFFECT_LITTLE_FRESH, - BEAUTIFY_EFFECT_PINK_LADY, - BEAUTIFY_EFFECT_ABAO, - BEAUTIFY_EFFECT_ICE_SPIRIT, - BEAUTIFY_EFFECT_JAPANESE, - BEAUTIFY_EFFECT_NEW_JAPANESE, - BEAUTIFY_EFFECT_WARM_YELLOW, - BEAUTIFY_EFFECT_BLUES, - BEAUTIFY_EFFECT_PURPLE_FANTASY, - - BEAUTIFY_EFFECT_BRIGHT_RED, - BEAUTIFY_EFFECT_CHRISTMAS_EVE, - BEAUTIFY_EFFECT_ASTRAL, - BEAUTIFY_EFFECT_PICK_LIGHT, -} BeautifyEffectType; - static const BeautifyEffectType basic_effects[] = { BEAUTIFY_EFFECT_SOFT_LIGHT, @@ -147,7 +115,6 @@ static GtkWidget* effect_icon_new (BeautifyEffectType effect); static gboolean select_effect (GtkWidget *widget, GdkEvent *event, gpointer user_data); -static void do_effect (gint32 image, BeautifyEffectType effect); static void reset_adjustment (); static void apply_effect (); @@ -890,7 +857,7 @@ effect_icon_new (BeautifyEffectType effect) } gint32 image = gimp_image_duplicate (preview_image); - do_effect (image, effect); + run_effect (image, effect); GtkWidget *box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); @@ -920,7 +887,7 @@ select_effect (GtkWidget *widget, GdkEvent *event, gpointer user_data) apply_effect(); BeautifyEffectType effect = (BeautifyEffectType) user_data; - do_effect (preview_image, effect); + run_effect (preview_image, effect); current_effect = effect; preview_update (preview); @@ -931,596 +898,6 @@ select_effect (GtkWidget *widget, GdkEvent *event, gpointer user_data) return TRUE; } -static void -do_effect (gint32 image, BeautifyEffectType effect) -{ - gimp_context_push (); - - gint32 layer = gimp_image_get_active_layer (image); - gint32 effect_layer = gimp_layer_copy (layer); - gimp_image_add_layer (image, effect_layer, -1); - - switch (effect) - { - case BEAUTIFY_EFFECT_SOFT_LIGHT: - gimp_layer_set_mode (effect_layer, GIMP_SOFTLIGHT_MODE); - break; - - case BEAUTIFY_EFFECT_WARM: - { - guint8 red_pts[] = { - 0.0, 0.082031 * 255, - 0.405488 * 255, 0.621094 * 255, - 0.954268 * 255, 1.000000 * 255, - }; - guint8 green_pts[] = { - 0.0, 0.0, - 0.503049 * 255, 0.636719 * 255, - 1.000000 * 255, 1.000000 * 255, - }; - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_RED, 6, red_pts); - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_GREEN, 6, green_pts); - } - break; - - case BEAUTIFY_EFFECT_SHARPEN: - { - gint nreturn_vals; - GimpParam *return_vals = gimp_run_procedure ("plug-in-sharpen", - &nreturn_vals, - GIMP_PDB_INT32, 1, - GIMP_PDB_IMAGE, image, - GIMP_PDB_DRAWABLE, effect_layer, - GIMP_PDB_INT32, 50, - GIMP_PDB_END); - gimp_destroy_params (return_vals, nreturn_vals); - } - break; - case BEAUTIFY_EFFECT_STRONG_CONTRAST: - { - guint8 red_pts[] = { - 0.000000 * 255, 0.003922 * 255, - 0.121569 * 255, 0.039216 * 255, - 0.247059 * 255, 0.105882 * 255, - 0.372549 * 255, 0.235294 * 255, - 0.498039 * 255, 0.537255 * 255, - 0.623529 * 255, 0.768627 * 255, - 0.749020 * 255, 0.858824 * 255, - 0.874510 * 255, 0.929412 * 255, - 1.000000 * 255, 1.000000 * 255, - }; - guint8 green_pts[] = { - 0.000000 * 255, 0.003922 * 255, - 0.121569 * 255, 0.027451 * 255, - 0.247059 * 255, 0.117647 * 255, - 0.372549 * 255, 0.286275 * 255, - 0.498039 * 255, 0.576471 * 255, - 0.623529 * 255, 0.780392 * 255, - 0.749020 * 255, 0.890196 * 255, - 0.874510 * 255, 0.952941 * 255, - 1.000000 * 255, 1.000000 * 255, - }; - guint8 blue_pts[] = { - 0.000000 * 255, 0.003922 * 255, - 0.121569 * 255, 0.050980 * 255, - 0.247059 * 255, 0.133333 * 255, - 0.372549 * 255, 0.294118 * 255, - 0.498039 * 255, 0.568627 * 255, - 0.623529 * 255, 0.772549 * 255, - 0.749020 * 255, 0.874510 * 255, - 0.874510 * 255, 0.941176 * 255, - 1.000000 * 255, 1.000000 * 255, - }; - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_RED, 18, red_pts); - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_GREEN, 18, green_pts); - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts); - break; - } - case BEAUTIFY_EFFECT_SMART_COLOR: - { - guint8 red_pts[] = { - 0.0, 0.001012 * 255, 0.121569 * 255, 0.126695 * 255, - 0.247059 * 255, 0.279821 * 255, 0.372549 * 255, 0.428038 * 255, - 0.498039 * 255, 0.567700 * 255, 0.623529 * 255, 0.699439 * 255, - 0.749020 * 255, 0.821423 * 255, 0.874510 * 255, 0.953474 * 255, - 1.000000 * 255, 0.997988 * 255, - }; - guint8 green_pts[] = { - 0.0, 0.004278 * 255, 0.121569 * 255, 0.107139 * 255, - 0.247059 * 255, 0.225961 * 255, 0.372549 * 255, 0.346578 * 255, - 0.498039 * 255, 0.472647 * 255, 0.623529 * 255, 0.602136 * 255, - 0.749020 * 255, 0.730046 * 255, 0.874510 * 255, 0.873495 * 255, - 1.000000 * 255, 0.996787 * 255, - }; - guint8 blue_pts[] = { - 0.0, 0.000105 * 255, 0.121569 * 255, 0.060601 * 255, - 0.247059 * 255, 0.146772 * 255, 0.372549 * 255, 0.262680 * 255, - 0.498039 * 255, 0.408053 * 255, 0.623529 * 255, 0.566459 * 255, - 0.749020 * 255, 0.691468 * 255, 0.874510 * 255, 0.847356 * 255, - 1.000000 * 255, 0.999226 * 255, - }; - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_RED, 18, red_pts); - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_GREEN, 18, green_pts); - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts); - } - break; - case BEAUTIFY_EFFECT_INVERT: - gimp_invert (effect_layer); - break; - case BEAUTIFY_EFFECT_GOTHIC_STYLE: - { - guint8 red_pts[] = { - 0.0, 0.003922 * 255, 0.121569 * 255, 0.011765 * 255, - 0.247059 * 255, 0.074510 * 255, 0.372549 * 255, 0.200000 * 255, - 0.498039 * 255, 0.380392 * 255, 0.623529 * 255, 0.584314 * 255, - 0.749020 * 255, 0.784314 * 255, 0.874510 * 255, 0.933333 * 255, - 1.000000 * 255, 1.000000 * 255, - }; - guint8 green_pts[] = { - 0.0, 0.003922 * 255, 0.121569 * 255, 0.039216 * 255, - 0.247059 * 255, 0.160784 * 255, 0.372549 * 255, 0.317647 * 255, - 0.498039 * 255, 0.501961 * 255, 0.623529 * 255, 0.682353 * 255, - 0.749020 * 255, 0.843137 * 255, 0.874510 * 255, 0.952941 * 255, - 1.000000 * 255, 1.000000 * 255, - }; - guint8 blue_pts[] = { - 0.0, 0.003922 * 255, 0.121569 * 255, 0.007843 * 255, - 0.247059 * 255, 0.058824 * 255, 0.372549 * 255, 0.172549 * 255, - 0.498039 * 255, 0.349020 * 255, 0.623529 * 255, 0.556863 * 255, - 0.749020 * 255, 0.768627 * 255, 0.874510 * 255, 0.929412 * 255, - 1.000000 * 255, 1.000000 * 255, - }; - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_RED, 18, red_pts); - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_GREEN, 18, green_pts); - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts); - } - break; - case BEAUTIFY_EFFECT_CLASSIC_HDR: - { - guint8 red_pts[] = { - 0.0, 0.054902 * 255, 0.121569 * 255, 0.070588 * 255, - 0.247059 * 255, 0.243137 * 255, 0.372549 * 255, 0.407843 * 255, - 0.498039 * 255, 0.552941 * 255, 0.623529 * 255, 0.678431 * 255, - 0.749020 * 255, 0.780392 * 255, 0.874510 * 255, 0.866667 * 255, - 1.000000 * 255, 0.949020 * 255, - }; - guint8 green_pts[] = { - 0.0, 0.007843 * 255, 0.121569 * 255, 0.023529 * 255, - 0.247059 * 255, 0.207843 * 255, 0.372549 * 255, 0.388235 * 255, - 0.498039 * 255, 0.541176 * 255, 0.623529 * 255, 0.682353 * 255, - 0.749020 * 255, 0.796078 * 255, 0.874510 * 255, 0.898039 * 255, - 1.000000 * 255, 0.996078 * 255, - }; - guint8 blue_pts[] = { - 0.0, 0.258824 * 255, 0.121569 * 255, 0.294118 * 255, - 0.247059 * 255, 0.372549 * 255, 0.372549 * 255, 0.450980 * 255, - 0.498039 * 255, 0.521569 * 255, 0.623529 * 255, 0.592157 * 255, - 0.749020 * 255, 0.654902 * 255, 0.874510 * 255, 0.717647 * 255, - 1.000000 * 255, 0.776471 * 255, - }; - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_RED, 18, red_pts); - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_GREEN, 18, green_pts); - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts); - } - break; - case BEAUTIFY_EFFECT_IMPRESSION: - { - guint8 red_pts[] = { - 0.000000 * 255, 0.113725 * 255, - 0.121569 * 255, 0.213975 * 255, - 0.247059 * 255, 0.323494 * 255, - 0.372549 * 255, 0.460137 * 255, - 0.498039 * 255, 0.621504 * 255, - 0.623529 * 255, 0.716847 * 255, - 0.749020 * 255, 0.766909 * 255, - 0.874510 * 255, 0.817666 * 255, - 1.000000 * 255, 0.862745 * 255, - }; - guint8 green_pts[] = { - 0.000000 * 255, 0.200000 * 255, - 0.121569 * 255, 0.317329 * 255, - 0.247059 * 255, 0.407881 * 255, - 0.372549 * 255, 0.535429 * 255, - 0.498039 * 255, 0.682828 * 255, - 0.623529 * 255, 0.770688 * 255, - 0.749020 * 255, 0.813005 * 255, - 0.874510 * 255, 0.852891 * 255, - 1.000000 * 255, 0.902716 * 255, - }; - guint8 blue_pts[] = { - 0.000000 * 255, 0.317714 * 255, - 0.121569 * 255, 0.364205 * 255, - 0.247059 * 255, 0.417294 * 255, - 0.372549 * 255, 0.495841 * 255, - 0.498039 * 255, 0.612710 * 255, - 0.623529 * 255, 0.719834 * 255, - 0.749020 * 255, 0.795937 * 255, - 0.874510 * 255, 0.845977 * 255, - 1.000000 * 255, 0.883024 * 255, - }; - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_RED, 18, red_pts); - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_GREEN, 18, green_pts); - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts); - break; - } - case BEAUTIFY_EFFECT_LITTLE_FRESH: - { - guint8 red_pts[] = { - 0.0, 0.002975 * 255, 0.121569 * 255, 0.135413 * 255, - 0.247059 * 255, 0.271797 * 255, 0.372549 * 255, 0.420642 * 255, - 0.498039 * 255, 0.587088 * 255, 0.623529 * 255, 0.672206 * 255, - 0.749020 * 255, 0.781208 * 255, 0.874510 * 255, 0.881668 * 255, - 1.000000 * 255, 0.993149 * 255, - }; - guint8 green_pts[] = { - 0.0, 0.001070 * 255, 0.121569 * 255, 0.123393 * 255, - 0.247059 * 255, 0.254300 * 255, 0.372549 * 255, 0.377336 * 255, - 0.498039 * 255, 0.486582 * 255, 0.623529 * 255, 0.607331 * 255, - 0.749020 * 255, 0.722174 * 255, 0.874510 * 255, 0.858206 * 255, - 1.000000 * 255, 0.992154 * 255, - }; - guint8 blue_pts[] = { - 0.0, 0.003917 * 255, 0.121569 * 255, 0.098807 * 255, - 0.247059 * 255, 0.234746 * 255, 0.372549 * 255, 0.378388 * 255, - 0.498039 * 255, 0.520273 * 255, 0.623529 * 255, 0.633239 * 255, - 0.749020 * 255, 0.748242 * 255, 0.874510 * 255, 0.862234 * 255, - 1.000000 * 255, 0.964176 * 255, - }; - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_RED, 18, red_pts); - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_GREEN, 18, green_pts); - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts); - } - break; - case BEAUTIFY_EFFECT_PINK_LADY: - { - guint8 red_pts[] = { - 0.000000 * 255, 0.003922 * 255, - 0.121569 * 255, 0.196078 * 255, - 0.247059 * 255, 0.356863 * 255, - 0.372549 * 255, 0.509804 * 255, - 0.498039 * 255, 0.647059 * 255, - 0.623529 * 255, 0.760784 * 255, - 0.749020 * 255, 0.858824 * 255, - 0.874510 * 255, 0.937255 * 255, - 1.000000 * 255, 1.000000 * 255, - }; - guint8 green_pts[] = { - 0.000000 * 255, 0.003922 * 255, - 0.121569 * 255, 0.180392 * 255, - 0.247059 * 255, 0.329412 * 255, - 0.372549 * 255, 0.478431 * 255, - 0.498039 * 255, 0.611765 * 255, - 0.623529 * 255, 0.729412 * 255, - 0.749020 * 255, 0.831373 * 255, - 0.874510 * 255, 0.921569 * 255, - 1.000000 * 255, 1.000000 * 255, - }; - guint8 blue_pts[] = { - 0.000000 * 255, 0.003922 * 255, - 0.121569 * 255, 0.168627 * 255, - 0.247059 * 255, 0.317647 * 255, - 0.372549 * 255, 0.458824 * 255, - 0.498039 * 255, 0.592157 * 255, - 0.623529 * 255, 0.709804 * 255, - 0.749020 * 255, 0.819608 * 255, - 0.874510 * 255, 0.913725 * 255, - 1.000000 * 255, 1.000000 * 255, - }; - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_RED, 18, red_pts); - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_GREEN, 18, green_pts); - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts); - break; - } - case BEAUTIFY_EFFECT_ABAO: - /* TODO */ - break; - case BEAUTIFY_EFFECT_ICE_SPIRIT: - { - guint8 red_pts[] = { - 0.0, 0.007843 * 255, 0.121569 * 255, 0.141176 * 255, - 0.247059 * 255, 0.286275 * 255, 0.372549 * 255, 0.423529 * 255, - 0.498039 * 255, 0.552941 * 255, 0.623529 * 255, 0.674510 * 255, - 0.749020 * 255, 0.792157 * 255, 0.874510 * 255, 0.898039 * 255, - 1.000000 * 255, 1.000000 * 255, - }; - guint8 green_pts[] = { - 0.0, 0.007843 * 255, 0.121569 * 255, 0.184314 * 255, - 0.247059 * 255, 0.360784 * 255, 0.372549 * 255, 0.517647 * 255, - 0.498039 * 255, 0.654902 * 255, 0.623529 * 255, 0.768627 * 255, - 0.749020 * 255, 0.866667 * 255, 0.874510 * 255, 0.945098 * 255, - 1.000000 * 255, 1.000000 * 255, - }; - guint8 blue_pts[] = { - 0.0, 0.007843 * 255, 0.121569 * 255, 0.211765 * 255, - 0.247059 * 255, 0.407843 * 255, 0.372549 * 255, 0.576471 * 255, - 0.498039 * 255, 0.717647 * 255, 0.623529 * 255, 0.827451 * 255, - 0.749020 * 255, 0.913725 * 255, 0.874510 * 255, 0.972549 * 255, - 1.000000 * 255, 1.000000 * 255, - }; - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_RED, 18, red_pts); - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_GREEN, 18, green_pts); - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts); - } - break; - case BEAUTIFY_EFFECT_JAPANESE: - { - guint8 red_pts[] = { - 0.0, 0.098039 * 255, 0.121569 * 255, 0.188479 * 255, - 0.247059 * 255, 0.329761 * 255, 0.372549 * 255, 0.496682 * 255, - 0.498039 * 255, 0.657383 * 255, 0.623529 * 255, 0.787002 * 255, - 0.749020 * 255, 0.864444 * 255, 0.874510 * 255, 0.900704 * 255, - 1.000000 * 255, 0.917552 * 255, - }; - guint8 green_pts[] = { - 0.0, 0.103431 * 255, 0.121569 * 255, 0.224676 * 255, - 0.247059 * 255, 0.394142 * 255, 0.372549 * 255, 0.541888 * 255, - 0.498039 * 255, 0.675963 * 255, 0.623529 * 255, 0.785613 * 255, - 0.749020 * 255, 0.893224 * 255, 0.874510 * 255, 0.943625 * 255, - 1.000000 * 255, 0.972720 * 255, - }; - guint8 blue_pts[] = { - 0.0, 0.412025 * 255, 0.121569 * 255, 0.469119 * 255, - 0.247059 * 255, 0.615777 * 255, 0.372549 * 255, 0.751174 * 255, - 0.498039 * 255, 0.862955 * 255, 0.623529 * 255, 0.954468 * 255, - 0.749020 * 255, 0.995760 * 255, 0.874510 * 255, 1.000000 * 255, - 1.000000 * 255, 1.000000 * 255, - }; - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_RED, 18, red_pts); - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_GREEN, 18, green_pts); - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts); - } - break; - case BEAUTIFY_EFFECT_NEW_JAPANESE: - { - guint8 red_pts[] = { - 0.0, 0.042969 * 255, - 0.350610 * 255, 0.320312 * 255, - 0.621951 * 255, 0.566406 * 255, - 0.847561 * 255, 0.632812 * 255, - 1.000000 * 255, 0.769531 * 255, - }; - guint8 green_pts[] = { - 0.0, 0.031250 * 255, - 0.125000 * 255, 0.144531 * 255, - 0.500000 * 255, 0.523438 * 255, - 0.881098 * 255, 0.738281 * 255, - 1.000000 * 255, 0.882812 * 255, - }; - guint8 blue_pts[] = { - 0.0, 0.0, - 0.121951 * 255, 0.039062 * 255, - 1.000000 * 255, 0.972656 * 255, - }; - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_RED, 10, red_pts); - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_GREEN, 10, green_pts); - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_BLUE, 6, blue_pts); - } - break; - case BEAUTIFY_EFFECT_WARM_YELLOW: - { - guint8 red_pts[] = { - 0.0, 0.000980 * 255, 0.121569 * 255, 0.065574 * 255, - 0.247059 * 255, 0.213677 * 255, 0.372549 * 255, 0.383298 * 255, - 0.498039 * 255, 0.556855 * 255, 0.623529 * 255, 0.726149 * 255, - 0.749020 * 255, 0.864046 * 255, 0.874510 * 255, 0.958157 * 255, - 1.000000 * 255, 0.996641 * 255, - }; - guint8 green_pts[] = { - 0.0, 0.005882 * 255, 0.121569 * 255, 0.107837 * 255, - 0.247059 * 255, 0.276792 * 255, 0.372549 * 255, 0.452811 * 255, - 0.498039 * 255, 0.617782 * 255, 0.623529 * 255, 0.763782 * 255, - 0.749020 * 255, 0.886822 * 255, 0.874510 * 255, 0.965223 * 255, - 1.000000 * 255, 0.996993 * 255, - }; - guint8 blue_pts[] = { - 0.0, 0.000495 * 255, 0.121569 * 255, 0.035825 * 255, - 0.247059 * 255, 0.149480 * 255, 0.372549 * 255, 0.305398 * 255, - 0.498039 * 255, 0.491352 * 255, 0.623529 * 255, 0.670305 * 255, - 0.749020 * 255, 0.838898 * 255, 0.874510 * 255, 0.951301 * 255, - 1.000000 * 255, 0.994118 * 255, - }; - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_RED, 18, red_pts); - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_GREEN, 18, green_pts); - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts); - } - break; - case BEAUTIFY_EFFECT_BLUES: - { - guint8 red_pts[] = { - 0.000000 * 255, 0.003922 * 255, - 0.121569 * 255, 0.321569 * 255, - 0.247059 * 255, 0.541176 * 255, - 0.372549 * 255, 0.713725 * 255, - 0.498039 * 255, 0.831373 * 255, - 0.623529 * 255, 0.905882 * 255, - 0.749020 * 255, 0.952941 * 255, - 0.874510 * 255, 0.980392 * 255, - 1.000000 * 255, 1.000000 * 255, - }; - guint8 green_pts[] = { - 0.000000 * 255, 0.003922 * 255, - 0.121569 * 255, 0.266667 * 255, - 0.247059 * 255, 0.466667 * 255, - 0.372549 * 255, 0.627451 * 255, - 0.498039 * 255, 0.756863 * 255, - 0.623529 * 255, 0.847059 * 255, - 0.749020 * 255, 0.917647 * 255, - 0.874510 * 255, 0.964706 * 255, - 1.000000 * 255, 1.000000 * 255, - }; - guint8 blue_pts[] = { - 0.000000 * 255, 0.007843 * 255, - 0.121569 * 255, 0.286275 * 255, - 0.247059 * 255, 0.505882 * 255, - 0.372549 * 255, 0.682353 * 255, - 0.498039 * 255, 0.811765 * 255, - 0.623529 * 255, 0.901961 * 255, - 0.749020 * 255, 0.960784 * 255, - 0.874510 * 255, 0.988235 * 255, - 1.000000 * 255, 0.996078 * 255, - }; - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_RED, 18, red_pts); - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_GREEN, 18, green_pts); - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts); - break; - } - case BEAUTIFY_EFFECT_PURPLE_FANTASY: - { - guint8 red_pts[] = { - 0.000000 * 255, 0.003922 * 255, - 0.121569 * 255, 0.184314 * 255, - 0.247059 * 255, 0.376471 * 255, - 0.372549 * 255, 0.533333 * 255, - 0.498039 * 255, 0.662745 * 255, - 0.623529 * 255, 0.788235 * 255, - 0.749020 * 255, 0.878431 * 255, - 0.874510 * 255, 0.941176 * 255, - 1.000000 * 255, 1.000000 * 255, - }; - guint8 green_pts[] = { - 0.000000 * 255, 0.003922 * 255, - 0.121569 * 255, 0.113725 * 255, - 0.247059 * 255, 0.243137 * 255, - 0.372549 * 255, 0.407843 * 255, - 0.498039 * 255, 0.623529 * 255, - 0.623529 * 255, 0.760784 * 255, - 0.749020 * 255, 0.847059 * 255, - 0.874510 * 255, 0.925490 * 255, - 1.000000 * 255, 1.000000 * 255, - }; - guint8 blue_pts[] = { - 0.000000 * 255, 0.007843 * 255, - 0.121569 * 255, 0.309804 * 255, - 0.247059 * 255, 0.505882 * 255, - 0.372549 * 255, 0.603922 * 255, - 0.498039 * 255, 0.709804 * 255, - 0.623529 * 255, 0.784314 * 255, - 0.749020 * 255, 0.854902 * 255, - 0.874510 * 255, 0.929412 * 255, - 1.000000 * 255, 1.000000 * 255, - }; - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_RED, 18, red_pts); - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_GREEN, 18, green_pts); - gimp_curves_spline (effect_layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts); - break; - } - case BEAUTIFY_EFFECT_BRIGHT_RED: - { - gint32 layer; - GdkPixbuf *pixbuf; - - pixbuf = gdk_pixbuf_new_from_inline (-1, texture_bright_red, FALSE, NULL); - layer = gimp_layer_new_from_pixbuf (image, "texture", pixbuf, 100, GIMP_SCREEN_MODE, 0, 0); - gimp_image_insert_layer (image, layer, -1, 0); - gimp_layer_scale (layer, width, height, FALSE); - gimp_image_merge_down (image, layer, GIMP_CLIP_TO_BOTTOM_LAYER); - - guint8 red_pts[] = { - 0.000000 * 255, 0.001183 * 255, - 0.121569 * 255, 0.131140 * 255, - 0.247059 * 255, 0.353431 * 255, - 0.372549 * 255, 0.538498 * 255, - 0.498039 * 255, 0.690185 * 255, - 0.623529 * 255, 0.804008 * 255, - 0.749020 * 255, 0.900806 * 255, - 0.874510 * 255, 0.988271 * 255, - 1.000000 * 255, 1.000000 * 255, - }; - guint8 green_pts[] = { - 0.000000 * 255, 0.000098 * 255, - 0.121569 * 255, 0.097098 * 255, - 0.247059 * 255, 0.286323 * 255, - 0.372549 * 255, 0.458654 * 255, - 0.498039 * 255, 0.611045 * 255, - 0.623529 * 255, 0.744221 * 255, - 0.749020 * 255, 0.858522 * 255, - 0.874510 * 255, 0.968540 * 255, - 1.000000 * 255, 1.000000 * 255, - }; - guint8 blue_pts[] = { - 0.000000 * 255, 0.000369 * 255, - 0.121569 * 255, 0.100320 * 255, - 0.247059 * 255, 0.285806 * 255, - 0.372549 * 255, 0.459693 * 255, - 0.498039 * 255, 0.612676 * 255, - 0.623529 * 255, 0.745027 * 255, - 0.749020 * 255, 0.860280 * 255, - 0.874510 * 255, 0.967918 * 255, - 1.000000 * 255, 1.000000 * 255, - }; - layer = gimp_image_get_active_layer (image); - gimp_curves_spline (layer, GIMP_HISTOGRAM_RED, 18, red_pts); - gimp_curves_spline (layer, GIMP_HISTOGRAM_GREEN, 18, green_pts); - gimp_curves_spline (layer, GIMP_HISTOGRAM_BLUE, 18, blue_pts); - break; - } - case BEAUTIFY_EFFECT_CHRISTMAS_EVE: - { - gint32 layer = gimp_layer_new (image, "color", width, height, GIMP_RGB_IMAGE, 100, GIMP_OVERLAY_MODE); - gimp_image_insert_layer (image, layer, -1, 0); - GimpRGB color = - { - (gdouble) 156.0 / 255.0, - (gdouble) 208.0 / 255.0, - (gdouble) 240.0 / 255.0, - 1.0, - }; - gimp_context_set_foreground (&color); - gimp_edit_fill (layer, GIMP_FOREGROUND_FILL); - gimp_image_merge_down (image, layer, GIMP_CLIP_TO_BOTTOM_LAYER); - - GdkPixbuf *pixbuf = gdk_pixbuf_new_from_inline (-1, texture_christmas_eve, FALSE, NULL); - gint32 texture_layer = gimp_layer_new_from_pixbuf (image, "texture", pixbuf, 100, GIMP_SCREEN_MODE, 0, 0); - gimp_image_insert_layer (image, texture_layer, -1, 0); - gimp_layer_scale (texture_layer, width, height, FALSE); - gimp_image_merge_down (image, texture_layer, GIMP_CLIP_TO_BOTTOM_LAYER); - break; - } - case BEAUTIFY_EFFECT_ASTRAL: - { - GdkPixbuf *pixbuf = gdk_pixbuf_new_from_inline (-1, texture_astral, FALSE, NULL); - gint32 texture_layer = gimp_layer_new_from_pixbuf (image, "texture", pixbuf, 100, GIMP_SOFTLIGHT_MODE, 0, 0); - gimp_image_insert_layer (image, texture_layer, -1, 0); - gimp_layer_scale (texture_layer, width, height, FALSE); - gimp_image_merge_down (image, texture_layer, GIMP_CLIP_TO_BOTTOM_LAYER); - } - break; - case BEAUTIFY_EFFECT_PICK_LIGHT: - { - gint32 layer; - GdkPixbuf *pixbuf; - - layer = gimp_layer_new (image, "color", width, height, GIMP_RGB_IMAGE, 100, GIMP_SCREEN_MODE); - gimp_image_insert_layer (image, layer, -1, 0); - GimpRGB color = - { - (gdouble) 62.0 / 255.0, - (gdouble) 62.0 / 255.0, - (gdouble) 62.0 / 255.0, - 1.0, - }; - gimp_context_set_foreground (&color); - gimp_edit_fill (layer, GIMP_FOREGROUND_FILL); - gimp_image_merge_down (image, layer, GIMP_CLIP_TO_BOTTOM_LAYER); - - pixbuf = gdk_pixbuf_new_from_inline (-1, texture_pick_light_1, FALSE, NULL); - layer = gimp_layer_new_from_pixbuf (image, "texture 1", pixbuf, 100, GIMP_SCREEN_MODE, 0, 0); - gimp_image_insert_layer (image, layer, -1, 0); - gimp_layer_scale (layer, width, height, FALSE); - gimp_image_merge_down (image, layer, GIMP_CLIP_TO_BOTTOM_LAYER); - - pixbuf = gdk_pixbuf_new_from_inline (-1, texture_pick_light_2, FALSE, NULL); - layer = gimp_layer_new_from_pixbuf (image, "texture 2", pixbuf, 100, GIMP_SCREEN_MODE, 0, 0); - gimp_image_insert_layer (image, layer, -1, 0); - gimp_layer_scale (layer, width, height, FALSE); - gimp_image_merge_down (image, layer, GIMP_CLIP_TO_BOTTOM_LAYER); - break; - } - } - - gimp_context_pop (); -} - static void reset_adjustment () {