byte skipWhiteSpace() throws IOException { for (;;) { byte c = in.readByte(); if (c != ' ' && c != '\t' && c != '\n') { return c; } } } }
byte skipWhiteSpace() throws IOException { for (;;) { byte c = in.readByte(); if (c != ' ' && c != '\t' && c != '\n') { return c; } } } }
@Override public boolean isThisType(RandomAccessInputStream stream) throws IOException { final int blockLen = 4; if (!FormatTools.validStream(stream, blockLen, false)) return false; byte endian1 = stream.readByte(); byte endian2 = stream.readByte(); return ((endian1 == 1 && endian2 == 0) || (endian1 == 0 && endian2 == 1)) && stream.readString(2).equals("AR"); }
double readNumberString() throws IOException { numberBuffer[0] = skipWhiteSpace(); for (int i = 1;; i++) { byte c = in.readByte(); if (!(c >= '0' && c <= '9') && c != '.') { return Double.parseDouble( new String(numberBuffer, 0, i, Constants.ENCODING)); } numberBuffer[i] = c; } }
double readNumberString() throws IOException { numberBuffer[0] = skipWhiteSpace(); for (int i = 1;; i++) { byte c = in.readByte(); if (!(c >= '0' && c <= '9') && c != '.') { return Double.parseDouble( new String(numberBuffer, 0, i, Constants.ENCODING)); } numberBuffer[i] = c; } }
@Override public boolean isThisType(RandomAccessInputStream stream) throws IOException { final int blockLen = 4; if (!FormatTools.validStream(stream, blockLen, false)) return false; byte endian1 = stream.readByte(); byte endian2 = stream.readByte(); return ((endian1 == 1 && endian2 == 0) || (endian1 == 0 && endian2 == 1)) && stream.readString(2).equals("AR"); }
private boolean getNextByte() throws IOException, FormatException { while (offset == count) { index++; if (index == stripByteCounts.length) { loaded = true; bHasNext = false; return false; } in.seek(stripOffsets[index]); offset = 0; count = (int)stripByteCounts[index]; } currentByte = in.readByte(); offset++; return true; }
private boolean getNextByte() throws IOException, FormatException { while (offset == count) { index++; if (index == stripByteCounts.length) { loaded = true; bHasNext = false; return false; } in.seek(stripOffsets[index]); offset = 0; count = (int)stripByteCounts[index]; } currentByte = in.readByte(); offset++; return true; }
@Override public int read() throws IOException { int b = readByte(); if (b == -1 && (getFilePointer() >= length())) return 0; return b; }
@Override public int read() throws IOException { int b = readByte(); if (b == -1 && (getFilePointer() >= length())) return 0; return b; }
private Table readTable(RandomAccessInputStream s) throws IOException { Table t = new Table(); t.position = s.readByte(); byte[] bits = new byte[16]; s.read(bits); int sum = 0; for (byte bit : bits) { sum += (bit & 0xff); } t.content = new byte[bits.length + sum]; System.arraycopy(bits, 0, t.content, 0, bits.length); s.read(t.content, bits.length, t.content.length - bits.length); return t; }
/** @see loci.formats.IFormatReader#isThisType(RandomAccessInputStream) */ @Override public boolean isThisType(RandomAccessInputStream stream) throws IOException { if (!FormatTools.validStream(stream, HEADER_SIZE, false)) { return false; } char pixelType = (char) stream.readByte(); if (pixelType != 'I' && pixelType != 'R' && pixelType != 'C') { return false; } char check = (char) stream.readByte(); if (check != ' ') { return false; } long pixelCount = getDimension(stream); pixelCount *= getDimension(stream); pixelCount *= getDimension(stream); return pixelCount > 0; }
/** @see loci.formats.IFormatReader#isThisType(RandomAccessInputStream) */ @Override public boolean isThisType(RandomAccessInputStream stream) throws IOException { if (!FormatTools.validStream(stream, HEADER_SIZE, false)) { return false; } char pixelType = (char) stream.readByte(); if (pixelType != 'I' && pixelType != 'R' && pixelType != 'C') { return false; } char check = (char) stream.readByte(); if (check != ' ') { return false; } long pixelCount = getDimension(stream); pixelCount *= getDimension(stream); pixelCount *= getDimension(stream); return pixelCount > 0; }
private int findNextOffset(RandomAccessInputStream s, byte[] marker) throws IOException { for (long i=s.getFilePointer(); i<s.length()-marker.length; i++) { s.seek(i); boolean found = true; for (int q=0; q<marker.length; q++) { if (marker[q] != s.readByte()) { found = false; break; } } if (found) return (int) (i + marker.length); } return -1; }
private int findNextOffset(RandomAccessInputStream s, byte[] marker) throws IOException { for (long i=s.getFilePointer(); i<s.length()-marker.length; i++) { s.seek(i); boolean found = true; for (int q=0; q<marker.length; q++) { if (marker[q] != s.readByte()) { found = false; break; } } if (found) return (int) (i + marker.length); } return -1; }
private long findPixelsOffset(int fileIndex) throws IOException { String file = files.get(fileIndex); long fp = 0; try (RandomAccessInputStream s = new RandomAccessInputStream(file)) { s.order(isLittleEndian()); s.findString(false, HEADER_MARKER); int plane = FormatTools.getPlaneSize(this); int planeCount = getSizeZ() * getSizeT(); long skip = (s.length() - s.getFilePointer() - (planeCount * plane)) / planeCount; fp = s.getFilePointer() + skip - HEADER_MARKER.length(); s.seek(fp); if (s.readByte() == PIXELS_MARKER[PIXELS_MARKER.length - 1]) { fp++; } } return fp; }
private long findPixelsOffset(int fileIndex) throws IOException { String file = files.get(fileIndex); long fp = 0; try (RandomAccessInputStream s = new RandomAccessInputStream(file)) { s.order(isLittleEndian()); s.findString(false, HEADER_MARKER); int plane = FormatTools.getPlaneSize(this); int planeCount = getSizeZ() * getSizeT(); long skip = (s.length() - s.getFilePointer() - (planeCount * plane)) / planeCount; fp = s.getFilePointer() + skip - HEADER_MARKER.length(); s.seek(fp); if (s.readByte() == PIXELS_MARKER[PIXELS_MARKER.length - 1]) { fp++; } } return fp; }
public DirectoryEntry(RandomAccessInputStream s) throws IOException { schemaType = s.readString(2); pixelType = s.readInt(); filePosition = s.readLong(); filePart = s.readInt(); compression = s.readInt(); pyramidType = s.readByte(); if (pyramidType == 1) { prestitched = false; } s.skipBytes(1); // reserved s.skipBytes(4); // reserved dimensionCount = s.readInt(); dimensionEntries = new DimensionEntry[dimensionCount]; for (int i=0; i<dimensionEntries.length; i++) { dimensionEntries[i] = new DimensionEntry(s); // invalid dimension found; ignore it and the previous one if (dimensionEntries[i].dimension.length() > 1) { dimensionEntries[i] = null; if (i > 0) { dimensionEntries[i - 1] = null; } } } }