# CSJ2K.j2k.codestream.writer.TagTreeEncoder

## Content

<div class="doc-site-dotnet-api-container">



  <h1 id="CSJ2K_j2k_codestream_writer_TagTreeEncoder" data-uid="CSJ2K.j2k.codestream.writer.TagTreeEncoder" class="text-break">TagTreeEncoder Class
</h1>
  <div class="markdown level0 summary"><p>This class implements the tag tree encoder. A tag tree codes a 2D matrix of
integer elements in an efficient way. The encoding procedure 'encode()'
codes information about a value of the matrix, given a threshold. The
procedure encodes the sufficient information to identify whether or not the
value is greater than or equal to the threshold.</p>
<pre><code>       &lt;p&gt;The tag tree saves encoded information to a BitOutputBuffer.&lt;/p&gt;

       &lt;p&gt;A particular and useful property of tag trees is that it is possible to
       change a value of the matrix, provided both new and old values of the
       element are both greater than or equal to the largest threshold which has
       yet been supplied to the coding procedure 'encode()'. This property can be
       exploited through the 'setValue()' method.&lt;/p&gt;

       &lt;p&gt;This class allows saving the state of the tree at any point and
       restoring it at a later time, by calling save() and restore().&lt;/p&gt;

       &lt;p&gt;A tag tree can also be reused, or restarted, if one of the reset()
       methods is called.&lt;/p&gt;

       &lt;p&gt;The TagTreeDecoder class implements the tag tree decoder.&lt;/p&gt;

       &lt;p&gt;Tag trees that have one dimension, or both, as 0 are allowed for
       convenience. Of course no values can be set or coded in such cases.&lt;/p&gt;
</code></pre>
</div>
  <div class="markdown level0 conceptual"></div>
  <div class="inheritance">
    <h5>Inheritance</h5>
    <div class="level0"><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></div>
    <div class="level1"><span class="xref">TagTreeEncoder</span></div>
  </div>
  <h6><strong>Namespace</strong>: <a class="xref" href="CSJ2K.j2k.codestream.writer.html">CSJ2K.j2k.codestream.writer</a></h6>
  <h6><strong>Assembly</strong>: C1.C1Pdf.4.8.dll</h6>
  <h5 id="CSJ2K_j2k_codestream_writer_TagTreeEncoder_syntax">Syntax</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public class TagTreeEncoder</code></pre>
  </div>
  <div class="codewrapper">
    <pre><code class="lang-vbnet hljs">Public Class TagTreeEncoder</code></pre>
  </div>
  <h3 id="constructors">Constructors
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_TagTreeEncoder__ctor_System_Int32_System_Int32_" data-uid="CSJ2K.j2k.codestream.writer.TagTreeEncoder.#ctor(System.Int32,System.Int32)">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.TagTreeEncoder.-ctor.html#CSJ2K_j2k_codestream_writer_TagTreeEncoder__ctor_System_Int32_System_Int32_">TagTreeEncoder(int, int)</a>
        </td>
        <td class="markdown level1 summary"><p>Creates a tag tree encoder with 'w' elements along the horizontal
dimension and 'h' elements along the vertical direction. The total
number of elements is thus 'vdim' x 'hdim'.</p>
<pre><code>       &lt;p&gt;The values of all elements are initialized to Integer.MAX_VALUE.&lt;/p&gt;
</code></pre>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_TagTreeEncoder__ctor_System_Int32_System_Int32_System_Int32___" data-uid="CSJ2K.j2k.codestream.writer.TagTreeEncoder.#ctor(System.Int32,System.Int32,System.Int32[])">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.TagTreeEncoder.-ctor.html#CSJ2K_j2k_codestream_writer_TagTreeEncoder__ctor_System_Int32_System_Int32_System_Int32___">TagTreeEncoder(int, int, int[])</a>
        </td>
        <td class="markdown level1 summary"><p>Creates a tag tree encoder with 'w' elements along the horizontal
