日期:2014-05-20 浏览次数:21082 次
private BufferedImage ReadImage(String filePath,int width,int height)
        {
            File file = new File(filePath);  
            if (!file.exists()) 
            {   
                return null;   
            }   
            try 
            {
                Image    imagemain = ImageIO.read(file);
                BufferedImage Mainimage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
                Mainimage.getGraphics().drawImage(imagemain.getScaledInstance(width, height,Image.SCALE_SMOOTH), 0, 0, null); 
                return Mainimage;
            }
            catch (IOException e) 
            {
                e.printStackTrace();
            }   
            return null;
        }