且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在java中将图像转换为透明图像

更新时间:2023-01-23 08:13:19

谷歌的第一个结果就是:

The first result from Google is this:

使颜色透明
http:// www .rgagnon.com / javadetails / java-0265.html

它使图像的蓝色部分透明,但我相信你可以适应使用白色intstead

It makes the Blue part of an image transparent, but I'm sure you can adapt that to use White intstead

(提示:将 Color.WHITE 传递给 makeColorTransparent 函数,而不是 Color.BLUE

(hint: Pass Color.WHITE to the makeColorTransparent function, instead of Color.BLUE)

在这里找到一个更完整和现代的答案: 如何使颜色透明在BufferedImage中保存为PNG

Found a more complete and modern answer here: How to make a color transparent in a BufferedImage and save as PNG