Skip to content
This repository
Browse code

add skin whitening tool

  • Loading branch information...
commit c32343de97226d6dc20ab73a86314dc18d95f30c 1 parent 977a259
Jian He authored
1  .gitignore
@@ -4,3 +4,4 @@ beautify-textures.h
4 4 rip-border
5 5 rip-border-textures.h
6 6 skin-whitening
  7 +skin-whitening-images.h
8 Makefile
@@ -51,7 +51,13 @@ rip-border-textures.h: rip-border-textures.list
51 51 $(GDK_PIXBUF_CSOURCE) --raw --build-list `cat rip-border-textures.list` > $(@F)
52 52
53 53 skin-whitening: skin-whitening.o
54   - $(CC) $(CFLAGS) -o $@ $^ $(LIBS)
  54 + $(CC) -o $@ $^ $(LIBS)
  55 +
  56 +skin-whitening.o: skin-whitening.c skin-whitening-images.h
  57 + $(CC) $(CFLAGS) -c skin-whitening.c -o skin-whitening.o
  58 +
  59 +skin-whitening-images.h: skin-whitening-images.list
  60 + $(GDK_PIXBUF_CSOURCE) --raw --build-list `cat skin-whitening-images.list` > $(@F)
55 61
56 62 clean:
57 63 rm -f *.o beautify rip-border skin-whitening
11 README
@@ -6,16 +6,11 @@ Beautify is a set of GIMP plugins for easiest and quickly photo beautify.
6 6 INSTALL
7 7 ===================
8 8
9   -just running the install.sh
  9 +make && make install
10 10
11 11 Note:
12 12 Be sure that you have installed the gimp-devel-tools package before install.
13 13
14   -UPDATE
15   -===================
16   -
17   -just running the install.sh to update.
18   -
19 14 USING
20 15 ===================
21 16
@@ -28,6 +23,10 @@ Support: #beautify on FreeNode
28 23 CHANGELOG
29 24 ===================
30 25
  26 +2012-07-16
  27 +add Makefile
  28 +add skin whitening tool
  29 +
