# CSJ2K.j2k.codestream.writer.PktEncoder

## Content

<div class="doc-site-dotnet-api-container">



  <h1 id="CSJ2K_j2k_codestream_writer_PktEncoder" data-uid="CSJ2K.j2k.codestream.writer.PktEncoder" class="text-break">PktEncoder Class
</h1>
  <div class="markdown level0 summary"><p>This class builds packets and keeps the state information of packet
interdependencies. It also supports saving the state and reverting
(restoring) to the last saved state, with the save() and restore() methods.</p>
<pre><code>       &lt;p&gt;Each time the encodePacket() method is called a new packet is encoded,
       the packet header is returned by the method, and the packet body can be
       obtained with the getLastBodyBuf() and getLastBodyLen() methods.&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">PktEncoder</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.WPF.ReportViewer.4.6.2.dll</h6>
  <h5 id="CSJ2K_j2k_codestream_writer_PktEncoder_syntax">Syntax</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public class PktEncoder</code></pre>
  </div>
  <div class="codewrapper">
    <pre><code class="lang-vbnet hljs">Public Class PktEncoder</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_PktEncoder__ctor_CSJ2K_j2k_entropy_encoder_CodedCBlkDataSrcEnc_CSJ2K_j2k_encoder_EncoderSpecs_CSJ2K_j2k_image_Coord_______CSJ2K_j2k_util_ParameterList_" data-uid="CSJ2K.j2k.codestream.writer.PktEncoder.#ctor(CSJ2K.j2k.entropy.encoder.CodedCBlkDataSrcEnc,CSJ2K.j2k.encoder.EncoderSpecs,CSJ2K.j2k.image.Coord[][][],CSJ2K.j2k.util.ParameterList)">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.PktEncoder.-ctor.html#CSJ2K_j2k_codestream_writer_PktEncoder__ctor_CSJ2K_j2k_entropy_encoder_CodedCBlkDataSrcEnc_CSJ2K_j2k_encoder_EncoderSpecs_CSJ2K_j2k_image_Coord_______CSJ2K_j2k_util_ParameterList_">PktEncoder(CodedCBlkDataSrcEnc, EncoderSpecs, Coord[][][], ParameterList)</a>
        </td>
        <td class="markdown level1 summary"><p>Creates a new packet encoder object, using the information from the
'infoSrc' object.</p>
</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_PktEncoder_OPT_PREFIX" data-uid="CSJ2K.j2k.codestream.writer.PktEncoder.OPT_PREFIX">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.PktEncoder.OPT_PREFIX.html">OPT_PREFIX</a>
        </td>
        <td class="markdown level1 summary"><p>The prefix for packet encoding options: 'P'</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_PktEncoder_LastBodyBuf" data-uid="CSJ2K.j2k.codestream.writer.PktEncoder.LastBodyBuf">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.PktEncoder.LastBodyBuf.html#CSJ2K_j2k_codestream_writer_PktEncoder_LastBodyBuf">LastBodyBuf</a>
        </td>
        <td class="markdown level1 summary"><p>Returns the buffer of the body of the last encoded packet. The length
of the body can be retrieved with the getLastBodyLen() method. The
length of the array returned by this method may be larger than the
actual body length.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_PktEncoder_LastBodyLen" data-uid="CSJ2K.j2k.codestream.writer.PktEncoder.LastBodyLen">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.PktEncoder.LastBodyLen.html#CSJ2K_j2k_codestream_writer_PktEncoder_LastBodyLen">LastBodyLen</a>
        </td>
        <td class="markdown level1 summary"><p>Returns the length of the body of the last encoded packet, in
bytes. The body itself can be retrieved with the getLastBodyBuf()
method.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_PktEncoder_PacketWritable" data-uid="CSJ2K.j2k.codestream.writer.PktEncoder.PacketWritable">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.PktEncoder.PacketWritable.html#CSJ2K_j2k_codestream_writer_PktEncoder_PacketWritable">PacketWritable</a>
        </td>
        <td class="markdown level1 summary"><p>Returns true if the current packet is writable i.e. should be written.
Returns false otherwise.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_PktEncoder_ParameterInfo" data-uid="CSJ2K.j2k.codestream.writer.PktEncoder.ParameterInfo">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.PktEncoder.ParameterInfo.html#CSJ2K_j2k_codestream_writer_PktEncoder_ParameterInfo">ParameterInfo</a>
        </td>
        <td class="markdown level1 summary"><p>Returns the parameters that are used in this class and implementing
classes. It returns a 2D String array. Each of the 1D arrays is for a
different option, and they have 3 elements. The first element is the
option name, the second one is the synopsis, the third one is a long
description of what the parameter is and the fourth is its default
value. The synopsis or description may be 'null', in which case it is
assumed that there is no synopsis or description of the option,
respectively. Null may be returned if no options are supported.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_PktEncoder_ROILen" data-uid="CSJ2K.j2k.codestream.writer.PktEncoder.ROILen">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.PktEncoder.ROILen.html#CSJ2K_j2k_codestream_writer_PktEncoder_ROILen">ROILen</a>
        </td>
        <td class="markdown level1 summary"><p>Gives the length to read in current packet body to get all ROI
