private static synchronized void readBandRasterData(final int sourceMinX, final int sourceMinY, final int sourceWidth, final int sourceHeight, final int sourceStepX, final int sourceStepY, final long bandOffset, final ImageInputStream imageInputStream, final Band destBand, final int destWidth, final ProductData destBuffer) throws IOException { final int sourceMaxX = sourceMinX + sourceWidth - 1; final int sourceMaxY = sourceMinY + sourceHeight - 1; final int sourceRasterWidth = destBand.getRasterWidth(); final int elemSize = destBuffer.getElemSize(); int destPos = 0; for (int sourceY = sourceMinY; sourceY <= sourceMaxY; sourceY += sourceStepY) { final long sourcePosY = sourceY * sourceRasterWidth; if (sourceStepX == 1) { imageInputStream.seek(bandOffset + elemSize * (sourcePosY + sourceMinX)); destBuffer.readFrom(destPos, destWidth, imageInputStream); destPos += destWidth; } else { for (int sourceX = sourceMinX; sourceX <= sourceMaxX; sourceX += sourceStepX) { imageInputStream.seek(bandOffset + elemSize * (sourcePosY + sourceX)); destBuffer.readFrom(destPos, 1, imageInputStream); destPos++; } } } }
if (sourceStepX == 1) { imageInputStream.seek(bandOffset + elemSize * (sourcePosY + sourceMinX)); tmpBuffer.readFrom(destPos, tmpWidth, imageInputStream); destPos += tmpWidth; } else { for (int sourceX = sourceMinX; sourceX <= sourceMaxX; sourceX += sourceStepX) { imageInputStream.seek(bandOffset + elemSize * (sourcePosY + sourceX)); tmpBuffer.readFrom(destPos, 2, imageInputStream); destPos++;
destBuffer.readFrom(y * destWidth + readWidth, bandDestWidth, readStream);
imageInputStream.seek(bandOffset + elemSize * (sourcePosY + sourceMinX)); destBuffer.readFrom(destPos, destWidth, imageInputStream); destPos += destWidth; } else { for (int sourceX = sourceMinX; sourceX <= sourceMaxX; sourceX += sourceStepX) { imageInputStream.seek(bandOffset + elemSize * (sourcePosY + sourceX)); destBuffer.readFrom(destPos, 1, imageInputStream); destPos++;
long lineStartPos = headerOffset + sourceY * lineSizeInBytes; bandInfo.inStream.seek(lineStartPos + elemSize * sourceOffsetX * numBands); lineData.readFrom(0, sourceWidth * numBands, bandInfo.inStream);
long lineStartPos = headerOffset + sourceY * lineSizeInBytes; inStream.seek(lineStartPos + elemSize * sourceOffsetX); lineData.readFrom(0, sourceWidth, inStream);
@Override protected void readBandRasterDataImpl(int sourceOffsetX, int sourceOffsetY, int sourceWidth, int sourceHeight, int sourceStepX, int sourceStepY, Band destBand, int destOffsetX, int destOffsetY, int destWidth, int destHeight, ProductData destBuffer, ProgressMonitor pm) throws IOException { final int sourceMaxY = sourceOffsetY + sourceHeight - 1; Product product = destBand.getProduct(); final int elemSize = destBuffer.getElemSize(); final int bandIndex = product.getBandIndex(destBand.getName()); final long lineSizeInBytes = (long)metadata.getRasterWidth() * (long)metadata.getRasterPixelSize(); int numBands = product.getNumBands(); pm.beginTask("Reading band '" + destBand.getName() + "'...", sourceMaxY - sourceOffsetY); try { int destPos = 0; for (int sourceY = sourceOffsetY; sourceY <= sourceMaxY; sourceY += sourceStepY) { if (pm.isCanceled()) { break; } synchronized (sharedLock) { long lineStartPos = sourceY * numBands * lineSizeInBytes + bandIndex * lineSizeInBytes; imageInputStream.seek(lineStartPos + elemSize * sourceOffsetX); destBuffer.readFrom(destPos, destWidth, imageInputStream); destPos += destWidth; } pm.worked(1); } } finally { pm.done(); } }
long lineStartPos = headerOffset + sourceY * lineSizeInBytes; inStream.seek(lineStartPos + elemSize * sourceOffsetX * numBands); lineData.readFrom(0, sourceWidth * numBands, inStream);
long lineStartPos = headerOffset + sourceY * lineSizeInBytes; inStream.seek(lineStartPos + elemSize * sourceOffsetX * numBands); lineData.readFrom(0, sourceWidth * numBands, inStream);