/// <summary> Initializes members of this class. This constructor takes a
/// HeaderDecoder object. This object must be initialized by the
/// constructor of the implementing class from the header of the bit
/// stream.
///
/// </summary>
/// <param name="hd">The decoded header of the bit stream from where to initialize
/// the values.
///
/// </param>
/// <param name="decSpec">The decoder specifications
///
/// </param>
protected internal BitstreamReaderAgent(HeaderDecoder hd, DecoderSpecs decSpec)
{
Coord co;
//int i, j, max;
this.decSpec = decSpec;
this.hd = hd;
// Number of components
nc = hd.NumComps;
offX = new int[nc];
offY = new int[nc];
culx = new int[nc];
culy = new int[nc];
// Image size and origin
imgW = hd.ImgWidth;
imgH = hd.ImgHeight;
ax = hd.ImgULX;
ay = hd.ImgULY;
// Tiles
co = hd.getTilingOrigin(null);
px = co.x;
py = co.y;
ntW = hd.NomTileWidth;
ntH = hd.NomTileHeight;
ntX = (ax + imgW - px + ntW - 1) / ntW;
ntY = (ay + imgH - py + ntH - 1) / ntH;
nt = ntX * ntY;
}