in src/main/java/org/apache/pdfbox/jbig2/image/Resizer.java [201:274]
private void resizeXfirst(final Object src, final Rectangle srcBounds, final Object dst,
final Rectangle dstBounds, final ParameterizedFilter xFilter,
final ParameterizedFilter yFilter)
{
// source scanline buffer
final Scanline buffer = createScanline(src, dst, srcBounds.width);
// accumulator buffer
final Scanline accumulator = createScanline(src, dst, dstBounds.width);
// a sampled filter for source pixels for each dest x position
final Weighttab xWeights[] = createXWeights(srcBounds, dstBounds, xFilter);
// Circular buffer of active lines
final int yBufferSize = yFilter.width + 2;
final Scanline lineBuffer[] = new Scanline[yBufferSize];
for (int y = 0; y < yBufferSize; y++)
{
lineBuffer[y] = createScanline(src, dst, dstBounds.width);
lineBuffer[y].y = -1; /* mark scanline as unread */
}
// range of source and destination scanlines in regions
final int srcY0 = srcBounds.y;
final int srcY1 = srcBounds.y + srcBounds.height;
final int dstY0 = dstBounds.y;
final int dstY1 = dstBounds.y + dstBounds.height;
int yFetched = -1; // used to assert no backtracking
// loop over dest scanlines
for (int dstY = dstY0; dstY < dstY1; dstY++)
{
// a sampled filter for source pixels for each dest x position
final Weighttab yWeight = new Weighttab(yFilter, weightOne,
mappingY.mapPixelCenter(dstY), srcY0, srcY1 - 1, true);
accumulator.clear();
// loop over source scanlines that contribute to this dest scanline
for (int srcY = yWeight.i0; srcY <= yWeight.i1; srcY++)
{
final Scanline srcBuffer = lineBuffer[srcY % yBufferSize];
if (debug)
System.out.println(" abuf.y / ayf " + srcBuffer.y + " / " + srcY);
if (srcBuffer.y != srcY)
{
// scanline needs to be fetched from src raster
srcBuffer.y = srcY;
if (srcY0 + srcY <= yFetched)
throw new AssertionError(
"Backtracking from line " + yFetched + " to " + (srcY0 + srcY));
buffer.fetch(srcBounds.x, srcY0 + srcY);
yFetched = srcY0 + srcY;
// filter it into the appropriate line of linebuf (xfilt)
buffer.filter(NO_SHIFT, bitsPerChannel, xWeights, srcBuffer);
}
// add weighted tbuf into accum (these do yfilt)
srcBuffer.accumulate(yWeight.weights[srcY - yWeight.i0], accumulator);
}
accumulator.shift(finalShift);
accumulator.store(dstBounds.x, dstY);
if (debug)
System.out.printf("\n");
}
}