gpt4 book ai didi

Java BufferedImage 没有注册透明像素?

转载 作者:行者123 更新时间:2023-11-30 08:29:25 24 4
gpt4 key购买 nike

我使用方法 ImageIO.read(File file); 读取 PNG 图像文件。但是,当我在其上使用 getRGB(int x, int y) 方法提取 alpha 时,无论像素是否透明,它始终返回 255。我该如何解决这种不便?

最佳答案

将打包的int 颜色转换为Color 对象时,您需要告诉它是否应该计算alpha 值。

new Color(image.getRGB(x, y), true).getAlpha();

参见 Color(int, boolean)了解更多详情

关于Java BufferedImage 没有注册透明像素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19440064/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com