我怎样才能找到BufferedImage在Java中使用Alpha的位置?

Rap*_*pti 6 java graphics bufferedimage alpha

我有一个BuferredImage和一个boolean [] []数组.我想将数组设置为true,其中图像是完全透明的.

就像是:

for(int x = 0; x < width; x++) {
    for(int y = 0; y < height; y++) {
        alphaArray[x][y] = bufferedImage.getAlpha(x, y) == 0;
    }
}
Run Code Online (Sandbox Code Playgroud)

但getAlpha(x,y)方法不存在,我找不到任何我可以使用的方法.有一个getRGB(x,y)方法,但我不确定它是否包含alpha值或如何提取它.

谁能帮我?谢谢!

Eng*_*uad 7

public static boolean isAlpha(BufferedImage image, int x, int y)
{
    return image.getRBG(x, y) & 0xFF000000 == 0xFF000000;
}
Run Code Online (Sandbox Code Playgroud)
for(int x = 0; x < width; x++)
{
    for(int y = 0; y < height; y++)
    {
        alphaArray[x][y] = isAlpha(bufferedImage, x, y);
    }
}
Run Code Online (Sandbox Code Playgroud)