Create a hard limit on fillDark

master
Joshua Sigona 5 years ago
parent c23231e281
commit a701b84d13
  1. 3
      src/main/java/com/example/demo/Controller.java
  2. 15
      src/main/java/sig/TypeFace.java

@ -17,6 +17,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.filter.CharacterEncodingFilter; import org.springframework.web.filter.CharacterEncodingFilter;
import com.fasterxml.jackson.annotation.JsonFormat;
import sig.TypeFace; import sig.TypeFace;
import sig.utils.FileUtils; import sig.utils.FileUtils;
import sig.utils.ImageUtils; import sig.utils.ImageUtils;
@ -95,6 +97,7 @@ public class Controller {
params.add(new BasicNameValuePair("combo", data.get("combo"))); params.add(new BasicNameValuePair("combo", data.get("combo")));
params.add(new BasicNameValuePair("mod", data.get("mod"))); params.add(new BasicNameValuePair("mod", data.get("mod")));
params.add(new BasicNameValuePair("gameScore", data.get("gameScore"))); params.add(new BasicNameValuePair("gameScore", data.get("gameScore")));
params.add(new BasicNameValuePair("src", body.get("url")));
try { try {
httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
} catch (UnsupportedEncodingException e) { } catch (UnsupportedEncodingException e) {

@ -125,7 +125,7 @@ public class TypeFace {
} }
} }
if (darkFillCheck) { if (darkFillCheck) {
success = fillDark(img,X,midY,0,0); success = fillDark(img,X,midY,0,0,0);
if (!success) { if (!success) {
//We're done. //We're done.
X=img.getWidth(); 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); //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()); img.setRGB(startX+x, startY+y, Color.BLACK.getRGB());
Color p = null; Color p = null;
if (startX+x+1<img.getWidth()) { if (startX+x+1<img.getWidth()) {
@ -284,7 +287,7 @@ public class TypeFace {
if (p.getBlue()>blue_fillminthreshold && p.getBlue()<blue_fillmaxthreshold && if (p.getBlue()>blue_fillminthreshold && p.getBlue()<blue_fillmaxthreshold &&
p.getGreen()>green_fillminthreshold && p.getGreen()<green_fillmaxthreshold && p.getGreen()>green_fillminthreshold && p.getGreen()<green_fillmaxthreshold &&
p.getRed()>red_fillminthreshold && p.getRed()<red_fillmaxthreshold) { p.getRed()>red_fillminthreshold && p.getRed()<red_fillmaxthreshold) {
fillDark(img,startX,startY,x+1,y); fillDark(img,startX,startY,x+1,y,iterations+1);
} }
} else { } else {
return false; return false;
@ -294,7 +297,7 @@ public class TypeFace {
if (p.getBlue()>blue_fillminthreshold && p.getBlue()<blue_fillmaxthreshold && if (p.getBlue()>blue_fillminthreshold && p.getBlue()<blue_fillmaxthreshold &&
p.getGreen()>green_fillminthreshold && p.getGreen()<green_fillmaxthreshold && p.getGreen()>green_fillminthreshold && p.getGreen()<green_fillmaxthreshold &&
p.getRed()>red_fillminthreshold && p.getRed()<red_fillmaxthreshold) { p.getRed()>red_fillminthreshold && p.getRed()<red_fillmaxthreshold) {
fillDark(img,startX,startY,x-1,y); fillDark(img,startX,startY,x-1,y,iterations+1);
} }
} else { } else {
return false; return false;
@ -304,7 +307,7 @@ public class TypeFace {
if (p.getBlue()>blue_fillminthreshold && p.getBlue()<blue_fillmaxthreshold && if (p.getBlue()>blue_fillminthreshold && p.getBlue()<blue_fillmaxthreshold &&
p.getGreen()>green_fillminthreshold && p.getGreen()<green_fillmaxthreshold && p.getGreen()>green_fillminthreshold && p.getGreen()<green_fillmaxthreshold &&
p.getRed()>red_fillminthreshold && p.getRed()<red_fillmaxthreshold) { p.getRed()>red_fillminthreshold && p.getRed()<red_fillmaxthreshold) {
fillDark(img,startX,startY,x,y+1); fillDark(img,startX,startY,x,y+1,iterations+1);
} }
} else { } else {
return false; return false;
@ -314,7 +317,7 @@ public class TypeFace {
if (p.getBlue()>blue_fillminthreshold && p.getBlue()<blue_fillmaxthreshold && if (p.getBlue()>blue_fillminthreshold && p.getBlue()<blue_fillmaxthreshold &&
p.getGreen()>green_fillminthreshold && p.getGreen()<green_fillmaxthreshold && p.getGreen()>green_fillminthreshold && p.getGreen()<green_fillmaxthreshold &&
p.getRed()>red_fillminthreshold && p.getRed()<red_fillmaxthreshold) { p.getRed()>red_fillminthreshold && p.getRed()<red_fillmaxthreshold) {
fillDark(img,startX,startY,x,y-1); fillDark(img,startX,startY,x,y-1,iterations+1);
} }
} else { } else {
return false; return false;

Loading…
Cancel
Save