Search code examples
javaimageimage-processingraster

How do I take an image file and convert it into a raster and then access its data?


How do I take an image file and convert it into a raster and then access its data (RBG values) pixel by pixel?


Solution

  • BufferedImage img = ImageIO.read(new File("lol"));
    int rgb = img.getRGB(x, y);
    
    Color c = new Color(rgb);
    

    Now you can use Color.getRed(), getGreen(), getBlue() and getAlpha() to get the different values