Fixed #2116 Limit maximum number of box blur pixels

This commit is contained in:
Jindra Petřík
2023-11-07 00:06:46 +01:00
parent c73defd056
commit 191eae40c5
4 changed files with 10 additions and 9 deletions

View File

@@ -977,7 +977,7 @@ public final class Configuration {
@ConfigurationCategory("format")
public static ConfigurationItem<Integer> tabSize = null;
@ConfigurationDefaultInt(1000000)
@ConfigurationDefaultInt(1000)
@ConfigurationCategory("limit")
public static ConfigurationItem<Integer> boxBlurPixelsLimit = null;

View File

@@ -63,17 +63,14 @@ public class Filtering {
if (radiusY == 0) {
radiusY = 1;
}
int radiusXHalf = radiusX / 2;
int radiusYHalf = radiusY / 2;
double divisor = radiusX * radiusY;
long limit = Configuration.boxBlurPixelsLimit.get() * 10000L;
if ((long) w * (long) h > Configuration.boxBlurPixelsLimit.get()) {
if ((long) w * (long) h > limit) {
return;
}
while (((long) radiusY * (long) radiusX * (long) w * (long) h) > Configuration.boxBlurPixelsLimit.get()) {
while (((long) radiusY * (long) radiusX * (long) w * (long) h) > limit) {
// decrease radius
if (radiusY > 1) {
radiusY--;
@@ -82,6 +79,10 @@ public class Filtering {
radiusX--;
}
}
int radiusXHalf = radiusX / 2;
int radiusYHalf = radiusY / 2;
double divisor = radiusX * radiusY;
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {