BitMiracle.LibTiff.Classic.Tiff.VTileSize C# (CSharp) Method

VTileSize() public method

Computes the number of bytes in a row-aligned tile with specified number of rows.
public VTileSize ( int rowCount ) : int
rowCount int The number of rows in a tile.
return int
        public int VTileSize(int rowCount)
        {
            if (m_dir.td_tilelength == 0 || m_dir.td_tilewidth == 0 || m_dir.td_tiledepth == 0)
                return 0;

            int tilesize;
            if (m_dir.td_planarconfig == PlanarConfig.CONTIG &&
                m_dir.td_photometric == Photometric.YCBCR && !IsUpSampled())
            {
                // Packed YCbCr data contain one Cb+Cr for every
                // HorizontalSampling * VerticalSampling Y values.
                // Must also roundup width and height when calculating since images that are not a
                // multiple of the horizontal/vertical subsampling area include YCbCr data for
                // the extended image.
                int w = roundUp(m_dir.td_tilewidth, m_dir.td_ycbcrsubsampling[0]);
                int rowsize = howMany8(multiply(w, m_dir.td_bitspersample, "VTileSize"));
                int samplingarea = m_dir.td_ycbcrsubsampling[0] * m_dir.td_ycbcrsubsampling[1];
                if (samplingarea == 0)
                {
                    ErrorExt(this, m_clientdata, m_name, "Invalid YCbCr subsampling");
                    return 0;
                }

                rowCount = roundUp(rowCount, m_dir.td_ycbcrsubsampling[1]);
                // NB: don't need howMany here 'cuz everything is rounded
                tilesize = multiply(rowCount, rowsize, "VTileSize");
                tilesize = summarize(tilesize, multiply(2, tilesize / samplingarea, "VTileSize"), "VTileSize");
            }
            else
            {
                tilesize = multiply(rowCount, TileRowSize(), "VTileSize");
            }

            return multiply(tilesize, m_dir.td_tiledepth, "VTileSize");
        }
Tiff