如何找出BufferedImage在Java中的Alpha位置? [英] How can i find out where a BufferedImage has Alpha in Java?
问题描述
我有一个BufferedImage和一个布尔型[] []数组。
我想将数组设置为true,以使图像完全透明。
类似于:
< (int y = 0; y< height; y ++){
alphaArray(pre $); pre> for(int x = 0; x< width; x ++) [x] [y] = bufferedImage.getAlpha(x,y)== 0;
}
}
但getAlpha(x,y)方法不会存在,我没有找到任何我可以使用的东西。
有一个getRGB(x,y)方法,但我不确定它是否包含alpha值或如何提取它。
任何人都可以帮我?
谢谢!
public static boolean isAlpha(BufferedImage image,int x,int y)
{
return image.getRBG(x,y)& 0xFF000000 == 0xFF000000;
for(int x = 0; x {
for(int y = 0; y {
alphaArray [x ] [y] = isAlpha(bufferedImage,x,y);
}
}
I've got a BuferredImage and a boolean[][] array. I want to set the array to true where the image is completely transparant.
Something 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 does not exist, and I did not find anything else I can use. There is a getRGB(x, y) method, but I'm not sure if it contains the alpha value or how to extract it.
Can anyone help me? Thank you!
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);
}
}
这篇关于如何找出BufferedImage在Java中的Alpha位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!