mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
move transform dispatcher into libImaging
This commit is contained in:
parent
2e914af758
commit
9902d2e1c5
32
_imaging.c
32
_imaging.c
|
@ -1553,8 +1553,8 @@ _resize(ImagingObject* self, PyObject* args)
|
|||
|
||||
imOut = ImagingNew(imIn->mode, xsize, ysize);
|
||||
|
||||
imOut = ImagingTransformAffine(
|
||||
imOut, imIn,
|
||||
imOut = ImagingTransform(
|
||||
imOut, imIn, IMAGING_TRANSFORM_AFFINE,
|
||||
0, 0, xsize, ysize,
|
||||
a, filter, 1);
|
||||
}
|
||||
|
@ -1613,7 +1613,6 @@ _transform2(ImagingObject* self, PyObject* args)
|
|||
{
|
||||
static const char* wrong_number = "wrong number of matrix entries";
|
||||
|
||||
Imaging imIn;
|
||||
Imaging imOut;
|
||||
int n;
|
||||
double *a;
|
||||
|
@ -1649,30 +1648,9 @@ _transform2(ImagingObject* self, PyObject* args)
|
|||
if (!a)
|
||||
return NULL;
|
||||
|
||||
imOut = self->image;
|
||||
imIn = imagep->image;
|
||||
|
||||
/* FIXME: move transform dispatcher into libImaging */
|
||||
|
||||
switch (method) {
|
||||
case IMAGING_TRANSFORM_AFFINE:
|
||||
imOut = ImagingTransformAffine(
|
||||
imOut, imIn, x0, y0, x1, y1, a, filter, 1
|
||||
);
|
||||
break;
|
||||
case IMAGING_TRANSFORM_PERSPECTIVE:
|
||||
imOut = ImagingTransformPerspective(
|
||||
imOut, imIn, x0, y0, x1, y1, a, filter, 1
|
||||
);
|
||||
break;
|
||||
case IMAGING_TRANSFORM_QUAD:
|
||||
imOut = ImagingTransformQuad(
|
||||
imOut, imIn, x0, y0, x1, y1, a, filter, 1
|
||||
);
|
||||
break;
|
||||
default:
|
||||
(void) ImagingError_ValueError("bad transform method");
|
||||
}
|
||||
imOut = ImagingTransform(
|
||||
self->image, imagep->image, method,
|
||||
x0, y0, x1, y1, a, filter, 1);
|
||||
|
||||
free(a);
|
||||
|
||||
|
|
|
@ -609,8 +609,7 @@ Imaging
|
|||
ImagingGenericTransform(
|
||||
Imaging imOut, Imaging imIn, int x0, int y0, int x1, int y1,
|
||||
ImagingTransformMap transform, void* transform_data,
|
||||
ImagingTransformFilter filter, void* filter_data,
|
||||
int fill)
|
||||
int filterid, void* filter_data, int fill)
|
||||
{
|
||||
/* slow generic transformation. use ImagingTransformAffine or
|
||||
ImagingScaleAffine where possible. */
|
||||
|
@ -620,6 +619,10 @@ ImagingGenericTransform(
|
|||
char *out;
|
||||
double xx, yy;
|
||||
|
||||
ImagingTransformFilter filter = getfilter(imIn, filterid);
|
||||
if (!filter)
|
||||
return (Imaging) ImagingError_ValueError("bad filter number");
|
||||
|
||||
if (!imOut || !imIn || strcmp(imIn->mode, imOut->mode) != 0)
|
||||
return (Imaging) ImagingError_ModeError();
|
||||
|
||||
|
@ -824,15 +827,11 @@ ImagingTransformAffine(Imaging imOut, Imaging imIn,
|
|||
double xo, yo;
|
||||
|
||||
if (filterid || imIn->type == IMAGING_TYPE_SPECIAL) {
|
||||
/* Filtered transform */
|
||||
ImagingTransformFilter filter = getfilter(imIn, filterid);
|
||||
if (!filter)
|
||||
return (Imaging) ImagingError_ValueError("unknown filter");
|
||||
return ImagingGenericTransform(
|
||||
imOut, imIn,
|
||||
x0, y0, x1, y1,
|
||||
affine_transform, a,
|
||||
filter, NULL, fill);
|
||||
filterid, NULL, fill);
|
||||
}
|
||||
|
||||
if (a[2] == 0 && a[4] == 0)
|
||||
|
@ -907,35 +906,29 @@ ImagingTransformAffine(Imaging imOut, Imaging imIn,
|
|||
}
|
||||
|
||||
Imaging
|
||||
ImagingTransformPerspective(Imaging imOut, Imaging imIn,
|
||||
int x0, int y0, int x1, int y1,
|
||||
double a[8], int filterid, int fill)
|
||||
ImagingTransform(Imaging imOut, Imaging imIn, int method,
|
||||
int x0, int y0, int x1, int y1,
|
||||
double a[8], int filterid, int fill)
|
||||
{
|
||||
ImagingTransformFilter filter = getfilter(imIn, filterid);
|
||||
if (!filter)
|
||||
return (Imaging) ImagingError_ValueError("bad filter number");
|
||||
ImagingTransformMap transform;
|
||||
|
||||
switch(method) {
|
||||
case IMAGING_TRANSFORM_AFFINE:
|
||||
return ImagingTransformAffine(
|
||||
imOut, imIn, x0, y0, x1, y1, a, filterid, fill);
|
||||
break;
|
||||
case IMAGING_TRANSFORM_PERSPECTIVE:
|
||||
transform = perspective_transform;
|
||||
break;
|
||||
case IMAGING_TRANSFORM_QUAD:
|
||||
transform = quad_transform;
|
||||
break;
|
||||
default:
|
||||
return (Imaging) ImagingError_ValueError("bad transform method");
|
||||
}
|
||||
|
||||
return ImagingGenericTransform(
|
||||
imOut, imIn,
|
||||
x0, y0, x1, y1,
|
||||
perspective_transform, a,
|
||||
filter, NULL,
|
||||
fill);
|
||||
}
|
||||
|
||||
Imaging
|
||||
ImagingTransformQuad(Imaging imOut, Imaging imIn,
|
||||
int x0, int y0, int x1, int y1,
|
||||
double a[8], int filterid, int fill)
|
||||
{
|
||||
ImagingTransformFilter filter = getfilter(imIn, filterid);
|
||||
if (!filter)
|
||||
return (Imaging) ImagingError_ValueError("bad filter number");
|
||||
|
||||
return ImagingGenericTransform(
|
||||
imOut, imIn,
|
||||
x0, y0, x1, y1,
|
||||
quad_transform, a,
|
||||
filter, NULL,
|
||||
fill);
|
||||
transform, a, filterid, NULL, fill);
|
||||
}
|
||||
|
|
|
@ -291,15 +291,9 @@ extern Imaging ImagingRotate180(Imaging imOut, Imaging imIn);
|
|||
extern Imaging ImagingRotate270(Imaging imOut, Imaging imIn);
|
||||
extern Imaging ImagingResample(Imaging imIn, int xsize, int ysize, int filter);
|
||||
extern Imaging ImagingTranspose(Imaging imOut, Imaging imIn);
|
||||
extern Imaging ImagingTransformPerspective(
|
||||
Imaging imOut, Imaging imIn, int x0, int y0, int x1, int y1,
|
||||
double a[8], int filter, int fill);
|
||||
extern Imaging ImagingTransformAffine(
|
||||
Imaging imOut, Imaging imIn, int x0, int y0, int x1, int y1,
|
||||
double a[6], int filter, int fill);
|
||||
extern Imaging ImagingTransformQuad(
|
||||
Imaging imOut, Imaging imIn, int x0, int y0, int x1, int y1,
|
||||
double a[8], int filter, int fill);
|
||||
extern Imaging ImagingTransform(
|
||||
Imaging imOut, Imaging imIn, int method, int x0, int y0, int x1, int y1,
|
||||
double *a, int filter, int fill);
|
||||
extern Imaging ImagingUnsharpMask(
|
||||
Imaging imOut, Imaging im, float radius, int percent, int threshold);
|
||||
extern Imaging ImagingBoxBlur(Imaging imOut, Imaging imIn, float radius, int n);
|
||||
|
|
Loading…
Reference in New Issue
Block a user