private BufferedImage flip(BufferedImage img)
	{
    int w = img.getWidth();
    int h = img.getHeight();
    BufferedImage dimg = new BufferedImage(w, h, img.getType());
    Graphics2D g = dimg.createGraphics();
    g.drawImage(img, 0, 0, w, h, 0, h, w, 0, null);
    g.dispose();
    return dimg;
	}