aboutsummaryrefslogtreecommitdiff
path: root/Plugins/subtract.cpp
blob: 89ba21635f5abdc8e72c265fda68c48b9e902ada (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// 0.20
// - from c to c++
// - pixelformat-aware

#include <stdlib.h>
#include <string.h>
#include "plugin.h"
#include "pixels.h"

void perform_effect(_frame f, _args a)
{
	pixels p(f);
	char *t;
	byte tr, tg, tb, r=0, g=0, b=0;

	if(!a.s) return;

	r = atoi(a.s);
	if(t = strstr(a.s, " "))
	{
		g = atoi(t+1);
		if (t = strstr(t+1, " "))
			b = atoi(t+1);
	}

	while(!p.eof())
	{
		tr = p.red();
		tg = p.green();
		tb = p.blue();
		p.putrgb(
		 tr>r ? tr-r : 0,
		 tg>g ? tg-g : 0,
		 tb>b ? tb-b : 0
		);
		p.next();
	}
}