ITeye博客

java另存图片底色变黑问题

lu_tan · 2014-07-16 11:32 · java · 编程语言 · Markdown

BufferedImage bufferImage; File outputFile = null; try{ Image image = ImageIO.red(new File("c:\pic\aa.jpeg")); int width = image.getWidth(null); int height = image.getHeight(null); bufferImage= new BufferedImage (width,height,BufferedImage.TYPE_INT_RGB); bufferImage.getGraphics().drawImage(image,0,0,width,height,image.getGraphics().getColor(),null);//设置底色

   outputFile = new File("c:\\pic\\bb.jpeg");
   if(!outputFile.exists())
        outputFile.mkdirs();
   ImageIO.write(bufferImage,"jpeg",outputFile);

}catch(IOException e){ e.printStackTrace(); }

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。