public byte[] openBytes(int no, byte[] buf, int x1, int y1, int w1, int h1) throws FormatException, IOException { FormatTools.assertId(currentId, true, 1); FormatTools.checkPlaneNumber(this, no); FormatTools.checkBufferSize(this, buf.length); int[] zct = FormatTools.getZCTCoords(this, no); byte[] plane = null; if (raw != null) { plane = raw.getPlane(zct[0], zct[1], zct[2]); } else if (prx != null) { try { plane = prx.getPlane(zct[0], zct[1], zct[2]); } catch (Exception e) { throw new RuntimeException(e); } } else { throw new RuntimeException("Improperly configured"); } int len = getSizeX() * getSizeY() * FormatTools.getBytesPerPixel(getPixelType()); System.arraycopy((byte[]) plane, 0, buf, 0, len); return buf; }