From a701b84d1360a9c3a6d8d0f0b5237115219c5210 Mon Sep 17 00:00:00 2001 From: Joshua Sigona Date: Thu, 6 Aug 2020 05:14:49 +0900 Subject: [PATCH] Create a hard limit on fillDark --- src/main/java/com/example/demo/Controller.java | 3 +++ src/main/java/sig/TypeFace.java | 15 +++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/example/demo/Controller.java b/src/main/java/com/example/demo/Controller.java index fa6aea5..0dc8cc9 100644 --- a/src/main/java/com/example/demo/Controller.java +++ b/src/main/java/com/example/demo/Controller.java @@ -17,6 +17,8 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.filter.CharacterEncodingFilter; +import com.fasterxml.jackson.annotation.JsonFormat; + import sig.TypeFace; import sig.utils.FileUtils; import sig.utils.ImageUtils; @@ -95,6 +97,7 @@ public class Controller { params.add(new BasicNameValuePair("combo", data.get("combo"))); params.add(new BasicNameValuePair("mod", data.get("mod"))); params.add(new BasicNameValuePair("gameScore", data.get("gameScore"))); + params.add(new BasicNameValuePair("src", body.get("url"))); try { httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); } catch (UnsupportedEncodingException e) { diff --git a/src/main/java/sig/TypeFace.java b/src/main/java/sig/TypeFace.java index 861243e..15565b6 100644 --- a/src/main/java/sig/TypeFace.java +++ b/src/main/java/sig/TypeFace.java @@ -125,7 +125,7 @@ public class TypeFace { } } if (darkFillCheck) { - success = fillDark(img,X,midY,0,0); + success = fillDark(img,X,midY,0,0,0); if (!success) { //We're done. X=img.getWidth(); @@ -275,8 +275,11 @@ public class TypeFace { } } - public boolean fillDark(BufferedImage img,int startX,int startY,int x,int y) { + public boolean fillDark(BufferedImage img,int startX,int startY,int x,int y, int iterations) { //rect.AddPixel(new Point(x,y), Color.BLACK); + if (iterations>Math.max(img.getWidth(),img.getHeight())) { + return false; + } img.setRGB(startX+x, startY+y, Color.BLACK.getRGB()); Color p = null; if (startX+x+1blue_fillminthreshold && p.getBlue()green_fillminthreshold && p.getGreen()red_fillminthreshold && p.getRed()blue_fillminthreshold && p.getBlue()green_fillminthreshold && p.getGreen()red_fillminthreshold && p.getRed()blue_fillminthreshold && p.getBlue()green_fillminthreshold && p.getGreen()red_fillminthreshold && p.getRed()blue_fillminthreshold && p.getBlue()green_fillminthreshold && p.getGreen()red_fillminthreshold && p.getRed()