I'm trying to use the following code of java to read image data on android. Since ImageIO is not supported, what are some ways I may use getData().getPixels()?
By changing BufferedImage into Bitmap, I can get all other codes working besides bi.getData().getPixels()?
Any method in the android library I may use to replace it?
In android Bitmap class: public void getPixels (int[] pixels, int offset, int stride, int x, int y, int width, int height)
This method supports int[], but not double[]. I'm not familiar with image processing will they be different?
Thank you.
private double[] getImageData(String imageFileName) throws FaceRecError {
BufferedImage bi = null;
double[] inputFace = null;
try{
bi = ImageIO.read(new File(imageFileName));
}catch(IOException ioe){
throw new FaceRecError(ioe.getMessage());
}
if (bi != null){
int imageWidth = bi.getWidth();
int imageHeight = bi.getHeight();
inputFace = new double[imageWidth * imageHeight];
bi.getData().getPixels(0, 0, imageWidth, imageHeight,inputFace);
}
return inputFace;
}