日期:2014-05-20 浏览次数:21151 次
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class Test {
public static void main(String[] args) throws IOException {
BufferedImage bi = (BufferedImage) ImageIO.read(new File("E:\\2.png"));
// 获取图像的宽度和高度
int width = bi.getWidth();
int height = bi.getHeight();
boolean isTransparent = true;
// 扫描图片
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {// 行扫描
int dip = bi.getRGB(j, i);
if (dip != -1){
isTransparent = false;
}
}
}
if(isTransparent){
System.out.println("透明图片");
}else{
System.out.println("不透明图片");
}
}
}