dimension and 'h' elements along the vertical direction. The total
number of elements is thus 'vdim' x 'hdim'. The values of the leafs in
the tag tree are initialized to the values of the 'val' array.</p>
<pre><code>       &lt;p&gt;The values in the 'val' array are supposed to appear in
       lexicographical order, starting at index 0.&lt;/p&gt;
</code></pre>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="fields">Fields
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_TagTreeEncoder_h" data-uid="CSJ2K.j2k.codestream.writer.TagTreeEncoder.h">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.TagTreeEncoder.h.html">h</a>
        </td>
        <td class="markdown level1 summary"><p>The vertical dimensions of the base level</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_TagTreeEncoder_lvls" data-uid="CSJ2K.j2k.codestream.writer.TagTreeEncoder.lvls">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.TagTreeEncoder.lvls.html">lvls</a>
        </td>
        <td class="markdown level1 summary"><p>The number of levels in the tag tree</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_TagTreeEncoder_saved" data-uid="CSJ2K.j2k.codestream.writer.TagTreeEncoder.saved">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.TagTreeEncoder.saved.html">saved</a>
        </td>
        <td class="markdown level1 summary"><p>The saved state. If true the values and states of the tree have been
saved since the creation or last reset.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_TagTreeEncoder_treeS" data-uid="CSJ2K.j2k.codestream.writer.TagTreeEncoder.treeS">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.TagTreeEncoder.treeS.html">treeS</a>
        </td>
        <td class="markdown level1 summary"><p>The tag tree state. The first index is the level, starting at level 0
(leafs). The second index is the element within the level, in
lexicographical order.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_TagTreeEncoder_treeSbak" data-uid="CSJ2K.j2k.codestream.writer.TagTreeEncoder.treeSbak">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.TagTreeEncoder.treeSbak.html">treeSbak</a>
        </td>
        <td class="markdown level1 summary"><p>The saved tag tree state. The first index is the level, starting at
level 0 (leafs). The second index is the element within the level, in
lexicographical order.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_TagTreeEncoder_treeV" data-uid="CSJ2K.j2k.codestream.writer.TagTreeEncoder.treeV">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.TagTreeEncoder.treeV.html">treeV</a>
        </td>
        <td class="markdown level1 summary"><p>The tag tree values. The first index is the level, starting at level 0
(leafs). The second index is the element within the level, in
lexicographical order.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_TagTreeEncoder_treeVbak" data-uid="CSJ2K.j2k.codestream.writer.TagTreeEncoder.treeVbak">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.TagTreeEncoder.treeVbak.html">treeVbak</a>
        </td>
        <td class="markdown level1 summary"><p>The saved tag tree values. The first index is the level, starting at
level 0 (leafs). The second index is the element within the level, in
lexicographical order.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_TagTreeEncoder_w" data-uid="CSJ2K.j2k.codestream.writer.TagTreeEncoder.w">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.TagTreeEncoder.w.html">w</a>
        </td>
        <td class="markdown level1 summary"><p>The horizontal dimension of the base level</p>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="properties">Properties
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_TagTreeEncoder_Height" data-uid="CSJ2K.j2k.codestream.writer.TagTreeEncoder.Height">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.TagTreeEncoder.Height.html#CSJ2K_j2k_codestream_writer_TagTreeEncoder_Height">Height</a>
        </td>
        <td class="markdown level1 summary"><p>Returns the number of leafs along the vertical direction.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_TagTreeEncoder_Values" data-uid="CSJ2K.j2k.codestream.writer.TagTreeEncoder.Values">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.TagTreeEncoder.Values.html#CSJ2K_j2k_codestream_writer_TagTreeEncoder_Values">Values</a>
        </td>
        <td class="markdown level1 summary"><p>Sets the values of the leafs to the new set of values and updates the
