我正在使用org.imgscalr.Scalr(http://www.thebuzzmedia.com/software/imgscalr-java-image-scaling-library/#solve)库来调整图像大小,但是当PNG图像具有透明背景时,调整大小后会变成黑色。我的代码如下:
public void scaleImage(String originalImage, int width, int height) throws IOException {
File imgFl = new File(originalImage);
BufferedImage originalBufImage = ImageIO.read(imgFl);
BufferedImage scaledImage = Scalr.resize(originalBufImage, Scalr.Method.ULTRA_QUALITY, width, height, Scalr.OP_BRIGHTER);
File outputfile = new File(originalImage);
String fileExtension = originalImage.substring(originalImage.indexOf(".") + 1, originalImage.length());
ImageIO.write(scaledImage, fileExtension, outputfile);
}
有人知道这是怎么回事吗?
谢谢,Abhishek