我注意到使用 ImageIO.write 有明显的质量损失,如何禁用自动压缩?
val baos: ByteArrayOutputStream = new ByteArrayOutputStream
val newBi = new BufferedImage(img.getWidth, img.getHeight, BufferedImage.TYPE_INT_RGB)
val gr = newBi.createGraphics()
gr.drawImage(img, 0, 0, img.getWidth(), img.getHeight(), Color.WHITE, null)
ImageIO.write(newBi, "jpeg", baos)
val b = baos.toByteArray
baos.close()