Example usage for java.awt.image Raster getNumBands

List of usage examples for java.awt.image Raster getNumBands

Introduction

In this page you can find the example usage for java.awt.image Raster getNumBands.

Prototype

public final int getNumBands() 

Source Link

Document

Returns the number of bands (samples per pixel) in this Raster.

Usage

From source file:tooltip.ImageComparison.java

public static void setUp() throws Exception {
    boolean ret = true;
    System.out.println("Inside Setup C:\\Comcast Project Docs\\Automation\\CAAP AUTOMATION\\Selenium");
    //System.setProperty("webdriver.chrome.driver","C:\\Users\\ajavva001c\\Downloads\\chromedriver.exe");

    WebDriver driver = new FirefoxDriver();
    driver.manage().window().maximize();
    driver.get("https://activator-web-qaauto.g1.app.cloud.comcast.net/Activate/comFlow");
    File url = new File("C:/Users/ajavva001c/HSD/unpacked.png");
    FileInputStream fi = new FileInputStream(url);
    BufferedImage bufImgOne = ImageIO.read(fi);
    String s1 = driver.findElement(By.xpath("//*[@id='responsive']/div/div/div[2]/div/ul/li[2]/img"))
            .getAttribute("src");
    URL urls = new URL(s1);
    System.out.println(urls);// w w w  . j a  v  a  2  s  .co  m
    BufferedImage bufImgOne1 = ImageIO.read(urls);
    Raster image = bufImgOne.getData();
    Raster image1 = bufImgOne1.getData();
    if (image.getNumBands() != image1.getNumBands() && image.getWidth() != image1.getWidth()
            && image.getHeight() != image1.getHeight()) {
        ret = false;
        System.out.println("fail");
    } else {
        search: for (int i = 0; i < image.getNumBands(); ++i) {
            for (int x = 0; x < image.getWidth(); ++x) {
                for (int y = 0; y < image.getHeight(); ++y) {
                    if (image.getSample(x, y, i) != image1.getSample(x, y, i)) {
                        ret = false;
                        break search;
                    }

                }
            }
        }
        System.out.println(ret);
    }
    driver.quit();
}