From 49248f0ad92ebc9ced7bbfc19b1325fa7470da63 Mon Sep 17 00:00:00 2001 From: Cedric Porter Date: Mon, 30 Jul 2012 14:14:41 +0800 Subject: [PATCH] empty color --- .gitignore | 1 + EffectLab/Effect.py | 4 ++-- EffectLab/core.c | 19 +++++++++++++------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 2f75dc3..fbad13d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ *~ .ropeproject/ *.jpg +*.so Images/ diff --git a/EffectLab/Effect.py b/EffectLab/Effect.py index f7fe5ff..cf9464f 100755 --- a/EffectLab/Effect.py +++ b/EffectLab/Effect.py @@ -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 @@ -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 diff --git a/EffectLab/core.c b/EffectLab/core.c index 4ebd179..20916ee 100644 --- a/EffectLab/core.c +++ b/EffectLab/core.c @@ -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; } @@ -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; @@ -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++) { @@ -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;