diff options
author | Juha Vehviläinen <jusu@users.sourceforge.net> | 2002-07-09 12:19:44 +0000 |
---|---|---|
committer | Juha Vehviläinen <jusu@users.sourceforge.net> | 2002-07-09 12:19:44 +0000 |
commit | 311e440f30c218015d17fb390f50829f430d5128 (patch) | |
tree | f2e4c13916e4b0fecae92e71d3ae21bdc4fe30f4 /Plugins | |
parent | 85d5e43cd4856dd3d14fefd450a0606666b6dc80 (diff) |
PixelPack002 by Olaf Matthes
svn path=/trunk/Framestein/; revision=30
Diffstat (limited to 'Plugins')
-rw-r--r-- | Plugins/compare.c | 163 | ||||
-rw-r--r-- | Plugins/compare.dll | bin | 0 -> 36864 bytes | |||
-rw-r--r-- | Plugins/convolution.c | 207 | ||||
-rw-r--r-- | Plugins/convolution.dll | bin | 0 -> 45056 bytes | |||
-rw-r--r-- | Plugins/darken.c | 87 | ||||
-rw-r--r-- | Plugins/darken.dll | bin | 0 -> 36864 bytes | |||
-rw-r--r-- | Plugins/deinterlace.c | 82 | ||||
-rw-r--r-- | Plugins/deinterlace.dll | bin | 0 -> 36864 bytes | |||
-rw-r--r-- | Plugins/difference.c | 86 | ||||
-rw-r--r-- | Plugins/difference.dll | bin | 0 -> 36864 bytes | |||
-rw-r--r-- | Plugins/interlace.c | 83 | ||||
-rw-r--r-- | Plugins/interlace.dll | bin | 0 -> 36864 bytes | |||
-rw-r--r-- | Plugins/lighten.c | 87 | ||||
-rw-r--r-- | Plugins/lighten.dll | bin | 0 -> 36864 bytes | |||
-rw-r--r-- | Plugins/multiply.c | 85 | ||||
-rw-r--r-- | Plugins/multiply.dll | bin | 0 -> 36864 bytes | |||
-rw-r--r-- | Plugins/overlay.c | 90 | ||||
-rw-r--r-- | Plugins/overlay.dll | bin | 0 -> 36864 bytes | |||
-rw-r--r-- | Plugins/screen.c | 90 | ||||
-rw-r--r-- | Plugins/screen.dll | bin | 0 -> 36864 bytes | |||
-rw-r--r-- | Plugins/shadowcaster.c | 417 | ||||
-rw-r--r-- | Plugins/shadowcaster.dll | bin | 0 -> 65536 bytes | |||
-rw-r--r-- | Plugins/softlight.c | 92 | ||||
-rw-r--r-- | Plugins/softlight.dll | bin | 0 -> 45056 bytes | |||
-rw-r--r-- | Plugins/tools.h | 15 |
25 files changed, 1584 insertions, 0 deletions
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); +} |