31 30 2012-07-15
32 31 beautify: add warm yellow effect
33 32 beautify: add classic HDR effect
45 curves/high-whitening
... ... @@ -0,0 +1,45 @@
  1 +# GIMP curves tool settings
  2 +
  3 +(time 0)
  4 +(time 0)
  5 +(channel value)
  6 +(curve
  7 + (curve-type smooth)
  8 + (n-points 17)
  9 + (points 34 0.000000 0.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 1.000000 1.000000)
  10 + (n-samples 256)
  11 + (samples 256 0.000000 0.003922 0.007843 0.011765 0.015686 0.019608 0.023529 0.027451 0.031373 0.035294 0.039216 0.043137 0.047059 0.050980 0.054902 0.058824 0.062745 0.066667 0.070588 0.074510 0.078431 0.082353 0.086275 0.090196 0.094118 0.098039 0.101961 0.105882 0.109804 0.113725 0.117647 0.121569 0.125490 0.129412 0.133333 0.137255 0.141176 0.145098 0.149020 0.152941 0.156863 0.160784 0.164706 0.168627 0.172549 0.176471 0.180392 0.184314 0.188235 0.192157 0.196078 0.200000 0.203922 0.207843 0.211765 0.215686 0.219608 0.223529 0.227451 0.231373 0.235294 0.239216 0.243137 0.247059 0.250980 0.254902 0.258824 0.262745 0.266667 0.270588 0.274510 0.278431 0.282353 0.286275 0.290196 0.294118 0.298039 0.301961 0.305882 0.309804 0.313725 0.317647 0.321569 0.325490 0.329412 0.333333 0.337255 0.341176 0.345098 0.349020 0.352941 0.356863 0.360784 0.364706 0.368627 0.372549 0.376471 0.380392 0.384314 0.388235 0.392157 0.396078 0.400000 0.403922 0.407843 0.411765 0.415686 0.419608 0.423529 0.427451 0.431373 0.435294 0.439216 0.443137 0.447059 0.450980 0.454902 0.458824 0.462745 0.466667 0.470588 0.474510 0.478431 0.482353 0.486275 0.490196 0.494118 0.498039 0.501961 0.505882 0.509804 0.513725 0.517647 0.521569 0.525490 0.529412 0.533333 0.537255 0.541176 0.545098 0.549020 0.552941 0.556863 0.560784 0.564706 0.568627 0.572549 0.576471 0.580392 0.584314 0.588235 0.592157 0.596078 0.600000 0.603922 0.607843 0.611765 0.615686 0.619608 0.623529 0.627451 0.631373 0.635294 0.639216 0.643137 0.647059 0.650980 0.654902 0.658824 0.662745 0.666667 0.670588 0.674510 0.678431 0.682353 0.686275 0.690196 0.694118 0.698039 0.701961 0.705882 0.709804 0.713725 0.717647 0.721569 0.725490 0.729412 0.733333 0.737255 0.741176 0.745098 0.749020 0.752941 0.756863 0.760784 0.764706 0.768627 0.772549 0.776471 0.780392 0.784314 0.788235 0.792157 0.796078 0.800000 0.803922 0.807843 0.811765 0.815686 0.819608 0.823529 0.827451 0.831373 0.835294 0.839216 0.843137 0.847059 0.850980 0.854902 0.858824 0.862745 0.866667 0.870588 0.874510 0.878431 0.882353 0.886275 0.890196 0.894118 0.898039 0.901961 0.905882 0.909804 0.913725 0.917647 0.921569 0.925490 0.929412 0.933333 0.937255 0.941176 0.945098 0.949020 0.952941 0.956863 0.960784 0.964706 0.968627 0.972549 0.976471 0.980392 0.984314 0.988235 0.992157 0.996078 1.000000))
  12 +(time 0)
  13 +(channel red)
  14 +(curve
  15 + (curve-type smooth)
  16 + (n-points 17)
  17 + (points 34 0.000000 0.007843 -1.000000 -1.000000 0.121569 0.223529 -1.000000 -1.000000 0.247059 0.427451 -1.000000 -1.000000 0.372549 0.600000 -1.000000 -1.000000 0.498039 0.741176 -1.000000 -1.000000 0.623529 0.854902 -1.000000 -1.000000 0.749020 0.933333 -1.000000 -1.000000 0.874510 0.980392 -1.000000 -1.000000 1.000000 0.996078)
  18 + (n-samples 256)
  19 + (samples 256 0.007843 0.014949 0.022054 0.029157 0.036258 0.043355 0.050447 0.057533 0.064613 0.071686 0.078750 0.085805 0.092850 0.099884 0.106905 0.113914 0.120909 0.127889 0.134853 0.141800 0.148730 0.155641 0.162533 0.169404 0.176254 0.183082 0.189887 0.196667 0.203422 0.210152 0.216854 0.223529 0.230187 0.236838 0.243481 0.250115 0.256740 0.263353 0.269953 0.276540 0.283112 0.289668 0.296207 0.302728 0.309229 0.315709 0.322167 0.328602 0.335013 0.341398 0.347757 0.354088 0.360389 0.366661 0.372901 0.379108 0.385282 0.391420 0.397523 0.403588 0.409614 0.415601 0.421547 0.427451 0.433318 0.439154 0.444960 0.450735 0.456480 0.462194 0.467877 0.473529 0.479151 0.484743 0.490303 0.495833 0.501333 0.506802 0.512240 0.517647 0.523024 0.528370 0.533686 0.538971 0.544225 0.549449 0.554642 0.559804 0.564936 0.570037 0.575107 0.580147 0.585156 0.590135 0.595083 0.600000 0.604885 0.609735 0.614552 0.619336 0.624086 0.628804 0.633490 0.638143 0.642765 0.647356 0.651916 0.656445 0.660944 0.665414 0.669854 0.674264 0.678647 0.683000 0.687326 0.691624 0.695895 0.700139 0.704356 0.708547 0.712713 0.716852 0.720967 0.725057 0.729122 0.733164 0.737182 0.741176 0.745149 0.749102 0.753035 0.756947 0.760836 0.764703 0.768546 0.772365 0.776159 0.779927 0.783670 0.787385 0.791072 0.794731 0.798361 0.801961 0.805530 0.809067 0.812573 0.816046 0.819486 0.822891 0.826261 0.829596 0.832894 0.836155 0.839378 0.842563 0.845708 0.848814 0.851879 0.854902 0.857885 0.860831 0.863739 0.866609 0.869443 0.872240 0.875001 0.877727 0.880417 0.883071 0.885692 0.888277 0.890829 0.893347 0.895832 0.898284 0.900704 0.903091 0.905446 0.907770 0.910063 0.912325 0.914557 0.916758 0.918930 0.921073 0.923187 0.925272 0.927328 0.929357 0.931359 0.933333 0.935278 0.937193 0.939077 0.940931 0.942754 0.944546 0.946308 0.948039 0.949739 0.951409 0.953048 0.954657 0.956234 0.957782 0.959298 0.960784 0.962239 0.963664 0.965058 0.966421 0.967754 0.969056 0.970328 0.971568 0.972779 0.973958 0.975107 0.976225 0.977313 0.978370 0.979396 0.980392 0.981350 0.982263 0.983133 0.983961 0.984749 0.985499 0.986211 0.986887 0.987529 0.988137 0.988715 0.989261 0.989780 0.990271 0.990736 0.991176 0.991594 0.991990 0.992366 0.992723 0.993063 0.993388 0.993698 0.993995 0.994280 0.994556 0.994823 0.995082 0.995336 0.995586 0.995833 0.996078))
  20 +(time 0)
  21 +(channel green)
  22 +(curve
  23 + (curve-type smooth)
  24 + (n-points 17)
  25 + (points 34 0.000000 0.007843 -1.000000 -1.000000 0.121569 0.223529 -1.000000 -1.000000 0.247059 0.427451 -1.000000 -1.000000 0.372549 0.600000 -1.000000 -1.000000 0.498039 0.741176 -1.000000 -1.000000 0.623529 0.854902 -1.000000 -1.000000 0.749020 0.933333 -1.000000 -1.000000 0.874510 0.980392 -1.000000 -1.000000 1.000000 0.996078)
  26 + (n-samples 256)
  27 + (samples 256 0.007843 0.014949 0.022054 0.029157 0.036258 0.043355 0.050447 0.057533 0.064613 0.071686 0.078750 0.085805 0.092850 0.099884 0.106905 0.113914 0.120909 0.127889 0.134853 0.141800 0.148730 0.155641 0.162533 0.169404 0.176254 0.183082 0.189887 0.196667 0.203422 0.210152 0.216854 0.223529 0.230187 0.236838 0.243481 0.250115 0.256740 0.263353 0.269953 0.276540 0.283112 0.289668 0.296207 0.302728 0.309229 0.315709 0.322167 0.328602 0.335013 0.341398 0.347757 0.354088 0.360389 0.366661 0.372901 0.379108 0.385282 0.391420 0.397523 0.403588 0.409614 0.415601 0.421547 0.427451 0.433318 0.439154 0.444960 0.450735 0.456480 0.462194 0.467877 0.473529 0.479151 0.484743 0.490303 0.495833 0.501333 0.506802 0.512240 0.517647 0.523024 0.528370 0.533686 0.538971 0.544225 0.549449 0.554642 0.559804 0.564936 0.570037 0.575107 0.580147 0.585156 0.590135 0.595083 0.600000 0.604885 0.609735 0.614552 0.619336 0.624086 0.628804 0.633490 0.638143 0.642765 0.647356 0.651916 0.656445 0.660944 0.665414 0.669854 0.674264 0.678647 0.683000 0.687326 0.691624 0.695895 0.700139 0.704356 0.708547 0.712713 0.716852 0.720967 0.725057 0.729122 0.733164 0.737182 0.741176 0.745149 0.749102 0.753035 0.756947 0.760836 0.764703 0.768546 0.772365 0.776159 0.779927 0.783670 0.787385 0.791072 0.794731 0.798361 0.801961 0.805530 0.809067 0.812573 0.816046 0.819486 0.822891 0.826261 0.829596 0.832894 0.836155 0.839378 0.842563 0.845708 0.848814 0.851879 0.854902 0.857885 0.860831 0.863739 0.866609 0.869443 0.872240 0.875001 0.877727 0.880417 0.883071 0.885692 0.888277 0.890829 0.893347 0.895832 0.898284 0.900704 0.903091 0.905446 0.907770 0.910063 0.912325 0.914557 0.916758 0.918930 0.921073 0.923187 0.925272 0.927328 0.929357 0.931359 0.933333 0.935278 0.937193 0.939077 0.940931 0.942754 0.944546 0.946308 0.948039 0.949739 0.951409 0.953048 0.954657 0.956234 0.957782 0.959298 0.960784 0.962239 0.963664 0.965058 0.966421 0.967754 0.969056 0.970328 0.971568 0.972779 0.973958 0.975107 0.976225 0.977313 0.978370 0.979396 0.980392 0.981350 0.982263 0.983133 0.983961 0.984749 0.985499 0.986211 0.986887 0.987529 0.988137 0.988715 0.989261 0.989780 0.990271 0.990736 0.991176 0.991594 0.991990 0.992366 0.992723 0.993063 0.993388 0.993698 0.993995 0.994280 0.994556 0.994823 0.995082 0.995336 0.995586 0.995833 0.996078))
  28 +(time 0)
  29 +(channel blue)
  30 +(curve
  31 + (curve-type smooth)
  32 + (n-points 17)
  33 + (points 34 0.000000 0.007843 -1.000000 -1.000000 0.121569 0.223529 -1.000000 -1.000000 0.247059 0.427451 -1.000000 -1.000000 0.372549 0.600000 -1.000000 -1.000000 0.498039 0.741176 -1.000000 -1.000000 0.623529 0.854902 -1.000000 -1.000000 0.749020 0.933333 -1.000000 -1.000000 0.874510 0.980392 -1.000000 -1.000000 1.000000 0.996078)
  34 + (n-samples 256)
  35 + (samples 256 0.007843 0.014949 0.022054 0.029157 0.036258 0.043355 0.050447 0.057533 0.064613 0.071686 0.078750 0.085805 0.092850 0.099884 0.106905 0.113914 0.120909 0.127889 0.134853 0.141800 0.148730 0.155641 0.162533 0.169404 0.176254 0.183082 0.189887 0.196667 0.203422 0.210152 0.216854 0.223529 0.230187 0.236838 0.243481 0.250115 0.256740 0.263353 0.269953 0.276540 0.283112 0.289668 0.296207 0.302728 0.309229 0.315709 0.322167 0.328602 0.335013 0.341398 0.347757 0.354088 0.360389 0.366661 0.372901 0.379108 0.385282 0.391420 0.397523 0.403588 0.409614 0.415601 0.421547 0.427451 0.433318 0.439154 0.444960 0.450735 0.456480 0.462194 0.467877 0.473529 0.479151 0.484743 0.490303 0.495833 0.501333 0.506802 0.512240 0.517647 0.523024 0.528370 0.533686 0.538971 0.544225 0.549449 0.554642 0.559804 0.564936 0.570037 0.575107 0.580147 0.585156 0.590135 0.595083 0.600000 0.604885 0.609735 0.614552 0.619336 0.624086 0.628804 0.633490 0.638143 0.642765 0.647356 0.651916 0.656445 0.660944 0.665414 0.669854 0.674264 0.678647 0.683000 0.687326 0.691624 0.695895 0.700139 0.704356 0.708547 0.712713 0.716852 0.720967 0.725057 0.729122 0.733164 0.737182 0.741176 0.745149 0.749102 0.753035 0.756947 0.760836 0.764703 0.768546 0.772365 0.776159 0.779927 0.783670 0.787385 0.791072 0.794731 0.798361 0.801961 0.805530 0.809067 0.812573 0.816046 0.819486 0.822891 0.826261 0.829596 0.832894 0.836155 0.839378 0.842563 0.845708 0.848814 0.851879 0.854902 0.857885 0.860831 0.863739 0.866609 0.869443 0.872240 0.875001 0.877727 0.880417 0.883071 0.885692 0.888277 0.890829 0.893347 0.895832 0.898284 0.900704 0.903091 0.905446 0.907770 0.910063 0.912325 0.914557 0.916758 0.918930 0.921073 0.923187 0.925272 0.927328 0.929357 0.931359 0.933333 0.935278 0.937193 0.939077 0.940931 0.942754 0.944546 0.946308 0.948039 0.949739 0.951409 0.953048 0.954657 0.956234 0.957782 0.959298 0.960784 0.962239 0.963664 0.965058 0.966421 0.967754 0.969056 0.970328 0.971568 0.972779 0.973958 0.975107 0.976225 0.977313 0.978370 0.979396 0.980392 0.981350 0.982263 0.983133 0.983961 0.984749 0.985499 0.986211 0.986887 0.987529 0.988137 0.988715 0.989261 0.989780 0.990271 0.990736 0.991176 0.991594 0.991990 0.992366 0.992723 0.993063 0.993388 0.993698 0.993995 0.994280 0.994556 0.994823 0.995082 0.995336 0.995586 0.995833 0.996078))
  36 +(time 0)
  37 +(channel alpha)
  38 +(curve
  39 + (curve-type free)
  40 + (n-points 17)
  41 + (points 34 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000 -1.000000)
  42 + (n-samples 256)
  43 + (samples 256 0.000000 0.003922 0.007843 0.011765 0.015686 0.019608 0.023529 0.027451 0.031373 0.035294 0.039216 0.043137 0.047059 0.050980 0.054902 0.058824 0.062745 0.066667 0.070588 0.074510 0.078431 0.082353 0.086275 0.090196 0.094118 0.098039 0.101961 0.105882 0.109804 0.113725 0.117647 0.121569 0.125490 0.129412 0.133333 0.137255 0.141176 0.145098 0.149020 0.152941 0.156863 0.160784 0.164706 0.168627 0.172549 0.176471 0.180392 0.184314 0.188235 0.192157 0.196078 0.200000 0.203922 0.207843 0.211765 0.215686 0.219608 0.223529 0.227451 0.231373 0.235294 0.239216 0.243137 0.247059 0.250980 0.254902 0.258824 0.262745 0.266667 0.270588 0.274510 0.278431 0.282353 0.286275 0.290196 0.294118 0.298039 0.301961 0.305882 0.309804 0.313725 0.317647 0.321569 0.325490 0.329412 0.333333 0.337255 0.341176 0.345098 0.349020 0.352941 0.356863 0.360784 0.364706 0.368627 0.372549 0.376471 0.380392 0.384314 0.388235 0.392157 0.396078 0.400000 0.403922 0.407843 0.411765 0.415686 0.419608 0.423529 0.427451 0.431373 0.435294 0.439216 0.443137 0.447059 0.450980 0.454902 0.458824 0.462745 0.466667 0.470588 0.474510 0.478431 0.482353 0.486275 0.490196 0.494118 0.498039 0.501961 0.505882 0.509804 0.513725 0.517647 0.521569 0.525490 0.529412 0.533333 0.537255 0.541176 0.545098 0.549020 0.552941 0.556863 0.560784 0.564706 0.568627 0.572549 0.576471 0.580392 0.584314 0.588235 0.592157 0.596078 0.600000 0.603922 0.607843 0.611765 0.615686 0.619608 0.623529 0.627451 0.631373 0.635294 0.639216 0.643137 0.647059 0.650980 0.654902 0.658824 0.662745 0.666667 0.670588 0.674510 0.678431 0.682353 0.686275 0.690196 0.694118 0.698039 0.701961 0.705882 0.709804 0.713725 0.717647 0.721569 0.725490 0.729412 0.733333 0.737255 0.741176 0.745098 0.749020 0.752941 0.756863 0.760784 0.764706 0.768627 0.772549 0.776471 0.780392 0.784314 0.788235 0.792157 0.796078 0.800000 0.803922 0.807843 0.811765 0.815686 0.819608 0.823529 0.827451 0.831373 0.835294 0.839216 0.843137 0.847059 0.850980 0.854902 0.858824 0.862745 0.866667 0.870588 0.874510 0.878431 0.882353 0.886275 0.890196 0.894118 0.898039 0.901961 0.905882 0.909804 0.913725 0.917647 0.921569 0.925490 0.929412 0.933333 0.937255 0.941176 0.945098 0.949020 0.952941 0.956863 0.960784 0.964706 0.968627 0.972549 0.976471 0.980392 0.984314 0.988235 0.992157 0.996078 1.000000))
  44 +
  45 +# end of curves tool settings
