J#-改变图片大小

public Image ImageChangeSize(String imageName,int width,int height)
    {
        Image img = null;
        try
        {
            File f = new File("src/Image/Software/Plane/"+imageName);//找到文件所在的位置
            BufferedImage src = ImageIO.read(f);//把文件读到缓存里去
            Graphics g = src.getGraphics();//给缓存添加一支画笔
            img = src.getScaledInstance(width,height,BufferedImage.SCALE_SMOOTH);//在缓存里描绘图片的大小
            g.drawImage(img,0,0,null);//用画笔画出图片
            g.dispose();//销毁画笔
        }
        catch(Exception ex)
        {
            ex.getStackTrace();
        }
        return img;
    }

 

posted on 2014-07-06 22:52  ylbtech  阅读(141)  评论(0编辑  收藏  举报