mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-04-29 05:23:41 +03:00
first Horizontal Blur for 32
This commit is contained in:
parent
d49459f5b2
commit
a6937d84d8
|
@ -2,7 +2,53 @@
|
||||||
#include "Imaging.h"
|
#include "Imaging.h"
|
||||||
|
|
||||||
|
|
||||||
Imaging ImagingBoxBlur(Imaging im, Imaging imOut, int radius)
|
Imaging
|
||||||
|
HorizontalBoxBlur32(Imaging im, Imaging imOut, int radius)
|
||||||
{
|
{
|
||||||
|
ImagingSectionCookie cookie;
|
||||||
|
|
||||||
|
int x, y, pix, offset;
|
||||||
|
int acc[4];
|
||||||
|
|
||||||
|
typedef UINT8 pixel[4];
|
||||||
|
pixel *line;
|
||||||
|
|
||||||
|
int window = radius * 2 + 1;
|
||||||
|
|
||||||
|
ImagingSectionEnter(&cookie);
|
||||||
|
|
||||||
|
for (y = 0; y < im->ysize; y++) {
|
||||||
|
line = (pixel *) im->image32[y];
|
||||||
|
for (x = 0; x < im->xsize; x++) {
|
||||||
|
acc[0] = acc[1] = acc[2] = acc[3] = 0;
|
||||||
|
for (pix = x - radius; pix <= x + radius; pix++) {
|
||||||
|
offset = pix;
|
||||||
|
if (pix < 0) {
|
||||||
|
offset = 0;
|
||||||
|
} else if (pix >= im->xsize) {
|
||||||
|
offset = im->xsize - 1;
|
||||||
|
}
|
||||||
|
acc[0] += line[offset][0];
|
||||||
|
acc[1] += line[offset][1];
|
||||||
|
acc[2] += line[offset][2];
|
||||||
|
acc[3] += line[offset][3];
|
||||||
|
}
|
||||||
|
|
||||||
|
imOut->image32[y][x] =
|
||||||
|
(UINT8)(acc[0] / window) | (UINT8)(acc[1] / window) << 8 |
|
||||||
|
(UINT8)(acc[2] / window) << 16 | (UINT8)(acc[3] / window) << 24;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImagingSectionLeave(&cookie);
|
||||||
|
|
||||||
|
return imOut;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Imaging
|
||||||
|
ImagingBoxBlur(Imaging im, Imaging imOut, int radius)
|
||||||
|
{
|
||||||
|
HorizontalBoxBlur32(im, imOut, radius);
|
||||||
return imOut;
|
return imOut;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user