CSJ2K.j2k.codestream.writer.HeaderEncoder.writeRGN C# (CSharp) Method

writeRGN() private method

Writes the RGN marker segment in the tile header. It describes the scaling value in each tile component

May be used in tile or main header. If used in main header, it refers to a ROI of the whole image, regardless of tiling. When used in tile header, only the particular tile is affected.

If an I/O error occurs while reading from the /// encoder header stream /// ///
private writeRGN ( int tIdx ) : void
tIdx int The tile index /// ///
return void
        private void writeRGN(int tIdx)
        {
            int i;
            int markSegLen; // the marker length

            // Write one RGN marker per component
            for (i = 0; i < nComp; i++)
            {
                // RGN marker
                hbuf.Write((System.Int16) CSJ2K.j2k.codestream.Markers.RGN);

                // Calculate length (Lrgn)
                // Basic: Lrgn (2) + Srgn (1) + SPrgn + one byte
                // or two for component number
                markSegLen = 4 + ((nComp < 257)?1:2);
                hbuf.Write((System.Int16) markSegLen);

                // Write component (Crgn)
                if (nComp < 257)
                {
                    hbuf.Write((System.Byte) i);
                }
                else
                {
                    hbuf.Write((System.Int16) i);
                }

                // Write type of ROI (Srgn)
                hbuf.Write((System.Byte) CSJ2K.j2k.codestream.Markers.SRGN_IMPLICIT);

                // Write ROI info (SPrgn)
                hbuf.Write((System.Byte) ((System.Int32) (encSpec.rois.getTileCompVal(tIdx, i))));
            }
        }