Java rewrite of image overlay