BIN  images/skin_whitening_1.jpg
BIN  images/skin_whitening_2.jpg
BIN  images/skin_whitening_3.jpg
BIN  images/skin_whitening_4.jpg
BIN  images/skin_whitening_5.jpg
BIN  images/skin_whitening_6.jpg
BIN  images/skin_whitening_7.jpg
BIN  images/skin_whitening_8.jpg
BIN  images/skin_whitening_9.jpg
18 skin-whitening-images.list
... ... @@ -0,0 +1,18 @@
  1 +skin_whitening_1
  2 + ./images/skin_whitening_1.jpg
  3 +skin_whitening_2
  4 + ./images/skin_whitening_2.jpg
  5 +skin_whitening_3
  6 + ./images/skin_whitening_3.jpg
  7 +skin_whitening_4
  8 + ./images/skin_whitening_4.jpg
  9 +skin_whitening_5
  10 + ./images/skin_whitening_5.jpg
  11 +skin_whitening_6
  12 + ./images/skin_whitening_6.jpg
  13 +skin_whitening_7
  14 + ./images/skin_whitening_7.jpg
  15 +skin_whitening_8
  16 + ./images/skin_whitening_8.jpg
  17 +skin_whitening_9
  18 + ./images/skin_whitening_9.jpg
349 skin-whitening.c
... ... @@ -0,0 +1,349 @@
  1 +/**
  2 + * Copyright (C) 2012 hejian <hejian.he@gmail.com>
  3 + *
  4 + * This program is free software: you can redistribute it and/or modify
  5 + * it under the terms of the GNU General Public License as published by
  6 + * the Free Software Foundation; either version 3 of the License, or
  7 + * (at your option) any later version.
  8 + *
  9 + * This program is distributed in the hope that it will be useful,
  10 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12 + * GNU General Public License for more details.
  13 + *
  14 + * You should have received a copy of the GNU General Public License
  15 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16 + */
  17 +
  18 +#include <libgimp/gimp.h>
  19 +#include <libgimp/gimpui.h>
  20 +
  21 +#include "skin-whitening-images.h"
  22 +
  23 +#define PLUG_IN_PROC "plug-in-skin-whitening"
  24 +#define PLUG_IN_BINARY "skin-whitening"
  25 +#define PLUG_IN_ROLE "gimp-skin-whitening"
  26 +
  27 +#define PREVIEW_SIZE 480
  28 +#define THUMBNAIL_SIZE 80
  29 +
  30 +typedef enum
  31 +{
  32 + WHITENING_EFFECT_HIGH_WHITENING,
  33 +} WhiteningEffectType;
  34 +
  35 +static const WhiteningEffectType effects[] =
  36 +{
  37 + WHITENING_EFFECT_HIGH_WHITENING,
  38 +};
  39 +
  40 +static void query (void);
  41 +static void run (const gchar *name,
  42 + gint nparams,
  43 + const GimpParam *param,
  44 + gint *nreturn_vals,
  45 + GimpParam **return_vals);
  46 +
  47 +static void skin_whitening (GimpDrawable *drawable);
  48 +
  49 +static gboolean skin_whitening_dialog (gint32 image_ID,
  50 + GimpDrawable *drawable);
  51 +
  52 +static void preview_update (GtkWidget *preview);
  53 +
  54 +static GtkWidget* effects_box_new ();
  55 +static GtkWidget* effect_icon_new (WhiteningEffectType effect);
  56 +static gboolean effect_select (GtkWidget *event_box, GdkEventButton *event, WhiteningEffectType effect);
  57 +
  58 +const GimpPlugInInfo PLUG_IN_INFO =
  59 +{
  60 + NULL, /* init_proc */
  61 + NULL, /* quit_proc */
  62 + query, /* query_proc */
  63 + run, /* run_proc */
  64 +};
  65 +
  66 +static gint32 image_ID = 0;
  67 +static gint width;
  68 +static gint height;
  69 +
  70 +static GtkWidget *preview = NULL;
  71 +static gint32 preview_image = 0;
  72 +
  73 +MAIN ()
  74 +
  75 +static void
  76 +query (void)
  77 +{
  78 + static const GimpParamDef args[] =
  79 + {
  80 + { GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" },
  81 + { GIMP_PDB_IMAGE, "image", "Input image" },
  82 + { GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
  83 + };
  84 +
  85 + gimp_install_procedure (PLUG_IN_PROC,
  86 + "the easiest way for skin whitening.",
  87 + "the easiest way for skin whitening.",
  88 + "Hejian <hejian.he@gmail.com>",
  89 + "Hejian <hejian.he@gmail.com>",
  90 + "2012",
  91 + "_Skin whitening...",
  92 + "RGB*, GRAY*",
  93 + GIMP_PLUGIN,
  94 + G_N_ELEMENTS (args), 0,
  95 + args, NULL);
  96 +
  97 + gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/Tools/Beautify");
  98 +}
  99 +
  100 +static void
  101 +run (const gchar *name,
  102 + gint nparams,
  103 + const GimpParam *param,
  104 + gint *nreturn_vals,
  105 + GimpParam **return_vals)
  106 +{
  107 + static GimpParam values[2];
  108 + GimpDrawable *drawable;
  109 + GimpRunMode run_mode;
  110 + GimpPDBStatusType status = GIMP_PDB_SUCCESS;
  111 +
  112 + run_mode = param[0].data.d_int32;
  113 +
  114 + *nreturn_vals = 1;
  115 + *return_vals = values;
  116 +
  117 + values[0].type = GIMP_PDB_STATUS;
  118 + values[0].data.d_status = status;
  119 +
  120 + image_ID = param[1].data.d_image;
  121 + drawable = gimp_drawable_get (param[2].data.d_drawable);
  122 +
  123 + width = gimp_image_width (image_ID);
  124 + height = gimp_image_height (image_ID);
  125 +
  126 + switch (run_mode)
  127 + {
  128 + case GIMP_RUN_INTERACTIVE:
  129 + if (! skin_whitening_dialog (image_ID, drawable))
  130 + return;
  131 + break;
  132 +
  133 + case GIMP_RUN_NONINTERACTIVE:
  134 + break;
  135 +
  136 + case GIMP_RUN_WITH_LAST_VALS:
  137 + break;
  138 +
  139 + default:
  140 + break;
  141 + }
  142 +
  143 + if ((status == GIMP_PDB_SUCCESS) &&
  144 + (gimp_drawable_is_rgb(drawable->drawable_id) ||
  145 + gimp_drawable_is_gray(drawable->drawable_id)))
  146 + {
  147 + /* Run! */
  148 + gimp_image_undo_group_start (image_ID);
  149 + skin_whitening (drawable);
  150 + gimp_image_undo_group_end (image_ID);
  151 +
  152 + /* If run mode is interactive, flush displays */
  153 + if (run_mode != GIMP_RUN_NONINTERACTIVE)
  154 + gimp_displays_flush ();
  155 +
  156 + /* Store data */
  157 + /*if (run_mode == GIMP_RUN_INTERACTIVE)
  158 + gimp_set_data (PLUG_IN_PROC, &bvals, sizeof (BeautifyValues));*/
  159 +
  160 + }
  161 +
  162 + gimp_drawable_detach (drawable);
  163 +}
  164 +
  165 +static void
  166 +skin_whitening (GimpDrawable *drawable)
  167 +{
  168 + gint32 source = gimp_image_get_active_layer (preview_image);
  169 + gimp_edit_copy (source);
  170 + gint32 floating_sel = gimp_edit_paste (drawable->drawable_id, FALSE);
  171 + gimp_floating_sel_anchor (floating_sel);
  172 +}
  173 +
  174 +static gboolean
  175 +skin_whitening_dialog (gint32 image_ID,
  176 + GimpDrawable *drawable)
  177 +{
  178 + GtkWidget *dialog;
  179 + GtkWidget *main_hbox;
  180 + GtkWidget *left_vbox;
  181 + GtkWidget *middle_vbox;
  182 + GtkWidget *right_vbox;
  183 +
  184 + gimp_ui_init (PLUG_IN_BINARY, FALSE);
  185 +
  186 + dialog = gimp_dialog_new ("Beautify", PLUG_IN_ROLE,
  187 + NULL, 0,
  188 + gimp_standard_help_func, PLUG_IN_PROC,
  189 +
  190 + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
  191 + GTK_STOCK_OK, GTK_RESPONSE_OK,
  192 +
  193 + NULL);
  194 +
  195 + gimp_window_set_transient (GTK_WINDOW (dialog));
  196 +
  197 + gtk_widget_show (dialog);
  198 +
  199 + main_hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
  200 + gtk_container_set_border_width (GTK_CONTAINER (main_hbox), 12);
  201 + gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
  202 + main_hbox, TRUE, TRUE, 0);
  203 + gtk_widget_show (main_hbox);
  204 +
  205 + left_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
  206 + gtk_container_set_border_width (GTK_CONTAINER (left_vbox), 12);
  207 + gtk_box_pack_start (GTK_BOX (main_hbox), left_vbox, TRUE, TRUE, 0);
  208 + gtk_widget_show (left_vbox);
  209 +
  210 + middle_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
  211 + gtk_container_set_border_width (GTK_CONTAINER (middle_vbox), 12);
  212 + gtk_box_pack_start (GTK_BOX (main_hbox), middle_vbox, TRUE, TRUE, 0);
  213 + gtk_widget_show (middle_vbox);
  214 +
  215 + right_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
  216 + gtk_container_set_border_width (GTK_CONTAINER (right_vbox), 12);
  217 + gtk_box_pack_start (GTK_BOX (main_hbox), right_vbox, TRUE, TRUE, 0);
  218 + gtk_widget_show (right_vbox);
  219 +
  220 + /* preview */
  221 + preview_image = gimp_image_duplicate (image_ID);
  222 +
  223 + preview = gtk_image_new();
  224 + preview_update (preview);
  225 +
  226 + gtk_box_pack_start (GTK_BOX (middle_vbox), preview, TRUE, TRUE, 0);
  227 + gtk_widget_show (preview);
  228 +
  229 + /* effects */
  230 + GtkWidget *label = gtk_label_new ("One click whitening");
  231 + gtk_box_pack_start (GTK_BOX (right_vbox), label, FALSE, FALSE, 0);
  232 + gtk_widget_show (label);
  233 +
  234 + GtkWidget *effects = effects_box_new ();
  235 + gtk_box_pack_start (GTK_BOX (right_vbox), effects, FALSE, FALSE, 0);
  236 + gtk_widget_show (effects);
  237 +
  238 + gboolean run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
  239 +
  240 + gtk_widget_destroy (dialog);
  241 +
  242 + return run;
  243 +}
  244 +
  245 +static void
  246 +preview_update (GtkWidget *preview)
  247 +{
  248 + gint preview_size = PREVIEW_SIZE;
  249 + gint max_size = height;
  250 + if (height < width)
  251 + max_size = width;
  252 + if (preview_size > max_size)
  253 + preview_size = max_size;
  254 + GdkPixbuf *pixbuf = gimp_image_get_thumbnail (preview_image, preview_size, preview_size, GIMP_PIXBUF_SMALL_CHECKS);
  255 + gtk_image_set_from_pixbuf (GTK_IMAGE(preview), pixbuf);
  256 +}
  257 +
  258 +static GtkWidget *
  259 +effects_box_new ()
  260 +{
  261 + gint rows = 5;
  262 + gint cols = 3;
  263 + GtkWidget *table = gtk_table_new (rows, cols, FALSE);
  264 + gtk_table_set_col_spacings (GTK_TABLE (table), 6);
  265 + gtk_table_set_row_spacings (GTK_TABLE (table), 6);
  266 +
  267 + gint row = 1;
  268 + gint col = 1;
  269 +
  270 + gint i;
  271 + for (i = 0; i < G_N_ELEMENTS (effects); i++) {
  272 + GtkWidget *icon = effect_icon_new (effects[i]);
  273 + gtk_table_attach_defaults (GTK_TABLE (table), icon, col - 1, col, row - 1, row);
  274 + gtk_widget_show (icon);
  275 +
  276 + col++;
  277 + if (col > cols)
  278 + {
  279 + row++;
  280 + col = 1;
  281 + }
  282 + }
  283 +
  284 + return table;
  285 +}
  286 +
  287 +static GtkWidget *
  288 +effect_icon_new (WhiteningEffectType effect)
  289 +{
  290 + const guint8 *data;
  291 + gchar *title;
  292 +
  293 + switch (effect) {
  294 + case WHITENING_EFFECT_HIGH_WHITENING:
  295 + data = skin_whitening_1;
  296 + title = "High Whitening";
  297 + break;
  298 + }
  299 +
  300 + GtkWidget *box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
  301 + gtk_container_set_border_width (GTK_CONTAINER (box), 12);
  302 +
  303 + /* image */
  304 + GdkPixbuf *pixbuf = gdk_pixbuf_new_from_inline (-1, data, FALSE, NULL);
  305 + GtkWidget *image = gtk_image_new_from_pixbuf (pixbuf);
  306 + GtkWidget *event_box = gtk_event_box_new ();
  307 + gtk_container_add (GTK_CONTAINER (event_box), image);
  308 + gtk_widget_show (image);
  309 + gtk_box_pack_start (GTK_BOX (box), event_box, FALSE, FALSE, 0);
  310 + gtk_widget_show (event_box);
  311 +
  312 + g_signal_connect (event_box, "button_press_event", G_CALLBACK (effect_select), (gpointer)effect);
  313 +
  314 + /* label */
  315 + GtkWidget *label = gtk_label_new (title);
  316 + gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
  317 + gtk_widget_show (label);
  318 +
  319 + return box;
  320 +}
  321 +
  322 +static gboolean
  323 +effect_select (GtkWidget *event_box, GdkEventButton *event, WhiteningEffectType effect)
  324 +{
  325 + gint32 layer = gimp_image_get_active_layer (preview_image);
  326 + switch (effect)
  327 + {
  328 + case WHITENING_EFFECT_HIGH_WHITENING:
  329 + {
  330 + guint8 pts[] = {
  331 + 0.000000 * 255, 0.007843 * 255,
  332 + 0.121569 * 255, 0.223529 * 255,
  333 + 0.247059 * 255, 0.427451 * 255,
  334 + 0.372549 * 255, 0.600000 * 255,
  335 + 0.498039 * 255, 0.741176 * 255,
  336 + 0.623529 * 255, 0.854902 * 255,
  337 + 0.749020 * 255, 0.933333 * 255,
  338 + 0.874510 * 255, 0.980392 * 255,
  339 + 1.000000 * 255, 0.996078 * 255,
  340 + };
  341 + gimp_curves_spline (layer, GIMP_HISTOGRAM_RED, 18, pts);
  342 + gimp_curves_spline (layer, GIMP_HISTOGRAM_GREEN, 18, pts);
  343 + gimp_curves_spline (layer, GIMP_HISTOGRAM_BLUE, 18, pts);
  344 + }
  345 + break;
  346 + }
  347 +
  348 + preview_update (preview);
  349 +}

0 comments on commit c32343d

Please sign in to comment.
Something went wrong with that request. Please try again.