java 实现图片任意角度旋转,及背景透明

public BufferedImage rotate(Image image, float angle) {
		int w = image.getWidth(null);
		int h = image.getHeight(null);
		BufferedImage bImage = new BufferedImage(w, h,
		BufferedImage.TYPE_INT_RGB);
		Graphics2D g2d = bImage.createGraphics();
		
		bImage = g2d.getDeviceConfiguration().createCompatibleImage(w, h, Transparency.TRANSLUCENT); 
		g2d.dispose(); 
		g2d = bImage.createGraphics(); 

		
		g2d.rotate(Math.toRadians(angle),w/2,h/2);
		g2d.drawImage(image,0, 0, null);
		g2d.dispose();
		return bImage;
		}

你可能感兴趣的:(java)