Exemplo n.º 1
0
  /** @see loci.formats.IFormatReader#openBytes(int, byte[], int, int, int, int) */
  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);

    String file = getFilename(getSeries(), no);
    int field = getSeries() % (fieldRows * fieldCols);
    int fieldRow = field / fieldCols;
    int fieldCol = field % fieldCols;

    if (file != null) {
      try {
        reader.setId(file);
        if (fieldRows * fieldCols == 1) {
          reader.openBytes(0, buf, x, y, w, h);
        } else {
          // fields are stored together in a single image,
          // so we need to split them up
          int fx = x + (fieldCol * getSizeX());
          int fy = y + (fieldRow * getSizeY());
          reader.openBytes(0, buf, fx, fy, w, h);
        }
      } catch (FormatException e) {
        LOGGER.debug("Could not read file " + file, e);
        return buf;
      } catch (IOException e) {
        LOGGER.debug("Could not read file " + file, e);
        return buf;
      }
    }

    return buf;
  }
Exemplo n.º 2
0
  /** @see loci.formats.IFormatReader#openBytes(int, byte[], int, int, int, int) */
  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);

    String file = positions.get(getSeries()).getFile(no);

    if (file != null && new Location(file).exists()) {
      tiffReader.setId(file);
      return tiffReader.openBytes(0, buf, x, y, w, h);
    }
    LOGGER.warn("File for image #{} ({}) is missing.", no, file);
    return buf;
  }
Exemplo n.º 3
0
  /** @see loci.formats.IFormatReader#openBytes(int, byte[], int, int, int, int) */
  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);
    if (getSizeC() == 1) {
      return super.openBytes(no, buf, x, y, w, h);
    }

    byte[] b = delegate.openBytes(no / getSizeC(), x, y, w, h);
    int bpp = FormatTools.getBytesPerPixel(getPixelType());
    int c = getZCTCoords(no)[1];
    ImageTools.splitChannels(b, buf, c, getSizeC(), bpp, false, isInterleaved(), w * h * bpp);
    return buf;
  }