@Override protected void initializeRasterReader( int width, int height, int bitsPerSample, RasterReader rasterReader) { IFD rasterIFD = ((TIFFMetadataSupport) metadata).getRasterIFD(); rasterReader.setWidth(width); rasterReader.setHeight(height); rasterReader.setBitsPerSample(bitsPerSample); // if (rasterReader instanceof Gray12RasterReader) { // IFD primaryIFD = ((TIFFMetadataSupport) metadata).getPrimaryIFD(); // ((Gray12RasterReader) rasterReader).setStripsOffset(primaryIFD.getStripOffsets()); // } if ((rasterIFD != null) && rasterIFD.isCompressionAvailable()) { rasterReader.setCompression(rasterIFD.getCompression().intValue()); } if ((rasterIFD != null) && rasterIFD.isStripByteCountsAvailable()) { rasterReader.setStripByteCount(rasterIFD.getStripByteCounts()); } if ((rasterIFD != null) && rasterIFD.isTileWidthAvailable()) { int imageWidth = rasterIFD.getImageWidth(); int imageLength = rasterIFD.getImageLength(); int tileWidth = rasterIFD.getTileWidth(); int tileLength = rasterIFD.getTileLength(); rasterReader.setTileWidth(tileWidth); rasterReader.setTileHeight(tileLength); rasterReader.setTilesAcross((imageWidth + tileWidth - 1) / tileWidth); rasterReader.setTilesDown((imageLength + tileLength - 1) / tileLength); rasterReader.setTileOffsets(rasterIFD.getTileOffsets()); // int[] tileByteCounts = imageIFD.getTileByteCounts(); } }
@Override protected WritableRaster loadRAWRaster() throws IOException { final IFD rasterIFD = ((TIFFMetadataSupport) metadata).getPrimaryIFD(); final RasterReader rasterReader = new Grey12RasterReader(); final int width = rasterIFD.getImageWidth(); final int height = rasterIFD.getImageLength(); final int bitsPerSample = rasterIFD.getBitsPerSample()[0]; initializeRasterReader(width, height, bitsPerSample, rasterReader); if (!rasterIFD.isTileWidthAvailable()) { iis.seek( rasterIFD.getStripOffsets()); // FIXME: move, it's responsibility of the rreader to seek } final WritableRaster raster = rasterReader.loadRaster(iis, this); return raster; }