mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-29 18:54:16 +03:00
2 times faster ImagingRotate180
This commit is contained in:
parent
97141bcfd6
commit
67459795db
|
@ -32,18 +32,16 @@ ImagingFlipLeftRight(Imaging imOut, Imaging imIn)
|
||||||
for (y = 0; y < imIn->ysize; y++) {
|
for (y = 0; y < imIn->ysize; y++) {
|
||||||
UINT8* in = (UINT8*) imIn->image8[y];
|
UINT8* in = (UINT8*) imIn->image8[y];
|
||||||
UINT8* out = (UINT8*) imOut->image8[y];
|
UINT8* out = (UINT8*) imOut->image8[y];
|
||||||
x = 0;
|
|
||||||
xr = imIn->xsize-1;
|
xr = imIn->xsize-1;
|
||||||
for (; x < imIn->xsize; x++, xr--)
|
for (x = 0; x < imIn->xsize; x++, xr--)
|
||||||
out[xr] = in[x];
|
out[xr] = in[x];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (y = 0; y < imIn->ysize; y++) {
|
for (y = 0; y < imIn->ysize; y++) {
|
||||||
UINT32* in = (UINT32*) imIn->image32[y];
|
UINT32* in = (UINT32*) imIn->image32[y];
|
||||||
UINT32* out = (UINT32*) imOut->image32[y];
|
UINT32* out = (UINT32*) imOut->image32[y];
|
||||||
x = 0;
|
|
||||||
xr = imIn->xsize-1;
|
xr = imIn->xsize-1;
|
||||||
for (; x < imIn->xsize; x++, xr--)
|
for (x = 0; x < imIn->xsize; x++, xr--)
|
||||||
out[xr] = in[x];
|
out[xr] = in[x];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,25 +173,29 @@ ImagingRotate180(Imaging imOut, Imaging imIn)
|
||||||
|
|
||||||
ImagingCopyInfo(imOut, imIn);
|
ImagingCopyInfo(imOut, imIn);
|
||||||
|
|
||||||
#define ROTATE_180(image)\
|
|
||||||
for (y = 0; y < imIn->ysize; y++, yr--) {\
|
|
||||||
xr = imIn->xsize-1;\
|
|
||||||
for (x = 0; x < imIn->xsize; x++, xr--)\
|
|
||||||
imOut->image[y][x] = imIn->image[yr][xr];\
|
|
||||||
}
|
|
||||||
|
|
||||||
ImagingSectionEnter(&cookie);
|
ImagingSectionEnter(&cookie);
|
||||||
|
|
||||||
yr = imIn->ysize-1;
|
yr = imIn->ysize-1;
|
||||||
if (imIn->image8)
|
if (imIn->image8) {
|
||||||
ROTATE_180(image8)
|
for (y = 0; y < imIn->ysize; y++, yr--) {
|
||||||
else
|
UINT8* in = (UINT8*) imIn->image8[y];
|
||||||
ROTATE_180(image32)
|
UINT8* out = (UINT8*) imOut->image8[yr];
|
||||||
|
xr = imIn->xsize-1;
|
||||||
|
for (x = 0; x < imIn->xsize; x++, xr--)
|
||||||
|
out[xr] = in[x];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (y = 0; y < imIn->ysize; y++, yr--) {
|
||||||
|
UINT32* in = (UINT32*) imIn->image32[y];
|
||||||
|
UINT32* out = (UINT32*) imOut->image32[yr];
|
||||||
|
xr = imIn->xsize-1;
|
||||||
|
for (x = 0; x < imIn->xsize; x++, xr--)
|
||||||
|
out[xr] = in[x];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ImagingSectionLeave(&cookie);
|
ImagingSectionLeave(&cookie);
|
||||||
|
|
||||||
#undef ROTATE_180
|
|
||||||
|
|
||||||
return imOut;
|
return imOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user