diff options
31 files changed, 2066 insertions, 0 deletions
diff --git a/Patches/17 PixelPack HISTORY.txt b/Patches/17 PixelPack HISTORY.txt new file mode 100644 index 0000000..646b311 --- /dev/null +++ b/Patches/17 PixelPack HISTORY.txt @@ -0,0 +1,11 @@ +version history of PixlePack plugins + +v 0.02: +- added plugins: interlace +- some code optimization + +v 0.01: +- plugins: compare, convolution, darken, deinterlace, difference, + lighten, multiply, overlay, screen, shadowcaster, softlight +- KNOWN BUG: some artefacts due to rounding errors (as we are using + 8bir values), especially in convolution
\ No newline at end of file diff --git a/Patches/17 PixelPack LICENSE.txt b/Patches/17 PixelPack LICENSE.txt new file mode 100644 index 0000000..5ea29a7 --- /dev/null +++ b/Patches/17 PixelPack LICENSE.txt @@ -0,0 +1,346 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) 19yy <name of author> + + 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; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. + diff --git a/Patches/17 PixelPack README.txt b/Patches/17 PixelPack README.txt new file mode 100644 index 0000000..82a4985 --- /dev/null +++ b/Patches/17 PixelPack README.txt @@ -0,0 +1,19 @@ +PixelPack 0.02 +copyright (c) 2002 by Olaf Matthes + +PixelPack is a collection of video plugins for Framestein (written +by Juha Vehviläinen). Framestein can be found at http://framestein.org +Get PixelPack at http://www.akustische-kunst.de/puredata/framestein/ + +To use PixelPack copy all files from the Patches and Plugins directoy of +this distribution into Framesteins directories of the same names. +Open example-PixelPack.pd for help. + +TO compile simply type "nmake nameofplugin". + + +This software is published under GPL terms, see file LICENSE. + +This is software with ABSOLUTELY NO WARRANTY. +Use it at your OWN RISK. It's possible to damage e.g. hardware or your hearing +due to a bug or for other reasons.
\ No newline at end of file diff --git a/Patches/17-01 example-PixelPack.pd b/Patches/17-01 example-PixelPack.pd new file mode 100644 index 0000000..6d8a92b --- /dev/null +++ b/Patches/17-01 example-PixelPack.pd @@ -0,0 +1,8 @@ +#N canvas 190 88 658 327 12; +#X text 25 18 PixelPack :: examples and help; +#X text 130 47 PixelPack contains several objects that would just overcrowd +a single helpfile. thus I've splitted them into a few categories:; +#X text 250 135 note: uses fs.layermode.pd perform the effects; +#X text 130 116 layer modes :: example-PixelPack-layermodes.pd; +#X text 31 244 PixelPack can be found at: http://www.akustische-kunst.de/puredata/framestein +; diff --git a/Patches/17-02 example-PixelPack-layermodes.pd b/Patches/17-02 example-PixelPack-layermodes.pd new file mode 100644 index 0000000..f3b37d5 --- /dev/null +++ b/Patches/17-02 example-PixelPack-layermodes.pd @@ -0,0 +1,66 @@ +#N canvas 9 10 1010 520 12; +#X obj 10 52 fs.main; +#X msg 10 23 6001; +#X msg 61 24 reset; +#X msg 159 206 597 + 108; +#X msg 393 166 815 + 109; +#X msg 347 397 696 + 342; +#X obj 160 39 fps 0; +#X floatatom 217 41 4 0 0; +#X msg 195 94 next \, bang; +#X msg 11 126 next \, bang; +#X obj 159 179 init; +#X obj 393 144 init; +#X obj 347 370 init; +#X text 682 44 drag and drop your videos here; +#X text 748 291 the result; +#X obj 160 67 t b b; +#X text 119 17 frame rate. start with something modest \, like 1; +#X obj 11 153 fs.framed example-PixelPack-layermodes; +#X obj 195 120 fs.framed example-PixelPack-layermodes; +#X obj 33 368 fs.framed example-PixelPack-layermodes; +#X obj 150 330 fs.layermode; +#X text 149 416 note: this examples is a variation of fs.blend.; +#X msg 300 194 difference; +#X msg 300 218 multiply; +#X msg 300 243 softlight; +#X msg 398 244 overlay; +#X msg 398 268 darken; +#X msg 398 292 lighten; +#X text 401 193 choose one of the; +#X text 400 209 layer modes !; +#X msg 398 315 screen; +#X text 148 447 on my machine (1.8 GHz P4) I manage to get about 5fps +when using full PAL resolution DV videos. take this as a guideline... +(and buy a faster computer \; -); +#X obj 217 67 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X connect 1 0 0 0; +#X connect 1 0 2 0; +#X connect 2 0 0 1; +#X connect 3 0 17 0; +#X connect 4 0 18 0; +#X connect 5 0 19 0; +#X connect 6 0 15 0; +#X connect 7 0 6 0; +#X connect 8 0 18 0; +#X connect 9 0 17 0; +#X connect 10 0 3 0; +#X connect 11 0 4 0; +#X connect 12 0 5 0; +#X connect 15 0 9 0; +#X connect 15 1 8 0; +#X connect 17 0 20 0; +#X connect 17 2 3 0; +#X connect 18 0 20 1; +#X connect 18 2 4 0; +#X connect 19 2 5 0; +#X connect 20 0 19 0; +#X connect 22 0 20 2; +#X connect 23 0 20 2; +#X connect 24 0 20 2; +#X connect 25 0 20 2; +#X connect 26 0 20 2; +#X connect 27 0 20 2; +#X connect 30 0 20 2; +#X connect 32 0 15 0; diff --git a/Patches/fs.layermode.pd b/Patches/fs.layermode.pd new file mode 100644 index 0000000..7e2ece2 --- /dev/null +++ b/Patches/fs.layermode.pd @@ -0,0 +1,32 @@ +#N canvas 30 209 753 358 10; +#X obj 55 42 inlet; +#X obj 159 301 outlet; +#X obj 239 43 inlet; +#X obj 90 143 fs.copy; +#X obj 173 146 fs.copy; +#X obj 192 104 symbol; +#X msg 286 215 flip_manual; +#X obj 346 174 init; +#X obj 63 91 t b s b; +#X msg 24 134 flip; +#X text 47 20 fs.frame; +#X text 229 19 fs.frame; +#X text 152 322 fs.frame; +#X msg 329 100 difference; +#X obj 295 43 inlet; +#X text 350 22 fs.layermode -- mix two images with difference layer +mode; +#X connect 0 0 8 0; +#X connect 2 0 5 1; +#X connect 3 0 1 0; +#X connect 4 0 1 0; +#X connect 5 0 4 0; +#X connect 6 0 1 0; +#X connect 7 0 6 0; +#X connect 7 0 13 0; +#X connect 8 0 9 0; +#X connect 8 1 3 0; +#X connect 8 2 5 0; +#X connect 9 0 1 0; +#X connect 13 0 3 1; +#X connect 14 0 3 1; diff --git a/Plugins/compare.c b/Plugins/compare.c new file mode 100644 index 0000000..a507be9 --- /dev/null +++ b/Plugins/compare.c @@ -0,0 +1,163 @@ +// +// compare - compare two images for differences +// +// if pixels are identical a background color get's displayed, +// returns number of pixels that are identical +// +// written by Olaf Matthes <olaf.matthes@gmx.de> +// inspired by code written by Trond Lossius, Bergen senter for elektronisk kunst (BEK) +// +// 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; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// usage: compare <red fuzz> <green fuzz> <blue fuzz> <bg red> <bg green> <bg blue> [<receive name>] +// in case the (optional) receive name is specified, you get back the number of pixels that have been +// found to be identical in both images +// + +#include <stdio.h> +#include <string.h> +#include "plugin.h" + +void perform_effect(struct frame f, struct args a) +{ + printf("Using compare as effect does nothing!\n"); +} + +void perform_copy(struct frame f1, struct frame f2, struct args a) +{ + short x, y, w, h, ret; + long count = 0; + pixel16 *pix1_16, *pix2_16; + pixel24 *pix1_24, *pix2_24; + pixel32 *pix1_32, *pix2_32; + byte redfuzzi, greenfuzzi, bluefuzzi, redbg, greenbg, bluebg, check; + char *t; + char *ret_count; // returns the result (number of identical pixels) + + w = f1.width<f2.width ? f1.width : f2.width; + h = f1.height<f2.height ? f1.height : f2.height; + + // get params + if(!a.s) return; + redfuzzi = klamp255(atoi(a.s)); + if(!(t = strstr(a.s, " "))) return; + greenfuzzi = klamp255(atoi(t+1)); + if(!(t = strstr(t+1, " "))) return; + bluefuzzi = klamp255(atoi(t+1)); + if(!(t = strstr(t+1, " "))) return; + redbg = klamp255(atoi(t+1)); + if(!(t = strstr(t+1, " "))) return; + greenbg = klamp255(atoi(t+1)); + if(!(t = strstr(t+1, " "))) return; + bluebg = klamp255(atoi(t+1)); + + printf("compare: rf%d gf%d bf%d - rbg%d gbg%d bbg%d\n", + redfuzzi, greenfuzzi, bluefuzzi, redbg, greenbg, bluebg); + + // get returnvaluereceivenames + if(!(t = strstr(t+1, " "))) + { + ret = 0; // don't return anything + } + else + { + ret = 1; // return number of identical pixels + ret_count = t+1; + t[0]=0; + } + + switch(f1.pixelformat) + { + case 16: + // compare images pixel by pixel + for(y = 0; y < h; y++) + { + pix1_16 = scanline16(f1, y); + pix2_16 = scanline16(f2, y); + for(x = 0; x < w; x++) + { + check = 1; + + if(abs(r16(pix1_16[x]) - r16(pix2_16[x])) > redfuzzi) + check = 0; + else if(abs(g16(pix1_16[x]) - g16(pix2_16[x])) > greenfuzzi) + check = 0; + else if(abs(b16(pix1_16[x]) - b16(pix2_16[x])) > bluefuzzi) + check = 0; + + if(check) + { + pix2_16[x] = rgbtocolor16(redbg, greenbg, bluebg); + count++; + } + } + } + break; + case 24: + for(y = 0; y < h; y++) + { + pix1_24 = scanline24(f1, y); + pix2_24 = scanline24(f2, y); + for(x = 0; x < w; x++) + { + check = 1; + + if(abs(r24(pix1_24[x]) - r24(pix2_24[x])) > redfuzzi) + check = 0; + else if(abs(g24(pix1_24[x]) - g24(pix2_24[x])) > greenfuzzi) + check = 0; + else if(abs(b24(pix1_24[x]) - b24(pix2_24[x])) > bluefuzzi) + check = 0; + + if(check) + { + pix1_24[x] = rgbtocolor24(redbg, greenbg, bluebg); + count++; + } + } + } + break; + case 32: + for(y = 0; y < h; y++) + { + pix1_32 = scanline32(f1, y); + pix2_32 = scanline32(f2, y); + for(x = 0; x < w; x++) + { + check = 1; + + if(abs(r32(pix1_32[x]) - r32(pix2_32[x])) > redfuzzi) + check = 0; + else if(abs(g32(pix1_32[x]) - g32(pix2_32[x])) > greenfuzzi) + check = 0; + else if(abs(b32(pix1_32[x]) - b32(pix2_32[x])) > bluefuzzi) + check = 0; + + if(check) + { + pix2_32[x] = rgbtocolor32(redbg, greenbg, bluebg); + count++; + } + } + } + break; + } + // return-value: + // + // framestein will send data given in the form "pd_receiver_name=value" + // back to pd. + + if(ret)sprintf(a.ret, "%s=%d", ret_count, count); +} diff --git a/Plugins/compare.dll b/Plugins/compare.dll Binary files differnew file mode 100644 index 0000000..5dabdde --- /dev/null +++ b/Plugins/compare.dll diff --git a/Plugins/convolution.c b/Plugins/convolution.c new file mode 100644 index 0000000..d1ec139 --- /dev/null +++ b/Plugins/convolution.c @@ -0,0 +1,207 @@ +// +// convolution - 5x5 convolution kernel matrix calculation +// +// written by Olaf Matthes <olaf.matthes@gmx.de> +// +// 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; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// usage: convolution <matrix[0]> <matrix[1]> <matrix[2]> <matrix[3]> <matrix[4]> +// <matrix[5]> <matrix[6]> <matrix[7]> <matrix[8]> <matrix[9]> +// <matrix[10]> <matrix[11]> <matrix[12]> <matrix[13]> <matrix[14]> +// <matrix[15]> <matrix[16]> <matrix[17]> <matrix[18]> <matrix[19]> +// <matrix[20]> <matrix[21]> <matrix[22]> <matrix[23]> <matrix[24]> +// <scale> <shift> +// +// KNOWN BUG: produces ugly colors (due to rounding error I guess) +// + +#include <stdio.h> +#include <string.h> +#include "plugin.h" + +void perform_effect(struct frame f, struct args a) +{ + short x, y; + long matrix[25], scale, shift; + pixel16 *p16[5], *c16; + pixel24 *p24[5], *c24; + pixel32 *p32[5], *c32; + long r, g, b; + char *t; + + // get params + if(!a.s) return; + matrix[0] = atoi(a.s); + if(!(t = strstr(a.s, " "))) return; + matrix[1] = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + matrix[2] = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + matrix[3] = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + matrix[4] = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + matrix[5] = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + matrix[6] = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + matrix[7] = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + matrix[8] = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + matrix[9] = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + matrix[10] = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + matrix[11] = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + matrix[12] = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + matrix[13] = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + matrix[14] = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + matrix[15] = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + matrix[16] = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + matrix[17] = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + matrix[18] = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + matrix[19] = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + matrix[20] = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + matrix[21] = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + matrix[22] = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + matrix[23] = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + matrix[24] = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + scale = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + shift = atoi(t+1); + + if(scale == 0) scale = 1; + + printf("convolution: matrix %d %d %d %d %d\n", matrix[0], matrix[1], matrix[2], matrix[3], matrix[4]); + printf(" %d %d %d %d %d\n", matrix[5], matrix[6], matrix[7], matrix[8], matrix[9]); + printf(" %d %d %d %d %d\n", matrix[10], matrix[11], matrix[12], matrix[13], matrix[14]); + printf(" %d %d %d %d %d\n", matrix[15], matrix[16], matrix[17], matrix[18], matrix[19]); + printf(" %d %d %d %d %d\n", matrix[20], matrix[21], matrix[22], matrix[23], matrix[24]); + printf(" scale %d, shift %d\n", scale, shift); + + switch(f.pixelformat) + { + case 16: + for(y = 0; y < f.height; y++) + { + if(y > 5) // we have read all 5 lines needed for calculation + { + c16 = scanline16(f, y - 3); // this will become our newly calculated line + for(x = 2; x < f.width - 2; x++) + { + r = (r16(p16[(y-5)%5][x-2])*matrix[0] + r16(p16[(y-5)%5][x-1])*matrix[1] + r16(p16[(y-5)%5][x])*matrix[2] + r16(p16[(y-5)%5][x+1])*matrix[3] + r16(p16[(y-5)%5][x+2])*matrix[4] + + r16(p16[(y-4)%5][x-2])*matrix[5] + r16(p16[(y-4)%5][x-1])*matrix[6] + r16(p16[(y-3)%5][x])*matrix[7] + r16(p16[(y-4)%5][x+1])*matrix[8] + r16(p16[(y-4)%5][x+2])*matrix[9] + + r16(p16[(y-3)%5][x-2])*matrix[10] + r16(p16[(y-3)%5][x-1])*matrix[11] + r16(p16[(y-3)%5][x])*matrix[12] + r16(p16[(y-3)%5][x+1])*matrix[13] + r16(p16[(y-3)%5][x+2])*matrix[14] + + r16(p16[(y-2)%5][x-2])*matrix[15] + r16(p16[(y-2)%5][x-1])*matrix[16] + r16(p16[(y-2)%5][x])*matrix[17] + r16(p16[(y-2)%5][x+1])*matrix[18] + r16(p16[(y-2)%5][x+2])*matrix[19] + + r16(p16[(y-1)%5][x-2])*matrix[20] + r16(p16[(y-1)%5][x-1])*matrix[21] + r16(p16[(y-1)%5][x])*matrix[22] + r16(p16[(y-1)%5][x+1])*matrix[23] + r16(p16[(y-1)%5][x+2])*matrix[24])/scale - shift; + g = (g16(p16[(y-5)%5][x-2])*matrix[0] + g16(p16[(y-5)%5][x-1])*matrix[1] + g16(p16[(y-5)%5][x])*matrix[2] + g16(p16[(y-5)%5][x+1])*matrix[3] + g16(p16[(y-5)%5][x+2])*matrix[4] + + g16(p16[(y-4)%5][x-2])*matrix[5] + g16(p16[(y-4)%5][x-1])*matrix[6] + g16(p16[(y-3)%5][x])*matrix[7] + g16(p16[(y-4)%5][x+1])*matrix[8] + g16(p16[(y-4)%5][x+2])*matrix[9] + + g16(p16[(y-3)%5][x-2])*matrix[10] + g16(p16[(y-3)%5][x-1])*matrix[11] + g16(p16[(y-3)%5][x])*matrix[12] + g16(p16[(y-3)%5][x+1])*matrix[13] + g16(p16[(y-3)%5][x+2])*matrix[14] + + g16(p16[(y-2)%5][x-2])*matrix[15] + g16(p16[(y-2)%5][x-1])*matrix[16] + g16(p16[(y-2)%5][x])*matrix[17] + g16(p16[(y-2)%5][x+1])*matrix[18] + g16(p16[(y-2)%5][x+2])*matrix[19] + + g16(p16[(y-1)%5][x-2])*matrix[20] + g16(p16[(y-1)%5][x-1])*matrix[21] + g16(p16[(y-1)%5][x])*matrix[22] + g16(p16[(y-1)%5][x+1])*matrix[23] + g16(p16[(y-1)%5][x+2])*matrix[24])/scale - shift; + b = (b16(p16[(y-5)%5][x-2])*matrix[0] + b16(p16[(y-5)%5][x-1])*matrix[1] + b16(p16[(y-5)%5][x])*matrix[2] + b16(p16[(y-5)%5][x+1])*matrix[3] + b16(p16[(y-5)%5][x+2])*matrix[4] + + b16(p16[(y-4)%5][x-2])*matrix[5] + b16(p16[(y-4)%5][x-1])*matrix[6] + b16(p16[(y-3)%5][x])*matrix[7] + b16(p16[(y-4)%5][x+1])*matrix[8] + b16(p16[(y-4)%5][x+2])*matrix[9] + + b16(p16[(y-3)%5][x-2])*matrix[10] + b16(p16[(y-3)%5][x-1])*matrix[11] + b16(p16[(y-3)%5][x])*matrix[12] + b16(p16[(y-3)%5][x+1])*matrix[13] + b16(p16[(y-3)%5][x+2])*matrix[14] + + b16(p16[(y-2)%5][x-2])*matrix[15] + b16(p16[(y-2)%5][x-1])*matrix[16] + b16(p16[(y-2)%5][x])*matrix[17] + b16(p16[(y-2)%5][x+1])*matrix[18] + b16(p16[(y-2)%5][x+2])*matrix[19] + + b16(p16[(y-1)%5][x-2])*matrix[20] + b16(p16[(y-1)%5][x-1])*matrix[21] + b16(p16[(y-1)%5][x])*matrix[22] + b16(p16[(y-1)%5][x+1])*matrix[23] + b16(p16[(y-1)%5][x+2])*matrix[24])/scale - shift; + c16[x] = rgbtocolor16(klamp255(r), klamp255(g), klamp255(b)); + } + } + // read in lines needed for calculation + p16[y % 5] = scanline16(f, y); + } + break; + case 24: + for(y=0; y<f.height; y++) + { + if(y > 5) // we have read all 5 lines needed for calculation + { + c24 = scanline24(f, y - 3); // this will become our newly calculated line + for(x = 2; x < f.width - 2; x++) + { + r = (r24(p24[(y-5)%5][x-2])*matrix[0] + r24(p24[(y-5)%5][x-1])*matrix[1] + r24(p24[(y-5)%5][x])*matrix[2] + r24(p24[(y-5)%5][x+1])*matrix[3] + r24(p24[(y-5)%5][x+2])*matrix[4] + + r24(p24[(y-4)%5][x-2])*matrix[5] + r24(p24[(y-4)%5][x-1])*matrix[6] + r24(p24[(y-3)%5][x])*matrix[7] + r24(p24[(y-4)%5][x+1])*matrix[8] + r24(p24[(y-4)%5][x+2])*matrix[9] + + r24(p24[(y-3)%5][x-2])*matrix[10] + r24(p24[(y-3)%5][x-1])*matrix[11] + r24(p24[(y-3)%5][x])*matrix[12] + r24(p24[(y-3)%5][x+1])*matrix[13] + r24(p24[(y-3)%5][x+2])*matrix[14] + + r24(p24[(y-2)%5][x-2])*matrix[15] + r24(p24[(y-2)%5][x-1])*matrix[16] + r24(p24[(y-2)%5][x])*matrix[17] + r24(p24[(y-2)%5][x+1])*matrix[18] + r24(p24[(y-2)%5][x+2])*matrix[19] + + r24(p24[(y-1)%5][x-2])*matrix[20] + r24(p24[(y-1)%5][x-1])*matrix[21] + r24(p24[(y-1)%5][x])*matrix[22] + r24(p24[(y-1)%5][x+1])*matrix[23] + r24(p24[(y-1)%5][x+2])*matrix[24])/scale - shift; + g = (g24(p24[(y-5)%5][x-2])*matrix[0] + g24(p24[(y-5)%5][x-1])*matrix[1] + g24(p24[(y-5)%5][x])*matrix[2] + g24(p24[(y-5)%5][x+1])*matrix[3] + g24(p24[(y-5)%5][x+2])*matrix[4] + + g24(p24[(y-4)%5][x-2])*matrix[5] + g24(p24[(y-4)%5][x-1])*matrix[6] + g24(p24[(y-3)%5][x])*matrix[7] + g24(p24[(y-4)%5][x+1])*matrix[8] + g24(p24[(y-4)%5][x+2])*matrix[9] + + g24(p24[(y-3)%5][x-2])*matrix[10] + g24(p24[(y-3)%5][x-1])*matrix[11] + g24(p24[(y-3)%5][x])*matrix[12] + g24(p24[(y-3)%5][x+1])*matrix[13] + g24(p24[(y-3)%5][x+2])*matrix[14] + + g24(p24[(y-2)%5][x-2])*matrix[15] + g24(p24[(y-2)%5][x-1])*matrix[16] + g24(p24[(y-2)%5][x])*matrix[17] + g24(p24[(y-2)%5][x+1])*matrix[18] + g24(p24[(y-2)%5][x+2])*matrix[19] + + g24(p24[(y-1)%5][x-2])*matrix[20] + g24(p24[(y-1)%5][x-1])*matrix[21] + g24(p24[(y-1)%5][x])*matrix[22] + g24(p24[(y-1)%5][x+1])*matrix[23] + g24(p24[(y-1)%5][x+2])*matrix[24])/scale - shift; + b = (b24(p24[(y-5)%5][x-2])*matrix[0] + b24(p24[(y-5)%5][x-1])*matrix[1] + b24(p24[(y-5)%5][x])*matrix[2] + b24(p24[(y-5)%5][x+1])*matrix[3] + b24(p24[(y-5)%5][x+2])*matrix[4] + + b24(p24[(y-4)%5][x-2])*matrix[5] + b24(p24[(y-4)%5][x-1])*matrix[6] + b24(p24[(y-3)%5][x])*matrix[7] + b24(p24[(y-4)%5][x+1])*matrix[8] + b24(p24[(y-4)%5][x+2])*matrix[9] + + b24(p24[(y-3)%5][x-2])*matrix[10] + b24(p24[(y-3)%5][x-1])*matrix[11] + b24(p24[(y-3)%5][x])*matrix[12] + b24(p24[(y-3)%5][x+1])*matrix[13] + b24(p24[(y-3)%5][x+2])*matrix[14] + + b24(p24[(y-2)%5][x-2])*matrix[15] + b24(p24[(y-2)%5][x-1])*matrix[16] + b24(p24[(y-2)%5][x])*matrix[17] + b24(p24[(y-2)%5][x+1])*matrix[18] + b24(p24[(y-2)%5][x+2])*matrix[19] + + b24(p24[(y-1)%5][x-2])*matrix[20] + b24(p24[(y-1)%5][x-1])*matrix[21] + b24(p24[(y-1)%5][x])*matrix[22] + b24(p24[(y-1)%5][x+1])*matrix[23] + b24(p24[(y-1)%5][x+2])*matrix[24])/scale - shift; + c24[x] = rgbtocolor24(klamp255(r), klamp255(g), klamp255(b)); + } + } + // read in lines needed for calculation + p24[y % 5] = scanline24(f, y); + } + break; + case 32: + for(y=0; y<f.height; y++) + { + if(y > 5) // we have read all 5 lines needed for calculation + { + c32 = scanline32(f, y - 3); // this will become our newly calculated line + for(x = 2; x < f.width - 2; x++) + { + r = (r32(p32[(y-5)%5][x-2])*matrix[0] + r32(p32[(y-5)%5][x-1])*matrix[1] + r32(p32[(y-5)%5][x])*matrix[2] + r32(p32[(y-5)%5][x+1])*matrix[3] + r32(p32[(y-5)%5][x+2])*matrix[4] + + r32(p32[(y-4)%5][x-2])*matrix[5] + r32(p32[(y-4)%5][x-1])*matrix[6] + r32(p32[(y-3)%5][x])*matrix[7] + r32(p32[(y-4)%5][x+1])*matrix[8] + r32(p32[(y-4)%5][x+2])*matrix[9] + + r32(p32[(y-3)%5][x-2])*matrix[10] + r32(p32[(y-3)%5][x-1])*matrix[11] + r32(p32[(y-3)%5][x])*matrix[12] + r32(p32[(y-3)%5][x+1])*matrix[13] + r32(p32[(y-3)%5][x+2])*matrix[14] + + r32(p32[(y-2)%5][x-2])*matrix[15] + r32(p32[(y-2)%5][x-1])*matrix[16] + r32(p32[(y-2)%5][x])*matrix[17] + r32(p32[(y-2)%5][x+1])*matrix[18] + r32(p32[(y-2)%5][x+2])*matrix[19] + + r32(p32[(y-1)%5][x-2])*matrix[20] + r32(p32[(y-1)%5][x-1])*matrix[21] + r32(p32[(y-1)%5][x])*matrix[22] + r32(p32[(y-1)%5][x+1])*matrix[23] + r32(p32[(y-1)%5][x+2])*matrix[24])/scale - shift; + g = (g32(p32[(y-5)%5][x-2])*matrix[0] + g32(p32[(y-5)%5][x-1])*matrix[1] + g32(p32[(y-5)%5][x])*matrix[2] + g32(p32[(y-5)%5][x+1])*matrix[3] + g32(p32[(y-5)%5][x+2])*matrix[4] + + g32(p32[(y-4)%5][x-2])*matrix[5] + g32(p32[(y-4)%5][x-1])*matrix[6] + g32(p32[(y-3)%5][x])*matrix[7] + g32(p32[(y-4)%5][x+1])*matrix[8] + g32(p32[(y-4)%5][x+2])*matrix[9] + + g32(p32[(y-3)%5][x-2])*matrix[10] + g32(p32[(y-3)%5][x-1])*matrix[11] + g32(p32[(y-3)%5][x])*matrix[12] + g32(p32[(y-3)%5][x+1])*matrix[13] + g32(p32[(y-3)%5][x+2])*matrix[14] + + g32(p32[(y-2)%5][x-2])*matrix[15] + g32(p32[(y-2)%5][x-1])*matrix[16] + g32(p32[(y-2)%5][x])*matrix[17] + g32(p32[(y-2)%5][x+1])*matrix[18] + g32(p32[(y-2)%5][x+2])*matrix[19] + + g32(p32[(y-1)%5][x-2])*matrix[20] + g32(p32[(y-1)%5][x-1])*matrix[21] + g32(p32[(y-1)%5][x])*matrix[22] + g32(p32[(y-1)%5][x+1])*matrix[23] + g32(p32[(y-1)%5][x+2])*matrix[24])/scale - shift; + b = (b32(p32[(y-5)%5][x-2])*matrix[0] + b32(p32[(y-5)%5][x-1])*matrix[1] + b32(p32[(y-5)%5][x])*matrix[2] + b32(p32[(y-5)%5][x+1])*matrix[3] + b32(p32[(y-5)%5][x+2])*matrix[4] + + b32(p32[(y-4)%5][x-2])*matrix[5] + b32(p32[(y-4)%5][x-1])*matrix[6] + b32(p32[(y-3)%5][x])*matrix[7] + b32(p32[(y-4)%5][x+1])*matrix[8] + b32(p32[(y-4)%5][x+2])*matrix[9] + + b32(p32[(y-3)%5][x-2])*matrix[10] + b32(p32[(y-3)%5][x-1])*matrix[11] + b32(p32[(y-3)%5][x])*matrix[12] + b32(p32[(y-3)%5][x+1])*matrix[13] + b32(p32[(y-3)%5][x+2])*matrix[14] + + b32(p32[(y-2)%5][x-2])*matrix[15] + b32(p32[(y-2)%5][x-1])*matrix[16] + b32(p32[(y-2)%5][x])*matrix[17] + b32(p32[(y-2)%5][x+1])*matrix[18] + b32(p32[(y-2)%5][x+2])*matrix[19] + + b32(p32[(y-1)%5][x-2])*matrix[20] + b32(p32[(y-1)%5][x-1])*matrix[21] + b32(p32[(y-1)%5][x])*matrix[22] + b32(p32[(y-1)%5][x+1])*matrix[23] + b32(p32[(y-1)%5][x+2])*matrix[24])/scale - shift; + c32[x] = rgbtocolor32(klamp255(r), klamp255(g), klamp255(b)); + } + } + // read in lines needed for calculation + p32[y % 5] = scanline32(f, y); + } + break; + } +} + +void perform_copy(struct frame f1, struct frame f2, struct args a) +{ + printf("Using convolution as copy operation does nothing!\n"); +} diff --git a/Plugins/convolution.dll b/Plugins/convolution.dll Binary files differnew file mode 100644 index 0000000..68a6ed2 --- /dev/null +++ b/Plugins/convolution.dll diff --git a/Plugins/darken.c b/Plugins/darken.c new file mode 100644 index 0000000..a57b0b7 --- /dev/null +++ b/Plugins/darken.c @@ -0,0 +1,87 @@ +// +// darken - darken of two images +// +// written by Olaf Matthes <olaf.matthes@gmx.de> +// +// 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; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// usage: darken +// + +#include <stdlib.h> +#include "plugin.h" + +void perform_effect(struct frame f, struct args a) +{ + printf("Using darken as effect does nothing!\n"); +} + +void perform_copy(struct frame f1, struct frame f2, struct args a) +{ + short x, y, w, h; + long count = 0; + pixel16 *pix1_16, *pix2_16; + pixel24 *pix1_24, *pix2_24; + pixel32 *pix1_32, *pix2_32; + + w = f1.width<f2.width ? f1.width : f2.width; + h = f1.height<f2.height ? f1.height : f2.height; + + printf("darken\n"); + + switch(f1.pixelformat) + { + case 16: + // compare images pixel by pixel + for(y = 0; y < h; y++) + { + pix1_16 = scanline16(f1, y); + pix2_16 = scanline16(f2, y); + for(x = 0; x < w; x++) + { + pix2_16[x] = rgbtocolor16(klamp255(min(r16(pix1_16[x]), r16(pix2_16[x]))), + klamp255(min(g16(pix1_16[x]), g16(pix2_16[x]))), + klamp255(min(b16(pix1_16[x]), b16(pix2_16[x])))); + } + } + break; + case 24: + for(y = 0; y < h; y++) + { + pix1_24 = scanline24(f1, y); + pix2_24 = scanline24(f2, y); + for(x = 0; x < w; x++) + { + pix2_24[x] = rgbtocolor24(klamp255(min(r24(pix1_24[x]), r24(pix2_24[x]))), + klamp255(min(g24(pix1_24[x]), g24(pix2_24[x]))), + klamp255(min(b24(pix1_24[x]), b24(pix2_24[x])))); + } + } + break; + case 32: + for(y = 0; y < h; y++) + { + pix1_32 = scanline32(f1, y); + pix2_32 = scanline32(f2, y); + for(x = 0; x < w; x++) + { + pix2_32[x] = rgbtocolor32(klamp255(min(r32(pix1_32[x]), r32(pix2_32[x]))), + klamp255(min(g32(pix1_32[x]), g32(pix2_32[x]))), + klamp255(min(b32(pix1_32[x]), b32(pix2_32[x])))); + } + } + break; + } +} diff --git a/Plugins/darken.dll b/Plugins/darken.dll Binary files differnew file mode 100644 index 0000000..174e654 --- /dev/null +++ b/Plugins/darken.dll diff --git a/Plugins/deinterlace.c b/Plugins/deinterlace.c new file mode 100644 index 0000000..ca12568 --- /dev/null +++ b/Plugins/deinterlace.c @@ -0,0 +1,82 @@ +// +// deinterlace - deinterlacing through pixel / line repitition +// +// written by Olaf Matthes <olaf.matthes@gmx.de> +// +// 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; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// usage: deinterlace <line> [ with line = 0 or 1 ] +// + +#include <stdio.h> +#include <string.h> +#include "plugin.h" + +void perform_effect(struct frame f, struct args a) +{ + short x, y, line = 0; + byte pixelsize = f.pixelformat/8; + pixel16 *p16, *c16; + pixel24 *p24, *c24; + pixel32 *p32, *c32; + char *t; + + // get params + if(a.s) + { + line = atoi(a.s); + } // else keep 0 + + printf("deinterlace: %d\n", line); + + y = f.height - line; + x = f.width; + + switch(f.pixelformat) + { + case 16: + while(y > 0) + { + p16 = scanline16(f, y); + c16 = scanline16(f, y-1); + memcpy(p16, c16, x*pixelsize); + y -= 2; + } + break; + case 24: + while(y > 0) + { + p24 = scanline24(f, y); + c24 = scanline24(f, y-1); + memcpy(p24, c24, x*pixelsize); + y -= 2; + } + break; + case 32: + while(y > 0) + { + p32 = scanline32(f, y); + c32 = scanline32(f, y-1); + memcpy(p32, c32, x*pixelsize); + y -= 2; + } + break; + } +} + +void perform_copy(struct frame f1, struct frame f2, struct args a) +{ + printf("Using deinterlace as copy operation does nothing!\n"); +} diff --git a/Plugins/deinterlace.dll b/Plugins/deinterlace.dll Binary files differnew file mode 100644 index 0000000..7c5daf3 --- /dev/null +++ b/Plugins/deinterlace.dll diff --git a/Plugins/difference.c b/Plugins/difference.c new file mode 100644 index 0000000..f8c23d5 --- /dev/null +++ b/Plugins/difference.c @@ -0,0 +1,86 @@ +// +// difference - difference of two images +// +// written by Olaf Matthes <olaf.matthes@gmx.de> +// +// 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; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// usage: difference +// + +#include "plugin.h" + +void perform_effect(struct frame f, struct args a) +{ + printf("Using difference as effect does nothing!\n"); +} + +void perform_copy(struct frame f1, struct frame f2, struct args a) +{ + short x, y, w, h, ret; + long count = 0; + pixel16 *pix1_16, *pix2_16; + pixel24 *pix1_24, *pix2_24; + pixel32 *pix1_32, *pix2_32; + + w = f1.width<f2.width ? f1.width : f2.width; + h = f1.height<f2.height ? f1.height : f2.height; + + printf("difference\n"); + + switch(f1.pixelformat) + { + case 16: + // compare images pixel by pixel + for(y = 0; y < h; y++) + { + pix1_16 = scanline16(f1, y); + pix2_16 = scanline16(f2, y); + for(x = 0; x < w; x++) + { + pix2_16[x] = rgbtocolor16(klamp255(abs(r16(pix1_16[x])-r16(pix2_16[x]))), + klamp255(abs(g16(pix1_16[x])-g16(pix2_16[x]))), + klamp255(abs(b16(pix1_16[x])-b16(pix2_16[x])))); + } + } + break; + case 24: + for(y = 0; y < h; y++) + { + pix1_24 = scanline24(f1, y); + pix2_24 = scanline24(f2, y); + for(x = 0; x < w; x++) + { + pix2_24[x] = rgbtocolor24(klamp255(abs(r24(pix1_24[x])-r24(pix2_24[x]))), + klamp255(abs(g24(pix1_24[x])-g24(pix2_24[x]))), + klamp255(abs(b24(pix1_24[x])-b24(pix2_24[x])))); + } + } + break; + case 32: + for(y = 0; y < h; y++) + { + pix1_32 = scanline32(f1, y); + pix2_32 = scanline32(f2, y); + for(x = 0; x < w; x++) + { + pix2_32[x] = rgbtocolor32(klamp255(abs(r32(pix1_32[x])-r32(pix2_32[x]))), + klamp255(abs(g32(pix1_32[x])-g32(pix2_32[x]))), + klamp255(abs(b32(pix1_32[x])-b32(pix2_32[x])))); + } + } + break; + } +} diff --git a/Plugins/difference.dll b/Plugins/difference.dll Binary files differnew file mode 100644 index 0000000..de38787 --- /dev/null +++ b/Plugins/difference.dll diff --git a/Plugins/interlace.c b/Plugins/interlace.c new file mode 100644 index 0000000..1ea045f --- /dev/null +++ b/Plugins/interlace.c @@ -0,0 +1,83 @@ +// +// interlace - deinterlacing through pixel / line repitition +// +// written by Olaf Matthes <olaf.matthes@gmx.de> +// +// 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; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// usage: interlace <line> [ with line = 0 or 1 ] +// + +#include <stdio.h> +#include <string.h> +#include "plugin.h" + +void perform_effect(struct frame f, struct args a) +{ + printf("Using interlace as effect does nothing!\n"); +} + +void perform_copy(struct frame f1, struct frame f2, struct args a) +{ + short h, w, line = 0; + byte pixelsize = f1.pixelformat/8; + pixel16 *p16, *c16; + pixel24 *p24, *c24; + pixel32 *p32, *c32; + char *t; + + // get params + if(a.s) + { + line = atoi(a.s); + } // else keep 0 + + printf("interlace: %d\n", line); + + w = f1.width<f2.width ? f1.width : f2.width; + h = f1.height<f2.height ? f1.height : f2.height; + h -= line; + + switch(f1.pixelformat) + { + case 16: + while(h > 0) + { + p16 = scanline16(f1, h); + c16 = scanline16(f2, h); + memcpy(c16, p16, w*pixelsize); + h -= 2; + } + break; + case 24: + while(h > 0) + { + p24 = scanline24(f1, h); + c24 = scanline24(f2, h); + memcpy(c24, p24, w*pixelsize); + h -= 2; + } + break; + case 32: + while(h > 0) + { + p32 = scanline32(f1, h); + c32 = scanline32(f2, h); + memcpy(c32, p32, w*pixelsize); + h -= 2; + } + break; + } +} diff --git a/Plugins/interlace.dll b/Plugins/interlace.dll Binary files differnew file mode 100644 index 0000000..4c07025 --- /dev/null +++ b/Plugins/interlace.dll diff --git a/Plugins/lighten.c b/Plugins/lighten.c new file mode 100644 index 0000000..ef1a065 --- /dev/null +++ b/Plugins/lighten.c @@ -0,0 +1,87 @@ +// +// lighten - lighten of two images +// +// written by Olaf Matthes <olaf.matthes@gmx.de> +// +// 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; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// usage: lighten +// + +#include <stdlib.h> +#include "plugin.h" + +void perform_effect(struct frame f, struct args a) +{ + printf("Using lighten as effect does nothing!\n"); +} + +void perform_copy(struct frame f1, struct frame f2, struct args a) +{ + short x, y, w, h; + long count = 0; + pixel16 *pix1_16, *pix2_16; + pixel24 *pix1_24, *pix2_24; + pixel32 *pix1_32, *pix2_32; + + w = f1.width<f2.width ? f1.width : f2.width; + h = f1.height<f2.height ? f1.height : f2.height; + + printf("lighten\n"); + + switch(f1.pixelformat) + { + case 16: + // compare images pixel by pixel + for(y = 0; y < h; y++) + { + pix1_16 = scanline16(f1, y); + pix2_16 = scanline16(f2, y); + for(x = 0; x < w; x++) + { + pix2_16[x] = rgbtocolor16(klamp255(max(r16(pix1_16[x]), r16(pix2_16[x]))), + klamp255(max(g16(pix1_16[x]), g16(pix2_16[x]))), + klamp255(max(b16(pix1_16[x]), b16(pix2_16[x])))); + } + } + break; + case 24: + for(y = 0; y < h; y++) + { + pix1_24 = scanline24(f1, y); + pix2_24 = scanline24(f2, y); + for(x = 0; x < w; x++) + { + pix2_24[x] = rgbtocolor24(klamp255(max(r24(pix1_24[x]), r24(pix2_24[x]))), + klamp255(max(g24(pix1_24[x]), g24(pix2_24[x]))), + klamp255(max(b24(pix1_24[x]), b24(pix2_24[x])))); + } + } + break; + case 32: + for(y = 0; y < h; y++) + { + pix1_32 = scanline32(f1, y); + pix2_32 = scanline32(f2, y); + for(x = 0; x < w; x++) + { + pix2_32[x] = rgbtocolor32(klamp255(max(r32(pix1_32[x]), r32(pix2_32[x]))), + klamp255(max(g32(pix1_32[x]), g32(pix2_32[x]))), + klamp255(max(b32(pix1_32[x]), b32(pix2_32[x])))); + } + } + break; + } +} diff --git a/Plugins/lighten.dll b/Plugins/lighten.dll Binary files differnew file mode 100644 index 0000000..8ef79aa --- /dev/null +++ b/Plugins/lighten.dll diff --git a/Plugins/multiply.c b/Plugins/multiply.c new file mode 100644 index 0000000..45aa9bb --- /dev/null +++ b/Plugins/multiply.c @@ -0,0 +1,85 @@ +// +// multiply - multiply of two images +// +// written by Olaf Matthes <olaf.matthes@gmx.de> +// +// 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; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// usage: multiply +// + +#include "plugin.h" + +void perform_effect(struct frame f, struct args a) +{ + printf("Using multiply as effect does nothing!\n"); +} + +void perform_copy(struct frame f1, struct frame f2, struct args a) +{ + short x, y, w, h; + pixel16 *pix1_16, *pix2_16; + pixel24 *pix1_24, *pix2_24; + pixel32 *pix1_32, *pix2_32; + + w = f1.width<f2.width ? f1.width : f2.width; + h = f1.height<f2.height ? f1.height : f2.height; + + printf("multiply\n"); + + switch(f1.pixelformat) + { + case 16: + // compare images pixel by pixel + for(y = 0; y < h; y++) + { + pix1_16 = scanline16(f1, y); + pix2_16 = scanline16(f2, y); + for(x = 0; x < w; x++) + { + pix2_16[x] = rgbtocolor16(klamp255(r16(pix1_16[x])*r16(pix2_16[x])/255), + klamp255(g16(pix1_16[x])*g16(pix2_16[x])/255), + klamp255(b16(pix1_16[x])*b16(pix2_16[x])/255)); + } + } + break; + case 24: + for(y = 0; y < h; y++) + { + pix1_24 = scanline24(f1, y); + pix2_24 = scanline24(f2, y); + for(x = 0; x < w; x++) + { + pix2_24[x] = rgbtocolor24(klamp255(r24(pix1_24[x])*r24(pix2_24[x])/255), + klamp255(g24(pix1_24[x])*g24(pix2_24[x])/255), + klamp255(b24(pix1_24[x])*b24(pix2_24[x])/255)); + } + } + break; + case 32: + for(y = 0; y < h; y++) + { + pix1_32 = scanline32(f1, y); + pix2_32 = scanline32(f2, y); + for(x = 0; x < w; x++) + { + pix2_32[x] = rgbtocolor32(klamp255(r32(pix1_32[x])*r32(pix2_32[x])/255), + klamp255(g32(pix1_32[x])*g32(pix2_32[x])/255), + klamp255(b32(pix1_32[x])*b32(pix2_32[x])/255)); + } + } + break; + } +} diff --git a/Plugins/multiply.dll b/Plugins/multiply.dll Binary files differnew file mode 100644 index 0000000..be177db --- /dev/null +++ b/Plugins/multiply.dll diff --git a/Plugins/overlay.c b/Plugins/overlay.c new file mode 100644 index 0000000..99ab68e --- /dev/null +++ b/Plugins/overlay.c @@ -0,0 +1,90 @@ +// +// overlay - overlay of two images +// +// written by Olaf Matthes <olaf.matthes@gmx.de> +// +// 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; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// usage: overlay +// + +#include <stdlib.h> +#include "plugin.h" + +void perform_effect(struct frame f, struct args a) +{ + printf("Using overlay as effect does nothing!\n"); +} + +void perform_copy(struct frame f1, struct frame f2, struct args a) +{ + short x, y, w, h; + pixel16 *pix1_16, *pix2_16; + pixel24 *pix1_24, *pix2_24; + pixel32 *pix1_32, *pix2_32; + byte r, g, b; + + w = f1.width<f2.width ? f1.width : f2.width; + h = f1.height<f2.height ? f1.height : f2.height; + + printf("overlay\n"); + + switch(f1.pixelformat) + { + case 16: + // compare images pixel by pixel + for(y = 0; y < h; y++) + { + pix1_16 = scanline16(f1, y); + pix2_16 = scanline16(f2, y); + for(x = 0; x < w; x++) + { + r = klamp255(r16(pix1_16[x]) < 128 ? (2*r16(pix1_16[x])*r16(pix2_16[x])/255) : 255-2*(255-r16(pix1_16[x]))*(255-r16(pix2_16[x]))/255); + g = klamp255(g16(pix1_16[x]) < 128 ? (2*g16(pix1_16[x])*g16(pix2_16[x])/255) : 255-2*(255-g16(pix1_16[x]))*(255-g16(pix2_16[x]))/255); + b = klamp255(b16(pix1_16[x]) < 128 ? (2*b16(pix1_16[x])*b16(pix2_16[x])/255) : 255-2*(255-b16(pix1_16[x]))*(255-b16(pix2_16[x]))/255); + pix2_16[x] = rgbtocolor16(r, g, b); + } + } + break; + case 24: + for(y = 0; y < h; y++) + { + pix1_24 = scanline24(f1, y); + pix2_24 = scanline24(f2, y); + for(x = 0; x < w; x++) + { + r = klamp255(r24(pix1_24[x]) < 128 ? (2*r24(pix1_24[x])*r24(pix2_24[x])/255) : 255-2*(255-r24(pix1_24[x]))*(255-r24(pix2_24[x]))/255); + g = klamp255(g24(pix1_24[x]) < 128 ? (2*g24(pix1_24[x])*g24(pix2_24[x])/255) : 255-2*(255-g24(pix1_24[x]))*(255-g24(pix2_24[x]))/255); + b = klamp255(b24(pix1_24[x]) < 128 ? (2*b24(pix1_24[x])*b24(pix2_24[x])/255) : 255-2*(255-b24(pix1_24[x]))*(255-b24(pix2_24[x]))/255); + pix2_24[x] = rgbtocolor24(r, g, b); + } + } + break; + case 32: + for(y = 0; y < h; y++) + { + pix1_32 = scanline32(f1, y); + pix2_32 = scanline32(f2, y); + for(x = 0; x < w; x++) + { + r = klamp255(r32(pix1_32[x]) < 128 ? (2*r32(pix1_32[x])*r32(pix2_32[x])/255) : 255-2*(255-r32(pix1_32[x]))*(255-r32(pix2_32[x]))/255); + g = klamp255(g32(pix1_32[x]) < 128 ? (2*g32(pix1_32[x])*g32(pix2_32[x])/255) : 255-2*(255-g32(pix1_32[x]))*(255-g32(pix2_32[x]))/255); + b = klamp255(b32(pix1_32[x]) < 128 ? (2*b32(pix1_32[x])*b32(pix2_32[x])/255) : 255-2*(255-b32(pix1_32[x]))*(255-b32(pix2_32[x]))/255); + pix2_32[x] = rgbtocolor32(r, g, b); + } + } + break; + } +} diff --git a/Plugins/overlay.dll b/Plugins/overlay.dll Binary files differnew file mode 100644 index 0000000..fc6771e --- /dev/null +++ b/Plugins/overlay.dll diff --git a/Plugins/screen.c b/Plugins/screen.c new file mode 100644 index 0000000..76fd6bd --- /dev/null +++ b/Plugins/screen.c @@ -0,0 +1,90 @@ +// +// screen - screen of two images +// +// written by Olaf Matthes <olaf.matthes@gmx.de> +// +// 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; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// usage: screen +// + +#include <stdlib.h> +#include "plugin.h" + +void perform_effect(struct frame f, struct args a) +{ + printf("Using screen as effect does nothing!\n"); +} + +void perform_copy(struct frame f1, struct frame f2, struct args a) +{ + short x, y, w, h; + pixel16 *pix1_16, *pix2_16; + pixel24 *pix1_24, *pix2_24; + pixel32 *pix1_32, *pix2_32; + byte r, g, b; + + w = f1.width<f2.width ? f1.width : f2.width; + h = f1.height<f2.height ? f1.height : f2.height; + + printf("difference\n"); + + switch(f1.pixelformat) + { + case 16: + // compare images pixel by pixel + for(y = 0; y < h; y++) + { + pix1_16 = scanline16(f1, y); + pix2_16 = scanline16(f2, y); + for(x = 0; x < w; x++) + { + r = klamp255(255 - ( (255-r16(pix1_16[x])) * (255-r16(pix2_16[x]) ) / 255 )); + g = klamp255(255 - ( (255-g16(pix1_16[x])) * (255-g16(pix2_16[x]) ) / 255 )); + b = klamp255(255 - ( (255-b16(pix1_16[x])) * (255-b16(pix2_16[x]) ) / 255 )); + pix2_16[x] = rgbtocolor16(r, g, b); + } + } + break; + case 24: + for(y = 0; y < h; y++) + { + pix1_24 = scanline24(f1, y); + pix2_24 = scanline24(f2, y); + for(x = 0; x < w; x++) + { + r = klamp255(255 - ( (255-r24(pix1_24[x])) * (255-r24(pix2_24[x]) ) / 255 )); + g = klamp255(255 - ( (255-g24(pix1_24[x])) * (255-g24(pix2_24[x]) ) / 255 )); + b = klamp255(255 - ( (255-b24(pix1_24[x])) * (255-b24(pix2_24[x]) ) / 255 )); + pix2_24[x] = rgbtocolor24(r, g, b); + } + } + break; + case 32: + for(y = 0; y < h; y++) + { + pix1_32 = scanline32(f1, y); + pix2_32 = scanline32(f2, y); + for(x = 0; x < w; x++) + { + r = klamp255(255 - ( (255-r32(pix1_32[x])) * (255-r32(pix2_32[x]) ) / 255 )); + g = klamp255(255 - ( (255-g32(pix1_32[x])) * (255-g32(pix2_32[x]) ) / 255 )); + b = klamp255(255 - ( (255-b32(pix1_32[x])) * (255-b32(pix2_32[x]) ) / 255 )); + pix2_32[x] = rgbtocolor32(r, g, b); + } + } + break; + } +} diff --git a/Plugins/screen.dll b/Plugins/screen.dll Binary files differnew file mode 100644 index 0000000..5b6f3c6 --- /dev/null +++ b/Plugins/screen.dll diff --git a/Plugins/shadowcaster.c b/Plugins/shadowcaster.c new file mode 100644 index 0000000..0411c79 --- /dev/null +++ b/Plugins/shadowcaster.c @@ -0,0 +1,417 @@ +// +// shadowcaster - porduce a cutout with shadow +// +// written by Olaf Matthes <olaf.matthes@gmx.de> +// +// 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; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// usage: shadowcaster <x_c> <y_c> <w_c> <h_c> <shadow width> <red intensity> <green intensity> <blue intensity> +// + +#include <stdlib.h> +#include <string.h> +#include <math.h> +#include "plugin.h" +#include "tools.h" + +#define MAX_SHADOW 128 /* maximum shadow width in px */ + +void perform_effect(struct frame f, struct args a) +{ + short x, y; + short x_c, y_c, w_c, h_c; // position and dimension of cutout + byte pixelsize = f.pixelformat/8; + pixel16 *pix16[MAX_SHADOW], *c16; + pixel24 *pix24[MAX_SHADOW], *c24; + pixel32 *pix32[MAX_SHADOW], *c32; + long r, g, b; + byte shadow, red, green, blue; + char *t; + + // get params + if(!a.s) return; + x_c = atoi(a.s); + if(!(t = strstr(a.s, " "))) return; + y_c = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + w_c = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + h_c = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + shadow = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + red = klamp255(atoi(t+1)); + if(!(t = strstr(t+1, " "))) return; + green = klamp255(atoi(t+1)); + if(!(t = strstr(t+1, " "))) return; + blue = klamp255(atoi(t+1)); + // check image boundaries + if(shadow > MAX_SHADOW)shadow = MAX_SHADOW; + if(shadow > x_c)shadow = x_c; + if(x_c + w_c + shadow > f.width) x_c -= ((x_c + w_c + shadow) - f.width); + if(y_c + h_c + shadow > f.height) y_c -= ((y_c + h_c + shadow) - f.height); + + printf("shadowcaster x%d y%d w%d h%d s%d - r%d g%d b%d\n", + x_c, y_c, w_c, h_c, shadow, red, green, blue); + + // allocate memory for cutout + for(y = 0; y < shadow; y++) + { + switch(f.pixelformat) + { + case 16: + pix16[y] = malloc(f.width*pixelsize); + if(!pix16[y])return; + break; + case 24: + pix24[y] = malloc(f.width*pixelsize); + if(!pix24[y])return; + break; + case 32: + pix32[y] = malloc(f.width*pixelsize); + if(!pix32[y])return; + break; + } + } + + switch(f.pixelformat) + { + case 16: + for(y = y_c - shadow - 1; y < y_c + h_c + shadow; y++) + { + c16 = scanline16(f, y); + memcpy(pix16[y % shadow], c16, f.width*pixelsize); // make copy of original image + if(y > y_c) // only process relevant lines + { + for(x = x_c; x < x_c + w_c + shadow; x++) + { + if(x >= x_c) + if((x > x_c + shadow - 1) && (y > y_c + shadow - 1)) // no shadow, just move cutout image + { + r = r16(pix16[(y-shadow) % shadow][x-shadow]); + g = g16(pix16[(y-shadow) % shadow][x-shadow]); + b = b16(pix16[(y-shadow) % shadow][x-shadow]); + } + else if((x < x_c + shadow) && (y > y_c + shadow-1)) // apply left shadow + { + r = (scl(x-x_c,0,shadow-1,red,255) * r16(pix16[(y-shadow) % shadow][x-shadow]))/255; + g = (scl(x-x_c,0,shadow-1,green,255) * g16(pix16[(y-shadow) % shadow][x-shadow]))/255; + b = (scl(x-x_c,0,shadow-1,blue,255) * b16(pix16[(y-shadow) % shadow][x-shadow]))/255; + } + else if((x > x_c + shadow-1) && (y < y_c + shadow)) // apply top shadow + { + r = (scl(y-y_c,0,shadow-1,red,255) * r16(pix16[(y-shadow) % shadow][x-shadow]))/255; + g = (scl(y-y_c,0,shadow-1,green,255) * g16(pix16[(y-shadow) % shadow][x-shadow]))/255; + b = (scl(y-y_c,0,shadow-1,blue,255) * b16(pix16[(y-shadow) % shadow][x-shadow]))/255; + } + else // apply top and left shadow together + { + r = (min(scl(x-x_c,0,shadow-1,red,255),scl(y-y_c,0,shadow-1,red,255)) * r16(pix16[(y-shadow) % shadow][x-shadow]))/255; + g = (min(scl(x-x_c,0,shadow-1,green,255),scl(y-y_c,0,shadow-1,green,255)) * g16(pix16[(y-shadow) % shadow][x-shadow]))/255; + b = (min(scl(x-x_c,0,shadow-1,blue,255),scl(y-y_c,0,shadow-1,blue,255)) * b16(pix16[(y-shadow) % shadow][x-shadow]))/255; + } + c16[x] = rgbtocolor16(klamp255(r), klamp255(g), klamp255(b)); + } + } + } + break; + case 24: + for(y = y_c - shadow - 1; y < y_c + h_c + shadow; y++) + { + c24 = scanline24(f, y); + memcpy(pix24[y % shadow], c24, f.width*pixelsize); // make copy of original image + if(y > y_c) // only process relevant lines + { + for(x = x_c; x < x_c + w_c + shadow; x++) + { + if(x >= x_c) + if((x > x_c + shadow - 1) && (y > y_c + shadow - 1)) // no shadow, just move cutout image + { + r = r24(pix24[(y-shadow) % shadow][x-shadow]); + g = g24(pix24[(y-shadow) % shadow][x-shadow]); + b = b24(pix24[(y-shadow) % shadow][x-shadow]); + } + else if((x < x_c + shadow) && (y > y_c + shadow-1)) // apply left shadow + { + r = (scl(x-x_c,0,shadow-1,red,255) * r24(pix24[(y-shadow) % shadow][x-shadow]))/255; + g = (scl(x-x_c,0,shadow-1,green,255) * g24(pix24[(y-shadow) % shadow][x-shadow]))/255; + b = (scl(x-x_c,0,shadow-1,blue,255) * b24(pix24[(y-shadow) % shadow][x-shadow]))/255; + } + else if((x > x_c + shadow-1) && (y < y_c + shadow)) // apply top shadow + { + r = (scl(y-y_c,0,shadow-1,red,255) * r24(pix24[(y-shadow) % shadow][x-shadow]))/255; + g = (scl(y-y_c,0,shadow-1,green,255) * g24(pix24[(y-shadow) % shadow][x-shadow]))/255; + b = (scl(y-y_c,0,shadow-1,blue,255) * b24(pix24[(y-shadow) % shadow][x-shadow]))/255; + } + else // apply top and left shadow together + { + r = (min(scl(x-x_c,0,shadow-1,red,255),scl(y-y_c,0,shadow-1,red,255)) * r24(pix24[(y-shadow) % shadow][x-shadow]))/255; + g = (min(scl(x-x_c,0,shadow-1,green,255),scl(y-y_c,0,shadow-1,green,255)) * g24(pix24[(y-shadow) % shadow][x-shadow]))/255; + b = (min(scl(x-x_c,0,shadow-1,blue,255),scl(y-y_c,0,shadow-1,blue,255)) * b24(pix24[(y-shadow) % shadow][x-shadow]))/255; + } + c24[x] = rgbtocolor24(klamp255(r), klamp255(g), klamp255(b)); + } + } + } + break; + case 32: + for(y = y_c - shadow - 1; y < y_c + h_c + shadow; y++) + { + c32 = scanline32(f, y); + memcpy(pix32[y % shadow], c32, f.width*pixelsize); // make copy of original image + if(y > y_c) // only process relevant lines + { + for(x = x_c; x < x_c + w_c + shadow; x++) + { + if(x >= x_c) + if((x > x_c + shadow - 1) && (y > y_c + shadow - 1)) // no shadow, just move cutout image + { + r = r32(pix32[(y-shadow) % shadow][x-shadow]); + g = g32(pix32[(y-shadow) % shadow][x-shadow]); + b = b32(pix32[(y-shadow) % shadow][x-shadow]); + } + else if((x < x_c + shadow) && (y > y_c + shadow-1)) // apply left shadow + { + r = (scl(x-x_c,0,shadow-1,red,255) * r32(pix32[(y-shadow) % shadow][x-shadow]))/255; + g = (scl(x-x_c,0,shadow-1,green,255) * g32(pix32[(y-shadow) % shadow][x-shadow]))/255; + b = (scl(x-x_c,0,shadow-1,blue,255) * b32(pix32[(y-shadow) % shadow][x-shadow]))/255; + } + else if((x > x_c + shadow-1) && (y < y_c + shadow)) // apply top shadow + { + r = (scl(y-y_c,0,shadow-1,red,255) * r32(pix32[(y-shadow) % shadow][x-shadow]))/255; + g = (scl(y-y_c,0,shadow-1,green,255) * g32(pix32[(y-shadow) % shadow][x-shadow]))/255; + b = (scl(y-y_c,0,shadow-1,blue,255) * b32(pix32[(y-shadow) % shadow][x-shadow]))/255; + } + else // apply top and left shadow together + { + r = (min(scl(x-x_c,0,shadow-1,red,255),scl(y-y_c,0,shadow-1,red,255)) * r32(pix32[(y-shadow) % shadow][x-shadow]))/255; + g = (min(scl(x-x_c,0,shadow-1,green,255),scl(y-y_c,0,shadow-1,green,255)) * g32(pix32[(y-shadow) % shadow][x-shadow]))/255; + b = (min(scl(x-x_c,0,shadow-1,blue,255),scl(y-y_c,0,shadow-1,blue,255)) * b32(pix32[(y-shadow) % shadow][x-shadow]))/255; + } + c32[x] = rgbtocolor32(klamp255(r), klamp255(g), klamp255(b)); + } + } + } + break; + } + + // free memory for cutout + for(y = 0; y < shadow; y++) + { + switch(f.pixelformat) + { + case 16: + free(pix16[y]); + break; + case 24: + free(pix24[y]); + break; + case 32: + free(pix32[y]); + break; + } + } +} + +void perform_copy(struct frame f1, struct frame f2, struct args a) +{ + short x, y, w, h; + short x_c, y_c, w_c, h_c; // position and dimension of cutout + byte pixelsize = f1.pixelformat/8; + pixel16 *pix16[MAX_SHADOW], *c16; + pixel24 *pix24[MAX_SHADOW], *c24; + pixel32 *pix32[MAX_SHADOW], *c32; + long r, g, b; + byte shadow, red, green, blue; + char *t; + + w = f1.width<f2.width ? f1.width : f2.width; + h = f1.height<f2.height ? f1.height : f2.height; + + // get params + if(!a.s) return; + x_c = atoi(a.s); + if(!(t = strstr(a.s, " "))) return; + y_c = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + w_c = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + h_c = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + shadow = atoi(t+1); + if(!(t = strstr(t+1, " "))) return; + red = klamp255(atoi(t+1)); + if(!(t = strstr(t+1, " "))) return; + green = klamp255(atoi(t+1)); + if(!(t = strstr(t+1, " "))) return; + blue = klamp255(atoi(t+1)); + + // check image boundaries + if(shadow > MAX_SHADOW)shadow = MAX_SHADOW; + if(shadow > x_c)shadow = x_c; + if(x_c + w_c + shadow > w) x_c -= ((x_c + w_c + shadow) - w); + if(y_c + h_c + shadow > h) y_c -= ((y_c + h_c + shadow) - h); + + printf("shadowcaster x%d y%d w%d h%d s%d - r%d g%d b%d\n", + x_c, y_c, w_c, h_c, shadow, red, green, blue); + + switch(f1.pixelformat) + { + case 16: + for(y = y_c - shadow - 1; y < y_c + h_c + shadow; y++) + { + pix16[y % shadow] = scanline16(f1, y); // read in lines we use later on + c16 = scanline16(f2, y); + if(y > y_c) // only process relevant lines + { + for(x = x_c; x < x_c + w_c + shadow; x++) + { + if(x >= x_c) + if((x > x_c + shadow - 1) && (y > y_c + shadow - 1)) // no shadow, just move cutout image + { + r = r16(pix16[(y-shadow) % shadow][x-shadow]); + g = g16(pix16[(y-shadow) % shadow][x-shadow]); + b = b16(pix16[(y-shadow) % shadow][x-shadow]); + } + else if((x < x_c + shadow) && (y > y_c + shadow-1)) // apply left shadow + { + r = ((scl(x-x_c,0,shadow-1,red,255) * r16(pix16[(y-shadow) % shadow][x-shadow]))/255) + + (((255-scl(x-x_c,0,shadow-1,red,255)) * r16(c16[x]))/255); + g = ((scl(x-x_c,0,shadow-1,green,255) * g16(pix16[(y-shadow) % shadow][x-shadow]))/255) + + (((255-scl(x-x_c,0,shadow-1,green,255)) * g16(c16[x]))/255); + b = ((scl(x-x_c,0,shadow-1,blue,255) * b16(pix16[(y-shadow) % shadow][x-shadow]))/255) + + (((255-scl(x-x_c,0,shadow-1,blue,255)) * b16(c16[x]))/255); + } + else if((x > x_c + shadow-1) && (y < y_c + shadow)) // apply top shadow + { + r = ((scl(y-y_c,0,shadow-1,red,255) * r16(pix16[(y-shadow) % shadow][x-shadow]))/255) + + (((255-scl(y-y_c,0,shadow-1,red,255)) * r16(c16[x]))/255); + g = ((scl(y-y_c,0,shadow-1,green,255) * g16(pix16[(y-shadow) % shadow][x-shadow]))/255) + + (((255-scl(y-y_c,0,shadow-1,green,255)) * g16(c16[x]))/255); + b = ((scl(y-y_c,0,shadow-1,blue,255) * b16(pix16[(y-shadow) % shadow][x-shadow]))/255) + + (((255-scl(y-y_c,0,shadow-1,blue,255)) * b16(c16[x]))/255); + } + else // apply top and left shadow together + { + r = ((min(scl(x-x_c,0,shadow-1,red,255),scl(y-y_c,0,shadow-1,red,255)) * r16(pix16[(y-shadow) % shadow][x-shadow]))/255) + + (((255-min(scl(x-x_c,0,shadow-1,red,255),scl(y-y_c,0,shadow-1,red,255))) * r16(c16[x]))/255); + g = ((min(scl(x-x_c,0,shadow-1,green,255),scl(y-y_c,0,shadow-1,green,255)) * g16(pix16[(y-shadow) % shadow][x-shadow]))/255) + + (((255-min(scl(x-x_c,0,shadow-1,green,255),scl(y-y_c,0,shadow-1,green,255))) * g16(c16[x]))/255); + b = ((min(scl(x-x_c,0,shadow-1,blue,255),scl(y-y_c,0,shadow-1,blue,255)) * b16(pix16[(y-shadow) % shadow][x-shadow]))/255) + + (((255-min(scl(x-x_c,0,shadow-1,blue,255),scl(y-y_c,0,shadow-1,blue,255))) * b16(c16[x]))/255); + } + c16[x] = rgbtocolor16(klamp255(r), klamp255(g), klamp255(b)); + } + } + } + break; + case 24: + for(y = y_c - shadow - 1; y < y_c + h_c + shadow; y++) + { + pix24[y % shadow] = scanline24(f1, y); // read in lines we use later on + c24 = scanline24(f2, y); + if(y > y_c) // only process relevant lines + { + for(x = x_c; x < x_c + w_c + shadow; x++) + { + if(x >= x_c) + if((x > x_c + shadow - 1) && (y > y_c + shadow - 1)) // no shadow, just move cutout image + { + r = r24(pix24[(y-shadow) % shadow][x-shadow]); + g = g24(pix24[(y-shadow) % shadow][x-shadow]); + b = b24(pix24[(y-shadow) % shadow][x-shadow]); + } + else if((x < x_c + shadow) && (y > y_c + shadow-1)) // apply left shadow + { + r = ((scl(x-x_c,0,shadow-1,red,255) * r24(pix24[(y-shadow) % shadow][x-shadow]))/255) + + (((255-scl(x-x_c,0,shadow-1,red,255)) * r24(c24[x]))/255); + g = ((scl(x-x_c,0,shadow-1,green,255) * g24(pix24[(y-shadow) % shadow][x-shadow]))/255) + + (((255-scl(x-x_c,0,shadow-1,green,255)) * g24(c24[x]))/255); + b = ((scl(x-x_c,0,shadow-1,blue,255) * b24(pix24[(y-shadow) % shadow][x-shadow]))/255) + + (((255-scl(x-x_c,0,shadow-1,blue,255)) * b24(c24[x]))/255); + } + else if((x > x_c + shadow-1) && (y < y_c + shadow)) // apply top shadow + { + r = ((scl(y-y_c,0,shadow-1,red,255) * r24(pix24[(y-shadow) % shadow][x-shadow]))/255) + + (((255-scl(y-y_c,0,shadow-1,red,255)) * r24(c24[x]))/255); + g = ((scl(y-y_c,0,shadow-1,green,255) * g24(pix24[(y-shadow) % shadow][x-shadow]))/255) + + (((255-scl(y-y_c,0,shadow-1,green,255)) * g24(c24[x]))/255); + b = ((scl(y-y_c,0,shadow-1,blue,255) * b24(pix24[(y-shadow) % shadow][x-shadow]))/255) + + (((255-scl(y-y_c,0,shadow-1,blue,255)) * b24(c24[x]))/255); + } + else // apply top and left shadow together + { + r = ((min(scl(x-x_c,0,shadow-1,red,255),scl(y-y_c,0,shadow-1,red,255)) * r24(pix24[(y-shadow) % shadow][x-shadow]))/255) + + (((255-min(scl(x-x_c,0,shadow-1,red,255),scl(y-y_c,0,shadow-1,red,255))) * r24(c24[x]))/255); + g = ((min(scl(x-x_c,0,shadow-1,green,255),scl(y-y_c,0,shadow-1,green,255)) * g24(pix24[(y-shadow) % shadow][x-shadow]))/255) + + (((255-min(scl(x-x_c,0,shadow-1,green,255),scl(y-y_c,0,shadow-1,green,255))) * g24(c24[x]))/255); + b = ((min(scl(x-x_c,0,shadow-1,blue,255),scl(y-y_c,0,shadow-1,blue,255)) * b24(pix24[(y-shadow) % shadow][x-shadow]))/255) + + (((255-min(scl(x-x_c,0,shadow-1,blue,255),scl(y-y_c,0,shadow-1,blue,255))) * b24(c24[x]))/255); + } + c24[x] = rgbtocolor24(klamp255(r), klamp255(g), klamp255(b)); + } + } + } + break; + case 32: + for(y = y_c - shadow - 1; y < y_c + h_c + shadow; y++) + { + pix32[y % shadow] = scanline32(f1, y); // read in lines we use later on + c32 = scanline32(f2, y); + if(y > y_c) // only process relevant lines + { + for(x = x_c; x < x_c + w_c + shadow; x++) + { + if(x >= x_c) + if((x > x_c + shadow - 1) && (y > y_c + shadow - 1)) // no shadow, just move cutout image + { + r = r32(pix32[(y-shadow) % shadow][x-shadow]); + g = g32(pix32[(y-shadow) % shadow][x-shadow]); + b = b32(pix32[(y-shadow) % shadow][x-shadow]); + } + else if((x < x_c + shadow) && (y > y_c + shadow-1)) // apply left shadow + { + r = ((scl(x-x_c,0,shadow-1,red,255) * r32(pix32[(y-shadow) % shadow][x-shadow]))/255) + + (((255-scl(x-x_c,0,shadow-1,red,255)) * r32(c32[x]))/255); + g = ((scl(x-x_c,0,shadow-1,green,255) * g32(pix32[(y-shadow) % shadow][x-shadow]))/255) + + (((255-scl(x-x_c,0,shadow-1,green,255)) * g32(c32[x]))/255); + b = ((scl(x-x_c,0,shadow-1,blue,255) * b32(pix32[(y-shadow) % shadow][x-shadow]))/255) + + (((255-scl(x-x_c,0,shadow-1,blue,255)) * b32(c32[x]))/255); + } + else if((x > x_c + shadow-1) && (y < y_c + shadow)) // apply top shadow + { + r = ((scl(y-y_c,0,shadow-1,red,255) * r32(pix32[(y-shadow) % shadow][x-shadow]))/255) + + (((255-scl(y-y_c,0,shadow-1,red,255)) * r32(c32[x]))/255); + g = ((scl(y-y_c,0,shadow-1,green,255) * g32(pix32[(y-shadow) % shadow][x-shadow]))/255) + + (((255-scl(y-y_c,0,shadow-1,green,255)) * g32(c32[x]))/255); + b = ((scl(y-y_c,0,shadow-1,blue,255) * b32(pix32[(y-shadow) % shadow][x-shadow]))/255) + + (((255-scl(y-y_c,0,shadow-1,blue,255)) * b32(c32[x]))/255); + } + else // apply top and left shadow together + { + r = ((min(scl(x-x_c,0,shadow-1,red,255),scl(y-y_c,0,shadow-1,red,255)) * r32(pix32[(y-shadow) % shadow][x-shadow]))/255) + + (((255-min(scl(x-x_c,0,shadow-1,red,255),scl(y-y_c,0,shadow-1,red,255))) * r32(c32[x]))/255); + g = ((min(scl(x-x_c,0,shadow-1,green,255),scl(y-y_c,0,shadow-1,green,255)) * g32(pix32[(y-shadow) % shadow][x-shadow]))/255) + + (((255-min(scl(x-x_c,0,shadow-1,green,255),scl(y-y_c,0,shadow-1,green,255))) * g32(c32[x]))/255); + b = ((min(scl(x-x_c,0,shadow-1,blue,255),scl(y-y_c,0,shadow-1,blue,255)) * b32(pix32[(y-shadow) % shadow][x-shadow]))/255) + + (((255-min(scl(x-x_c,0,shadow-1,blue,255),scl(y-y_c,0,shadow-1,blue,255))) * b32(c32[x]))/255); + } + c32[x] = rgbtocolor32(klamp255(r), klamp255(g), klamp255(b)); + } + } + } + break; + } +} diff --git a/Plugins/shadowcaster.dll b/Plugins/shadowcaster.dll Binary files differnew file mode 100644 index 0000000..7e2137d --- /dev/null +++ b/Plugins/shadowcaster.dll diff --git a/Plugins/softlight.c b/Plugins/softlight.c new file mode 100644 index 0000000..90dc4b0 --- /dev/null +++ b/Plugins/softlight.c @@ -0,0 +1,92 @@ +// +// softlight - softlight overlay of two images +// +// written by Olaf Matthes <olaf.matthes@gmx.de> +// +// 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; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// usage: softlight +// + +#include <stdlib.h> +#include "plugin.h" +#include "tools.h" + +void perform_effect(struct frame f, struct args a) +{ + printf("Using softlight as effect does nothing!\n"); +} + +void perform_copy(struct frame f1, struct frame f2, struct args a) +{ + short x, y, w, h; + pixel16 *pix1_16, *pix2_16; + pixel24 *pix1_24, *pix2_24; + pixel32 *pix1_32, *pix2_32; + byte r, g, b; + char *t; + + w = f1.width<f2.width ? f1.width : f2.width; + h = f1.height<f2.height ? f1.height : f2.height; + + printf("soft light\n"); + + switch(f1.pixelformat) + { + case 16: + // compare images pixel by pixel + for(y = 0; y < h; y++) + { + pix1_16 = scanline16(f1, y); + pix2_16 = scanline16(f2, y); + for(x = 0; x < w; x++) + { + r = klamp255(r16(pix1_16[x]) < 128 ? 2*scl(r16(pix2_16[x]),0,255,64,192)*r16(pix1_16[x])/255 : 255-(2*(255-scl(r16(pix2_16[x]),0,255,64,192))*(255-r16(pix1_16[x]))/255)); + g = klamp255(g16(pix1_16[x]) < 128 ? 2*scl(g16(pix2_16[x]),0,255,64,192)*g16(pix1_16[x])/255 : 255-(2*(255-scl(g16(pix2_16[x]),0,255,64,192))*(255-g16(pix1_16[x]))/255)); + b = klamp255(b16(pix1_16[x]) < 128 ? 2*scl(b16(pix2_16[x]),0,255,64,192)*b16(pix1_16[x])/255 : 255-(2*(255-scl(b16(pix2_16[x]),0,255,64,192))*(255-b16(pix1_16[x]))/255)); + pix2_16[x] = rgbtocolor16(r, g, b); + } + } + break; + case 24: + for(y = 0; y < h; y++) + { + pix1_24 = scanline24(f1, y); + pix2_24 = scanline24(f2, y); + for(x = 0; x < w; x++) + { + r = klamp255(r24(pix1_24[x]) < 128 ? 2*scl(r24(pix2_24[x]),0,255,64,192)*r24(pix1_24[x])/255 : 255-(2*(255-scl(r24(pix2_24[x]),0,255,64,192))*(255-r24(pix1_24[x]))/255)); + g = klamp255(g24(pix1_24[x]) < 128 ? 2*scl(g24(pix2_24[x]),0,255,64,192)*g24(pix1_24[x])/255 : 255-(2*(255-scl(g24(pix2_24[x]),0,255,64,192))*(255-g24(pix1_24[x]))/255)); + b = klamp255(b24(pix1_24[x]) < 128 ? 2*scl(b24(pix2_24[x]),0,255,64,192)*b24(pix1_24[x])/255 : 255-(2*(255-scl(b24(pix2_24[x]),0,255,64,192))*(255-b24(pix1_24[x]))/255)); + pix2_24[x] = rgbtocolor24(r, g, b); + } + } + break; + case 32: + for(y = 0; y < h; y++) + { + pix1_32 = scanline32(f1, y); + pix2_32 = scanline32(f2, y); + for(x = 0; x < w; x++) + { + r = klamp255(r32(pix1_32[x]) < 128 ? 2*scl(r32(pix2_32[x]),0,255,64,192)*r32(pix1_32[x])/255 : 255-(2*(255-scl(r32(pix2_32[x]),0,255,64,192))*(255-r32(pix1_32[x]))/255)); + g = klamp255(g32(pix1_32[x]) < 128 ? 2*scl(g32(pix2_32[x]),0,255,64,192)*g32(pix1_32[x])/255 : 255-(2*(255-scl(g32(pix2_32[x]),0,255,64,192))*(255-g32(pix1_32[x]))/255)); + b = klamp255(b32(pix1_32[x]) < 128 ? 2*scl(b32(pix2_32[x]),0,255,64,192)*b32(pix1_32[x])/255 : 255-(2*(255-scl(b32(pix2_32[x]),0,255,64,192))*(255-b32(pix1_32[x]))/255)); + pix2_32[x] = rgbtocolor32(r, g, b); + } + } + break; + } +} diff --git a/Plugins/softlight.dll b/Plugins/softlight.dll Binary files differnew file mode 100644 index 0000000..3eeb131 --- /dev/null +++ b/Plugins/softlight.dll diff --git a/Plugins/tools.h b/Plugins/tools.h new file mode 100644 index 0000000..272ff63 --- /dev/null +++ b/Plugins/tools.h @@ -0,0 +1,15 @@ +// +// some small helpers +// +// written by olaf.matthes@gmx.de +// + +// scale an input f that goes from il to ih to go from ol to oh +__inline long scl(long f, long il, long ih, long ol, long oh) +{ + long or = abs(oh-ol); + long ir = abs(ih-il); + float ratio = or/ir; + long steps = f-il; + return(steps*ratio+ol); +} |