From e0b1b07ab86b34db7df0080d7d6577cc63ea628a Mon Sep 17 00:00:00 2001 From: Manish Singh Date: Sat, 6 Jun 1998 23:22:22 +0000 Subject: [PATCH] adding Lighting plugin * adding Lighting plugin * updated despeckle, png, sgi, and sharpen -Yosh --- ChangeLog | 6 + configure.in | 1 + plug-ins/Lighting/.cvsignore | 6 + plug-ins/Lighting/ChangeLog | 21 + plug-ins/Lighting/Makefile.am | 41 + plug-ins/Lighting/README | 39 + plug-ins/Lighting/TODO | 15 + plug-ins/Lighting/amb1.xpm | 88 ++ plug-ins/Lighting/amb2.xpm | 58 ++ plug-ins/Lighting/diffint1.xpm | 44 + plug-ins/Lighting/diffint2.xpm | 80 ++ plug-ins/Lighting/diffref1.xpm | 46 ++ plug-ins/Lighting/diffref2.xpm | 75 ++ plug-ins/Lighting/high1.xpm | 75 ++ plug-ins/Lighting/high2.xpm | 78 ++ plug-ins/Lighting/lighting_apply.c | 147 ++++ plug-ins/Lighting/lighting_apply.h | 18 + plug-ins/Lighting/lighting_image.c | 342 ++++++++ plug-ins/Lighting/lighting_image.h | 49 ++ plug-ins/Lighting/lighting_main.c | 332 ++++++++ plug-ins/Lighting/lighting_main.h | 106 +++ plug-ins/Lighting/lighting_pixmaps.h | 26 + plug-ins/Lighting/lighting_preview.c | 404 ++++++++++ plug-ins/Lighting/lighting_preview.h | 41 + plug-ins/Lighting/lighting_shade.c | 634 +++++++++++++++ plug-ins/Lighting/lighting_shade.h | 23 + plug-ins/Lighting/lighting_ui.c | 1102 ++++++++++++++++++++++++++ plug-ins/Lighting/lighting_ui.h | 30 + plug-ins/Lighting/specref1.xpm | 75 ++ plug-ins/Lighting/specref2.xpm | 79 ++ plug-ins/Makefile.am | 1 + plug-ins/common/despeckle.c | 25 +- plug-ins/common/png.c | 53 +- plug-ins/common/sharpen.c | 74 +- plug-ins/despeckle/despeckle.c | 25 +- plug-ins/png/png.c | 53 +- plug-ins/sgi/sgi.c | 54 +- plug-ins/sgi/sgi.h | 19 +- plug-ins/sgi/sgilib.c | 88 +- plug-ins/sharpen/sharpen.c | 74 +- 40 files changed, 4252 insertions(+), 295 deletions(-) create mode 100644 plug-ins/Lighting/.cvsignore create mode 100644 plug-ins/Lighting/ChangeLog create mode 100644 plug-ins/Lighting/Makefile.am create mode 100644 plug-ins/Lighting/README create mode 100644 plug-ins/Lighting/TODO create mode 100644 plug-ins/Lighting/amb1.xpm create mode 100644 plug-ins/Lighting/amb2.xpm create mode 100644 plug-ins/Lighting/diffint1.xpm create mode 100644 plug-ins/Lighting/diffint2.xpm create mode 100644 plug-ins/Lighting/diffref1.xpm create mode 100644 plug-ins/Lighting/diffref2.xpm create mode 100644 plug-ins/Lighting/high1.xpm create mode 100644 plug-ins/Lighting/high2.xpm create mode 100644 plug-ins/Lighting/lighting_apply.c create mode 100644 plug-ins/Lighting/lighting_apply.h create mode 100644 plug-ins/Lighting/lighting_image.c create mode 100644 plug-ins/Lighting/lighting_image.h create mode 100644 plug-ins/Lighting/lighting_main.c create mode 100644 plug-ins/Lighting/lighting_main.h create mode 100644 plug-ins/Lighting/lighting_pixmaps.h create mode 100644 plug-ins/Lighting/lighting_preview.c create mode 100644 plug-ins/Lighting/lighting_preview.h create mode 100644 plug-ins/Lighting/lighting_shade.c create mode 100644 plug-ins/Lighting/lighting_shade.h create mode 100644 plug-ins/Lighting/lighting_ui.c create mode 100644 plug-ins/Lighting/lighting_ui.h create mode 100644 plug-ins/Lighting/specref1.xpm create mode 100644 plug-ins/Lighting/specref2.xpm diff --git a/ChangeLog b/ChangeLog index 5f622fb771..b511309e54 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Jun 6 16:12:20 PDT 1998 Manish Singh + + * adding Lighting plugin + + * updated despeckle, png, sgi, and sharpen + Sat Jun 6 14:22:19 PDT 1998 Manish Singh * app/interface.c: changed it back, things work now diff --git a/configure.in b/configure.in index f49d5524cf..28d7c37d30 100644 --- a/configure.in +++ b/configure.in @@ -562,6 +562,7 @@ plug-ins/screenshot/Makefile plug-ins/sharpen/Makefile plug-ins/psd/Makefile plug-ins/gpc/Makefile +plug-ins/Lighting/Makefile app/Makefile docs/Makefile data/Makefile diff --git a/plug-ins/Lighting/.cvsignore b/plug-ins/Lighting/.cvsignore new file mode 100644 index 0000000000..253dd3464d --- /dev/null +++ b/plug-ins/Lighting/.cvsignore @@ -0,0 +1,6 @@ +Makefile.in +Makefile +.deps +_libs +.libs +Lighting diff --git a/plug-ins/Lighting/ChangeLog b/plug-ins/Lighting/ChangeLog new file mode 100644 index 0000000000..9a4e45a827 --- /dev/null +++ b/plug-ins/Lighting/ChangeLog @@ -0,0 +1,21 @@ + +Changes: +======== + +0.2.2: Fixed a bug in the preview code sometimes causing a SIGSEGV. + Thanks to Prabhanjan for reporting it. + +0.2.1: Fixed a bug in the calculation of the normals. Thanks to + Simon Budig for pointing this out. + +0.2.0: Fixed crashes when rerunning after closing mapping images. Removed + GckNotebook and fixed gtk refcounting problems. Added non-interactive + (scripting) interface. First non-beta release. + +0.1.1: Transparent background and RGBA support, various bug fixes and + minor speed ups. First beta version. + +0.0.x: Many bug fixes. Moved it to "..filters/Light Effects/Lighting Effects" + +0.0.1: First version for 0.99.x + diff --git a/plug-ins/Lighting/Makefile.am b/plug-ins/Lighting/Makefile.am new file mode 100644 index 0000000000..36056ce76a --- /dev/null +++ b/plug-ins/Lighting/Makefile.am @@ -0,0 +1,41 @@ +## Process this file with automake to produce Makefile.in + +pluginlibdir = $(gimpplugindir)/plug-ins + +pluginlib_PROGRAMS = Lighting + +Lighting_SOURCES = \ + amb1.xpm amb2.xpm diffint1.xpm diffint2.xpm diffref1.xpm diffref2.xpm high1.xpm high2.xpm lighting_apply.c lighting_apply.h lighting_image.c lighting_image.h lighting_main.c lighting_main.h lighting_pixmaps.h lighting_preview.c lighting_preview.h lighting_shade.c lighting_shade.h lighting_ui.c lighting_ui.h specref1.xpm specref2.xpm + +INCLUDES = \ + -I$(top_srcdir) \ + -I$(top_srcdir)/plug-ins/libgck \ + -I$(includedir) \ + $(X_CFLAGS) + +LDADD = \ + $(top_builddir)/libgimp/libgimpui.la \ + $(top_builddir)/libgimp/libgimp.la \ + $(top_builddir)/plug-ins/libgck/gck/libgck.la \ + $(X_LIBS) \ + -lc + +DEPS = \ + $(top_builddir)/libgimp/libgimpui.la \ + $(top_builddir)/libgimp/libgimp.la \ + $(top_builddir)/plug-ins/libgck/gck/libgck.la + +Lighting_DEPENDENCIES = $(DEPS) + +.PHONY: files + +files: + @files=`ls $(DISTFILES) 2> /dev/null`; for p in $$files; do \ + echo $$p; \ + done + @for subdir in $(SUBDIRS); do \ + files=`cd $$subdir; $(MAKE) files | grep -v "make\[[1-9]\]"`; \ + for file in $$files; do \ + echo $$subdir/$$file; \ + done; \ + done diff --git a/plug-ins/Lighting/README b/plug-ins/Lighting/README new file mode 100644 index 0000000000..c6f503177d --- /dev/null +++ b/plug-ins/Lighting/README @@ -0,0 +1,39 @@ + +Lighting Effects 0.2.2 -- image filter plug-in for The GIMP program +=================================================================== + +Copyright (C) 1996-98 Tom Bech +Copyright (C) 1996-98 Federico Mena Quintero + +You can reach the author(s) via E-mail: +tomb@gimp.org (Tom) or quartic@gimp.org (Federico). + +The GIMP was developed by Peter Mattis and Spencer Kimball. +You can contact them at gimp@xcf.berkeley.edu. + +There's more GIMP stuff on our home pages: +http://www.ii.uib.no/~tomb/gimp.html (Tom's page) +http://www.nuclecu.unam.mx/~federico/gimp/index.html (Quartic's page) + + +Legal stuff +=========== + +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 2 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 (see "COPYING" file); if not, write to the Free Software Foundation, +Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +In other words, you can't sue us for whatever happens while using this ;) + +Have fun, + +Tom diff --git a/plug-ins/Lighting/TODO b/plug-ins/Lighting/TODO new file mode 100644 index 0000000000..5ed6c230c4 --- /dev/null +++ b/plug-ins/Lighting/TODO @@ -0,0 +1,15 @@ + +The lighting plug-in "todo"-list: +================================= + +* Supersampling/antialiasing +* Bilinear filtering of enviroment map +* Refraction back in? +* Support for any-sized non-gray bump-maps. +* Support for gray or alpha-channeled env-maps. +* Zooming and scrolling in preview window +* Autoconf/automake stuff +* Put spotlight back in +* Nicer interactive UI +* Presets +* Multiple light sources diff --git a/plug-ins/Lighting/amb1.xpm b/plug-ins/Lighting/amb1.xpm new file mode 100644 index 0000000000..d9fb4a1b4e --- /dev/null +++ b/plug-ins/Lighting/amb1.xpm @@ -0,0 +1,88 @@ +/* XPM */ +char * amb1_xpm[] = { +"32 32 53 1", +" c None", +". c #861786178617", +"X c #861782078617", +"o c #69A66DB669A6", +"O c #8E388E388E38", +"+ c #B6DAB2CAB6DA", +"@ c #BEFBBAEABEFB", +"# c #AEBAAEBAAEBA", +"$ c #9E799E799E79", +"% c #8E388A288E38", +"& c #618565956185", +"* c #30C234D330C2", +"= c #A699A699A699", +"- c #CF3CCF3CCF3C", +"; c #D75CD34CD75C", +": c #C71BC30BC71B", +"> c #DF7DDF7DDF7D", +", c #D75CD75CD75C", +"< c #CF3CCB2BCF3C", +"1 c #AEBAAAAAAEBA", +"2 c #965896589658", +"3 c #79E779E779E7", +"4 c #514455555144", +"5 c #18611C711861", +"6 c #E79DE38DE79D", +"7 c #E79DE79DE79D", +"8 c #DF7DDB6CDF7D", +"9 c #BEFBBEFBBEFB", +"0 c #9E799A699E79", +"q c #79E77DF779E7", +"w c #618561856185", +"e c #38E338E338E3", +"r c #000004100000", +"t c #EFBEEFBEEFBE", +"y c #FFFFFBEEFFFF", +"u c #410341034103", +"i c #08200C300820", +"p c #FFFFFFFFFFFF", +"a c #B6DAB6DAB6DA", +"s c #965892489658", +"d c #104014511040", +"f c #71C675D671C6", +"g c #596559655965", +"h c #104010401040", +"j c #000000000000", +"k c #514451445144", +"l c #30C230C230C2", +"z c #59655D755965", +"x c #410345144103", +"c c #208124922081", +"v c #49244D344924", +"b c #208120812081", +"n c #082008200820", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" .Xo ", +" O+@@#$%&* ", +" =-;;-:+$.&* ", +" =;>>>,<@12345 ", +" O->6778-9#0qwer ", +" +;>7tyt-910X&ui ", +" @;>7ypy-a=sqwud ", +" .@-,8ty6:#$Ofgehj ", +" X#:<---:+=2Xoklij ", +" o$+@99a#=2.fzxcrj ", +" %$1#1=$2.f&v*dj ", +" &.200sOXf&kebrj ", +" *&3qXqfozvecnjj ", +" *4w&wgkx*bnjj ", +" 5euuelcdrjj ", +" ridhirjjj ", +" jjj ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/plug-ins/Lighting/amb2.xpm b/plug-ins/Lighting/amb2.xpm new file mode 100644 index 0000000000..c9cc0eda5c --- /dev/null +++ b/plug-ins/Lighting/amb2.xpm @@ -0,0 +1,58 @@ +/* XPM */ +char * amb2_xpm[] = { +"32 32 23 1", +" c None", +". c #CF3CCF3CCF3C", +"X c #CF3CCB2BCF3C", +"o c #C71BC30BC71B", +"O c #D75CD75CD75C", +"+ c #DF7DDB6CDF7D", +"@ c #C71BC71BC71B", +"# c #AEBAAEBAAEBA", +"$ c #DF7DDF7DDF7D", +"% c #E79DE38DE79D", +"& c #D75CD34CD75C", +"* c #E79DE79DE79D", +"= c #AEBAAAAAAEBA", +"- c #EFBEEBADEFBE", +"; c #BEFBBEFBBEFB", +": c #A699A289A699", +"> c #F7DEF3CEF7DE", +", c #F7DEF7DEF7DE", +"< c #B6DAB2CAB6DA", +"1 c #FFFFFFFFFFFF", +"2 c #FFFFFBEEFFFF", +"3 c #B6DAB6DAB6DA", +"4 c #BEFBBAEABEFB", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ..X ", +" oO+++O.@# ", +" X$%%$$+O&X# ", +" X%%*%%$$+&.@= ", +" o$%**-*%$+O.@;: ", +" O%**>,,%$+O.Xo< ", +" +%%-,12*+O&.Xo3 ", +" .+$%*,2,%+O&.@;3< ", +" .+$$%%*%+O&.X@;3< ", +" XO+$$$++OO&.@o43< ", +" .O+++OO&&.Xo;3< ", +" @&&OO&&..X@;43# ", +" #X.....X@o;43<: ", +" #@@XX@@o;43<: ", +" =;oo;;433<: ", +" :<3333<#: ", +" <<< ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/plug-ins/Lighting/diffint1.xpm b/plug-ins/Lighting/diffint1.xpm new file mode 100644 index 0000000000..323af173c3 --- /dev/null +++ b/plug-ins/Lighting/diffint1.xpm @@ -0,0 +1,44 @@ +/* XPM */ +char * diffint1_xpm[] = { +"32 32 9 1", +" c None", +". c #514455555144", +"X c #514451445144", +"o c #49244D344924", +"O c #596559655965", +"+ c #492449244924", +"@ c #410345144103", +"# c #59655D755965", +"$ c #618561856185", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ..X ", +" o.OO...X+ ", +" XOOOOOO..X+ ", +" XOOOOOOO...X+ ", +" oOOOOOOOOO..Xo@ ", +" .OOO###OO...XX+ ", +" OOOO#$#OO...XXo ", +" .OOOO###OO...XXoo ", +" ..OOOOOOO...XXooo ", +" X.OOOOOO....XXooo ", +" ...O......XXooo ", +" X........XXXoo+ ", +" +X.....XXXXooo@ ", +" +XXXXXXXoooo@ ", +" +oXXXooooo@ ", +" @+ooooo+@ ", +" ooo ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/plug-ins/Lighting/diffint2.xpm b/plug-ins/Lighting/diffint2.xpm new file mode 100644 index 0000000000..289db9eab9 --- /dev/null +++ b/plug-ins/Lighting/diffint2.xpm @@ -0,0 +1,80 @@ +/* XPM */ +char * diffint2_xpm[] = { +"32 32 45 1", +" c None", +". c #A699A699A699", +"X c #A699A289A699", +"o c #965896589658", +"O c #BEFBBEFBBEFB", +"+ c #CF3CCB2BCF3C", +"@ c #C71BC71BC71B", +"# c #C71BC30BC71B", +"$ c #B6DAB6DAB6DA", +"% c #8E388E388E38", +"& c #69A669A669A6", +"* c #D75CD75CD75C", +"= c #DF7DDB6CDF7D", +"- c #CF3CCF3CCF3C", +"; c #965892489658", +": c #DF7DDF7DDF7D", +"> c #E79DE38DE79D", +", c #D75CD34CD75C", +"< c #AEBAAEBAAEBA", +"1 c #9E799E799E79", +"2 c #861786178617", +"3 c #596559655965", +"4 c #E79DE79DE79D", +"5 c #B6DAB2CAB6DA", +"6 c #71C671C671C6", +"7 c #492449244924", +"8 c #F7DEF3CEF7DE", +"9 c #F7DEF7DEF7DE", +"0 c #71C675D671C6", +"q c #514455555144", +"w c #FFFFFFFFFFFF", +"e c #FFFFFBEEFFFF", +"r c #BEFBBAEABEFB", +"t c #EFBEEBADEFBE", +"y c #AEBAAAAAAEBA", +"u c #9E799A699E79", +"i c #8E388A288E38", +"p c #49244D344924", +"a c #861782078617", +"s c #69A66DB669A6", +"d c #79E779E779E7", +"f c #618565956185", +"g c #514451445144", +"h c #618561856185", +"j c #410345144103", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" .Xo ", +" .O+@#$.%& ", +" $*==*-#$.;& ", +" $=:>:=,+O<123 ", +" .*:444:*+O5X%67 ", +" O=>4898*+O5X%0q ", +" +=:49we=@r<1%03 ", +" .@*=:8et-#$yui03p ", +" X#-,**=-#r c #A699A289A699", +", c #618565956185", +"< c #AEBAAEBAAEBA", +"1 c #861786178617", +"2 c #492449244924", +"3 c #8E388E388E38", +"4 c #596559655965", +"5 c #CF3CCB2BCF3C", +"6 c #618561856185", +"7 c #DF7DDB6CDF7D", +"8 c #C71BC30BC71B", +"9 c #AEBAAAAAAEBA", +"0 c #8E388A288E38", +"q c #49244D344924", +"w c #9E799E799E79", +"e c #79E77DF779E7", +"r c #965892489658", +"t c #71C671C671C6", +"y c #514451445144", +"u c #9E799A699E79", +"i c #861782078617", +"p c #69A66DB669A6", +"a c #514455555144", +"s c #410345144103", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" .Xo ", +" .O+@@#$%& ", +" *=====@-$%& ", +" *=======+;:>, ", +" .========+*X<12 ", +" O========+*X%34 ", +" +========O;5<36 ", +" .@=======@#78906q ", +" X@======@O;Xowe4q ", +" o#@====@O*$89rtyq ", +" $-+++O#;$:%ui6q ", +" %$;**;7X8%w0py2 ", +" &%:XX58o9u0taqs ", +" &><%<9wripaqs ", +" ,1330et6yqs ", +" 24664yq2s ", +" qqq ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/plug-ins/Lighting/high1.xpm b/plug-ins/Lighting/high1.xpm new file mode 100644 index 0000000000..b542308d05 --- /dev/null +++ b/plug-ins/Lighting/high1.xpm @@ -0,0 +1,75 @@ +/* XPM */ +char * high1_xpm[] = { +"32 32 40 1", +" c None", +". c #D75CD34CD75C", +"X c #CF3CCF3CCF3C", +"o c #BEFBBAEABEFB", +"O c #F7DEF3CEF7DE", +"+ c #F7DEF7DEF7DE", +"@ c #FFFFFBEEFFFF", +"# c #EFBEEBADEFBE", +"$ c #D75CD75CD75C", +"% c #B6DAB2CAB6DA", +"& c #79E779E779E7", +"* c #E79DE79DE79D", +"= c #FFFFFFFFFFFF", +"- c #EFBEEFBEEFBE", +"; c #E79DE38DE79D", +": c #C71BC71BC71B", +"> c #A699A289A699", +", c #618565956185", +"< c #AEBAAEBAAEBA", +"1 c #861786178617", +"2 c #492449244924", +"3 c #8E388E388E38", +"4 c #596559655965", +"5 c #CF3CCB2BCF3C", +"6 c #618561856185", +"7 c #DF7DDB6CDF7D", +"8 c #C71BC30BC71B", +"9 c #AEBAAAAAAEBA", +"0 c #8E388A288E38", +"q c #49244D344924", +"w c #9E799E799E79", +"e c #79E77DF779E7", +"r c #965892489658", +"t c #71C671C671C6", +"y c #514451445144", +"u c #9E799A699E79", +"i c #861782078617", +"p c #69A66DB669A6", +"a c #514455555144", +"s c #410345144103", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" .Xo ", +" .O+@@#$%& ", +" *=====@-$%& ", +" *=======+;:>, ", +" .========+*X<12 ", +" O========+*X%34 ", +" +========O;5<36 ", +" .@=======@#78906q ", +" X@======@O;Xowe4q ", +" o#@====@O*$89rtyq ", +" $-+++O#;$:%ui6q ", +" %$;**;7X8%w0py2 ", +" &%:XX58o9u0taqs ", +" &><%<9wripaqs ", +" ,1330et6yqs ", +" 24664yq2s ", +" qqq ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/plug-ins/Lighting/high2.xpm b/plug-ins/Lighting/high2.xpm new file mode 100644 index 0000000000..49447a19fe --- /dev/null +++ b/plug-ins/Lighting/high2.xpm @@ -0,0 +1,78 @@ +/* XPM */ +char * high2_xpm[] = { +"32 32 43 1", +" c None", +". c #A699A699A699", +"X c #A699A289A699", +"o c #965896589658", +"O c #BEFBBEFBBEFB", +"+ c #CF3CCB2BCF3C", +"@ c #C71BC71BC71B", +"# c #C71BC30BC71B", +"$ c #B6DAB6DAB6DA", +"% c #8E388E388E38", +"& c #69A669A669A6", +"* c #D75CD75CD75C", +"= c #DF7DDB6CDF7D", +"- c #CF3CCF3CCF3C", +"; c #965892489658", +": c #DF7DDF7DDF7D", +"> c #E79DE38DE79D", +", c #D75CD34CD75C", +"< c #AEBAAEBAAEBA", +"1 c #9E799E799E79", +"2 c #861786178617", +"3 c #596559655965", +"4 c #E79DE79DE79D", +"5 c #B6DAB2CAB6DA", +"6 c #71C671C671C6", +"7 c #492449244924", +"8 c #F7DEF7DEF7DE", +"9 c #71C675D671C6", +"0 c #514455555144", +"q c #FFFFFFFFFFFF", +"w c #BEFBBAEABEFB", +"e c #F7DEF3CEF7DE", +"r c #AEBAAAAAAEBA", +"t c #9E799A699E79", +"y c #8E388A288E38", +"u c #49244D344924", +"i c #861782078617", +"p c #69A66DB669A6", +"a c #79E779E779E7", +"s c #618565956185", +"d c #514451445144", +"f c #618561856185", +"g c #410345144103", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" .Xo ", +" .O+@#$.%& ", +" $*==*-#$.;& ", +" $=:>:=,+O<123 ", +" .*:>4>=*+O5X%67 ", +" O=>4>8:,+O5X%90 ", +" +=:>8qq-@w<1%93 ", +" .@*==:e=+#$rty93u ", +" X#-,*,*-#wid))) + { + /* Create a new image */ + /* ================== */ + + new_image_id=gimp_image_new(width,height,RGB); + + if (mapvals.transparent_background==TRUE) + { + /* Add a layer with an alpha channel */ + /* ================================= */ + + new_layer_id=gimp_layer_new(new_image_id,"Background", + width,height,RGBA_IMAGE,100.0,NORMAL_MODE); + } + else + { + /* Create a "normal" layer */ + /* ======================= */ + + new_layer_id=gimp_layer_new(new_image_id,"Background", + width,height,RGB_IMAGE,100.0,NORMAL_MODE); + } + + gimp_image_add_layer(new_image_id,new_layer_id,0); + output_drawable=gimp_drawable_get(new_layer_id); + } + + if (mapvals.bump_mapped==TRUE && mapvals.bumpmap_id!=-1) + { + gimp_pixel_rgn_init (&bump_region, gimp_drawable_get(mapvals.bumpmap_id), + 0, 0, width, height, FALSE, FALSE); + precompute_init(width,height); + } + + if (!mapvals.env_mapped || mapvals.envmap_id==-1) + ray_func = get_ray_color; + else + { + gimp_pixel_rgn_init (&env_region, gimp_drawable_get(mapvals.envmap_id), + 0, 0, env_width, env_height, FALSE, FALSE); + ray_func = get_ray_color_ref; + } + + gimp_pixel_rgn_init (&dest_region, output_drawable, 0,0, width,height, TRUE,TRUE); + + obpp=gimp_drawable_bpp(output_drawable->id); + has_alpha=gimp_drawable_has_alpha(output_drawable->id); + + row = (guchar *)malloc(sizeof(guchar)*(size_t)(obpp)*(size_t)(width)); + + gimp_progress_init("Lighting Effects"); + +/* if (mapvals.antialiasing==FALSE) + { */ + for (ycount=0;ycountid, TRUE); + gimp_drawable_update(output_drawable->id, 0,0, width,height); + + if (new_image_id!=-1) + { + gimp_display_new(new_image_id); + gimp_displays_flush(); + gimp_drawable_detach(output_drawable); + } + +} + diff --git a/plug-ins/Lighting/lighting_apply.h b/plug-ins/Lighting/lighting_apply.h new file mode 100644 index 0000000000..c9f47f26b8 --- /dev/null +++ b/plug-ins/Lighting/lighting_apply.h @@ -0,0 +1,18 @@ +#ifndef LIGHTINGAPPLYH +#define LIGHTINGAPPLYH + +#include +#include +#include +#include +#include +#include +#include + +#include "lighting_main.h" +#include "lighting_image.h" + +extern void init_compute (void); +extern void compute_image (void); + +#endif diff --git a/plug-ins/Lighting/lighting_image.c b/plug-ins/Lighting/lighting_image.c new file mode 100644 index 0000000000..e2869db0d0 --- /dev/null +++ b/plug-ins/Lighting/lighting_image.c @@ -0,0 +1,342 @@ +/*************************************/ +/* GIMP image manipulation routines. */ +/*************************************/ + +#include "lighting_image.h" + +GDrawable *input_drawable,*output_drawable; +GPixelRgn source_region, dest_region; + +GDrawable *bump_drawable = NULL; +GPixelRgn bump_region; + +GDrawable *env_drawable = NULL; +GPixelRgn env_region; + +guchar *preview_rgb_data = NULL; +GdkImage *image = NULL; + +glong maxcounter; +gint imgtype,width,height,env_width,env_height,in_channels,out_channels; +GckRGB background; + +gint border_x1,border_y1,border_x2,border_y2; + +guchar sinemap[256],spheremap[256],logmap[256]; + +/******************/ +/* Implementation */ +/******************/ + +guchar peek_map(GPixelRgn *region,gint x,gint y) +{ + guchar data; + + gimp_pixel_rgn_get_pixel(region,&data,x,y); + + return(data); +} + +GckRGB peek(gint x,gint y) +{ + guchar data[4]; + GckRGB color; + + gimp_pixel_rgn_get_pixel(&source_region,data,x,y); + + color.r=(gdouble)(data[0])/255.0; + color.g=(gdouble)(data[1])/255.0; + color.b=(gdouble)(data[2])/255.0; + + if (input_drawable->bpp==4) + { + if (in_channels==4) + color.a=(gdouble)(data[3])/255.0; + else + color.a=1.0; + } + else + color.a=1.0; + + return(color); +} + +GckRGB peek_env_map(gint x,gint y) +{ + guchar data[4]; + GckRGB color; + + if (x<0) + x=0; + else if (x>=env_width) + x=env_width-1; + if (y<0) + y=0; + else if (y>=env_height) + y=env_height-1; + + gimp_pixel_rgn_get_pixel(&env_region,data,x,y); + + color.r=(gdouble)(data[0])/255.0; + color.g=(gdouble)(data[1])/255.0; + color.b=(gdouble)(data[2])/255.0; + color.a=1.0; + + return(color); +} + +void poke(gint x,gint y,GckRGB *color) +{ + static guchar data[4]; + + if (x<0) + x=0; + else if (x>=width) + x=width-1; + if (y<0) + y=0; + else if (y>=height) + y=height-1; + + data[0]=(guchar)(color->r*255.0); + data[1]=(guchar)(color->g*255.0); + data[2]=(guchar)(color->b*255.0); + data[3]=(guchar)(color->a*255.0); + + gimp_pixel_rgn_set_pixel(&dest_region,data,x,y); +} + +gint check_bounds(gint x,gint y) +{ + if (x=border_x2 || y>=border_y2) + return(FALSE); + else + return(TRUE); +} + +GckVector3 int_to_pos(gint x,gint y) +{ + GckVector3 pos; + + if (width>=height) + { + pos.x=(gdouble)x/(gdouble)width; + pos.y=(gdouble)y/(gdouble)width; + + pos.y+=0.5*(1.0-(gdouble)height/(gdouble)width); + } + else + { + pos.x=(gdouble)x/(gdouble)height; + pos.y=(gdouble)y/(gdouble)height; + + pos.x+=0.5*(1.0-(gdouble)width/(gdouble)height); + } + + pos.z=0.0; + return(pos); +} + +GckVector3 int_to_posf(gdouble x,gdouble y) +{ + GckVector3 pos; + + if (width>=height) + { + pos.x=x/(gdouble)width; + pos.y=y/(gdouble)width; + + pos.y+=0.5*(1.0-(gdouble)height/(gdouble)width); + } + else + { + pos.x=x/(gdouble)height; + pos.y=y/(gdouble)height; + + pos.x+=0.5*(1.0-(gdouble)width/(gdouble)height); + } + + pos.z=0.0; + return(pos); +} + +void pos_to_int(gdouble x,gdouble y,gint *scr_x,gint *scr_y) +{ + if (width>=height) + { + y-=0.5*(1.0-(gdouble)height/(gdouble)width); + *scr_x=(gint)((x*(gdouble)width)+0.5); + *scr_y=(gint)((y*(gdouble)width)+0.5); + } + else + { + x-=0.5*(1.0-(gdouble)width/(gdouble)height); + + *scr_x=(gint)((x*(gdouble)height)+0.5); + *scr_y=(gint)((y*(gdouble)height)+0.5); + } +} + +void pos_to_float(gdouble x,gdouble y,gdouble *xf,gdouble *yf) +{ + if (width>=height) + { + y-=0.5*(1.0-(gdouble)height/(gdouble)width); + *xf=x*(gdouble)width; + *yf=y*(gdouble)width; + } + else + { + x-=0.5*(1.0-(gdouble)width/(gdouble)height); + + *xf=x*(gdouble)height; + *yf=y*(gdouble)height; + } +} + +/**********************************************/ +/* Compute the image color at pos (u,v) using */ +/* Quartics bilinear interpolation stuff. */ +/**********************************************/ + +GckRGB get_image_color(gdouble u,gdouble v,gint *inside) +{ + gint x1, y1, x2, y2; + GckRGB p[4]; + + x1=(gint)(u+0.5); + y1=(gint)(v+0.5); + + if (check_bounds(x1,y1)==FALSE) + { + *inside=FALSE; + return(background); + } + + x2 = (x1 + 1); + y2 = (y1 + 1); + + if (check_bounds(x2,y2)==FALSE) + { + *inside=TRUE; + return(peek(x1,y1)); + } + + *inside=TRUE; + p[0] = peek(x1, y1); + p[1] = peek(x2, y1); + p[2] = peek(x1, y2); + p[3] = peek(x2, y2); + + return(gck_bilinear_rgba(u, v, p)); +} + +gdouble get_map_value(GPixelRgn *region, gdouble u,gdouble v, gint *inside) +{ + gint x1, y1, x2, y2; + gdouble p[4]; + + x1=(gint)(u+0.5); + y1=(gint)(v+0.5); + + x2 = (x1 + 1); + y2 = (y1 + 1); + + if (check_bounds(x2,y2)==FALSE) + { + *inside=TRUE; + return((gdouble)peek_map(region, x1,y1)); + } + + *inside=TRUE; + p[0] = (gdouble)peek_map(region, x1, y1); + p[1] = (gdouble)peek_map(region, x2, y1); + p[2] = (gdouble)peek_map(region, x1, y2); + p[3] = (gdouble)peek_map(region, x2, y2); + + return(gck_bilinear(u, v, p)); +} + +void compute_maps(void) +{ + gint x; + gdouble val,c,d; + + /* Compute Sine, Log ans Spherical transfer function maps */ + /* ====================================================== */ + + c=1.0/255.0; + d=1.15*255.0; + + for (x=0;x<256;x++) + { + sinemap[x]=(guchar)(255.0*(0.5*(sin((M_PI*c*(gdouble)x)-0.5*M_PI)+1.0))); + spheremap[x]=(guchar)(255.0*(sqrt(sin(M_PI*(gdouble)x/512.0)))); + val=(d*exp(-1.0/(8.0*c*((gdouble)x+5.0)))); + + if (val>255.0) + val=255.0; + logmap[x]=(guchar)val; + } + +} + +/****************************************/ +/* Allocate memory for temporary images */ +/****************************************/ + +gint image_setup(GDrawable *drawable,gint interactive) +{ + glong numbytes; + + compute_maps(); + + /* Get some useful info on the input drawable */ + /* ========================================== */ + + input_drawable=drawable; + output_drawable=drawable; + + gimp_drawable_mask_bounds (drawable->id, &border_x1, &border_y1, &border_x2, &border_y2); + + width=input_drawable->width; + height=input_drawable->height; + + gimp_pixel_rgn_init (&source_region, input_drawable, 0, 0, width, height, FALSE, FALSE); + + maxcounter=(glong)width*(glong)height; + + /* Assume at least RGB */ + /* =================== */ + + in_channels=3; + if (gimp_drawable_has_alpha(input_drawable->id)==TRUE) + in_channels++; + + if (interactive==TRUE) + { + /* Allocate memory for temp. images */ + /* ================================ */ + + image=gdk_image_new(GDK_IMAGE_FASTEST,appwin->visinfo->visual,PREVIEW_WIDTH,PREVIEW_HEIGHT); + + if (image==NULL) + return(FALSE); + + numbytes=(glong)PREVIEW_WIDTH*(glong)PREVIEW_HEIGHT*3; + preview_rgb_data=(guchar *)malloc((size_t)numbytes); + + if (preview_rgb_data==NULL) + return(FALSE); + + memset(preview_rgb_data,0,numbytes); + + /* Convert from raw RGB to GdkImage */ + /* ================================ */ + + gck_rgb_to_gdkimage(appwin->visinfo,preview_rgb_data,image,PREVIEW_WIDTH,PREVIEW_HEIGHT); + } + + return(TRUE); +} + diff --git a/plug-ins/Lighting/lighting_image.h b/plug-ins/Lighting/lighting_image.h new file mode 100644 index 0000000000..476e9398ec --- /dev/null +++ b/plug-ins/Lighting/lighting_image.h @@ -0,0 +1,49 @@ +#ifndef LIGHTINGIMAGEH +#define LIGHTINGIMAGEH + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "lighting_main.h" + +extern GDrawable *input_drawable,*output_drawable; +extern GPixelRgn source_region, dest_region; + +extern GDrawable *bump_drawable; +extern GPixelRgn bump_region; + +extern GDrawable *env_drawable; +extern GPixelRgn env_region; + +extern guchar *preview_rgb_data; +extern GdkImage *image; + +extern glong maxcounter; +extern gint imgtype,width,height,env_width,env_height,in_channels,out_channels; +extern GckRGB background; + +extern gint border_x1,border_y1,border_x2,border_y2; + +extern guchar sinemap[256],spheremap[256],logmap[256]; + +guchar peek_map (GPixelRgn *region,gint x,gint y); +GckRGB peek (gint x,gint y); +GckRGB peek_env_map (gint x,gint y); +void poke (gint x,gint y,GckRGB *color); +gint check_bounds (gint x,gint y); +GckVector3 int_to_pos (gint x,gint y); +GckVector3 int_to_posf (gdouble x,gdouble y); +extern void pos_to_int (gdouble x,gdouble y,gint *scr_x,gint *scr_y); +extern void pos_to_float (gdouble x,gdouble y,gdouble *xf,gdouble *yf); +extern GckRGB get_image_color (gdouble u,gdouble v,gint *inside); +extern gdouble get_map_value (GPixelRgn *region, gdouble u,gdouble v, gint *inside); +extern gint image_setup (GDrawable *drawable,gint interactive); + +#endif diff --git a/plug-ins/Lighting/lighting_main.c b/plug-ins/Lighting/lighting_main.c new file mode 100644 index 0000000000..2d492f372c --- /dev/null +++ b/plug-ins/Lighting/lighting_main.c @@ -0,0 +1,332 @@ +/*********************************************************************************/ +/* Lighting Effects 0.2.2 -- image filter plug-in for The Gimp program */ +/* Copyright (C) 1996-98 Tom Bech */ +/* Copyright (C) 1996-98 Federico Mena Quintero */ +/*===============================================================================*/ +/* E-mail: tomb@gimp.org (Tom) or quartic@gimp.org (Federico) */ +/* You can contact the original The Gimp authors at gimp@xcf.berkeley.edu */ +/*===============================================================================*/ +/* 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 2 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 (read the "COPYING" file); if not, write to the Free Software */ +/* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/*===============================================================================*/ +/* In other words, you can't sue us for whatever happens while using this ;) */ +/*********************************************************************************/ + +#include "lighting_main.h" + +/* Global variables */ +/* ================ */ + +LightingValues mapvals; + +/******************/ +/* Implementation */ +/******************/ + +void lighting_interactive (GDrawable *drawable); +void lighting_noninteractive (GDrawable *drawable); + +/*************************************/ +/* Set parameters to standard values */ +/*************************************/ + +void set_default_settings(void) +{ + gck_vector3_set(&mapvals.viewpoint, 0.5, 0.5, 0.25); + gck_vector3_set(&mapvals.planenormal, 0.0, 0.0, 1.0); + + gck_vector3_set(&mapvals.lightsource.position, 1.0, 0.0, 1.0); + gck_vector3_set(&mapvals.lightsource.direction, -1.0, -1.0, 1.0); + + gck_rgb_set(&mapvals.lightsource.color, 1.0, 1.0, 1.0); + mapvals.lightsource.intensity = 1.0; + mapvals.lightsource.type = POINT_LIGHT; + + mapvals.material.ambient_int = 0.3; + mapvals.material.diffuse_int = 1.0; + mapvals.material.diffuse_ref = 0.4; + mapvals.material.specular_ref = 0.6; + mapvals.material.highlight = 27.0; + + mapvals.pixel_treshold = 0.25; + mapvals.max_depth = 3.0; + mapvals.preview_zoom_factor = 1.0; + +/* mapvals.bumptype=0; */ + mapvals.bumpmaptype=0; + mapvals.bumpmin=0.0; + mapvals.bumpmax=0.1; + + mapvals.antialiasing = FALSE; + mapvals.create_new_image = FALSE; + mapvals.transparent_background = FALSE; + mapvals.tooltips_enabled = FALSE; + mapvals.bump_mapped=FALSE; + mapvals.env_mapped=FALSE; + mapvals.ref_mapped=FALSE; + mapvals.previewquality=FALSE; + + mapvals.bumpmap_id=-1; + mapvals.envmap_id=-1; +} + +void check_drawables(void) +{ + /* Check that envmap_id and bumpmap_id references legal images (are valid drawables) */ + /* ================================================================================= */ + + if (mapvals.bumpmap_id!=-1 && gimp_drawable_image_id(mapvals.bumpmap_id)==-1) + { + mapvals.bump_mapped=FALSE; + mapvals.bumpmap_id=-1; + } + + if (mapvals.envmap_id!=-1 && gimp_drawable_image_id(mapvals.envmap_id)==-1) + { + mapvals.env_mapped=FALSE; + mapvals.envmap_id=-1; + } + + if (mapvals.bump_mapped) + { + /* Check if bump-map is grayscale and of the same size as the input drawable */ + /* ========================================================================= */ + + if (!gimp_drawable_gray(mapvals.bumpmap_id) || + gimp_drawable_width(mapvals.drawable_id)!=gimp_drawable_width(mapvals.bumpmap_id) || + gimp_drawable_height(mapvals.drawable_id)!=gimp_drawable_height(mapvals.bumpmap_id)) + { + /* If not then we silently disable bump mapping */ + /* ============================================ */ + + mapvals.bump_mapped=FALSE; + mapvals.bumpmap_id=-1; + } + } + + if (mapvals.env_mapped) + { + /* Check if env-map is grayscale or has alpha */ + /* ========================================== */ + + if (gimp_drawable_gray(mapvals.envmap_id) || + gimp_drawable_has_alpha(mapvals.envmap_id)) + { + /* If it has then we silently disable env mapping */ + /* ============================================== */ + + mapvals.bump_mapped=FALSE; + mapvals.bumpmap_id=-1; + } + } +} + +MAIN(); + +static void query(void) +{ + static GParamDef args[] = + { + { PARAM_INT32, "run_mode", "Interactive (0), non-interactive (1)" }, + { PARAM_IMAGE, "image", "Input image" }, + { PARAM_DRAWABLE, "drawable", "Input drawable" }, + { PARAM_DRAWABLE, "bumpdrawable", "Bumpmap drawable (set to 0 if disabled)" }, + { PARAM_DRAWABLE, "envdrawable", "Environmentmap drawable (set to 0 if disabled)" }, + { PARAM_INT32, "dobumpmap", "Enable bumpmapping (TRUE/FALSE)" }, + { PARAM_INT32, "doenvmap", "Enable envmapping (TRUE/FALSE)" }, + { PARAM_INT32, "bumpmaptype", "Type of mapping (0=linear,1=log, 2=sinusoidal, 3=spherical)" }, + { PARAM_INT32, "lighttype", "Type of lightsource (0=point,1=directional,3=spot,4=none)" }, + { PARAM_COLOR, "lightcolor", "Lightsource color (r,g,b)" }, + { PARAM_FLOAT, "lightposition_x", "Lightsource position (x,y,z)" }, + { PARAM_FLOAT, "lightposition_y", "Lightsource position (x,y,z)" }, + { PARAM_FLOAT, "lightposition_z", "Lightsource position (x,y,z)" }, + { PARAM_FLOAT, "lightdirection_x", "Lightsource direction [x,y,z]" }, + { PARAM_FLOAT, "lightdirection_y", "Lightsource direction [x,y,z]" }, + { PARAM_FLOAT, "lightdirection_z", "Lightsource direction [x,y,z]" }, + { PARAM_FLOAT, "ambient_intensity", "Material ambient intensity (0..1)" }, + { PARAM_FLOAT, "diffuse_intensity", "Material diffuse intensity (0..1)" }, + { PARAM_FLOAT, "diffuse_reflectivity", "Material diffuse reflectivity (0..1)" }, + { PARAM_FLOAT, "specular_reflectivity", "Material specular reflectivity (0..1)" }, + { PARAM_FLOAT, "highlight", "Material highlight (0..->), note: it's expotential" }, + { PARAM_INT32, "antialiasing", "Apply antialiasing (TRUE/FALSE)" }, + { PARAM_INT32, "newimage", "Create a new image (TRUE/FALSE)" }, + { PARAM_INT32, "transparentbackground", "Make background transparent (TRUE/FALSE)" } + }; + + + static GParamDef *return_vals = NULL; + static gint nargs = sizeof (args) / sizeof (args[0]); + static gint nreturn_vals = 0; + + gimp_install_procedure ("plug_in_lighting", + "Apply various lighting effects to an image", + "No help yet", + "Tom Bech & Federico Mena Quintero", + "Tom Bech & Federico Mena Quintero", + "Version 0.2.0, March 15 1998", + "/Filters/Light Effects/Lighting Effects", + "RGB*", + PROC_PLUG_IN, + nargs, nreturn_vals, + args, return_vals); +} + +static void run(gchar *name, + gint nparams, + GParam *param, + gint *nreturn_vals, + GParam **return_vals) +{ + static GParam values[1]; + GDrawable *drawable; + GRunModeType run_mode; + GStatusType status = STATUS_SUCCESS; + + run_mode = param[0].data.d_int32; + + *nreturn_vals = 1; + *return_vals = values; + + values[0].type = PARAM_STATUS; + values[0].data.d_status = status; + + /* Set default values */ + /* ================== */ + + set_default_settings(); + + /* Possibly retrieve data */ + /* ====================== */ + + gimp_get_data ("plug_in_lighting", &mapvals); + + /* Get the specified drawable */ + /* ========================== */ + + drawable = gimp_drawable_get (param[2].data.d_drawable); + + mapvals.drawable_id=drawable->id; + + check_drawables(); + + if (status == STATUS_SUCCESS) + { + /* Make sure that the drawable is RGBA or RGB color */ + /* ================================================ */ + + if (gimp_drawable_color(drawable->id)) + { + /* Set the tile cache size */ + /* ======================= */ + + gimp_tile_cache_ntiles(TILE_CACHE_SIZE); + + switch (run_mode) + { + case RUN_INTERACTIVE: + lighting_interactive(drawable); + gimp_set_data("plug_in_lighting", &mapvals, sizeof(LightingValues)); + break; + case RUN_WITH_LAST_VALS: + image_setup(drawable,FALSE); + compute_image(); + break; + case RUN_NONINTERACTIVE: + if (nparams != 24) + status = STATUS_CALLING_ERROR; + else if (status == STATUS_SUCCESS) + { + mapvals.bumpmap_id = param[3].data.d_drawable; + mapvals.envmap_id = param[4].data.d_drawable; + mapvals.bump_mapped = (gint)param[5].data.d_int32; + mapvals.env_mapped = (gint)param[6].data.d_int32; + mapvals.bumpmaptype = (gint)param[7].data.d_int32; + mapvals.lightsource.type = (LightType)param[8].data.d_int32; + mapvals.lightsource.color.r = param[9].data.d_color.red; + mapvals.lightsource.color.g = param[9].data.d_color.green; + mapvals.lightsource.color.b = param[9].data.d_color.blue; + mapvals.lightsource.position.x = param[10].data.d_float; + mapvals.lightsource.position.y = param[11].data.d_float; + mapvals.lightsource.position.z = param[12].data.d_float; + mapvals.lightsource.direction.x = param[13].data.d_float; + mapvals.lightsource.direction.y = param[14].data.d_float; + mapvals.lightsource.direction.z = param[15].data.d_float; + mapvals.material.ambient_int = param[16].data.d_float; + mapvals.material.diffuse_int = param[17].data.d_float; + mapvals.material.diffuse_ref = param[18].data.d_float; + mapvals.material.specular_ref = param[19].data.d_float; + mapvals.material.highlight = param[20].data.d_float; + mapvals.antialiasing = (gint)param[21].data.d_int32; + mapvals.create_new_image = (gint)param[22].data.d_int32; + mapvals.transparent_background = (gint)param[23].data.d_int32; + + check_drawables(); + image_setup(drawable, FALSE); + compute_image(); + } + default: + break; + } + } + else + status = STATUS_EXECUTION_ERROR; + } + + values[0].data.d_status = status; + gimp_drawable_detach (drawable); +} + +GPlugInInfo PLUG_IN_INFO = +{ + NULL, /* init_proc */ + NULL, /* quit_proc */ + query, /* query_proc */ + run, /* run_proc */ +}; + +void lighting_interactive(GDrawable *drawable) +{ + gchar **argv; + gint argc; + + argc = 1; + argv = g_new (gchar *, 1); + argv[0] = g_strdup ("lighting"); + + gdk_set_show_events(0); + gdk_set_use_xshm(gimp_use_xshm()); + + gtk_init (&argc, &argv); + + /* Create application window */ + /* ========================= */ + + create_main_dialog(); + + /* Prepare images */ + /* ============== */ + + image_setup(drawable,TRUE); + + /* Gtk main event loop */ + /* =================== */ + + gtk_main(); + gdk_flush(); +} + +void lighting_noninteractive(GDrawable *drawable) +{ + printf("Noninteractive not yet implemented! Sorry.\n"); +} + diff --git a/plug-ins/Lighting/lighting_main.h b/plug-ins/Lighting/lighting_main.h new file mode 100644 index 0000000000..ef32857f68 --- /dev/null +++ b/plug-ins/Lighting/lighting_main.h @@ -0,0 +1,106 @@ +#ifndef LIGHTINGMAINH +#define LIGHTINGMAINH + +#include +#include +#include +#include +#include +#include +#include + +#include "lighting_ui.h" +#include "lighting_image.h" +#include "lighting_apply.h" +#include "lighting_preview.h" + +/* Defines and stuff */ +/* ================= */ + +#define TILE_CACHE_SIZE 16 + +/* Typedefs */ +/* ======== */ + +typedef enum { + POINT_LIGHT, + DIRECTIONAL_LIGHT, + SPOT_LIGHT, + NO_LIGHT +} LightType; + +enum { + IMAGE_BUMP, + WAVES_BUMP +}; + +typedef struct +{ + gdouble ambient_int; + gdouble diffuse_int; + gdouble diffuse_ref; + gdouble specular_ref; + gdouble highlight; + GckRGB color; +} MaterialSettings; + +typedef struct +{ + LightType type; + GckVector3 position; + GckVector3 direction; + GckRGB color; + gdouble intensity; +} LightSettings; + +typedef struct { + + gint32 drawable_id; + gint32 bumpmap_id; + gint32 envmap_id; + + /* Render variables */ + /* ================ */ + + GckVector3 viewpoint; + GckVector3 planenormal; + LightSettings lightsource; + MaterialSettings material; + MaterialSettings ref_material; + + gdouble pixel_treshold; + gdouble bumpmax,bumpmin; +/* gdouble wave_cx,wave_cy; + gdouble wave_lx,wave_ly; + gdouble wave_amp,wave_ph; */ + gint max_depth; + gint bumpmaptype; +/* gint bumptype; */ + + /* Flags */ + /* ===== */ + + gint antialiasing; + gint create_new_image; + gint transparent_background; + gint tooltips_enabled; + gint bump_mapped; + gint env_mapped; + gint ref_mapped; + gint bumpstretch; + gint previewquality; + + /* Misc */ + /* ==== */ + + gdouble preview_zoom_factor; + +} LightingValues; + +/* Externally visible variables */ +/* ============================ */ + +extern LightingValues mapvals; +extern GckRGB background; + +#endif diff --git a/plug-ins/Lighting/lighting_pixmaps.h b/plug-ins/Lighting/lighting_pixmaps.h new file mode 100644 index 0000000000..d8db35a748 --- /dev/null +++ b/plug-ins/Lighting/lighting_pixmaps.h @@ -0,0 +1,26 @@ +#ifndef LIGHTINGPIXMAPSH +#define LIGHTINGPIXMAPSH + +#include "amb1.xpm" +#include "amb2.xpm" +#include "diffint1.xpm" +#include "diffint2.xpm" +#include "diffref1.xpm" +#include "diffref2.xpm" +#include "specref1.xpm" +#include "specref2.xpm" +#include "high1.xpm" +#include "high2.xpm" + +extern char *amb1_xpm[]; +extern char *amb2_xpm[]; +extern char *diffint1_xpm[]; +extern char *diffint2_xpm[]; +extern char *diffref1_xpm[]; +extern char *diffref2_xpm[]; +extern char *specref1_xpm[]; +extern char *specref2_xpm[]; +extern char *high1_xpm[]; +extern char *high2_xpm[]; + +#endif diff --git a/plug-ins/Lighting/lighting_preview.c b/plug-ins/Lighting/lighting_preview.c new file mode 100644 index 0000000000..cbfc5c6c5a --- /dev/null +++ b/plug-ins/Lighting/lighting_preview.c @@ -0,0 +1,404 @@ +/*************************************************/ +/* Compute a preview image and preview wireframe */ +/*************************************************/ + +#include "lighting_preview.h" + +gint lightx,lighty; +BackBuffer backbuf={0,0,0,0,NULL}; +gdouble *xpostab=NULL,*ypostab=NULL; + +/* Protos */ +/* ====== */ + +void draw_preview_image (gint recompute); +void update_light (gint xpos,gint ypos); +void draw_light_marker (gint xpos,gint ypos); +void clear_light_marker (void); + +void compute_preview (gint startx,gint starty,gint w,gint h) +{ + gint xcnt,ycnt,f1,f2; + gdouble imagex,imagey; + gint32 index=0; + GckRGB color,darkcheck,lightcheck,temp; + GckVector3 pos; + get_ray_func ray_func; + + xpostab = (gdouble *)malloc(sizeof(gdouble)*w); + ypostab = (gdouble *)malloc(sizeof(gdouble)*h); + + for (xcnt=0;xcnt=starty && ycnt<(starty+h)) && + (xcnt>=startx && xcnt<(startx+w))) + { + imagex=xpostab[xcnt-startx]; + imagey=ypostab[ycnt-starty]; + pos=int_to_posf(imagex,imagey); + if (mapvals.bump_mapped==TRUE && mapvals.bumpmap_id!=-1 && xcnt==startx) + { + pos_to_float(pos.x,pos.y,&imagex,&imagey); + precompute_normals(0,width,(gint)(imagey+0.5)); + } + + color=(*ray_func)(&pos); + + if (color.a<1.0) + { + f1=((xcnt % 32)<16); + f2=((ycnt % 32)<16); + f1=f1^f2; + + if (f1) + { + if (color.a==0.0) + color=lightcheck; + else + { + gck_rgb_mul(&color,color.a); + temp=lightcheck; + gck_rgb_mul(&temp,1.0-color.a); + gck_rgb_add(&color,&temp); + } + } + else + { + if (color.a==0.0) + color=darkcheck; + else + { + gck_rgb_mul(&color,color.a); + temp=darkcheck; + gck_rgb_mul(&temp,1.0-color.a); + gck_rgb_add(&color,&temp); + } + } + } + + preview_rgb_data[index++]=(guchar)(255.0*color.r); + preview_rgb_data[index++]=(guchar)(255.0*color.g); + preview_rgb_data[index++]=(guchar)(255.0*color.b); + imagex++; + } + else + { + preview_rgb_data[index++]=200; + preview_rgb_data[index++]=200; + preview_rgb_data[index++]=200; + } + } + } + + gck_rgb_to_gdkimage(appwin->visinfo, preview_rgb_data, image, PREVIEW_WIDTH, PREVIEW_HEIGHT); +} + +void blah() +{ + /* First, compute the linear mapping (x,y,x+w,y+h) to (0,0,pw,ph) */ + /* ============================================================== */ + +/* realw=(p2.x-p1.x); + realh=(p2.y-p1.y); + + for (xcnt=0;xcnt same color, so skip shading */ + /* ================================================= */ + +/* p2=p1; + color=get_ray_color(&p1); + + if (color.a<1.0) + { + f1=((xcnt % 32)<16); + f2=((ycnt % 32)<16); + f1=f1^f2; + + if (f1) + { + if (color.a==0.0) + color=lightcheck; + else + { + gck_rgb_mul(&color,color.a); + temp=lightcheck; + gck_rgb_mul(&temp,1.0-color.a); + gck_rgb_add(&color,&temp); + } + } + else + { + if (color.a==0.0) + color=darkcheck; + else + { + gck_rgb_mul(&color,color.a); + temp=darkcheck; + gck_rgb_mul(&temp,1.0-color.a); + gck_rgb_add(&color,&temp); + } + } + } + + preview_rgb_data[index++]=(guchar)(color.r*255.0); + preview_rgb_data[index++]=(guchar)(color.g*255.0); + preview_rgb_data[index++]=(guchar)(color.b*255.0); + } + } */ + + /* Convert to visual type */ + /* ====================== */ + +/* gck_rgb_to_gdkimage(appwin->visinfo,preview_rgb_data,image,pw,ph); */ + +} + +/*************************************************/ +/* Check if the given position is within the */ +/* light marker. Return TRUE if so, FALSE if not */ +/*************************************************/ + +gint check_light_hit(gint xpos,gint ypos) +{ +/* gdouble dx,dy,r; + + if (mapvals.lightsource.type==POINT_LIGHT) + { + dx=(gdouble)lightx-xpos; + dy=(gdouble)lighty-ypos; + r=sqrt(dx*dx+dy*dy)+0.5; + + if ((gint)r>7) + return(FALSE); + else + return(TRUE); + } + */ + return(FALSE); +} + +/****************************************/ +/* Draw a marker to show light position */ +/****************************************/ + +void draw_light_marker(gint xpos,gint ypos) +{ +/* gck_gc_set_foreground(appwin->visinfo,gc,0,50,255); + gck_gc_set_background(appwin->visinfo,gc,0,0,0); + + gdk_gc_set_function(gc,GDK_COPY); + + if (mapvals.lightsource.type==POINT_LIGHT) + { + lightx=xpos; + lighty=ypos; */ + + /* Save background */ + /* =============== */ + +/* backbuf.x=lightx-7; + backbuf.y=lighty-7; + backbuf.w=14; + backbuf.h=14; */ + + /* X doesn't like images that's outside a window, make sure */ + /* we get the backbuffer image from within the boundaries */ + /* ======================================================== */ + +/* if (backbuf.x<0) + backbuf.x=0; + else if ((backbuf.x+backbuf.w)>PREVIEW_WIDTH) + backbuf.w=(PREVIEW_WIDTH-backbuf.x); + + if (backbuf.y<0) + backbuf.y=0; + else if ((backbuf.y+backbuf.h)>PREVIEW_HEIGHT) + backbuf.h=(PREVIEW_WIDTH-backbuf.y); + + backbuf.image=gdk_image_get(previewarea->window,backbuf.x,backbuf.y,backbuf.w,backbuf.h); + gdk_draw_arc(previewarea->window,gc,TRUE,lightx-7,lighty-7,14,14,0,360*64); + } */ +} + +void clear_light_marker(void) +{ + /* Restore background if it has been saved */ + /* ======================================= */ + +/* if (backbuf.image!=NULL) + { + gck_gc_set_foreground(appwin->visinfo,gc,255,255,255); + gck_gc_set_background(appwin->visinfo,gc,0,0,0); + + gdk_gc_set_function(gc,GDK_COPY); + gdk_draw_image(previewarea->window,gc,backbuf.image,0,0,backbuf.x,backbuf.y, + backbuf.w,backbuf.h); + gdk_image_destroy(backbuf.image); + backbuf.image=NULL; + } */ +} + +void draw_lights(void) +{ +/* gdouble dxpos,dypos; + gint xpos,ypos; + + clear_light_marker(); + + gck_3d_to_2d(startx,starty,pw,ph,&dxpos,&dypos,&mapvals.viewpoint, + &mapvals.lightsource.position); + + xpos=(gint)(dxpos+0.5); + ypos=(gint)(dypos+0.5); + + if (xpos>=0 && xpos<=PREVIEW_WIDTH && ypos>=0 && ypos<=PREVIEW_HEIGHT) + draw_light_marker(xpos,ypos); */ +} + +/*************************************************/ +/* Update light position given new screen coords */ +/*************************************************/ + +void update_light(gint xpos,gint ypos) +{ +/* gint startx,starty,pw,ph; + + pw=PREVIEW_WIDTH >> mapvals.preview_zoom_factor; + ph=PREVIEW_HEIGHT >> mapvals.preview_zoom_factor; + startx=(PREVIEW_WIDTH-pw)>>1; + starty=(PREVIEW_HEIGHT-ph)>>1; + + gck_2d_to_3d(startx,starty,pw,ph,xpos,ypos,&mapvals.viewpoint, + &mapvals.lightsource.position); + + draw_lights(startx,starty,pw,ph); */ +} + +void compute_preview_rectangle(gint *xp,gint *yp,gint *wid,gint *heig) +{ + gdouble x,y,w,h; + + if (width>=height) + { + w=(PREVIEW_WIDTH-50.0); + h=(gdouble)height*(w/(gdouble)width); + + x=(PREVIEW_WIDTH-w)/2.0; + y=(PREVIEW_HEIGHT-h)/2.0; + } + else + { + h=(PREVIEW_HEIGHT-50.0); + w=(gdouble)width*(h/(gdouble)height); + + x=(PREVIEW_WIDTH-w)/2.0; + y=(PREVIEW_HEIGHT-h)/2.0; + } + + *xp=(gint)(x+0.5); + *yp=(gint)(y+0.5); + *wid=(gint)(w+0.5); + *heig=(gint)(h+0.5); +} + +/******************************************************************/ +/* Draw preview image. if DoCompute is TRUE then recompute image. */ +/******************************************************************/ + +void draw_preview_image(gint recompute) +{ + gint startx,starty,pw,ph; + + gck_gc_set_foreground(appwin->visinfo,gc,255,255,255); + gck_gc_set_background(appwin->visinfo,gc,0,0,0); + + gdk_gc_set_function(gc,GDK_COPY); + + compute_preview_rectangle(&startx,&starty,&pw,&ph); + + if (recompute==TRUE) + { + gck_cursor_set(previewarea->window,GDK_WATCH); + compute_preview(startx,starty,pw,ph); + gck_cursor_set(previewarea->window,GDK_HAND2); + clear_light_marker(); + } + +/* if (pw!=PREVIEW_WIDTH) + gdk_window_clear(previewarea->window); */ + + gdk_draw_image(previewarea->window,gc,image,0,0,0,0,PREVIEW_WIDTH,PREVIEW_HEIGHT); + +/* draw_lights(); */ +} + diff --git a/plug-ins/Lighting/lighting_preview.h b/plug-ins/Lighting/lighting_preview.h new file mode 100644 index 0000000000..753b971bd8 --- /dev/null +++ b/plug-ins/Lighting/lighting_preview.h @@ -0,0 +1,41 @@ +#ifndef LIGHTINGPREVIEWH +#define LIGHTINGPREVIEWH + +#include +#include +#include +#include +#include +#include +#include + +#include "lighting_main.h" +#include "lighting_ui.h" +#include "lighting_image.h" +#include "lighting_apply.h" +#include "lighting_shade.h" + +#define PREVIEW_WIDTH 300 +#define PREVIEW_HEIGHT 300 + +typedef struct +{ + gint x,y,w,h; + GdkImage *image; +} BackBuffer; + +/* Externally visible variables */ +/* ============================ */ + +extern gint lightx,lighty; +extern BackBuffer backbuf; +extern gdouble *xpostab,*ypostab; + +/* Externally visible functions */ +/* ============================ */ + +extern void draw_preview_image (gint recompute); +extern gint check_light_hit (gint xpos,gint ypos); +extern void update_light (gint xpos,gint ypos); + +#endif diff --git a/plug-ins/Lighting/lighting_shade.c b/plug-ins/Lighting/lighting_shade.c new file mode 100644 index 0000000000..29132e7413 --- /dev/null +++ b/plug-ins/Lighting/lighting_shade.c @@ -0,0 +1,634 @@ +/*****************/ +/* Shading stuff */ +/*****************/ + +#include "lighting_shade.h" + +GckVector3 *triangle_normals[2] = { NULL, NULL }; +GckVector3 *vertex_normals[3] = { NULL, NULL, NULL }; +gdouble *heights[3] = { NULL, NULL, NULL }; +gdouble xstep,ystep; +guchar *bumprow=NULL; + +gint pre_w=-1; +gint pre_h=-1; + +/*****************/ +/* Phong shading */ +/*****************/ + +GckRGB phong_shade(GckVector3 *position,GckVector3 *viewpoint, + GckVector3 *normal,GckVector3 *lightposition, + GckRGB *diff_col,GckRGB *spec_col, + LightType light_type) +{ + GckRGB ambient_color,diffuse_color,specular_color; + gdouble nl,rv,dist; + GckVector3 l,nn,v,n; + + /* Compute ambient intensity */ + /* ========================= */ + + n=*normal; + ambient_color=*diff_col; + gck_rgb_mul(&ambient_color,mapvals.material.ambient_int); + + /* Compute (N*L) term of Phong's equation */ + /* ====================================== */ + + if (light_type==POINT_LIGHT) + gck_vector3_sub(&l,lightposition,position); + else + l=*lightposition; + + dist=gck_vector3_length(&l); + + if (dist!=0.0) + gck_vector3_mul(&l,1.0/dist); + + nl=2.0*gck_vector3_inner_product(&n,&l); + + if (nl>=0.0) + { + /* Compute (R*V)^alpha term of Phong's equation */ + /* ============================================ */ + + gck_vector3_sub(&v,viewpoint,position); + gck_vector3_normalize(&v); + + gck_vector3_mul(&n,nl); + gck_vector3_sub(&nn,&n,&l); + rv=gck_vector3_inner_product(&nn,&v); + rv=pow(rv,mapvals.material.highlight); + + /* Compute diffuse and specular intensity contribution */ + /* =================================================== */ + + diffuse_color=*diff_col; + gck_rgb_mul(&diffuse_color,mapvals.material.diffuse_ref); + gck_rgb_mul(&diffuse_color,nl); + + specular_color=*spec_col; + gck_rgb_mul(&specular_color,mapvals.material.specular_ref); + gck_rgb_mul(&specular_color,rv); + + gck_rgb_add(&diffuse_color,&specular_color); + gck_rgb_mul(&diffuse_color,mapvals.material.diffuse_int); + gck_rgb_clamp(&diffuse_color); + + gck_rgb_add(&ambient_color,&diffuse_color); + } + + gck_rgb_clamp(&ambient_color); + return(ambient_color); +} + +void get_normal(gdouble xf,gdouble yf,GckVector3 *normal) +{ + GckVector3 v1,v2,n; + gint numvecs=0,x,y,f; + gdouble val,val1=-1.0,val2=-1.0,val3=-1.0,val4=-1.0, xstep,ystep; + + x=(gint)(xf+0.5); + y=(gint)(yf+0.5); + + xstep=1.0/(gdouble)width; + ystep=1.0/(gdouble)height; + + val=mapvals.bumpmax*get_map_value(&bump_region, xf,yf, &f)/255.0; + if (check_bounds(x-1,y)) val1=mapvals.bumpmax*get_map_value(&bump_region, xf-1.0,yf, &f)/255.0 - val; + if (check_bounds(x,y-1)) val2=mapvals.bumpmax*get_map_value(&bump_region, xf,yf-1.0, &f)/255.0 - val; + if (check_bounds(x+1,y)) val3=mapvals.bumpmax*get_map_value(&bump_region, xf+1.0,yf, &f)/255.0 - val; + if (check_bounds(x,y+1)) val4=mapvals.bumpmax*get_map_value(&bump_region, xf,yf+1.0, &f)/255.0 - val; + + gck_vector3_set(normal, 0.0,0.0,0.0); + + if (val1!=-1.0 && val4!=-1.0) + { + v1.x=-xstep; v1.y=0.0; v1.z=val1; + v2.x=0.0; v2.y=ystep; v2.z=val4; + n=gck_vector3_cross_product(&v1,&v2); + gck_vector3_normalize(&n); + + if (n.z<0.0) + n.z=-n.z; + + gck_vector3_add(normal,normal,&n); + numvecs++; + } + + if (val1!=-1.0 && val2!=-1.0) + { + v1.x=-xstep; v1.y=0.0; v1.z=val1; + v2.x=0.0; v2.y=-ystep; v2.z=val2; + n=gck_vector3_cross_product(&v1,&v2); + gck_vector3_normalize(&n); + + if (n.z<0.0) + n.z=-n.z; + + gck_vector3_add(normal,normal,&n); + numvecs++; + } + + if (val2!=-1.0 && val3!=-1.0) + { + v1.x=0.0; v1.y=-ystep; v1.z=val2; + v2.x=xstep; v2.y=0.0; v2.z=val3; + n=gck_vector3_cross_product(&v1,&v2); + gck_vector3_normalize(&n); + + if (n.z<0.0) + n.z=-n.z; + + gck_vector3_add(normal,normal,&n); + numvecs++; + } + + if (val3!=-1.0 && val4!=-1.0) + { + v1.x=xstep; v1.y=0.0; v1.z=val3; + v2.x=0.0; v2.y=ystep; v2.z=val4; + n=gck_vector3_cross_product(&v1,&v2); + gck_vector3_normalize(&n); + + if (n.z<0.0) + n.z=-n.z; + + gck_vector3_add(normal,normal,&n); + numvecs++; + } + + gck_vector3_mul(normal,1.0/(gdouble)numvecs); + gck_vector3_normalize(normal); +} + +void precompute_init(gint w,gint h) +{ + gint n; + + xstep=1.0/(gdouble)width; + ystep=1.0/(gdouble)height; + + pre_w=w; + pre_h=h; + + for (n=0;n<3;n++) + { + if (vertex_normals[n]!=NULL) + free(vertex_normals[n]); + if (heights[n]!=NULL) + free(heights[n]); + + heights[n]=(gdouble *)malloc(sizeof(gdouble)*(size_t)w); + vertex_normals[n]=(GckVector3 *)malloc(sizeof(GckVector3)*(size_t)w); + } + + for (n=0;n<2;n++) + if (triangle_normals[n]!=NULL) + free(triangle_normals[n]); + + if (bumprow!=NULL) + { + free(bumprow); + bumprow=NULL; + } + + bumprow=(guchar *)malloc(sizeof(guchar)*(size_t)w); + + triangle_normals[0]=(GckVector3 *)malloc(sizeof(GckVector3)*(size_t)((w<<1)+2)); + triangle_normals[1]=(GckVector3 *)malloc(sizeof(GckVector3)*(size_t)((w<<1)+2)); + + for (n=0;n<(w<<1)+1;n++) + { + gck_vector3_set(&triangle_normals[0][n],0.0,0.0,1.0); + gck_vector3_set(&triangle_normals[1][n],0.0,0.0,1.0); + } + + for (n=0;n0) + { + switch (mapvals.bumpmaptype) + { + case 1: + map=logmap; + break; + case 2: + map=sinemap; + break; + default: + map=spheremap; + break; + } + for (n=0;n<(x2-x1);n++) + heights[2][n]=(gdouble)mapvals.bumpmax*(gdouble)map[bumprow[n]]/255.0; + } + else for (n=0;n<(x2-x1);n++) + heights[2][n]=(gdouble)mapvals.bumpmax*(gdouble)bumprow[n]/255.0; + + /* Compute triangle normals */ + /* ======================== */ + + i=0; + for (n=0;n<(x2-x1-1);n++) + { + p1.x=0.0; + p1.y=ystep; + p1.z=heights[2][n]-heights[1][n]; + + p2.x=xstep; + p2.y=ystep; + p2.z=heights[2][n+1]-heights[1][n]; + + p3.x=xstep; + p3.y=0.0; + p3.z=heights[1][n+1]-heights[1][n]; + + triangle_normals[1][i]=gck_vector3_cross_product(&p2,&p1); + triangle_normals[1][i+1]=gck_vector3_cross_product(&p3,&p2); + + gck_vector3_normalize(&triangle_normals[1][i]); + gck_vector3_normalize(&triangle_normals[1][i+1]); + + i+=2; + } + + /* Compute vertex normals */ + /* ====================== */ + + i=0; + gck_vector3_set(&normal, 0.0,0.0,0.0); + for (n=0;n<(x2-x1-1);n++) + { + nv=0; + if (n>0) + { + if (y>0) + { + gck_vector3_add(&normal, &normal, &triangle_normals[0][i-1]); + gck_vector3_add(&normal, &normal, &triangle_normals[0][i-2]); + nv+=2; + } + if (y0) + { + gck_vector3_add(&normal, &normal, &triangle_normals[0][i]); + gck_vector3_add(&normal, &normal, &triangle_normals[0][i+1]); + nv+=2; + } + if (y1.0) + fac=1.0; + else if (fac<-1.0) + fac=-1.0; + + *u=acos(fac)/(2.0*M_PI); + + cross_prod=gck_vector3_cross_product(&secondaxis,&firstaxis); + + if (gck_vector3_inner_product(&cross_prod,normal)<0.0) + *u=1.0-*u; + } +} + +/*********************************************************************/ +/* These routines computes the color of the surface at a given point */ +/*********************************************************************/ + +GckRGB get_ray_color(GckVector3 *position) +{ + GckRGB color; + gint x,f; + gdouble xf,yf; + GckVector3 normal,*p; + + pos_to_float(position->x,position->y,&xf,&yf); + + x = (gint)(xf+0.5); + + if (mapvals.transparent_background && heights[1][x]==0) + color.a=0.0; + else + { + color=get_image_color(xf,yf,&f); + + if (mapvals.lightsource.type==POINT_LIGHT) + p=&mapvals.lightsource.position; + else + p=&mapvals.lightsource.direction; + + if (mapvals.bump_mapped==FALSE || mapvals.bumpmap_id==-1) + color=phong_shade(position, + &mapvals.viewpoint, + &mapvals.planenormal, + p, + &color, + &mapvals.lightsource.color, + mapvals.lightsource.type); + else + { + normal=vertex_normals[1][(gint)(xf+0.5)]; + + color=phong_shade(position, + &mapvals.viewpoint, + &normal, + p, + &color, + &mapvals.lightsource.color, + mapvals.lightsource.type); + } + } + + return(color); +} + +GckRGB get_ray_color_ref(GckVector3 *position) +{ + GckRGB color,env_color; + gint x,f; + gdouble xf,yf; + GckVector3 normal,*p,v,r; + + pos_to_float(position->x,position->y,&xf,&yf); + + x = (gint)(xf+0.5); + + if (mapvals.transparent_background && heights[1][x]==0) + color.a=0.0; + else + { + color=get_image_color(xf,yf,&f); + + if (mapvals.lightsource.type==POINT_LIGHT) + p=&mapvals.lightsource.position; + else + p=&mapvals.lightsource.direction; + + if (mapvals.bump_mapped==FALSE || mapvals.bumpmap_id==-1) + color=phong_shade(position, + &mapvals.viewpoint, + &mapvals.planenormal, + p, + &color, + &mapvals.lightsource.color, + mapvals.lightsource.type); + else + { + normal=vertex_normals[1][(gint)(xf+0.5)]; + + gck_vector3_sub(&v,&mapvals.viewpoint,position); + gck_vector3_normalize(&v); + + r = compute_reflected_ray(&normal,&v); + + /* Get color in the direction of r */ + /* =============================== */ + + sphere_to_image(&r,&xf,&yf); + env_color = peek_env_map((gint)(env_width*xf+0.5),(gint)(env_height*yf+0.5)); + + color=phong_shade(position, + &mapvals.viewpoint, + &normal, + p, + &env_color, + &mapvals.lightsource.color, + mapvals.lightsource.type); + } + } + + return(color); +} + +GckRGB get_ray_color_no_bilinear(GckVector3 *position) +{ + GckRGB color; + gint x; + gdouble xf,yf; + GckVector3 normal,*p; + + pos_to_float(position->x,position->y,&xf,&yf); + + x = (gint)(xf+0.5); + + if (mapvals.transparent_background && heights[1][x]==0) + color.a=0.0; + else + { + color=peek(x,(gint)(yf+0.5)); + + if (mapvals.lightsource.type==POINT_LIGHT) + p=&mapvals.lightsource.position; + else + p=&mapvals.lightsource.direction; + + if (mapvals.bump_mapped==FALSE || mapvals.bumpmap_id==-1) + color=phong_shade(position, + &mapvals.viewpoint, + &mapvals.planenormal, + p, + &color, + &mapvals.lightsource.color, + mapvals.lightsource.type); + else + { + normal=vertex_normals[1][x]; + + color=phong_shade(position, + &mapvals.viewpoint, + &normal, + p, + &color, + &mapvals.lightsource.color, + mapvals.lightsource.type); + } + } + + return(color); +} + +GckRGB get_ray_color_no_bilinear_ref(GckVector3 *position) +{ + GckRGB color,env_color; + gint x; + gdouble xf,yf; + GckVector3 normal,*p,v,r; + + pos_to_float(position->x,position->y,&xf,&yf); + + x = (gint)(xf+0.5); + + if (mapvals.transparent_background && heights[1][x]==0) + color.a=0.0; + else + { + color=peek((gint)(xf+0.5),(gint)(yf+0.5)); + + if (mapvals.lightsource.type==POINT_LIGHT) + p=&mapvals.lightsource.position; + else + p=&mapvals.lightsource.direction; + + if (mapvals.bump_mapped==FALSE || mapvals.bumpmap_id==-1) + { + pos_to_float(position->x,position->y,&xf,&yf); + + color=peek((gint)(xf+0.5),(gint)(yf+0.5)); + + gck_vector3_sub(&v,&mapvals.viewpoint,position); + gck_vector3_normalize(&v); + + r = compute_reflected_ray(&mapvals.planenormal,&v); + + /* Get color in the direction of r */ + /* =============================== */ + + sphere_to_image(&r,&xf,&yf); + env_color = peek_env_map((gint)(env_width*xf+0.5),(gint)(env_height*yf+0.5)); + + color=phong_shade(position, + &mapvals.viewpoint, + &mapvals.planenormal, + p, + &env_color, + &mapvals.lightsource.color, + mapvals.lightsource.type); + } + else + { + normal=vertex_normals[1][(gint)(xf+0.5)]; + + pos_to_float(position->x,position->y,&xf,&yf); + color=peek((gint)(xf+0.5),(gint)(yf+0.5)); + + gck_vector3_sub(&v,&mapvals.viewpoint,position); + gck_vector3_normalize(&v); + + r = compute_reflected_ray(&normal,&v); + + /* Get color in the direction of r */ + /* =============================== */ + + sphere_to_image(&r,&xf,&yf); + env_color = peek_env_map((gint)(env_width*xf+0.5),(gint)(env_height*yf+0.5)); + + color=phong_shade(position, + &mapvals.viewpoint, + &normal, + p, + &env_color, + &mapvals.lightsource.color, + mapvals.lightsource.type); + } + } + + return(color); +} + diff --git a/plug-ins/Lighting/lighting_shade.h b/plug-ins/Lighting/lighting_shade.h new file mode 100644 index 0000000000..b24e3554e4 --- /dev/null +++ b/plug-ins/Lighting/lighting_shade.h @@ -0,0 +1,23 @@ +#ifndef LIGHTINGSHADEH +#define LIGHTINGSHADEH + +#include +#include +#include +#include +#include + +#include "lighting_main.h" +#include "lighting_image.h" + +typedef GckRGB (*get_ray_func) (GckVector3 *); + +extern GckRGB get_ray_color (GckVector3 *position); +extern GckRGB get_ray_color_no_bilinear (GckVector3 *position); +extern GckRGB get_ray_color_ref (GckVector3 *position); +extern GckRGB get_ray_color_no_bilinear_ref (GckVector3 *position); + +extern void precompute_init (gint w,gint h); +extern void precompute_normals (gint x1,gint x2,gint y); + +#endif diff --git a/plug-ins/Lighting/lighting_ui.c b/plug-ins/Lighting/lighting_ui.c new file mode 100644 index 0000000000..b5f67e7caf --- /dev/null +++ b/plug-ins/Lighting/lighting_ui.c @@ -0,0 +1,1102 @@ +/**************************************************************/ +/* Dialog creation and updaters, callbacks and event-handlers */ +/**************************************************************/ + +#include "lighting_ui.h" +#include "lighting_pixmaps.h" + +extern LightingValues mapvals; + +GckApplicationWindow *appwin = NULL; +GtkWidget *color_select_diag = NULL; +GtkNotebook *options_note_book = NULL; +GtkWidget *bump_page = NULL; +GtkWidget *env_page = NULL; +GtkTooltips *tooltips = NULL; +GdkGC *gc = NULL; + +GtkWidget *previewarea,*pointlightwid,*dirlightwid; +GtkWidget *imagewid,*waveswid,*bump_label,*env_label; +GtkWidget *xentry,*yentry,*zentry; + +GckRGB old_light_color; + +gint color_dialog_id = -1; +gint bump_page_pos,env_page_pos; + +guint left_button_pressed = FALSE, light_hit = FALSE; +guint32 blackpixel,whitepixel; + +GckScaleValues sample_scale_vals = {128,3.0,1.0,6.0,1.0,1.0,1.0,GTK_UPDATE_CONTINUOUS,TRUE}; + +gchar *light_labels[] = + { + "Point light", + "Directional light", + "Spot light", + "No light", + NULL + }; + +gchar *maptype_labels[] = + { + "From image", + "Waves", + NULL + }; + +gchar *curvetype_labels[] = + { + "Linear", + "Logarithmic", + "Sinusoidal", + "Spherical", + NULL + }; + +/**********/ +/* Protos */ +/**********/ + +void create_main_dialog (void); +void create_main_notebook (GtkWidget *); + +/**************************/ +/* Callbacks and updaters */ +/**************************/ + +gint preview_events (GtkWidget *area, GdkEvent *event); +void xyzval_update (GtkWidget *widget, GtkEntry *entry); +void entry_update (GtkWidget *widget, GtkEntry *entry); +void scale_update (GtkWidget *widget, GtkScale *scale); +void toggle_update (GtkWidget *button, gpointer data); +void toggleanti_update (GtkWidget *button, gpointer data); +void toggletips_update (GtkWidget *button, gpointer data); +void toggletrans_update (GtkWidget *button, gpointer data); +void togglebump_update (GtkWidget *button, gpointer data); +void toggleenvironment_update (GtkWidget *button, gpointer data); +void togglerefraction_update (GtkWidget *button, gpointer data); + +void lightmenu_callback (GtkWidget *widget, gpointer client_data); +void preview_callback (GtkWidget *widget, gpointer client_data); +void apply_callback (GtkWidget *widget, gpointer client_data); +void exit_callback (GtkWidget *widget, gpointer client_data); +void color_ok_callback (GtkWidget *widget, gpointer client_data); +void color_changed_callback (GtkColorSelection *colorsel, gpointer client_data); +void color_cancel_callback (GtkWidget *widget, gpointer client_data); +void light_color_callback (GtkWidget *widget, gpointer client_data); + +GtkWidget *create_bump_page (void); +GtkWidget *create_environment_page (void); + +gint bumpmap_constrain (gint32 image_id, gint32 drawable_id, gpointer data); +void bumpmap_drawable_callback (gint32 id, gpointer data); + +gint envmap_constrain (gint32 image_id, gint32 drawable_id, gpointer data); +void envmap_drawable_callback (gint32 id, gpointer data); + +/******************/ +/* Implementation */ +/******************/ + +/**********************************************************/ +/* Update entry fields that affect the preview parameters */ +/**********************************************************/ + +void xyzval_update(GtkWidget *widget, GtkEntry *entry) +{ + gdouble *valueptr; + gdouble value; + + valueptr=(gdouble *)gtk_object_get_data(GTK_OBJECT(widget),"ValuePtr"); + value = atof(gtk_entry_get_text(entry)); + + *valueptr=value; +} + +/*********************/ +/* Std. entry update */ +/*********************/ + +void entry_update(GtkWidget *widget, GtkEntry *entry) +{ + gdouble *valueptr; + gdouble value; + + valueptr=(gdouble *)gtk_object_get_data(GTK_OBJECT(widget),"ValuePtr"); + value = atof(gtk_entry_get_text(entry)); + + *valueptr=value; +} + +/*********************/ +/* Std. scale update */ +/*********************/ + +void scale_update(GtkWidget *widget,GtkScale *scale) +{ + gdouble *valueptr; + GtkAdjustment *adjustment; + + valueptr=(gdouble *)gtk_object_get_data(GTK_OBJECT(widget),"ValuePtr"); + adjustment=gtk_range_get_adjustment(GTK_RANGE(scale)); + + *valueptr=(gdouble)adjustment->value; +} + +/**********************/ +/* Std. toggle update */ +/**********************/ + +void toggle_update(GtkWidget *button, gpointer data) +{ + gint *value; + + value=(gint *)gtk_object_get_data(GTK_OBJECT(button),"ValuePtr"); + *value=!(*value); +} + +void togglestretch_update(GtkWidget *button, gpointer data) +{ + gint *value; + + value=(gint *)gtk_object_get_data(GTK_OBJECT(button),"ValuePtr"); + *value=!(*value); +} + +void togglequality_update(GtkWidget *button, gpointer data) +{ + gint *value; + + value=(gint *)gtk_object_get_data(GTK_OBJECT(button),"ValuePtr"); + *value=!(*value); + + draw_preview_image(TRUE); +} + +/**********************************/ +/* Toggle refractive layer update */ +/**********************************/ + +void togglerefraction_update(GtkWidget *button, gpointer data) +{ + gint *value; + + value=(gint *)gtk_object_get_data(GTK_OBJECT(button),"ValuePtr"); + *value=!(*value); +} + +/*****************************/ +/* Toggle bumpmapping update */ +/*****************************/ + +void togglebump_update(GtkWidget *button, gpointer data) +{ + gint *value; + + value=(gint *)gtk_object_get_data(GTK_OBJECT(button),"ValuePtr"); + *value=!(*value); + + if (mapvals.bump_mapped==TRUE) + { + bump_page_pos = g_list_length(options_note_book->children); + + bump_page = create_bump_page(); + bump_label = gtk_label_new("Bump"); + gtk_notebook_append_page(options_note_book,bump_page,bump_label); + } + else + { + gtk_notebook_remove_page(options_note_book,bump_page_pos); + if (bump_page_poschildren); + + env_page = create_environment_page(); + env_label = gtk_label_new("Env"); + + gtk_notebook_append_page(options_note_book,env_page,env_label); + } + else + { + gtk_notebook_remove_page(options_note_book,env_page_pos); + if (env_page_posok_button),"clicked", + (GtkSignalFunc)color_ok_callback,(gpointer)color_select_diag); + gtk_signal_connect(GTK_OBJECT(csd->cancel_button),"clicked", + (GtkSignalFunc)color_cancel_callback,(gpointer)color_select_diag); + gtk_signal_connect(GTK_OBJECT(csd->colorsel),"color_changed", + (GtkSignalFunc)color_changed_callback,(gpointer)color_select_diag); + } +} + +gint bumpmap_constrain(gint32 image_id, gint32 drawable_id, gpointer data) +{ + if (drawable_id == -1) + return(TRUE); + + return (gimp_drawable_gray(drawable_id) && !gimp_drawable_has_alpha(drawable_id) && + gimp_drawable_width(drawable_id)==gimp_drawable_width(mapvals.drawable_id) && + gimp_drawable_height(drawable_id)==gimp_drawable_height(mapvals.drawable_id)); +} + +void bumpmap_drawable_callback(gint32 id, gpointer data) +{ + mapvals.bumpmap_id = id; +} + +gint envmap_constrain(gint32 image_id, gint32 drawable_id, gpointer data) +{ + if (drawable_id == -1) + return(TRUE); + + return (!gimp_drawable_gray(drawable_id) && !gimp_drawable_has_alpha(drawable_id)); +} + +void envmap_drawable_callback(gint32 id, gpointer data) +{ + mapvals.envmap_id = id; + env_width = gimp_drawable_width(mapvals.envmap_id); + env_height = gimp_drawable_height(mapvals.envmap_id); +} + +/******************************/ +/* Preview area event handler */ +/******************************/ + +gint preview_events(GtkWidget *area, GdkEvent *event) +{ + switch (event->type) + { + case GDK_EXPOSE: + + /* Is this the first exposure? */ + /* =========================== */ + + if (!gc) + { + gc=gdk_gc_new(area->window); + draw_preview_image(TRUE); + } + else + draw_preview_image(FALSE); + break; + case GDK_ENTER_NOTIFY: + break; + case GDK_LEAVE_NOTIFY: + break; + case GDK_BUTTON_PRESS: + light_hit=check_light_hit(event->button.x,event->button.y); + left_button_pressed=TRUE; + break; + case GDK_BUTTON_RELEASE: + if (light_hit==TRUE) + draw_preview_image(TRUE); + left_button_pressed=FALSE; + break; + case GDK_MOTION_NOTIFY: + if (left_button_pressed==TRUE && light_hit==TRUE) + update_light(event->motion.x,event->motion.y); + break; + default: + break; + } + + return(FALSE); +} + +/***********************/ +/* Dialog constructors */ +/***********************/ + +GtkWidget *create_options_page(void) +{ + GtkWidget *page,*frame,*toggletrans,*toggleimage; + GtkWidget *toggletips,*togglequality,*vbox,*hbox; + GtkWidget *toggleenvironment,*toggleanti,*togglebump; + GtkWidget *widget1,*widget2,*label; + + /* General options page */ + /* ==================== */ + + page = gck_vbox_new(NULL,FALSE,FALSE,FALSE,0,0,0); + + frame=gck_frame_new("General options",page,GTK_SHADOW_ETCHED_IN,FALSE,FALSE,0,5); + vbox=gck_vbox_new(frame,FALSE,FALSE,FALSE,0,5,5); + + togglebump=gck_checkbutton_new("Use bump mapping",vbox,mapvals.bump_mapped, + (GtkSignalFunc)togglebump_update); + toggleenvironment=gck_checkbutton_new("Use environment mapping",vbox,mapvals.env_mapped, + (GtkSignalFunc)toggleenvironment_update); +/* togglerefraction=gck_checkbutton_new("Use refraction mapping",vbox,mapvals.ref_mapped, + (GtkSignalFunc)togglerefraction_update); */ + toggletrans=gck_checkbutton_new("Transparent background",vbox,mapvals.transparent_background, + (GtkSignalFunc)toggletrans_update); + toggleimage=gck_checkbutton_new("Create new image",vbox,mapvals.create_new_image, + (GtkSignalFunc)toggle_update); + togglequality=gck_checkbutton_new("High preview quality",vbox,mapvals.previewquality, + (GtkSignalFunc)togglequality_update); + toggletips=gck_checkbutton_new("Enable tooltips",vbox,mapvals.tooltips_enabled, + (GtkSignalFunc)toggletips_update); + + gtk_tooltips_set_tip(tooltips,togglebump,"Enable/disable bump-mapping (image depth)",NULL); + gtk_tooltips_set_tip(tooltips,toggleenvironment,"Enable/disable environment mapping (reflection)",NULL); +/* gtk_tooltips_set_tips(tooltips,togglerefraction,"Enable/disable refractive layer"); */ + gtk_tooltips_set_tip(tooltips,toggletrans,"Make destination image transparent where bump height is zero",NULL); + gtk_tooltips_set_tip(tooltips,toggleimage,"Create a new image when applying filter",NULL); + gtk_tooltips_set_tip(tooltips,togglequality,"Enable/disable high quality previews",NULL); + gtk_tooltips_set_tip(tooltips,toggletips,"Enable/disable tooltip messages",NULL); + + gtk_object_set_data(GTK_OBJECT(togglebump),"ValuePtr",(gpointer)&mapvals.bump_mapped); + gtk_object_set_data(GTK_OBJECT(toggleenvironment),"ValuePtr",(gpointer)&mapvals.env_mapped); +/* gtk_object_set_data(GTK_OBJECT(togglerefraction),"ValuePtr",(gpointer)&mapvals.ref_mapped); */ + gtk_object_set_data(GTK_OBJECT(toggletrans),"ValuePtr",(gpointer)&mapvals.transparent_background); + gtk_object_set_data(GTK_OBJECT(toggleimage),"ValuePtr",(gpointer)&mapvals.create_new_image); + gtk_object_set_data(GTK_OBJECT(togglequality),"ValuePtr",(gpointer)&mapvals.previewquality); + gtk_object_set_data(GTK_OBJECT(toggletips),"ValuePtr", (gpointer)&mapvals.tooltips_enabled); + + gtk_widget_show(togglebump); + gtk_widget_show(toggleenvironment); + gtk_widget_show(toggletrans); + gtk_widget_show(toggleimage); + gtk_widget_show(togglequality); + gtk_widget_show(toggletips); + gtk_widget_show(vbox); + gtk_widget_show(frame); + + frame=gck_frame_new("Antialiasing options",page,GTK_SHADOW_ETCHED_IN,FALSE,FALSE,0,5); + vbox=gck_vbox_new(frame,FALSE,FALSE,FALSE,5,5,5); + + toggleanti=gck_checkbutton_new("Enable antialiasing",vbox,mapvals.antialiasing, + (GtkSignalFunc)toggleanti_update); + gtk_object_set_data(GTK_OBJECT(toggleanti),"ValuePtr",(gpointer)&mapvals.antialiasing); + gtk_tooltips_set_tip(tooltips,toggleanti,"Enable/disable jagged edges removal (antialiasing)",NULL); + + hbox=gck_hbox_new(vbox,FALSE,TRUE,TRUE,0,0,0); + + gtk_widget_show(toggleanti); + gtk_widget_show(vbox); + gtk_widget_show(frame); + + vbox=gck_vbox_new(hbox,TRUE,FALSE,TRUE,0,0,0); + frame=gck_frame_new(NULL,vbox,GTK_SHADOW_NONE,TRUE,TRUE,0,0); + label=gck_label_aligned_new("Depth:",frame,GCK_ALIGN_RIGHT,GCK_ALIGN_BOTTOM); + gtk_widget_show(label); + gtk_widget_show(frame); + + frame=gck_frame_new(NULL,vbox,GTK_SHADOW_NONE,TRUE,TRUE,0,0); + label=gck_label_aligned_new("Treshold:",frame,GCK_ALIGN_RIGHT,GCK_ALIGN_CENTERED); + gtk_widget_show(label); + gtk_widget_show(vbox); + gtk_widget_show(frame); + + vbox=gck_vbox_new(hbox,TRUE,FALSE,FALSE,5,0,0); + + widget1=gck_hscale_new(NULL,vbox,&sample_scale_vals,(GtkSignalFunc)scale_update); + widget2=gck_entryfield_new(NULL,vbox,mapvals.pixel_treshold,(GtkSignalFunc)entry_update); + gtk_object_set_data(GTK_OBJECT(widget1),"ValuePtr",(gpointer)&mapvals.max_depth); + gtk_object_set_data(GTK_OBJECT(widget2),"ValuePtr",(gpointer)&mapvals.pixel_treshold); + + gtk_tooltips_set_tip(tooltips,widget1,"Antialiasing quality. Higher is better, but slower",NULL); + gtk_tooltips_set_tip(tooltips,widget2,"Stop when pixel differences are smaller than this value",NULL); + + gtk_widget_show(widget1); + gtk_widget_show(widget2); + gtk_widget_show(vbox); + gtk_widget_show(hbox); + + gtk_widget_show(page); + + return(page); +} + +/******************************/ +/* Create light settings page */ +/******************************/ + +GtkWidget *create_light_page(void) +{ + GtkWidget *page,*frame,*vbox; + GtkWidget *widget1,*widget2,*widget3; + + page=gtk_vbox_new(FALSE,0); + + frame=gck_frame_new("Light settings",page,GTK_SHADOW_ETCHED_IN,FALSE,FALSE,0,5); + vbox=gck_vbox_new(frame,FALSE,TRUE,TRUE,5,0,5); + + gck_auto_show(TRUE); + widget1=gck_option_menu_new("Lightsource type:",vbox,TRUE,TRUE,0, + light_labels,(GtkSignalFunc)lightmenu_callback, NULL); + gtk_option_menu_set_history(GTK_OPTION_MENU(widget1),mapvals.lightsource.type); + gck_auto_show(FALSE); + + widget2=gck_pushbutton_new("Lightsource color",vbox,TRUE,FALSE,0, + (GtkSignalFunc)light_color_callback); + + gtk_widget_show(widget2); + gtk_widget_show(vbox); + gtk_widget_show(frame); + + gtk_tooltips_set_tip(tooltips,widget1,"Type of light source to apply",NULL); + gtk_tooltips_set_tip(tooltips,widget2,"Set light source color (white is default)",NULL); + + pointlightwid=gck_frame_new("Position",page,GTK_SHADOW_ETCHED_IN,FALSE,FALSE,0,5); + vbox=gck_vbox_new(pointlightwid,FALSE,FALSE,FALSE,5,0,5); + + xentry=gck_entryfield_new("X:",vbox,mapvals.lightsource.position.x,(GtkSignalFunc)entry_update); + yentry=gck_entryfield_new("Y:",vbox,mapvals.lightsource.position.y,(GtkSignalFunc)entry_update); + zentry=gck_entryfield_new("Z:",vbox,mapvals.lightsource.position.z,(GtkSignalFunc)entry_update); + + gtk_object_set_data(GTK_OBJECT(xentry),"ValuePtr",(gpointer)&mapvals.lightsource.position.x); + gtk_object_set_data(GTK_OBJECT(yentry),"ValuePtr",(gpointer)&mapvals.lightsource.position.y); + gtk_object_set_data(GTK_OBJECT(zentry),"ValuePtr",(gpointer)&mapvals.lightsource.position.z); + + gtk_tooltips_set_tip(tooltips,xentry,"Light source X position in XYZ space",NULL); + gtk_tooltips_set_tip(tooltips,yentry,"Light source Y position in XYZ space",NULL); + gtk_tooltips_set_tip(tooltips,zentry,"Light source Z position in XYZ space",NULL); + + gtk_widget_show(xentry); + gtk_widget_show(yentry); + gtk_widget_show(zentry); + gtk_widget_show(vbox); + gtk_widget_show(frame); + gtk_widget_show(pointlightwid); + + dirlightwid=gck_frame_new("Direction vector",page,GTK_SHADOW_ETCHED_IN,FALSE,FALSE,0,5); + vbox=gck_vbox_new(dirlightwid,FALSE,FALSE,FALSE,5,0,5); + + widget1=gck_entryfield_new("X:",vbox,mapvals.lightsource.direction.x,(GtkSignalFunc)entry_update); + widget2=gck_entryfield_new("Y:",vbox,mapvals.lightsource.direction.y,(GtkSignalFunc)entry_update); + widget3=gck_entryfield_new("Z:",vbox,mapvals.lightsource.direction.z,(GtkSignalFunc)entry_update); + + gtk_tooltips_set_tip(tooltips,widget1,"Light source X direction in XYZ space",NULL); + gtk_tooltips_set_tip(tooltips,widget2,"Light source Y direction in XYZ space",NULL); + gtk_tooltips_set_tip(tooltips,widget3,"Light source Z direction in XYZ space",NULL); + + gtk_object_set_data(GTK_OBJECT(widget1),"ValuePtr",(gpointer)&mapvals.lightsource.direction.x); + gtk_object_set_data(GTK_OBJECT(widget2),"ValuePtr",(gpointer)&mapvals.lightsource.direction.y); + gtk_object_set_data(GTK_OBJECT(widget3),"ValuePtr",(gpointer)&mapvals.lightsource.direction.z); + + gtk_widget_show(widget1); + gtk_widget_show(widget2); + gtk_widget_show(widget3); + gtk_widget_show(vbox); + + gtk_widget_show(page); + + return page; +} + +/*********************************/ +/* Create material settings page */ +/*********************************/ + +GtkWidget *create_material_page(void) +{ + GtkWidget *page,*frame,*table; + GtkWidget *label1,*label2,*label3; + GtkWidget *widget1,*widget2,*widget3; + GdkPixmap *image; + GdkBitmap *mask; + GtkStyle *style; + GtkWidget *pixmap; + + page=gtk_vbox_new(FALSE,0); + + frame=gck_frame_new("Intensity levels",page,GTK_SHADOW_ETCHED_IN,FALSE,FALSE,0,5); + + table=gtk_table_new(2,4,FALSE); + gtk_container_add(GTK_CONTAINER(frame),table); + + label1=gck_label_aligned_new("Ambient:",NULL,GCK_ALIGN_RIGHT,GCK_ALIGN_CENTERED); + label2=gck_label_aligned_new("Diffuse:",NULL,GCK_ALIGN_RIGHT,GCK_ALIGN_CENTERED); + + gtk_table_attach(GTK_TABLE(table),label1,0,1,0,1, 0,0,0,0); + gtk_table_attach(GTK_TABLE(table),label2,0,1,1,2, 0,0,0,0); + + widget1=gck_entryfield_new(NULL,NULL,mapvals.material.ambient_int,(GtkSignalFunc)entry_update); + widget2=gck_entryfield_new(NULL,NULL,mapvals.material.diffuse_int,(GtkSignalFunc)entry_update); + + gtk_table_attach(GTK_TABLE(table),widget1,2,3,0,1, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); + gtk_table_attach(GTK_TABLE(table),widget2,2,3,1,2, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); + + style=gtk_widget_get_style(table); + + image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],amb1_xpm); + pixmap=gtk_pixmap_new(image,mask); + gtk_table_attach(GTK_TABLE(table),pixmap,1,2,0,1, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); + gtk_widget_show(pixmap); + + image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],amb2_xpm); + pixmap=gtk_pixmap_new(image,mask); + gtk_table_attach(GTK_TABLE(table),pixmap,3,4,0,1, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); + gtk_widget_show(pixmap); + + image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],diffint1_xpm); + pixmap=gtk_pixmap_new(image,mask); + gtk_table_attach(GTK_TABLE(table),pixmap,1,2,1,2, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); + gtk_widget_show(pixmap); + + image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],diffint2_xpm); + pixmap=gtk_pixmap_new(image,mask); + gtk_table_attach(GTK_TABLE(table),pixmap,3,4,1,2, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); + gtk_widget_show(pixmap); + + gtk_widget_show(label1); + gtk_widget_show(label2); + gtk_widget_show(widget1); + gtk_widget_show(widget2); + gtk_widget_show(table); + gtk_widget_show(frame); + + gtk_tooltips_set_tip(tooltips,widget1,"Amount of original color to show where no direct light falls",NULL); + gtk_tooltips_set_tip(tooltips,widget2,"Intensity of original color when lit by a light source",NULL); + + gtk_object_set_data(GTK_OBJECT(widget1),"ValuePtr",(gpointer)&mapvals.material.ambient_int); + gtk_object_set_data(GTK_OBJECT(widget2),"ValuePtr",(gpointer)&mapvals.material.diffuse_int); + + frame=gck_frame_new("Reflectivity",page,GTK_SHADOW_ETCHED_IN,FALSE,FALSE,0,5); + + table=gtk_table_new(3,4,FALSE); + gtk_container_add(GTK_CONTAINER(frame),table); + + label1=gck_label_aligned_new("Diffuse:",NULL,GCK_ALIGN_RIGHT,GCK_ALIGN_CENTERED); + label2=gck_label_aligned_new("Specular:",NULL,GCK_ALIGN_RIGHT,GCK_ALIGN_CENTERED); + label3=gck_label_aligned_new("Hightlight:",NULL,GCK_ALIGN_RIGHT,GCK_ALIGN_CENTERED); + + gtk_table_attach(GTK_TABLE(table),label1,0,1,0,1, 0,0,0,0); + gtk_table_attach(GTK_TABLE(table),label2,0,1,1,2, 0,0,0,0); + gtk_table_attach(GTK_TABLE(table),label3,0,1,2,3, 0,0,0,0); + + widget1=gck_entryfield_new(NULL,NULL,mapvals.material.diffuse_ref,(GtkSignalFunc)entry_update); + widget2=gck_entryfield_new(NULL,NULL,mapvals.material.specular_ref,(GtkSignalFunc)entry_update); + widget3=gck_entryfield_new(NULL,NULL,mapvals.material.highlight,(GtkSignalFunc)entry_update); + + gtk_table_attach(GTK_TABLE(table),widget1,2,3,0,1, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); + gtk_table_attach(GTK_TABLE(table),widget2,2,3,1,2, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); + gtk_table_attach(GTK_TABLE(table),widget3,2,3,2,3, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); + + gtk_tooltips_set_tip(tooltips,widget1,"Higher values makes the object reflect more light (appear lighter)",NULL); + gtk_tooltips_set_tip(tooltips,widget2,"Controls how intense the highlights will be",NULL); + gtk_tooltips_set_tip(tooltips,widget3,"Higher values makes the highlights more focused",NULL); + + gtk_object_set_data(GTK_OBJECT(widget1),"ValuePtr",(gpointer)&mapvals.material.diffuse_ref); + gtk_object_set_data(GTK_OBJECT(widget2),"ValuePtr",(gpointer)&mapvals.material.specular_ref); + gtk_object_set_data(GTK_OBJECT(widget3),"ValuePtr",(gpointer)&mapvals.material.highlight); + + style=gtk_widget_get_style(table); + + image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],diffref1_xpm); + pixmap=gtk_pixmap_new(image,mask); + gtk_table_attach(GTK_TABLE(table),pixmap,1,2,0,1, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); + gtk_widget_show(pixmap); + + image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],diffref2_xpm); + pixmap=gtk_pixmap_new(image,mask); + gtk_table_attach(GTK_TABLE(table),pixmap,3,4,0,1, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); + gtk_widget_show(pixmap); + + image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],specref1_xpm); + pixmap=gtk_pixmap_new(image,mask); + gtk_table_attach(GTK_TABLE(table),pixmap,1,2,1,2, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); + gtk_widget_show(pixmap); + + image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],specref2_xpm); + pixmap=gtk_pixmap_new(image,mask); + gtk_table_attach(GTK_TABLE(table),pixmap,3,4,1,2, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); + gtk_widget_show(pixmap); + + image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],high1_xpm); + pixmap=gtk_pixmap_new(image,mask); + gtk_table_attach(GTK_TABLE(table),pixmap,1,2,2,3, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); + gtk_widget_show(pixmap); + + image=gdk_pixmap_create_from_xpm_d(appwin->widget->window,&mask,&style->bg[GTK_STATE_NORMAL],high2_xpm); + pixmap=gtk_pixmap_new(image,mask); + gtk_table_attach(GTK_TABLE(table),pixmap,3,4,2,3, GTK_EXPAND|GTK_FILL,GTK_EXPAND|GTK_FILL, 0,0); + gtk_widget_show(pixmap); + + gtk_widget_show(label1); + gtk_widget_show(label2); + gtk_widget_show(label3); + gtk_widget_show(widget1); + gtk_widget_show(widget2); + gtk_widget_show(widget3); + gtk_widget_show(table); + gtk_widget_show(frame); + + gtk_widget_show(page); + + return page; +} + +GtkWidget *create_bump_page(void) +{ + GtkWidget *page,*widget1,*widget2,*imagewid; + GtkWidget *frame,*vbox,*label; + + /* Bump mapping page */ + /* ================= */ + + page=gtk_vbox_new(FALSE,0); + + frame=gck_frame_new("Bumpmap settings",page,GTK_SHADOW_ETCHED_IN,FALSE,FALSE,0,5); + vbox=gck_vbox_new(frame,FALSE,TRUE,TRUE,5,0,5); + + imagewid=gck_vbox_new(vbox,FALSE,TRUE,TRUE,5,0,5); + + widget1=gck_hbox_new(imagewid,FALSE,TRUE,TRUE,5,0,3); + label = gck_label_new("Bumpmap image:",widget1); + + gtk_widget_show(label); + gtk_widget_show(widget1); + + widget2=gtk_option_menu_new(); + gtk_box_pack_end(GTK_BOX(widget1),widget2,TRUE,TRUE,0); + gtk_widget_show(widget2); + + widget1 = gimp_drawable_menu_new (bumpmap_constrain, bumpmap_drawable_callback, + NULL, mapvals.bumpmap_id); + gtk_option_menu_set_menu(GTK_OPTION_MENU(widget2), widget1); + + gck_auto_show(TRUE); + widget1=gck_option_menu_new("Curve:",imagewid,TRUE,TRUE,0,curvetype_labels, + (GtkSignalFunc)mapmenu2_callback,NULL); + gtk_option_menu_set_history(GTK_OPTION_MENU(widget1),mapvals.bumpmaptype); + gck_auto_show(FALSE); + + widget1=gck_entryfield_new("Minimum height:",imagewid,mapvals.bumpmin, + (GtkSignalFunc)entry_update); + widget2=gck_entryfield_new("Maximum height:",imagewid,mapvals.bumpmax, + (GtkSignalFunc)entry_update); + + gtk_object_set_data(GTK_OBJECT(widget1),"ValuePtr",(gpointer)&mapvals.bumpmin); + gtk_object_set_data(GTK_OBJECT(widget2),"ValuePtr",(gpointer)&mapvals.bumpmax); + gtk_widget_show(widget1); + gtk_widget_show(widget2); + + widget1=gck_checkbutton_new("Autostretch to fit value range",imagewid,mapvals.bumpstretch, + (GtkSignalFunc)togglestretch_update); + gtk_object_set_data(GTK_OBJECT(widget1),"ValuePtr",(gpointer)&mapvals.bumpstretch); + gtk_widget_show(widget1); + + gtk_widget_show(imagewid); + gtk_widget_show(vbox); + gtk_widget_show(frame); + gtk_widget_show(page); + + return(page); +} + +GtkWidget *create_environment_page(void) +{ + GtkWidget *page,*frame,*vbox,*imagewid; + GtkWidget *widget1,*widget2; + + /* Environment mapping page */ + /* ======================== */ + + page=gck_vbox_new(NULL,FALSE,FALSE,FALSE,0,0,0); + + frame=gck_frame_new("Environment settings",page, + GTK_SHADOW_ETCHED_IN,FALSE,FALSE,0,5); + vbox=gck_vbox_new(frame,FALSE,TRUE,TRUE,5,0,5); + + imagewid=gck_vbox_new(vbox,FALSE,TRUE,TRUE,5,0,5); + + widget1=gck_hbox_new(imagewid,FALSE,TRUE,TRUE,5,0,3); + gck_label_new("Environment image:",widget1); + + widget2=gtk_option_menu_new(); + gtk_box_pack_end(GTK_BOX(widget1),widget2,TRUE,TRUE,0); + + gtk_widget_show(widget1); + + widget1 = gimp_drawable_menu_new (envmap_constrain, envmap_drawable_callback, + NULL, mapvals.envmap_id); + gtk_option_menu_set_menu(GTK_OPTION_MENU(widget2), widget1); + + gtk_widget_show(widget2); + gtk_widget_show(imagewid); + gtk_widget_show(vbox); + gtk_widget_show(frame); + gtk_widget_show(page); + + return(page); +} + +/****************************/ +/* Create notbook and pages */ +/****************************/ + +void create_main_notebook(GtkWidget *container) +{ + GtkWidget *page,*label; + + gck_auto_show(FALSE); + + options_note_book=GTK_NOTEBOOK(gtk_notebook_new()); + gtk_container_add(GTK_CONTAINER(container),GTK_WIDGET(options_note_book)); + + page = create_options_page(); + label=gtk_label_new("Options"); + gtk_widget_show(label); + + gtk_notebook_append_page(options_note_book,page,label); + + page = create_light_page(); + label=gtk_label_new("Light"); + gtk_widget_show(label); + + gtk_notebook_append_page(options_note_book,page,label); + + page = create_material_page(); + label=gtk_label_new("Material"); + gtk_widget_show(label); + + gtk_notebook_append_page(options_note_book,page,label); + + if (mapvals.bump_mapped==TRUE) + { + bump_page = create_bump_page(); + bump_label=gtk_label_new("Bump"); + gtk_widget_show(bump_label); + bump_page_pos = g_list_length(options_note_book->children); + gtk_notebook_append_page(options_note_book,bump_page,bump_label); + } + + if (mapvals.env_mapped==TRUE) + { + env_page = create_environment_page(); + env_label=gtk_label_new("Env"); + gtk_widget_show(env_label); + env_page_pos = g_list_length(options_note_book->children); + gtk_notebook_append_page(options_note_book,env_page,env_label); + } + + gtk_widget_show(GTK_WIDGET(options_note_book)); + + gck_auto_show(TRUE); +} + +/*****************************************************/ +/* Create and show main dialog. Uses the plugin_ui.c */ +/* routines when possible, gtk itself when not. */ +/*****************************************************/ + +void create_main_dialog(void) +{ + GtkWidget *main_vbox,*main_workbox,*actionbox,*workbox1,*workbox1b,*workbox2; + GtkWidget *frame,*applybutton,*cancelbutton,*helpbutton,*hbox,*wid; + + appwin = gck_application_window_new("Lighting effects"); + gtk_widget_realize(appwin->widget); + + tooltips=gtk_tooltips_new(); + + /* Main manager widget */ + /* =================== */ + + main_vbox=gck_vbox_new(appwin->widget,FALSE,FALSE,FALSE,8,0,0); + + /* Work area manager widget */ + /* ======================== */ + + main_workbox=gck_hbox_new(main_vbox,FALSE,FALSE,FALSE,5,0,5); + + /* Action area manager widget */ + /* ========================== */ + + gck_hseparator_new(main_vbox); + actionbox=gck_hbox_new(main_vbox,FALSE,FALSE,FALSE,5,0,5); + + /* Add Ok, Cancel and Help buttons to the action area */ + /* ================================================== */ + + applybutton=gck_pushbutton_new("Apply",actionbox,FALSE,FALSE,5,(GtkSignalFunc)apply_callback); + cancelbutton=gck_pushbutton_new("Cancel",actionbox,FALSE,FALSE,5,(GtkSignalFunc)exit_callback); + helpbutton=gck_pushbutton_new("Help",actionbox,FALSE,FALSE,5,NULL); + + GTK_WIDGET_SET_FLAGS (applybutton, GTK_CAN_DEFAULT); + GTK_WIDGET_SET_FLAGS (cancelbutton, GTK_CAN_DEFAULT); + GTK_WIDGET_SET_FLAGS (helpbutton, GTK_CAN_DEFAULT); + + gtk_widget_grab_default (applybutton); + gtk_widget_set_sensitive(helpbutton,FALSE); + + gtk_tooltips_set_tip(tooltips,applybutton,"Apply filter with current settings",NULL); + gtk_tooltips_set_tip(tooltips,cancelbutton,"Close filter without doing anything",NULL); + + /* Split the workarea in two */ + /* ========================= */ + + frame=gck_frame_new(NULL,main_workbox,GTK_SHADOW_ETCHED_IN,TRUE,TRUE,0,0); + workbox1=gck_vbox_new(frame,FALSE,TRUE,TRUE,5,0,5); + workbox2=gck_vbox_new(main_workbox,FALSE,FALSE,FALSE,0,0,0); + + /* Add preview widget and various buttons to the first part */ + /* ======================================================== */ + + frame=gck_frame_new(NULL,workbox1,GTK_SHADOW_IN,FALSE,FALSE,0,0); + previewarea = gck_drawing_area_new(frame, PREVIEW_WIDTH, PREVIEW_HEIGHT, + GDK_EXPOSURE_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_PRESS_MASK | + GDK_BUTTON_RELEASE_MASK, (GtkSignalFunc)preview_events); + + workbox1b=gck_vbox_new(workbox1,FALSE,FALSE,FALSE,0,0,0); + + hbox=gck_hbox_new(workbox1b,FALSE,FALSE,FALSE,5,0,0); + wid=gck_pushbutton_new(" Preview! ",hbox,FALSE,FALSE,0,(GtkSignalFunc)preview_callback); + gtk_tooltips_set_tip(tooltips,wid,"Recompute preview image",NULL); + hbox=gck_hbox_new(hbox,TRUE,FALSE,FALSE,0,0,0); + wid=gck_pushbutton_new(" + ",hbox,FALSE,FALSE,0,(GtkSignalFunc)zoomin_callback); + gtk_tooltips_set_tip(tooltips,wid,"Zoom in (make image bigger)",NULL); + wid=gck_pushbutton_new(" - ",hbox,FALSE,FALSE,0,(GtkSignalFunc)zoomout_callback); + gtk_tooltips_set_tip(tooltips,wid,"Zoom out (make image smaller)",NULL); + + create_main_notebook(workbox2); + + /* Now lets check out the result of this mess */ + /*=========================================== */ + + gtk_widget_show(appwin->widget); + + gck_cursor_set(previewarea->window,GDK_HAND2); + gtk_tooltips_set_colors(tooltips, + gck_rgb_to_gdkcolor(appwin->visinfo,255,255,220), + gck_rgb_to_gdkcolor(appwin->visinfo,0,0,0)); + + if (mapvals.tooltips_enabled==FALSE) + gtk_tooltips_disable(tooltips); +} diff --git a/plug-ins/Lighting/lighting_ui.h b/plug-ins/Lighting/lighting_ui.h new file mode 100644 index 0000000000..d5b8083e8c --- /dev/null +++ b/plug-ins/Lighting/lighting_ui.h @@ -0,0 +1,30 @@ +#ifndef LIGHTINGUIH +#define LIGHTINGUIH + +#include +#include +#include +#include +#include +#include +#include + +#include "lighting_main.h" +#include "lighting_image.h" +#include "lighting_apply.h" +#include "lighting_preview.h" + +/* Externally visible variables */ +/* ============================ */ + +extern GckApplicationWindow *appwin; + +extern GdkGC *gc; +extern GtkWidget *previewarea; + +/* Externally visible functions */ +/* ============================ */ + +extern void create_main_dialog (void); + +#endif diff --git a/plug-ins/Lighting/specref1.xpm b/plug-ins/Lighting/specref1.xpm new file mode 100644 index 0000000000..fea662e764 --- /dev/null +++ b/plug-ins/Lighting/specref1.xpm @@ -0,0 +1,75 @@ +/* XPM */ +char * specref1_xpm[] = { +"32 32 40 1", +" c None", +". c #A699A699A699", +"X c #A699A289A699", +"o c #965896589658", +"O c #BEFBBEFBBEFB", +"+ c #CF3CCB2BCF3C", +"@ c #C71BC71BC71B", +"# c #C71BC30BC71B", +"$ c #B6DAB6DAB6DA", +"% c #8E388E388E38", +"& c #69A669A669A6", +"* c #D75CD75CD75C", +"= c #DF7DDB6CDF7D", +"- c #CF3CCF3CCF3C", +"; c #965892489658", +": c #DF7DDF7DDF7D", +"> c #E79DE38DE79D", +", c #D75CD34CD75C", +"< c #AEBAAEBAAEBA", +"1 c #9E799E799E79", +"2 c #861786178617", +"3 c #596559655965", +"4 c #E79DE79DE79D", +"5 c #B6DAB2CAB6DA", +"6 c #71C671C671C6", +"7 c #492449244924", +"8 c #71C675D671C6", +"9 c #514455555144", +"0 c #BEFBBAEABEFB", +"q c #AEBAAAAAAEBA", +"w c #9E799A699E79", +"e c #8E388A288E38", +"r c #49244D344924", +"t c #861782078617", +"y c #69A66DB669A6", +"u c #79E779E779E7", +"i c #618565956185", +"p c #514451445144", +"a c #618561856185", +"s c #410345144103", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" .Xo ", +" .O+@#$.%& ", +" $*==*-#$.;& ", +" $=:>:=,+O<123 ", +" .*:>4>=*+O5X%67 ", +" O=>4>>=,+O5X%89 ", +" +=:>>:*-@0<1%83 ", +" .@*===*,+#$qwe83r ", +" X#-,*,-+#0 c #E79DE38DE79D", +", c #D75CD34CD75C", +"< c #AEBAAEBAAEBA", +"1 c #9E799E799E79", +"2 c #861786178617", +"3 c #596559655965", +"4 c #E79DE79DE79D", +"5 c #EFBEEFBEEFBE", +"6 c #B6DAB2CAB6DA", +"7 c #71C671C671C6", +"8 c #492449244924", +"9 c #FFFFFBEEFFFF", +"0 c #FFFFFFFFFFFF", +"q c #71C675D671C6", +"w c #514455555144", +"e c #EFBEEBADEFBE", +"r c #BEFBBAEABEFB", +"t c #AEBAAAAAAEBA", +"y c #9E799A699E79", +"u c #8E388A288E38", +"i c #49244D344924", +"p c #861782078617", +"a c #69A66DB669A6", +"s c #79E779E779E7", +"d c #618565956185", +"f c #514451445144", +"g c #618561856185", +"h c #410345144103", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" .Xo ", +" .O+@#$.%& ", +" $*==*-#$.;& ", +" $=:>:=,+O<123 ", +" .*:4454*+O6X%78 ", +" O=>4900>+O6X%qw ", +" +=:5000e+r<1%q3 ", +" .@*=4009=#$tyuq3i ", +" X#-,*>e=@r #include #include -#include #include #include #include @@ -155,7 +147,7 @@ */ #define PLUG_IN_NAME "plug_in_despeckle" -#define PLUG_IN_VERSION "1.3.1 - 27 April 1998" +#define PLUG_IN_VERSION "1.3.2 - 17 May 1998" #define PREVIEW_SIZE 128 #define SCALE_WIDTH 64 #define ENTRY_WIDTH 64 @@ -707,9 +699,6 @@ despeckle_dialog(void) gtk_rc_parse(gimp_gtkrc()); gdk_set_use_xshm(gimp_use_xshm()); - /* signal(SIGBUS, SIG_DFL); - signal(SIGSEGV, SIG_DFL); */ - gtk_preview_set_gamma(gimp_gamma()); gtk_preview_set_install_cmap(gimp_install_cmap()); color_cube = gimp_color_cube(); diff --git a/plug-ins/common/png.c b/plug-ins/common/png.c index e598b2f463..99480d96d2 100644 --- a/plug-ins/common/png.c +++ b/plug-ins/common/png.c @@ -37,55 +37,18 @@ * Revision History: * * $Log$ - * Revision 1.7 1998/05/31 06:49:16 yosh - * * app/interface.c: plug mem leak in message_box + * Revision 1.8 1998/06/06 23:22:17 yosh + * * adding Lighting plugin * - * * plug-ins/mail/mail.c: use g_message - * - * * plug-ins/script-fu/scripts/carve-it.scm: fix for gimp-layer-new params from - * Kevin Cozens - * - * * plug-ins/CEL/CEL.c - * * plug-ins/pcx/pcx.c - * * plug-ins/tiff/tiff.c: updates from author - * - * * plug-ins/png/png.c: correct copyright - * - * * plug-ins/print/print.h: use correct version + * * updated despeckle, png, sgi, and sharpen * * -Yosh * - * Revision 1.6 1998/04/13 05:43:08 yosh - * Have fun recompiling gimp everyone. It's the great FSF address change! + * Revision 1.14 1998/05/17 15:54:15 mike + * Added gtk_rc_parse(), removed unnecessary variables. * - * -Yosh - * - * Revision 1.5 1998/03/30 19:05:47 adrian - * updated png.c so non-interactive mode works now - * -adrian - * - * Revision 1.4 1998/03/26 02:08:23 yosh - * * applied gimp-quinet-980122-0 and tweaked the tests a bit, this makes the - * optional library tests in configure. - * - * * applied gimp-jbuhler-980321-0, fixes more warnings in plug-ins - * - * -Yosh - * - * Revision 1.3 1998/03/16 06:33:54 yosh - * configure saves CFLAGS properly - * all plugins should parse gtkrc now - * - * -Yosh - * - * Revision 1.2 1998/01/05 09:30:23 yosh - * Check for div-by-zero in by_color_select.c when threshold is 0 - * The text tool handles the no fonts case better - * Minor bug in tile saving squashed - * updated png plugin - * added flarefx plugin - * - * -Yosh + * Revision 1.13 1998/04/02 16:00:13 mike + * Fixed bug in run() - was looking for 6 arguments and not 7 as advertised. * * Revision 1.12 1998/01/04 14:10:09 mike * Fixed paletted image saving bug - wasn't correctly storing the number of @@ -150,7 +113,7 @@ * Constants... */ -#define PLUG_IN_VERSION "1.1.5 - 4 January 1998" +#define PLUG_IN_VERSION "1.1.6 - 17 May 1998" #define SCALE_WIDTH 125 diff --git a/plug-ins/common/sharpen.c b/plug-ins/common/sharpen.c index 63c33ef819..0785cc4c40 100644 --- a/plug-ins/common/sharpen.c +++ b/plug-ins/common/sharpen.c @@ -44,23 +44,17 @@ * Revision History: * * $Log$ - * Revision 1.6 1998/04/28 03:50:19 yosh - * * plug-ins/animationplay/animationplay.c - * * plug-ins/CEL/CEL.c - * * plug-ins/psd/psd.c - * * plug-ins/xd/xd.c: applied gimp-joke-980427-0, warning cleanups + * Revision 1.7 1998/06/06 23:22:22 yosh + * * adding Lighting plugin * - * * app/temp_buf.c: applied gimp-entity-980427-0, temp_buf swap speedups and - * more robust tempfile handling + * * updated despeckle, png, sgi, and sharpen * * -Yosh * - * Revision 1.5 1998/04/27 22:01:01 neo - * Updated sharpen and despeckle. Wow, sharpen is balzingly fast now, while - * despeckle is still sort of lame... - * - * - * --Sven + * Revision 1.14 1998/05/17 16:01:33 mike + * Removed signal handler stuff used for debugging. + * Added gtk_rc_parse(). + * Removed extra variables. * * Revision 1.13 1998/04/27 15:55:38 mike * Sharpen would shift the image down one pixel; was using the wrong "source" @@ -133,7 +127,7 @@ */ #define PLUG_IN_NAME "plug_in_sharpen" -#define PLUG_IN_VERSION "1.3 - 27 April 1998" +#define PLUG_IN_VERSION "1.4.2 - 3 June 1998" #define PREVIEW_SIZE 128 #define SCALE_WIDTH 64 #define ENTRY_WIDTH 64 @@ -342,8 +336,8 @@ run(char *name, /* I - Name of filter program. */ default : status = STATUS_CALLING_ERROR; - break; - } + break;; + }; /* * Sharpen the image... @@ -383,7 +377,7 @@ run(char *name, /* I - Name of filter program. */ } else status = STATUS_EXECUTION_ERROR; - } + }; /* * Reset the current run status... @@ -414,7 +408,7 @@ compute_luts(void) { pos_lut[i] = 100 * i / fact; neg_lut[i] = sharpen_percent * i / 8 / fact; - } + }; } @@ -463,7 +457,7 @@ sharpen(void) { src_rows[row] = g_malloc(width * sizeof(guchar)); neg_rows[row] = g_malloc(width * sizeof(guchar)); - } + }; dst_row = g_malloc(width * sizeof(guchar)); @@ -498,7 +492,7 @@ sharpen(void) case 4 : filter = rgba_filter; break; - } + }; /* * Sharpen... @@ -539,7 +533,7 @@ sharpen(void) */ count --; - } + }; /* * Now sharpen pixels and save the results... @@ -558,10 +552,17 @@ sharpen(void) gimp_pixel_rgn_set_row(&dst_rgn, dst_row, sel_x1, y, sel_width); } + else if (count == 2) + { + if (y == sel_y1) + gimp_pixel_rgn_set_row(&dst_rgn, src_rows[0], sel_x1, y, sel_width); + else + gimp_pixel_rgn_set_row(&dst_rgn, src_rows[2], sel_x1, y, sel_width); + }; if ((y & 15) == 0) gimp_progress_update((double)(y - sel_y1) / (double)sel_height); - } + }; /* * OK, we're done. Free all memory used... @@ -571,7 +572,7 @@ sharpen(void) { g_free(src_rows[row]); g_free(neg_rows[row]); - } + }; g_free(dst_row); @@ -622,9 +623,6 @@ sharpen_dialog(void) gtk_widget_set_default_visual(gtk_preview_get_visual()); gtk_widget_set_default_colormap(gtk_preview_get_cmap()); - signal(SIGBUS, SIG_DFL); - signal(SIGSEGV, SIG_DFL); - /* * Dialog window... */ @@ -852,7 +850,7 @@ preview_update(void) case 4 : filter = rgba_filter; break; - } + }; /* * Sharpen... @@ -907,7 +905,7 @@ preview_update(void) else image_ptr[0] = image_ptr[1] = image_ptr[2] = check + ((dst_ptr[0] - check) * dst_ptr[1]) / 255; - } + }; break; case 3 : @@ -942,10 +940,10 @@ preview_update(void) image_ptr[0] = check + ((dst_ptr[0] - check) * dst_ptr[3]) / 255; image_ptr[1] = check + ((dst_ptr[1] - check) * dst_ptr[3]) / 255; image_ptr[2] = check + ((dst_ptr[2] - check) * dst_ptr[3]) / 255; - } - } + }; + }; break; - } + }; /* * Draw the preview image on the screen... @@ -1065,7 +1063,7 @@ dialog_iscale_update(GtkAdjustment *adjustment, /* I - New value */ compute_luts(); preview_update(); - } + }; } @@ -1098,8 +1096,8 @@ dialog_ientry_update(GtkWidget *widget, /* I - Entry widget */ compute_luts(); preview_update(); - } - } + }; + }; } @@ -1174,7 +1172,7 @@ gray_filter(int width, /* I - Width of line in pixels */ neg1 ++; neg2 ++; width --; - } + }; *dst++ = *src++; } @@ -1216,7 +1214,7 @@ graya_filter(int width, /* I - Width of line in pixels */ neg1 += 2; neg2 += 2; width --; - } + }; *dst++ = *src++; *dst++ = *src++; @@ -1279,7 +1277,7 @@ rgb_filter(int width, /* I - Width of line in pixels */ neg1 += 3; neg2 += 3; width --; - } + }; *dst++ = *src++; *dst++ = *src++; @@ -1346,7 +1344,7 @@ rgba_filter(int width, /* I - Width of line in pixels */ neg1 += 4; neg2 += 4; width --; - } + }; *dst++ = *src++; *dst++ = *src++; diff --git a/plug-ins/despeckle/despeckle.c b/plug-ins/despeckle/despeckle.c index e8546d3ebc..410535a78e 100644 --- a/plug-ins/despeckle/despeckle.c +++ b/plug-ins/despeckle/despeckle.c @@ -43,23 +43,16 @@ * Revision History: * * $Log$ - * Revision 1.12 1998/04/28 03:50:16 yosh - * * plug-ins/animationplay/animationplay.c - * * plug-ins/CEL/CEL.c - * * plug-ins/psd/psd.c - * * plug-ins/xd/xd.c: applied gimp-joke-980427-0, warning cleanups + * Revision 1.13 1998/06/06 23:22:16 yosh + * * adding Lighting plugin * - * * app/temp_buf.c: applied gimp-entity-980427-0, temp_buf swap speedups and - * more robust tempfile handling + * * updated despeckle, png, sgi, and sharpen * * -Yosh * - * Revision 1.11 1998/04/27 22:00:59 neo - * Updated sharpen and despeckle. Wow, sharpen is balzingly fast now, while - * despeckle is still sort of lame... - * - * - * --Sven + * Revision 1.21 1998/05/17 15:57:33 mike + * Removed extra variables. + * Removed signal handlers (used for debugging) * * Revision 1.20 1998/04/27 15:59:17 mike * Fixed RGB preview problem... @@ -144,7 +137,6 @@ #include #include #include -#include #include #include #include @@ -155,7 +147,7 @@ */ #define PLUG_IN_NAME "plug_in_despeckle" -#define PLUG_IN_VERSION "1.3.1 - 27 April 1998" +#define PLUG_IN_VERSION "1.3.2 - 17 May 1998" #define PREVIEW_SIZE 128 #define SCALE_WIDTH 64 #define ENTRY_WIDTH 64 @@ -707,9 +699,6 @@ despeckle_dialog(void) gtk_rc_parse(gimp_gtkrc()); gdk_set_use_xshm(gimp_use_xshm()); - /* signal(SIGBUS, SIG_DFL); - signal(SIGSEGV, SIG_DFL); */ - gtk_preview_set_gamma(gimp_gamma()); gtk_preview_set_install_cmap(gimp_install_cmap()); color_cube = gimp_color_cube(); diff --git a/plug-ins/png/png.c b/plug-ins/png/png.c index e598b2f463..99480d96d2 100644 --- a/plug-ins/png/png.c +++ b/plug-ins/png/png.c @@ -37,55 +37,18 @@ * Revision History: * * $Log$ - * Revision 1.7 1998/05/31 06:49:16 yosh - * * app/interface.c: plug mem leak in message_box + * Revision 1.8 1998/06/06 23:22:17 yosh + * * adding Lighting plugin * - * * plug-ins/mail/mail.c: use g_message - * - * * plug-ins/script-fu/scripts/carve-it.scm: fix for gimp-layer-new params from - * Kevin Cozens - * - * * plug-ins/CEL/CEL.c - * * plug-ins/pcx/pcx.c - * * plug-ins/tiff/tiff.c: updates from author - * - * * plug-ins/png/png.c: correct copyright - * - * * plug-ins/print/print.h: use correct version + * * updated despeckle, png, sgi, and sharpen * * -Yosh * - * Revision 1.6 1998/04/13 05:43:08 yosh - * Have fun recompiling gimp everyone. It's the great FSF address change! + * Revision 1.14 1998/05/17 15:54:15 mike + * Added gtk_rc_parse(), removed unnecessary variables. * - * -Yosh - * - * Revision 1.5 1998/03/30 19:05:47 adrian - * updated png.c so non-interactive mode works now - * -adrian - * - * Revision 1.4 1998/03/26 02:08:23 yosh - * * applied gimp-quinet-980122-0 and tweaked the tests a bit, this makes the - * optional library tests in configure. - * - * * applied gimp-jbuhler-980321-0, fixes more warnings in plug-ins - * - * -Yosh - * - * Revision 1.3 1998/03/16 06:33:54 yosh - * configure saves CFLAGS properly - * all plugins should parse gtkrc now - * - * -Yosh - * - * Revision 1.2 1998/01/05 09:30:23 yosh - * Check for div-by-zero in by_color_select.c when threshold is 0 - * The text tool handles the no fonts case better - * Minor bug in tile saving squashed - * updated png plugin - * added flarefx plugin - * - * -Yosh + * Revision 1.13 1998/04/02 16:00:13 mike + * Fixed bug in run() - was looking for 6 arguments and not 7 as advertised. * * Revision 1.12 1998/01/04 14:10:09 mike * Fixed paletted image saving bug - wasn't correctly storing the number of @@ -150,7 +113,7 @@ * Constants... */ -#define PLUG_IN_VERSION "1.1.5 - 4 January 1998" +#define PLUG_IN_VERSION "1.1.6 - 17 May 1998" #define SCALE_WIDTH 125 diff --git a/plug-ins/sgi/sgi.c b/plug-ins/sgi/sgi.c index 4bda95353f..a0deec170f 100644 --- a/plug-ins/sgi/sgi.c +++ b/plug-ins/sgi/sgi.c @@ -34,23 +34,18 @@ * Revision History: * * $Log$ - * Revision 1.8 1998/04/24 02:18:44 yosh - * * Added sharpen to stable dist + * Revision 1.9 1998/06/06 23:22:19 yosh + * * adding Lighting plugin * - * * updated sgi and despeckle plugins - * - * * plug-ins/xd/xd.c: works with xdelta 0.18. The use of xdelta versions prior - * to this is not-supported. - * - * * plug-in/gfig/gfig.c: spelling corrections :) - * - * * app/fileops.c: applied gimp-gord-980420-0, fixes stale save procs in the - * file dialog - * - * * app/text_tool.c: applied gimp-egger-980420-0, text tool optimization + * * updated despeckle, png, sgi, and sharpen * * -Yosh * + * Revision 1.5 1998/05/17 16:01:33 mike + * Removed signal handler stuff used for debugging. + * Added gtk_rc_parse(). + * Removed extra variables. + * * Revision 1.4 1998/04/23 17:40:49 mike * Updated to support 16-bit image data. * @@ -80,7 +75,7 @@ * Constants... */ -#define PLUG_IN_VERSION "1.1 - 23 April 1998" +#define PLUG_IN_VERSION "1.1.1 - 17 May 1998" /* @@ -256,7 +251,7 @@ run(char *name, /* I - Name of filter program. */ if (compression < 0 || compression > 2) values[0].data.d_status = STATUS_CALLING_ERROR; - } + }; break; case RUN_WITH_LAST_VALS : @@ -269,7 +264,7 @@ run(char *name, /* I - Name of filter program. */ default : break; - } + }; if (values[0].data.d_status == STATUS_SUCCESS) { @@ -278,7 +273,7 @@ run(char *name, /* I - Name of filter program. */ gimp_set_data("file_sgi_save", &compression, sizeof(compression)); else values[0].data.d_status = STATUS_EXECUTION_ERROR; - } + }; } else values[0].data.d_status = STATUS_EXECUTION_ERROR; @@ -320,7 +315,7 @@ load_image(char *filename) /* I - File to load */ { g_print("can't open image file\n"); gimp_quit(); - } + }; if (strrchr(filename, '/') != NULL) sprintf(progress, "Loading %s:", strrchr(filename, '/') + 1); @@ -354,14 +349,14 @@ load_image(char *filename) /* I - File to load */ image_type = RGB; layer_type = RGBA_IMAGE; break; - } + }; image = gimp_image_new(sgip->xsize, sgip->ysize, image_type); if (image == -1) { g_print("can't allocate new image\n"); gimp_quit(); - } + }; gimp_image_set_filename(image, filename); @@ -413,7 +408,7 @@ load_image(char *filename) /* I - File to load */ count = 0; gimp_progress_update((double)y / (double)sgip->ysize); - } + }; for (i = 0; i < sgip->zsize; i ++) if (sgiGetRow(sgip, rows[i], sgip->ysize - 1 - y, i) < 0) @@ -439,8 +434,8 @@ load_image(char *filename) /* I - File to load */ for (x = 0, pptr = pixels[count]; x < sgip->xsize; x ++) for (i = 0; i < sgip->zsize; i ++, pptr ++) *pptr = rows[i][x] >> 8; - } - } + }; + }; /* * Do the last n rows (count always > 0) @@ -520,7 +515,7 @@ save_image(char *filename, /* I - File to save to */ case RGBA_IMAGE : zsize = 4; break; - } + }; /* * Open the file for writing... @@ -532,7 +527,7 @@ save_image(char *filename, /* I - File to save to */ { g_print("can't create image file\n"); gimp_quit(); - } + }; if (strrchr(filename, '/') != NULL) sprintf(progress, "Saving %s:", strrchr(filename, '/') + 1); @@ -587,10 +582,10 @@ save_image(char *filename, /* I - File to save to */ for (j = 0; j < zsize; j ++) sgiPutRow(sgip, rows[j], drawable->height - 1 - y - i, j); - } + }; gimp_progress_update((double)y / (double)drawable->height); - } + }; /* * Done with the file... @@ -680,9 +675,6 @@ save_dialog(void) gtk_init(&argc, &argv); gtk_rc_parse(gimp_gtkrc()); - signal(SIGBUS, SIG_DFL); - signal(SIGSEGV, SIG_DFL); - /* * Open a dialog window... */ @@ -742,7 +734,7 @@ save_dialog(void) (gpointer)((long)i)); gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); gtk_widget_show(button); - } + }; /* * Show everything and go... diff --git a/plug-ins/sgi/sgi.h b/plug-ins/sgi/sgi.h index 40c67a37b3..d1fec157a6 100644 --- a/plug-ins/sgi/sgi.h +++ b/plug-ins/sgi/sgi.h @@ -22,23 +22,16 @@ * Revision History: * * $Log$ - * Revision 1.7 1998/04/24 02:18:45 yosh - * * Added sharpen to stable dist + * Revision 1.8 1998/06/06 23:22:20 yosh + * * adding Lighting plugin * - * * updated sgi and despeckle plugins - * - * * plug-ins/xd/xd.c: works with xdelta 0.18. The use of xdelta versions prior - * to this is not-supported. - * - * * plug-in/gfig/gfig.c: spelling corrections :) - * - * * app/fileops.c: applied gimp-gord-980420-0, fixes stale save procs in the - * file dialog - * - * * app/text_tool.c: applied gimp-egger-980420-0, text tool optimization + * * updated despeckle, png, sgi, and sharpen * * -Yosh * + * Revision 1.5 1998/05/17 16:01:33 mike + * Added header file. + * * Revision 1.4 1998/04/23 17:40:49 mike * Updated to support 16-bit image data. * diff --git a/plug-ins/sgi/sgilib.c b/plug-ins/sgi/sgilib.c index a37b2e0556..e32faf00f9 100644 --- a/plug-ins/sgi/sgilib.c +++ b/plug-ins/sgi/sgilib.c @@ -38,20 +38,10 @@ * Revision History: * * $Log$ - * Revision 1.6 1998/04/24 02:18:46 yosh - * * Added sharpen to stable dist + * Revision 1.7 1998/06/06 23:22:21 yosh + * * adding Lighting plugin * - * * updated sgi and despeckle plugins - * - * * plug-ins/xd/xd.c: works with xdelta 0.18. The use of xdelta versions prior - * to this is not-supported. - * - * * plug-in/gfig/gfig.c: spelling corrections :) - * - * * app/fileops.c: applied gimp-gord-980420-0, fixes stale save procs in the - * file dialog - * - * * app/text_tool.c: applied gimp-egger-980420-0, text tool optimization + * * updated despeckle, png, sgi, and sharpen * * -Yosh * @@ -125,19 +115,19 @@ sgiClose(sgi_t *sgip) /* I - SGI image */ i --, offset ++) if (putlong(offset[0], sgip->file) < 0) return (-1); - } + }; if (sgip->table != NULL) { free(sgip->table[0]); free(sgip->table); - } + }; if (sgip->length != NULL) { free(sgip->length[0]); free(sgip->length); - } + }; if (sgip->comp == SGI_COMP_ARLE) free(sgip->arle_row); @@ -190,7 +180,7 @@ sgiGetRow(sgi_t *sgip, /* I - SGI image */ { for (x = sgip->xsize; x > 0; x --, row ++) *row = getshort(sgip->file); - } + }; break; case SGI_COMP_RLE : @@ -203,7 +193,7 @@ sgiGetRow(sgi_t *sgip, /* I - SGI image */ else return (read_rle16(sgip->file, row, sgip->xsize)); break; - } + }; return (0); } @@ -275,7 +265,7 @@ sgiOpenFile(FILE *file, /* I - File to open */ { free(sgip); return (NULL); - } + }; sgip->comp = getc(sgip->file); sgip->bpp = getc(sgip->file); @@ -302,7 +292,7 @@ sgiOpenFile(FILE *file, /* I - File to open */ for (i = 0; i < sgip->zsize; i ++) for (j = 0; j < sgip->ysize; j ++) sgip->table[i][j] = getlong(sgip->file); - } + }; break; case SGI_WRITE : @@ -314,7 +304,7 @@ sgiOpenFile(FILE *file, /* I - File to open */ { free(sgip); return (NULL); - } + }; sgip->mode = SGI_WRITE; @@ -334,7 +324,7 @@ sgiOpenFile(FILE *file, /* I - File to open */ { putlong(-32768, sgip->file); /* Minimum pixel */ putlong(32767, sgip->file); /* Maximum pixel */ - } + }; putlong(0, sgip->file); /* Reserved */ memset(name, 0, sizeof(name)); @@ -360,7 +350,7 @@ sgiOpenFile(FILE *file, /* I - File to open */ { for (i = xsize * ysize * zsize; i > 0; i --) putshort(0, sgip->file); - } + }; break; case SGI_COMP_ARLE : /* Aggressive RLE */ @@ -386,13 +376,13 @@ sgiOpenFile(FILE *file, /* I - File to open */ for (i = 1; i < sgip->zsize; i ++) sgip->length[i] = sgip->length[0] + i * sgip->ysize; break; - } + }; break; default : free(sgip); return (NULL); - } + }; return (sgip); } @@ -439,7 +429,7 @@ sgiPutRow(sgi_t *sgip, /* I - SGI image */ { for (x = sgip->xsize; x > 0; x --, row ++) putshort(*row, sgip->file); - } + }; break; case SGI_COMP_ARLE : @@ -461,8 +451,8 @@ sgiPutRow(sgi_t *sgip, /* I - SGI image */ sgip->table[z][y] = sgip->arle_offset; sgip->length[z][y] = sgip->arle_length; return (0); - } - } + }; + }; /* * If that didn't match, search all the previous rows... @@ -479,7 +469,7 @@ sgiPutRow(sgi_t *sgip, /* I - SGI image */ { x = 0; break; - } + }; for (x = 0; x < sgip->xsize; x ++) if (row[x] != sgip->arle_row[x]) @@ -496,14 +486,14 @@ sgiPutRow(sgi_t *sgip, /* I - SGI image */ { x = 0; break; - } + }; for (x = 0; x < sgip->xsize; x ++) if (row[x] != sgip->arle_row[x]) break; } while (x < sgip->xsize); - } + }; if (x == sgip->xsize) { @@ -533,13 +523,13 @@ sgiPutRow(sgi_t *sgip, /* I - SGI image */ sgip->arle_offset = offset; sgip->arle_length = x; memcpy(sgip->arle_row, row, sgip->xsize * sizeof(short)); - } + }; sgip->nextrow = ftell(sgip->file); sgip->length[z][y] = x; return (x); - } + }; return (0); } @@ -651,8 +641,8 @@ read_rle8(FILE *fp, /* I - File to read from */ length ++; for (i = 0; i < count; i ++, row ++, xsize --) *row = ch; - } - } + }; + }; return (xsize > 0 ? -1 : length); } @@ -696,8 +686,8 @@ read_rle16(FILE *fp, /* I - File to read from */ length ++; for (i = 0; i < count; i ++, row ++, xsize --) *row = ch; - } - } + }; + }; return (xsize > 0 ? -1 : length * 2); } @@ -730,7 +720,7 @@ write_rle8(FILE *fp, /* I - File to write to */ { row ++; x --; - } + }; row -= 2; x += 2; @@ -752,8 +742,8 @@ write_rle8(FILE *fp, /* I - File to write to */ start ++; i --; length ++; - } - } + }; + }; if (x <= 0) break; @@ -768,7 +758,7 @@ write_rle8(FILE *fp, /* I - File to write to */ { row ++; x --; - } + }; count = row - start; while (count > 0) @@ -783,8 +773,8 @@ write_rle8(FILE *fp, /* I - File to write to */ if (putc(repeat, fp) == EOF) return (-1); length ++; - } - } + }; + }; length ++; @@ -822,7 +812,7 @@ write_rle16(FILE *fp, /* I - File to write to */ { row ++; x --; - } + }; row -= 2; x += 2; @@ -844,8 +834,8 @@ write_rle16(FILE *fp, /* I - File to write to */ start ++; i --; length ++; - } - } + }; + }; if (x <= 0) break; @@ -860,7 +850,7 @@ write_rle16(FILE *fp, /* I - File to write to */ { row ++; x --; - } + }; count = row - start; while (count > 0) @@ -875,8 +865,8 @@ write_rle16(FILE *fp, /* I - File to write to */ if (putshort(repeat, fp) == EOF) return (-1); length ++; - } - } + }; + }; length ++; diff --git a/plug-ins/sharpen/sharpen.c b/plug-ins/sharpen/sharpen.c index 63c33ef819..0785cc4c40 100644 --- a/plug-ins/sharpen/sharpen.c +++ b/plug-ins/sharpen/sharpen.c @@ -44,23 +44,17 @@ * Revision History: * * $Log$ - * Revision 1.6 1998/04/28 03:50:19 yosh - * * plug-ins/animationplay/animationplay.c - * * plug-ins/CEL/CEL.c - * * plug-ins/psd/psd.c - * * plug-ins/xd/xd.c: applied gimp-joke-980427-0, warning cleanups + * Revision 1.7 1998/06/06 23:22:22 yosh + * * adding Lighting plugin * - * * app/temp_buf.c: applied gimp-entity-980427-0, temp_buf swap speedups and - * more robust tempfile handling + * * updated despeckle, png, sgi, and sharpen * * -Yosh * - * Revision 1.5 1998/04/27 22:01:01 neo - * Updated sharpen and despeckle. Wow, sharpen is balzingly fast now, while - * despeckle is still sort of lame... - * - * - * --Sven + * Revision 1.14 1998/05/17 16:01:33 mike + * Removed signal handler stuff used for debugging. + * Added gtk_rc_parse(). + * Removed extra variables. * * Revision 1.13 1998/04/27 15:55:38 mike * Sharpen would shift the image down one pixel; was using the wrong "source" @@ -133,7 +127,7 @@ */ #define PLUG_IN_NAME "plug_in_sharpen" -#define PLUG_IN_VERSION "1.3 - 27 April 1998" +#define PLUG_IN_VERSION "1.4.2 - 3 June 1998" #define PREVIEW_SIZE 128 #define SCALE_WIDTH 64 #define ENTRY_WIDTH 64 @@ -342,8 +336,8 @@ run(char *name, /* I - Name of filter program. */ default : status = STATUS_CALLING_ERROR; - break; - } + break;; + }; /* * Sharpen the image... @@ -383,7 +377,7 @@ run(char *name, /* I - Name of filter program. */ } else status = STATUS_EXECUTION_ERROR; - } + }; /* * Reset the current run status... @@ -414,7 +408,7 @@ compute_luts(void) { pos_lut[i] = 100 * i / fact; neg_lut[i] = sharpen_percent * i / 8 / fact; - } + }; } @@ -463,7 +457,7 @@ sharpen(void) { src_rows[row] = g_malloc(width * sizeof(guchar)); neg_rows[row] = g_malloc(width * sizeof(guchar)); - } + }; dst_row = g_malloc(width * sizeof(guchar)); @@ -498,7 +492,7 @@ sharpen(void) case 4 : filter = rgba_filter; break; - } + }; /* * Sharpen... @@ -539,7 +533,7 @@ sharpen(void) */ count --; - } + }; /* * Now sharpen pixels and save the results... @@ -558,10 +552,17 @@ sharpen(void) gimp_pixel_rgn_set_row(&dst_rgn, dst_row, sel_x1, y, sel_width); } + else if (count == 2) + { + if (y == sel_y1) + gimp_pixel_rgn_set_row(&dst_rgn, src_rows[0], sel_x1, y, sel_width); + else + gimp_pixel_rgn_set_row(&dst_rgn, src_rows[2], sel_x1, y, sel_width); + }; if ((y & 15) == 0) gimp_progress_update((double)(y - sel_y1) / (double)sel_height); - } + }; /* * OK, we're done. Free all memory used... @@ -571,7 +572,7 @@ sharpen(void) { g_free(src_rows[row]); g_free(neg_rows[row]); - } + }; g_free(dst_row); @@ -622,9 +623,6 @@ sharpen_dialog(void) gtk_widget_set_default_visual(gtk_preview_get_visual()); gtk_widget_set_default_colormap(gtk_preview_get_cmap()); - signal(SIGBUS, SIG_DFL); - signal(SIGSEGV, SIG_DFL); - /* * Dialog window... */ @@ -852,7 +850,7 @@ preview_update(void) case 4 : filter = rgba_filter; break; - } + }; /* * Sharpen... @@ -907,7 +905,7 @@ preview_update(void) else image_ptr[0] = image_ptr[1] = image_ptr[2] = check + ((dst_ptr[0] - check) * dst_ptr[1]) / 255; - } + }; break; case 3 : @@ -942,10 +940,10 @@ preview_update(void) image_ptr[0] = check + ((dst_ptr[0] - check) * dst_ptr[3]) / 255; image_ptr[1] = check + ((dst_ptr[1] - check) * dst_ptr[3]) / 255; image_ptr[2] = check + ((dst_ptr[2] - check) * dst_ptr[3]) / 255; - } - } + }; + }; break; - } + }; /* * Draw the preview image on the screen... @@ -1065,7 +1063,7 @@ dialog_iscale_update(GtkAdjustment *adjustment, /* I - New value */ compute_luts(); preview_update(); - } + }; } @@ -1098,8 +1096,8 @@ dialog_ientry_update(GtkWidget *widget, /* I - Entry widget */ compute_luts(); preview_update(); - } - } + }; + }; } @@ -1174,7 +1172,7 @@ gray_filter(int width, /* I - Width of line in pixels */ neg1 ++; neg2 ++; width --; - } + }; *dst++ = *src++; } @@ -1216,7 +1214,7 @@ graya_filter(int width, /* I - Width of line in pixels */ neg1 += 2; neg2 += 2; width --; - } + }; *dst++ = *src++; *dst++ = *src++; @@ -1279,7 +1277,7 @@ rgb_filter(int width, /* I - Width of line in pixels */ neg1 += 3; neg2 += 3; width --; - } + }; *dst++ = *src++; *dst++ = *src++; @@ -1346,7 +1344,7 @@ rgba_filter(int width, /* I - Width of line in pixels */ neg1 += 4; neg2 += 4; width --; - } + }; *dst++ = *src++; *dst++ = *src++;