Java: Further cleanup of calculation. Correct image size from 512 to 768.

The code is much more readable and the image size is corrected. The new string fits now in the image. Still a problem is the creation of garbage in the calculation.