File iconFile = new File("C://icon.jpg"); BufferedImage imgBuffTmp; if(iconFile.exists()){ try { //得到图象 BufferedImage imgBuff = ImageIO.read(iconFile); //调整图片大小 imgBuffTmp = ImageEdit.resizeImage(imgBuff,360,360); //扫描图象旋转90度 imgBuffTmp = ImageEdit.rotateImage(imgBuffTmp,90); //输出图象 ImageIO.write(imgBuffTmp,"jpeg",iconFile); } catch (IOException e1) { // TODO 自动生成 catch 块 e1.printStackTrace(); } pform.setPath("C://icon.jpg"); pform.setScanFlag("1"); } /* * 创建日期 2009-6-26 * * TODO 要更改此生成的文件的模板,请转至 * 窗口 - 首选项 - Java - 代码样式 - 代码模板 */ package com.jgc.web.util; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.image.BufferedImage; /** * @author hl * * TODO 要更改此生成的类型注释的模板,请转至 * 窗口 - 首选项 - Java - 代码样式 - 代码模板 */ public class ImageEdit { /** * 旋转图片为指定角度 * * @param bufferedimage * 目标图像 * @param degree * 旋转角度 * @return * * 2009-06-25 * * by hl */ public static BufferedImage 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); graphics2d.drawImage(bufferedimage, 0, 0, null); graphics2d.dispose(); return img; } /** * 变更图像为指定大小 * * @param bufferedimage * 目标图像 * @param w * 宽 * @param h * 高 * @return * * 2009-06-25 * * by hl */ public static BufferedImage resizeImage(final BufferedImage bufferedimage, final int w, final int h){ 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.drawImage(bufferedimage, 0, 0, w, h, 0, 0, bufferedimage .getWidth(), bufferedimage.getHeight(), null); graphics2d.dispose(); return img; } }