private void conceal(DataBlk cblk, int bp)
{
int l; // line index
int k; // array index
int kmax; // 'k' limit
int dk; // Value of data[k]
int[] data; // the data array
int setmask; // Bitmask to set approximation to 1/2 of
// known interval on significant data
int resetmask; // Bitmask to erase all the data from
// bit-plane 'bp'
// Initialize masks
setmask = 1 << bp;
resetmask = (- 1) << (bp);
// Get the data array
data = (int[]) cblk.Data;
// Visit each sample, apply the reset mask to it and add an
// approximation if significant.
for (l = cblk.h - 1, k = cblk.offset; l >= 0; l--)
{
for (kmax = k + cblk.w; k < kmax; k++)
{
dk = data[k];
if ((dk & resetmask & 0x7FFFFFFF) != 0)
{
// Something was decoded in previous bit-planes => set the
// approximation for previous bit-plane
data[k] = (dk & resetmask) | setmask;
}
else
{
// Was insignificant in previous bit-planes = set to zero
data[k] = 0;
}
}
k += cblk.scanw - cblk.w;
}
}