if (isOptimizedCase) {
ByteComponentRaster tile =
(ByteComponentRaster)image.getTile(0, 0);
byte[] data = ((DataBufferByte)tile.getDataBuffer()).getData();
ComponentSampleModel csm =
(ComponentSampleModel)tile.getSampleModel();
int offset = csm.getOffset(sourceXOffset, sourceYOffset, 0);
// take into account the raster data offset
offset += tile.getDataOffset(0);
int lineStride = csm.getScanlineStride();
writeRowsOpt(data, offset, lineStride, compressor,
0, 8, destWidth, destHeight,
numRowsWritten, progressReportRowPeriod);
if (abortRequested()) {
return;
}
numRowsWritten += destHeight/8;
writeRowsOpt(data, offset, lineStride, compressor,
4, 8, destWidth, destHeight,
numRowsWritten, progressReportRowPeriod);
if (abortRequested()) {
return;
}
numRowsWritten += (destHeight - 4)/8;
writeRowsOpt(data, offset, lineStride, compressor,
2, 4, destWidth, destHeight,
numRowsWritten, progressReportRowPeriod);
if (abortRequested()) {
return;
}
numRowsWritten += (destHeight - 2)/4;
writeRowsOpt(data, offset, lineStride, compressor,
1, 2, destWidth, destHeight,
numRowsWritten, progressReportRowPeriod);
} else {
writeRows(image, compressor,
sourceXOffset, periodX,
sourceYOffset, 8*periodY,
sourceWidth,
0, 8, destWidth, destHeight,
numRowsWritten, progressReportRowPeriod);
if (abortRequested()) {
return;
}
numRowsWritten += destHeight/8;
writeRows(image, compressor, sourceXOffset, periodX,
sourceYOffset + 4*periodY, 8*periodY,
sourceWidth,
4, 8, destWidth, destHeight,
numRowsWritten, progressReportRowPeriod);
if (abortRequested()) {
return;
}
numRowsWritten += (destHeight - 4)/8;
writeRows(image, compressor, sourceXOffset, periodX,
sourceYOffset + 2*periodY, 4*periodY,
sourceWidth,
2, 4, destWidth, destHeight,
numRowsWritten, progressReportRowPeriod);
if (abortRequested()) {
return;
}
numRowsWritten += (destHeight - 2)/4;
writeRows(image, compressor, sourceXOffset, periodX,
sourceYOffset + periodY, 2*periodY,
sourceWidth,
1, 2, destWidth, destHeight,
numRowsWritten, progressReportRowPeriod);
}
} else {
if (DEBUG) System.out.println("Writing non-interlaced");
if (isOptimizedCase) {
Raster tile = image.getTile(0, 0);
byte[] data = ((DataBufferByte)tile.getDataBuffer()).getData();
ComponentSampleModel csm =
(ComponentSampleModel)tile.getSampleModel();
int offset = csm.getOffset(sourceXOffset, sourceYOffset, 0);
int lineStride = csm.getScanlineStride();
writeRowsOpt(data, offset, lineStride, compressor,
0, 1, destWidth, destHeight,
numRowsWritten, progressReportRowPeriod);
} else {