/** * @see loci.formats.IFormatReader#openBytes(int, byte[], int, int, int, int) */ @Override public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException { FormatTools.checkPlaneParameters(this, no, buf.length, x, y, w, h); int[] coords = getZCTCoords(no); long offset = getPlaneByteOffset(coords[0], coords[1], coords[2]); if (offset < in.length()) { in.seek(offset); readPlane(in, x, getSizeY() - h - y, w, h, buf); // reverse the order of the rows // planes are stored with the origin in the lower-left corner byte[] tmp = new byte[w * FormatTools.getBytesPerPixel(getPixelType())]; for (int row=0; row<h/2; row++) { int src = row * tmp.length; int dest = (h - row - 1) * tmp.length; System.arraycopy(buf, src, tmp, 0, tmp.length); System.arraycopy(buf, dest, buf, src, tmp.length); System.arraycopy(tmp, 0, buf, dest, tmp.length); } } return buf; }
/** * @see loci.formats.IFormatReader#openBytes(int, byte[], int, int, int, int) */ @Override public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException { FormatTools.checkPlaneParameters(this, no, buf.length, x, y, w, h); int[] coords = getZCTCoords(no); long offset = getPlaneByteOffset(coords[0], coords[1], coords[2]); if (offset < in.length()) { in.seek(offset); readPlane(in, x, getSizeY() - h - y, w, h, buf); // reverse the order of the rows // planes are stored with the origin in the lower-left corner byte[] tmp = new byte[w * FormatTools.getBytesPerPixel(getPixelType())]; for (int row=0; row<h/2; row++) { int src = row * tmp.length; int dest = (h - row - 1) * tmp.length; System.arraycopy(buf, src, tmp, 0, tmp.length); System.arraycopy(buf, dest, buf, src, tmp.length); System.arraycopy(tmp, 0, buf, dest, tmp.length); } } return buf; }
getSizeX() * getSizeY() * FormatTools.getBytesPerPixel(getPixelType()); int realPlaneCount = (int) ((in.length() - HEADER_LENGTH - extSize) / planeSize);
getSizeX() * getSizeY() * FormatTools.getBytesPerPixel(getPixelType()); int realPlaneCount = (int) ((in.length() - HEADER_LENGTH - extSize) / planeSize);
@Test(dependsOnMethods={"testSetId"}) public void testDimensions() { assertEquals(all.getSeriesCount(), pixelsOnly.getSeriesCount()); assertEquals(all.getSizeX(), pixelsOnly.getSizeX()); assertEquals(all.getSizeY(), pixelsOnly.getSizeY()); assertEquals(all.getSizeZ(), pixelsOnly.getSizeZ()); assertEquals(all.getSizeC(), pixelsOnly.getSizeC()); assertEquals(all.getSizeT(), pixelsOnly.getSizeT()); assertEquals(all.getPixelType(), pixelsOnly.getPixelType()); }