JAVA图片类型转换

public static void main(String[] args) throws Exception {
		File source = new File("E://1.bmp");
		String type = "gif";
		BufferedImage inImg = ImageIO.read(source);
		int wideth = inImg.getWidth(null);
		int height = inImg.getHeight(null);
		BufferedImage bimage = new BufferedImage(wideth, height,
				BufferedImage.SCALE_SMOOTH);
		bimage.getGraphics().drawImage(inImg, 0, 0, wideth, height, null);
		File outfile = new File("E://2.gif");
		OutputStream out = new FileOutputStream(outfile);
		ImageIO.write(bimage, type, out);
		source.delete();
		out.close();
	}

你可能感兴趣的:(java)