Java BufferedImage Load loadImageData(String name)

Here you can find the source of loadImageData(String name)

Description

load Image Data

License

Apache License

Declaration

public static double[] loadImageData(String name) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.awt.image.BufferedImage;

import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;

public class Main {
    public static double[] loadImageData(String name) {
        BufferedImage bi = null;/*from w  w  w.  jav a  2  s  .  c o m*/
        double[] arr = null;
        try {
            File f = new File(name);
            bi = ImageIO.read(f);
            int w = bi.getWidth(null);
            int h = bi.getHeight(null);
            arr = new double[w * h];
            System.out.println("w " + w + " : h " + h);
            bi.getRaster().getPixels(0, 0, w, h, arr);
        } catch (IOException e) {
            System.out.println("Image could not be read");
            System.exit(1);
        }
        return arr;
    }
}

Related

  1. loadImage(String resourceName)
  2. loadImage(String url)
  3. loadImage(URL resource)
  4. loadImage(URL url)
  5. loadImageData(BufferedImage image)
  6. loadImageFromBytes(byte[] bytes)
  7. loadImageFromFile(File f)
  8. loadImageFromFile(File file)
  9. loadImageFromFile(String filename)