public static BufferedImage getPanel(int w, int h, BufferedImage img) {
        BufferedImage res = new BufferedImage(w, h, 2);
	int onew = img.getWidth() / 3;
	int oneh = img.getHeight() / 3;
	
	res.getGraphics().drawImage(img.getSubimage(0, 0, onew, oneh), 0, 0, onew, oneh, null);
	res.getGraphics().drawImage(img.getSubimage(onew * 2, 0, onew, oneh), w - onew, 0, onew, oneh, null);
	res.getGraphics().drawImage(img.getSubimage(0, oneh * 2, onew, oneh), 0, h - oneh, onew, oneh, null);
	res.getGraphics().drawImage(img.getSubimage(onew, oneh, onew * 2, oneh * 2), w - onew, h - oneh, onew, oneh, null);

	try{res.getGraphics().drawImage(fill(img.getSubimage(onew, 0, onew, oneh), w - onew * 2, oneh), onew, 0, w - onew * 2, oneh, null);}catch(Exception e){}
	try{res.getGraphics().drawImage(fill(img.getSubimage(0, oneh, onew, oneh), onew, h - oneh * 2), 0, oneh, onew, h - oneh * 2, null);}catch(Exception e){}
	try{res.getGraphics().drawImage(fill(img.getSubimage(onew, oneh * 2, onew, oneh), w - onew * 2, oneh), onew, h - oneh, w - onew * 2, oneh, null);}catch(Exception e){}
	try{res.getGraphics().drawImage(fill(img.getSubimage(onew * 2, oneh, onew, oneh), onew, h - oneh * 2), w - onew, oneh, onew, h - oneh * 2, null);}catch(Exception e){}
	try{res.getGraphics().drawImage(fill(img.getSubimage(onew, oneh, onew, oneh), w - onew * 2, h - oneh * 2), onew, oneh, w - onew * 2, h - oneh * 2, null);}catch(Exception e){}

	return res;
    }