public static BufferedImage convert(Bitmap bitmap, int w, int h, Object game, SpriteHandler sprite) throws IOException {
    	Bitmap result = bitmap;
        InputStream input = null;
        BufferedImage image = null;
        BufferedImage finalImage = null;
        for(int i = 0; i < sprite.getLength(); i++) {
        	for(int j = 0; j < sprite.getLength(i); j++) {
        		if(result == sprite.getSprites(i, j)) {
        			input = game.getClass().getResourceAsStream(sprite.getRes());
        			image = ImageIO.read(input);
        			finalImage = image.getSubimage(i * w, j * h, w, h);
        		}
        	}
        }
        if(image != null)
        	image.flush();
        input.close();
        return finalImage;
    }