java另存图片底色变黑问题
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();
}