Skip to content

Commit

Permalink
empty color
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricporter committed Jul 30, 2012
1 parent 66fa045 commit 49248f0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
*~
.ropeproject/
*.jpg
*.so
Images/
4 changes: 2 additions & 2 deletions EffectLab/Effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def filter(self, img):
'''

try:
return core.lens_warp(img, self.formula, self.antialias)
return core.lens_warp(img, self.formula, self.antialias, self.empty_color)
except:
pass

Expand Down Expand Up @@ -261,7 +261,7 @@ def __init__(self, formula, antialias=2):
self.antialias = antialias

def filter(self, img):
return core.radian_warp(img, self.formula, self.antialias)
return core.radian_warp(img, self.formula, self.antialias, self.empty_color)

def radian_formula(x, y):
'''transform formula
Expand Down
19 changes: 13 additions & 6 deletions EffectLab/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,10 @@ static PyObject* _lens_warp(PyObject *self, PyObject *args, int (*warp)(PyObject
UINT8 *pixel;
int i3, j3;
PyObject *func, *ret;
PyObject *empty_color;
int er, eg, eb, ea;

if (!PyArg_ParseTuple(args, "OOi", &image, &func, &antialias))
if (!PyArg_ParseTuple(args, "OOiO", &image, &func, &antialias, &empty_color))
{
return NULL;
}
Expand All @@ -141,6 +143,11 @@ static PyObject* _lens_warp(PyObject *self, PyObject *args, int (*warp)(PyObject
}
imOut = core->image;

if (!PyArg_ParseTuple(empty_color, "iiii", &er, &eg, &eb, &ea))
{
return NULL;
}

width = imIn->xsize;
height = imIn->ysize;

Expand All @@ -156,10 +163,10 @@ static PyObject* _lens_warp(PyObject *self, PyObject *args, int (*warp)(PyObject

pixel = imOut->image[j];
pixel += i * 4;
pixel[0] = 128;
pixel[1] = 128;
pixel[2] = 128;
pixel[3] = 128;
pixel[0] = er;
pixel[1] = eg;
pixel[2] = eb;
pixel[3] = ea;

for (ai = 0; ai < antialias; ai++)
{
Expand Down Expand Up @@ -283,7 +290,7 @@ static PyObject* wave_warp(PyObject *self, PyObject *args)

if (!PyArg_ParseTuple(empty_color, "iiii", &er, &eg, &eb, &ea))
{
return 0;
return NULL;
}

width = imIn->xsize;
Expand Down

0 comments on commit 49248f0

Please sign in to comment.