From 311e440f30c218015d17fb390f50829f430d5128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juha=20Vehvil=C3=A4inen?= Date: Tue, 9 Jul 2002 12:19:44 +0000 Subject: PixelPack002 by Olaf Matthes svn path=/trunk/Framestein/; revision=30 --- Plugins/compare.c | 163 ++++++++++++++++++ Plugins/compare.dll | Bin 0 -> 36864 bytes Plugins/convolution.c | 207 +++++++++++++++++++++++ Plugins/convolution.dll | Bin 0 -> 45056 bytes Plugins/darken.c | 87 ++++++++++ Plugins/darken.dll | Bin 0 -> 36864 bytes Plugins/deinterlace.c | 82 ++++++++++ Plugins/deinterlace.dll | Bin 0 -> 36864 bytes Plugins/difference.c | 86 ++++++++++ Plugins/difference.dll | Bin 0 -> 36864 bytes Plugins/interlace.c | 83 ++++++++++ Plugins/interlace.dll | Bin 0 -> 36864 bytes Plugins/lighten.c | 87 ++++++++++ Plugins/lighten.dll | Bin 0 -> 36864 bytes Plugins/multiply.c | 85 ++++++++++ Plugins/multiply.dll | Bin 0 -> 36864 bytes Plugins/overlay.c | 90 ++++++++++ Plugins/overlay.dll | Bin 0 -> 36864 bytes Plugins/screen.c | 90 ++++++++++ Plugins/screen.dll | Bin 0 -> 36864 bytes Plugins/shadowcaster.c | 417 +++++++++++++++++++++++++++++++++++++++++++++++ Plugins/shadowcaster.dll | Bin 0 -> 65536 bytes Plugins/softlight.c | 92 +++++++++++ Plugins/softlight.dll | Bin 0 -> 45056 bytes Plugins/tools.h | 15 ++ 25 files changed, 1584 insertions(+) create mode 100644 Plugins/compare.c create mode 100644 Plugins/compare.dll create mode 100644 Plugins/convolution.c create mode 100644 Plugins/convolution.dll create mode 100644 Plugins/darken.c create mode 100644 Plugins/darken.dll create mode 100644 Plugins/deinterlace.c create mode 100644 Plugins/deinterlace.dll create mode 100644 Plugins/difference.c create mode 100644 Plugins/difference.dll create mode 100644 Plugins/interlace.c create mode 100644 Plugins/interlace.dll create mode 100644 Plugins/lighten.c create mode 100644 Plugins/lighten.dll create mode 100644 Plugins/multiply.c create mode 100644 Plugins/multiply.dll create mode 100644 Plugins/overlay.c create mode 100644 Plugins/overlay.dll create mode 100644 Plugins/screen.c create mode 100644 Plugins/screen.dll create mode 100644 Plugins/shadowcaster.c create mode 100644 Plugins/shadowcaster.dll create mode 100644 Plugins/softlight.c create mode 100644 Plugins/softlight.dll create mode 100644 Plugins/tools.h (limited to 'Plugins') 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 +// 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 [] +// 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 +#include +#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 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 new file mode 100644 index 0000000..5dabdde Binary files /dev/null and b/Plugins/compare.dll differ 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 +// +// 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 +// +// +// +// +// +// +// KNOWN BUG: produces ugly colors (due to rounding error I guess) +// + +#include +#include +#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 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 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 new file mode 100644 index 0000000..68a6ed2 Binary files /dev/null and b/Plugins/convolution.dll differ 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 +// +// 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 +#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 +// +// 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 [ with line = 0 or 1 ] +// + +#include +#include +#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 new file mode 100644 index 0000000..7c5daf3 Binary files /dev/null and b/Plugins/deinterlace.dll differ 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 +// +// 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 +// +// 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 [ with line = 0 or 1 ] +// + +#include +#include +#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 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 new file mode 100644 index 0000000..4c07025 Binary files /dev/null and b/Plugins/interlace.dll differ 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 +// +// 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 +#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 +// +// 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 +// +// 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 +#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 +// +// 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 +#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 +// +// 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 +// + +#include +#include +#include +#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 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 new file mode 100644 index 0000000..7e2137d Binary files /dev/null and b/Plugins/shadowcaster.dll differ 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 +// +// 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 +#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