I am trying to convert a pixel matrix into an image but its not working. Can anyone help me? Below is the code :  public static Image getImageFromArray(int[] pixels, int width, int height) throws IOException {
        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
        WritableRaster raster = (WritableRaster) image.getData();
        raster.setPixels(0,0,width,height,pixels);
        File output = new File("C:\\out.png");
	    ImageIO.write(image,"png",output);
	    System.out.print("written");
        return image;
    }
    public static void main(String args[]) throws IOException{
    	int width, height;
    	 BufferedImage source = ImageIO.read(new File(args[0]));
    	 width=source.getWidth();
    	 height=source.getHeight();
    	 //Util obj = new Util();
    	 Util.getImageFromArray(convertToPixels(source),width, height);
    }
}
