Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ext/gd/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ if test "$PHP_GD" != "no"; then
libgd/gd_io.c
libgd/gd_jpeg.c
libgd/gd_matrix.c
libgd/gd_pixelate.c
libgd/gd_png.c
libgd/gd_rotate.c
libgd/gd_security.c
Expand Down
2 changes: 1 addition & 1 deletion ext/gd/config.w32
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ if (PHP_GD != "no") {
gdft.c gd_gd2.c gd_gd.c gd_gif_in.c gd_gif_out.c gdhelpers.c gd_io.c gd_io_dp.c \
gd_io_file.c gd_io_ss.c gd_jpeg.c gdkanji.c gd_png.c gd_ss.c \
gdtables.c gd_topal.c gd_wbmp.c gdxpm.c wbmp.c gd_xbm.c gd_security.c gd_transform.c \
gd_filter.c gd_pixelate.c gd_rotate.c gd_color_match.c gd_webp.c gd_avif.c \
gd_filter.c gd_rotate.c gd_color_match.c gd_webp.c gd_avif.c \
gd_crop.c gd_interpolation.c gd_matrix.c gd_bmp.c gd_tga.c", "gd");
AC_DEFINE('HAVE_GD_BUNDLED', 1, "Define to 1 if gd extension uses GD library bundled in PHP.");
AC_DEFINE('HAVE_GD_PNG', 1, "Define to 1 if gd extension has PNG support.");
Expand Down
56 changes: 56 additions & 0 deletions ext/gd/libgd/gd_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,62 @@ int gdImageScatterEx(gdImagePtr im, gdScatterPtr scatter)
return 1;
}

int gdImagePixelate(gdImagePtr im, int block_size, const unsigned int mode)
{
int x, y;

if (block_size <= 0) {
return 0;
} else if (block_size == 1) {
return 1;
}
switch (mode) {
case GD_PIXELATE_UPPERLEFT:
for (y = 0; y < im->sy; y += block_size) {
for (x = 0; x < im->sx; x += block_size) {
if (gdImageBoundsSafe(im, x, y)) {
int c = gdImageGetPixel(im, x, y);
gdImageFilledRectangle(im, x, y, x + block_size - 1, y + block_size - 1, c);
}
}
}
break;
case GD_PIXELATE_AVERAGE:
for (y = 0; y < im->sy; y += block_size) {
for (x = 0; x < im->sx; x += block_size) {
int a, r, g, b, c;
int total;
int cx, cy;

a = r = g = b = c = total = 0;
/* sampling */
for (cy = 0; cy < block_size; cy++) {
for (cx = 0; cx < block_size; cx++) {
if (!gdImageBoundsSafe(im, x + cx, y + cy)) {
continue;
}
c = gdImageGetPixel(im, x + cx, y + cy);
a += gdImageAlpha(im, c);
r += gdImageRed(im, c);
g += gdImageGreen(im, c);
b += gdImageBlue(im, c);
total++;
}
}
/* drawing */
if (total > 0) {
c = gdImageColorResolveAlpha(im, r / total, g / total, b / total, a / total);
gdImageFilledRectangle(im, x, y, x + block_size - 1, y + block_size - 1, c);
}
}
}
break;
default:
return 0;
}
return 1;
}

/* invert src image */
int gdImageNegate(gdImagePtr src)
{
Expand Down
57 changes: 0 additions & 57 deletions ext/gd/libgd/gd_pixelate.c

This file was deleted.

Loading