Hi,
This is my first question, and I'm just programming as a hobby, so keep that in mind when trying to help me, please.
I have a function that tries to read the center point of a crosshair. Something like a positioner in a game. The code is as follows:
public static Point location(BufferedImage image) {
int pixelLeft;
int pixelTop;
Point point = new Point();
for (int i = Main.RADAR_TOP+1; i < Main.RADAR_BOTTOM; i++) {
pixelLeft = image.getRGB(Main.RADAR_LEFT+7, i);
if ((((pixelLeft>>16) & 0xff) > 35 &&
((pixelLeft>>8) & 0xff) > 35 &&
((pixelLeft) & 0xff) > 35)){
point.y = i;
break;
}
}
for (int j = Main.RADAR_LEFT+1; j < Main.RADAR_RIGHT; j++) {
pixelTop = image.getRGB(j, Main.RADAR_TOP+5);
if ((((pixelTop>>16) & 0xff) > 35 &&
((pixelTop>>8) & 0xff) > 35 &&
((pixelTop) & 0xff) > 35)){
point.x = j;
break;
}
}
System.out.println("location: "+point.x+","+point.y);
return point;
}
It happens that sometimes this function simply does not return control to the main application. Mostly it gets stuck. Therefore, the last comment in the function is to check. At first I thought that maybe this was due to reading the static members of the class that this function is in, so I commented on them, as you can see at the end. The problem is still happening.
- . , - .