tag tree accordingly. No leaf can change its value if either the new or
old value is smaller than largest threshold which has yet been supplied
to 'encode()'. However such a leaf can keep its old value (i.e. new and
old value must be identical.</p>
<pre><code>       &lt;p&gt;This method is more efficient than the setValue() method if a large
       proportion of the leafs change their value. Note that for leafs which
       don't have their value defined yet the value should be
       Integer.MAX_VALUE (which is the default initialization value).&lt;/p&gt;
</code></pre>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_TagTreeEncoder_Width" data-uid="CSJ2K.j2k.codestream.writer.TagTreeEncoder.Width">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.TagTreeEncoder.Width.html#CSJ2K_j2k_codestream_writer_TagTreeEncoder_Width">Width</a>
        </td>
        <td class="markdown level1 summary"><p>Returns the number of leafs along the horizontal direction.</p>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="methods">Methods
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_TagTreeEncoder_encode_System_Int32_System_Int32_System_Int32_CSJ2K_j2k_codestream_writer_BitOutputBuffer_" data-uid="CSJ2K.j2k.codestream.writer.TagTreeEncoder.encode(System.Int32,System.Int32,System.Int32,CSJ2K.j2k.codestream.writer.BitOutputBuffer)">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.TagTreeEncoder.encode.html#CSJ2K_j2k_codestream_writer_TagTreeEncoder_encode_System_Int32_System_Int32_System_Int32_CSJ2K_j2k_codestream_writer_BitOutputBuffer_">encode(int, int, int, BitOutputBuffer)</a>
        </td>
        <td class="markdown level1 summary"><p>Encodes information for the specified element of the tree, given the
threshold and sends it to the 'out' stream. The information that is
coded is whether or not the value of the element is greater than or
equal to the value of the threshold.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_TagTreeEncoder_reset" data-uid="CSJ2K.j2k.codestream.writer.TagTreeEncoder.reset">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.TagTreeEncoder.reset.html#CSJ2K_j2k_codestream_writer_TagTreeEncoder_reset">reset()</a>
        </td>
        <td class="markdown level1 summary"><p>Resets the tree values and state. All the values are set to
Integer.MAX_VALUE and the states to 0.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_TagTreeEncoder_reset_System_Int32___" data-uid="CSJ2K.j2k.codestream.writer.TagTreeEncoder.reset(System.Int32[])">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.TagTreeEncoder.reset.html#CSJ2K_j2k_codestream_writer_TagTreeEncoder_reset_System_Int32___">reset(int[])</a>
        </td>
        <td class="markdown level1 summary"><p>Resets the tree values and state. The values are set to the values in
'val'. The states are all set to 0.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_TagTreeEncoder_restore" data-uid="CSJ2K.j2k.codestream.writer.TagTreeEncoder.restore">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.TagTreeEncoder.restore.html#CSJ2K_j2k_codestream_writer_TagTreeEncoder_restore">restore()</a>
        </td>
        <td class="markdown level1 summary"><p>Restores the saved values and state of the tree. An
IllegalArgumentException is thrown if the tree values and state have
not been saved yet.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_TagTreeEncoder_save" data-uid="CSJ2K.j2k.codestream.writer.TagTreeEncoder.save">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.TagTreeEncoder.save.html#CSJ2K_j2k_codestream_writer_TagTreeEncoder_save">save()</a>
        </td>
        <td class="markdown level1 summary"><p>Saves the current values and state of the tree. Calling restore()
restores the tag tree the saved state.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_TagTreeEncoder_setValue_System_Int32_System_Int32_System_Int32_" data-uid="CSJ2K.j2k.codestream.writer.TagTreeEncoder.setValue(System.Int32,System.Int32,System.Int32)">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.TagTreeEncoder.setValue.html#CSJ2K_j2k_codestream_writer_TagTreeEncoder_setValue_System_Int32_System_Int32_System_Int32_">setValue(int, int, int)</a>
        </td>
        <td class="markdown level1 summary"><p>Changes the value of a leaf in the tag tree. The new and old values of
the element must be not smaller than the largest threshold which has
yet been supplied to 'encode()'.</p>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="seealso">See Also</h3>
  <div class="seealso">
      <div><a class="xref" href="CSJ2K.j2k.codestream.writer.BitOutputBuffer.html">BitOutputBuffer</a></div>
  </div>

</div>
