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++) {

View File

@@ -750,4 +750,4 @@ config.name.formatting.tab.size = Tab size
config.description.formatting.tab.size = Number of spaces per tab
config.name.boxBlurPixelsLimit = Box blur filter pixels limit
config.description.boxBlurPixelsLimit = Maximum number of pixels to calculate boxblur filter. If the number of pixels is greater, then blurring is skipped.
config.description.boxBlurPixelsLimit = Maximum number of pixels to calculate boxblur filter. The actual limit is this number multiplied by 10000. If the number of pixels is greater, then blurX and blurY is decreased.

View File

@@ -740,4 +740,4 @@ config.name.formatting.tab.size = Velikost tabel\u00e1toru
config.description.formatting.tab.size = Po\u010det mezer v tabel\u00e1toru
config.name.boxBlurPixelsLimit = Limit pixel\u016f box blur filtru
config.description.boxBlurPixelsLimit = Maxim\u00e1ln\u00ed po\u010det pixel\u016f pro v\u00fdpo\u010det boxblur filtru. Pokud je po\u010det pixel\u016f v\u011bt\u0161\u00ed, blur je p\u0159esko\u010den.
config.description.boxBlurPixelsLimit = Maxim\u00e1ln\u00ed po\u010det pixel\u016f pro v\u00fdpo\u010det boxblur filtru. Aktu\u00e1ln\u00ed limit je toto \u010d\u00edslo kr\u00e1t 10000. Pokud je po\u010det pixel\u016f v\u011bt\u0161\u00ed, je zmen\u0161en blurX, blurY.