content: package com.zzk.teris.util;
  
  import java.awt.Graphics2D;
  import java.awt.Image;
  import java.awt.RenderingHints;
  import java.awt.image.BufferedImage;
  import java.io.IOException;
  import java.net.URL;
  
  import javax.imageio.ImageIO;
  
  public class GameUtil {
  
  	/**
  	 * ͼƬ·ȡͼƬ
  	 * 
  	 * @param imagePath
  	 * @return ͼƬ
  	 */
  	public static Image getImage(String imagePath) {
  		URL url = GameUtil.class.getClassLoader().getResource(imagePath);
  		BufferedImage img = null;
  		try {
  			img = ImageIO.read(url);
  		} catch (IOException e) {
  			e.printStackTrace();
  		}
  		return img;
  	}
  	/**
  	 * ָǶתͼƬ
  	 * @param bufferedimage
  	 * @param degree
  	 * @return ͼƬ
  	 */
  	public static Image rotateImage(final BufferedImage bufferedimage, final int degree) {
  		int w = bufferedimage.getWidth();// õͼƬȡ
  		int h = bufferedimage.getHeight();// õͼƬ߶ȡ
  		int type = bufferedimage.getColorModel().getTransparency();// õͼƬ͸ȡ
  		BufferedImage img;// յͼƬ
  		Graphics2D graphics2d;// յĻʡ
  		(graphics2d = (img = new BufferedImage(w, h, type)).createGraphics())
  				.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
  		graphics2d.rotate(Math.toRadians(degree), w / 2, h / 2);// תdegreeͣ紹ֱ90ȡ
  		graphics2d.drawImage(bufferedimage, 0, 0, null);// bufferedimagecopyͼƬimg0,0imgꡣ
  		graphics2d.dispose();
  		return img;// ظƺõͼƬԭͼƬȻûб䣬ûת´λʹá
  	}
  }
  