mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-10 16:22:22 +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 = ImagingNew(imIn->mode, xsize, ysize);
|
||||||
|
|
||||||
imOut = ImagingTransformAffine(
|
imOut = ImagingTransform(
|
||||||
imOut, imIn,
|
imOut, imIn, IMAGING_TRANSFORM_AFFINE,
|
||||||
0, 0, xsize, ysize,
|
0, 0, xsize, ysize,
|
||||||
a, filter, 1);
|
a, filter, 1);
|
||||||
}
|
}
|
||||||
|
@ -1613,7 +1613,6 @@ _transform2(ImagingObject* self, PyObject* args)
|
||||||
{
|
{
|
||||||
static const char* wrong_number = "wrong number of matrix entries";
|
static const char* wrong_number = "wrong number of matrix entries";
|
||||||
|
|
||||||
Imaging imIn;
|
|
||||||
Imaging imOut;
|
Imaging imOut;
|
||||||
int n;
|
int n;
|
||||||
double *a;
|
double *a;
|
||||||
|
@ -1649,30 +1648,9 @@ _transform2(ImagingObject* self, PyObject* args)
|
||||||
if (!a)
|
if (!a)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
imOut = self->image;
|
imOut = ImagingTransform(
|
||||||
imIn = imagep->image;
|
self->image, imagep->image, method,
|
||||||
|
x0, y0, x1, y1, a, filter, 1);
|
||||||
/* 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");
|
|
||||||
}
|
|
||||||
|
|
||||||
free(a);
|
free(a);
|
||||||
|
|
||||||
|
|
|
@ -609,8 +609,7 @@ Imaging
|
||||||
ImagingGenericTransform(
|
ImagingGenericTransform(
|
||||||
Imaging imOut, Imaging imIn, int x0, int y0, int x1, int y1,
|
Imaging imOut, Imaging imIn, int x0, int y0, int x1, int y1,
|
||||||
ImagingTransformMap transform, void* transform_data,
|
ImagingTransformMap transform, void* transform_data,
|
||||||
ImagingTransformFilter filter, void* filter_data,
|
int filterid, void* filter_data, int fill)
|
||||||
int fill)
|
|
||||||
{
|
{
|
||||||
/* slow generic transformation. use ImagingTransformAffine or
|
/* slow generic transformation. use ImagingTransformAffine or
|
||||||
ImagingScaleAffine where possible. */
|
ImagingScaleAffine where possible. */
|
||||||
|
@ -620,6 +619,10 @@ ImagingGenericTransform(
|
||||||
char *out;
|
char *out;
|
||||||
double xx, yy;
|
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)
|
if (!imOut || !imIn || strcmp(imIn->mode, imOut->mode) != 0)
|
||||||
return (Imaging) ImagingError_ModeError();
|
return (Imaging) ImagingError_ModeError();
|
||||||
|
|
||||||
|
@ -824,15 +827,11 @@ ImagingTransformAffine(Imaging imOut, Imaging imIn,
|
||||||
double xo, yo;
|
double xo, yo;
|
||||||
|
|
||||||
if (filterid || imIn->type == IMAGING_TYPE_SPECIAL) {
|
if (filterid || imIn->type == IMAGING_TYPE_SPECIAL) {
|
||||||
/* Filtered transform */
|
|
||||||
ImagingTransformFilter filter = getfilter(imIn, filterid);
|
|
||||||
if (!filter)
|
|
||||||
return (Imaging) ImagingError_ValueError("unknown filter");
|
|
||||||
return ImagingGenericTransform(
|
return ImagingGenericTransform(
|
||||||
imOut, imIn,
|
imOut, imIn,
|
||||||
x0, y0, x1, y1,
|
x0, y0, x1, y1,
|
||||||
affine_transform, a,
|
affine_transform, a,
|
||||||
filter, NULL, fill);
|
filterid, NULL, fill);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a[2] == 0 && a[4] == 0)
|
if (a[2] == 0 && a[4] == 0)
|
||||||
|
@ -907,35 +906,29 @@ ImagingTransformAffine(Imaging imOut, Imaging imIn,
|
||||||
}
|
}
|
||||||
|
|
||||||
Imaging
|
Imaging
|
||||||
ImagingTransformPerspective(Imaging imOut, Imaging imIn,
|
ImagingTransform(Imaging imOut, Imaging imIn, int method,
|
||||||
int x0, int y0, int x1, int y1,
|
int x0, int y0, int x1, int y1,
|
||||||
double a[8], int filterid, int fill)
|
double a[8], int filterid, int fill)
|
||||||
{
|
{
|
||||||
ImagingTransformFilter filter = getfilter(imIn, filterid);
|
ImagingTransformMap transform;
|
||||||
if (!filter)
|
|
||||||
return (Imaging) ImagingError_ValueError("bad filter number");
|
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(
|
return ImagingGenericTransform(
|
||||||
imOut, imIn,
|
imOut, imIn,
|
||||||
x0, y0, x1, y1,
|
x0, y0, x1, y1,
|
||||||
perspective_transform, a,
|
transform, a, filterid, NULL, fill);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -291,15 +291,9 @@ extern Imaging ImagingRotate180(Imaging imOut, Imaging imIn);
|
||||||
extern Imaging ImagingRotate270(Imaging imOut, Imaging imIn);
|
extern Imaging ImagingRotate270(Imaging imOut, Imaging imIn);
|
||||||
extern Imaging ImagingResample(Imaging imIn, int xsize, int ysize, int filter);
|
extern Imaging ImagingResample(Imaging imIn, int xsize, int ysize, int filter);
|
||||||
extern Imaging ImagingTranspose(Imaging imOut, Imaging imIn);
|
extern Imaging ImagingTranspose(Imaging imOut, Imaging imIn);
|
||||||
extern Imaging ImagingTransformPerspective(
|
extern Imaging ImagingTransform(
|
||||||
Imaging imOut, Imaging imIn, int x0, int y0, int x1, int y1,
|
Imaging imOut, Imaging imIn, int method, int x0, int y0, int x1, int y1,
|
||||||
double a[8], int filter, int fill);
|
double *a, 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 ImagingUnsharpMask(
|
extern Imaging ImagingUnsharpMask(
|
||||||
Imaging imOut, Imaging im, float radius, int percent, int threshold);
|
Imaging imOut, Imaging im, float radius, int percent, int threshold);
|
||||||
extern Imaging ImagingBoxBlur(Imaging imOut, Imaging imIn, float radius, int n);
|
extern Imaging ImagingBoxBlur(Imaging imOut, Imaging imIn, float radius, int n);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user