information</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_PktEncoder_ROIinPkt" data-uid="CSJ2K.j2k.codestream.writer.PktEncoder.ROIinPkt">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.PktEncoder.ROIinPkt.html#CSJ2K_j2k_codestream_writer_PktEncoder_ROIinPkt">ROIinPkt</a>
        </td>
        <td class="markdown level1 summary"><p>Tells if there was ROI information in the last written packet</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_PktEncoder_encodePacket_System_Int32_System_Int32_System_Int32_System_Int32_CSJ2K_j2k_entropy_encoder_CBlkRateDistStats_____System_Int32_____CSJ2K_j2k_codestream_writer_BitOutputBuffer_System_Byte___System_Int32_" data-uid="CSJ2K.j2k.codestream.writer.PktEncoder.encodePacket(System.Int32,System.Int32,System.Int32,System.Int32,CSJ2K.j2k.entropy.encoder.CBlkRateDistStats[][],System.Int32[][],CSJ2K.j2k.codestream.writer.BitOutputBuffer,System.Byte[],System.Int32)">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.PktEncoder.encodePacket.html#CSJ2K_j2k_codestream_writer_PktEncoder_encodePacket_System_Int32_System_Int32_System_Int32_System_Int32_CSJ2K_j2k_entropy_encoder_CBlkRateDistStats_____System_Int32_____CSJ2K_j2k_codestream_writer_BitOutputBuffer_System_Byte___System_Int32_">encodePacket(int, int, int, int, CBlkRateDistStats[][], int[][], BitOutputBuffer, byte[], int)</a>
        </td>
        <td class="markdown level1 summary"><p>Encodes a packet and returns the buffer containing the encoded packet
header. The code-blocks appear in a 3D array of CBlkRateDistStats,
'cbs'. The first index is the tile index in lexicographical order, the
second index is the subband index (as defined in the Subband class),
and the third index is the code-block index (whithin the subband tile)
in lexicographical order as well. The indexes of the new truncation
points for each code-block are specified by the 3D array of int
'tIndx'. The indices of this array are the same as for cbs. The
truncation point indices in 'tIndx' are the indices of the elements of
the 'truncIdxs' array, of the CBlkRateDistStats class, that give the
real truncation points. If a truncation point index is negative it
means that the code-block has not been included in any layer yet. If
the truncation point is less than or equal to the highest truncation
point used in previous layers then the code-block is not included in
the packet. Otherwise, if larger, the code-block is included in the
packet. The body of the packet can be obtained with the
getLastBodyBuf() and getLastBodyLen() methods.</p>
<pre><code>       &lt;p&gt;Layers must be coded in increasing order, in consecutive manner, for
       each tile, component and resolution level (e.g., layer 1, then layer 2,
       etc.). For different tile, component and/or resolution level no
       particular order must be followed.&lt;/p&gt;
</code></pre>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_PktEncoder_getPrecInfo_System_Int32_System_Int32_System_Int32_System_Int32_" data-uid="CSJ2K.j2k.codestream.writer.PktEncoder.getPrecInfo(System.Int32,System.Int32,System.Int32,System.Int32)">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.PktEncoder.getPrecInfo.html#CSJ2K_j2k_codestream_writer_PktEncoder_getPrecInfo_System_Int32_System_Int32_System_Int32_System_Int32_">getPrecInfo(int, int, int, int)</a>
        </td>
        <td class="markdown level1 summary"><p>Returns information about a given precinct</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_PktEncoder_reset" data-uid="CSJ2K.j2k.codestream.writer.PktEncoder.reset">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.PktEncoder.reset.html#CSJ2K_j2k_codestream_writer_PktEncoder_reset">reset()</a>
        </td>
        <td class="markdown level1 summary"><p>Resets the state of the object to the initial state, as if the object
was just created.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_PktEncoder_restore" data-uid="CSJ2K.j2k.codestream.writer.PktEncoder.restore">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.PktEncoder.restore.html#CSJ2K_j2k_codestream_writer_PktEncoder_restore">restore()</a>
        </td>
        <td class="markdown level1 summary"><p>Restores the last saved state of this object. An
IllegalArgumentException is thrown if no state has been saved.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_PktEncoder_save" data-uid="CSJ2K.j2k.codestream.writer.PktEncoder.save">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.PktEncoder.save.html#CSJ2K_j2k_codestream_writer_PktEncoder_save">save()</a>
        </td>
        <td class="markdown level1 summary"><p>Saves the current state of this object. The last saved state
can be restored with the restore() method.</p>
</td>
      </tr>
    </tbody>
  </table>

</div>
