/** * Reads the image from the InputStream and returns the pixel array (byte, short, int or float). * Returns null if there was an IO exception. Does not close the InputStream. */ public Object readPixels(InputStream in) { Object pixels; startTime = System.currentTimeMillis(); try { switch (fi.fileType) { case FileInfo.GRAY8: case FileInfo.COLOR8: bytesPerPixel = 1; skip(in); pixels = (Object) read8bitImage(in); break; case FileInfo.GRAY16_SIGNED: case FileInfo.GRAY16_UNSIGNED: bytesPerPixel = 2; skip(in); pixels = (Object) read16bitImage(in); break; case FileInfo.GRAY32_INT: case FileInfo.GRAY32_UNSIGNED: case FileInfo.GRAY32_FLOAT: bytesPerPixel = 4; skip(in); pixels = (Object) read32bitImage(in); break; case FileInfo.GRAY64_FLOAT: bytesPerPixel = 8; skip(in); pixels = (Object) read64bitImage(in); break; case FileInfo.RGB: case FileInfo.BGR: case FileInfo.ARGB: case FileInfo.ABGR: case FileInfo.BARG: case FileInfo.CMYK: bytesPerPixel = fi.getBytesPerPixel(); skip(in); pixels = (Object) readChunkyRGB(in); break; case FileInfo.RGB_PLANAR: bytesPerPixel = 3; skip(in); pixels = (Object) readPlanarRGB(in); break; case FileInfo.BITMAP: bytesPerPixel = 1; skip(in); pixels = (Object) read1bitImage(in); break; case FileInfo.RGB48: bytesPerPixel = 6; skip(in); pixels = (Object) readRGB48(in); break; case FileInfo.RGB48_PLANAR: bytesPerPixel = 2; skip(in); pixels = (Object) readRGB48Planar(in); break; case FileInfo.GRAY12_UNSIGNED: skip(in); short[] data = read12bitImage(in); pixels = (Object) data; break; case FileInfo.GRAY24_UNSIGNED: skip(in); pixels = (Object) read24bitImage(in); break; default: pixels = null; } showProgress(1, 1); return pixels; } catch (IOException e) { IJ.log("" + e); return null; } }