CSJ2K.j2k.codestream.reader.BitstreamReaderAgent.getTileWidth C# (CSharp) Method

getTileWidth() public method

Returns the overall width of the current tile in pixels for the given (tile) resolution level. This is the tile's width without accounting for any component subsampling.

Note: Tile resolution level indexes may be different from tile-component resolution index. They are indeed indexed starting from the lowest number of decomposition levels of each component of the tile.

For an image (1 tile) with 2 components (component 0 having 2 decomposition levels and component 1 having 3 decomposition levels), the first (tile-)component has 3 resolution levels and the second one has 4 resolution levels, whereas the tile has only 3 resolution levels available.

public getTileWidth ( int rl ) : int
rl int The (tile) resolution level. /// ///
return int
        public virtual int getTileWidth(int rl)
        {
            // The minumum number of decomposition levels between all the
            // components
            int mindl = decSpec.dls.getMinInTile(TileIdx);
            if (rl > mindl)
            {
                throw new System.ArgumentException("Requested resolution level" + " is not available for, at " + "least, one component in " + "tile: " + ctX + "x" + ctY);
            }
            int ctulx, ntulx;
            int dl = mindl - rl; // Number of decomposition to obtain this
            // resolution

            // Calculate starting X of current tile at hi-res
            ctulx = (ctX == 0)?ax:px + ctX * ntW;
            // Calculate starting X of next tile X-wise at hi-res
            ntulx = (ctX < ntX - 1)?px + (ctX + 1) * ntW:ax + imgW;

            // The difference at the rl resolution level is the width
            return (ntulx + (1 << dl) - 1) / (1 << dl) - (ctulx + (1 << dl) - 1) / (1 << dl);
        }