public class SlidingBitmapWindow extends Object
Bitmap, providing efficient
single-bit access to a 3-row neighbourhood around a current position.
The window maintains three rows simultaneously: the row above (-1),
the current row (0), and the row below (+1). Each row is held as a
24-bit register (prevByte | currentByte | nextByte). As the window
advances horizontally via advance(), bits slide through the
register so that only a new byte needs to be fetched at each byte
boundary. As the window moves down via nextRow(), registers
rotate so that only the new bottom row needs to be fetched.
The optional dx/dy offsets allow the window to track
a spatially shifted bitmap (e.g. GRREFERENCEDX / GRREFERENCEDY in §6.3.5).
A call to getBit(int, int) at logical position (x, y) reads
bitmap position (x - dx, y - dy).
All out-of-bounds accesses return 0 per §6.3.5.2.
Current status: this class is not yet used in production decoding
paths. It exists as a standalone, testable abstraction of the sliding window
bit-access mechanics that are currently inlined inside
GenericRefinementRegionDecodingProcedure
for the template 0 paths (decodeTemplate,
decodeTypicalPredictedLineTemplate0). Its primary purpose is to
provide a test bed for verifying the correctness of those paths — in
particular at byte boundaries, edge rows, and non-zero reference offsets —
where latent bugs may exist that are not yet covered by the current test
suite.
| Constructor and Description |
|---|
SlidingBitmapWindow(Bitmap bitmap)
Constructs a window over the given bitmap, positioned at (0, 0).
|
SlidingBitmapWindow(Bitmap bitmap,
int dx,
int dy)
Constructs a window over the given bitmap with a coordinate offset, positioned at (0, 0).
|
| Modifier and Type | Method and Description |
|---|---|
void |
advance()
Advances the window one pixel to the right.
|
int |
getBit(int rowOffset,
int colOffset)
Returns the bit value at the given row and column offset relative to the current position.
|
int |
getBitFast(int rowOffset,
int colOffset)
Returns the bit value at the given row and column offset without bounds checking.
|
void |
moveTo(int x,
int y)
Repositions the window to (x, y), loading the 3-row neighbourhood.
|
void |
nextRow()
Moves the window one row down and resets to x=0.
|
void |
reset()
Resets the window to (0, 0), reloading the 3-row neighbourhood.
|
public SlidingBitmapWindow(Bitmap bitmap)
bitmap - the bitmap to window overpublic SlidingBitmapWindow(Bitmap bitmap, int dx, int dy)
bitmap - the bitmap to window overdx - horizontal offset (GRREFERENCEDX)dy - vertical offset (GRREFERENCEDY)public void moveTo(int x,
int y)
x - logical x coordinatey - logical y coordinatepublic void reset()
moveTo(0,
0) but intended for use in benchmarks to avoid object allocation between invocations.public void advance()
public void nextRow()
public int getBit(int rowOffset,
int colOffset)
rowOffset - -1 (above), 0 (current), or +1 (below)colOffset - column offset relative to current position, typically in the range -2 to +2public int getBitFast(int rowOffset,
int colOffset)
rowOffset - -1 (above), 0 (current), or +1 (below)colOffset - column offset, typically -2 to +2Copyright © 2026 The Apache Software Foundation. All rights reserved.