How can I find where bufferedimage uses alpha in Java?

I have a buffered image and a Boolean [] [] array

It's like:

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

But the getalpha (x, y) method doesn't exist, and I can't find any method I can use There is a getrgb (x, y) method, but I'm not sure if it contains an alpha value or how to extract it

Who can help me? thank you!

Solution

public static boolean isAlpha(BufferedImage image,int x,int y)
public static boolean isAlpha(BufferedImage image,int x,int y)
{
    return image.getRBG(x,y) & 0xFF000000 == 0xFF000000;
}
for(int x = 0; x < width; x++)
{
    for(int y = 0; y < height; y++)
    {
        alphaArray[x][y] = isAlpha(bufferedImage,x,y);
    }
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>