# CSJ2K.j2k.codestream.writer.CodestreamWriter

## Content

<div class="doc-site-dotnet-api-container">



  <h1 id="CSJ2K_j2k_codestream_writer_CodestreamWriter" data-uid="CSJ2K.j2k.codestream.writer.CodestreamWriter" class="text-break">CodestreamWriter Class
</h1>
  <div class="markdown level0 summary"><p>This is the abstract class for writing to a codestream. A codestream
corresponds to headers (main and tile-parts) and packets. Each packet has a
head and a body. The codestream always has a maximum number of bytes that
can be written to it. After that many number of bytes no more data is
written to the codestream but the number of bytes is counted so that the
value returned by getMaxAvailableBytes() is negative. If the number of
bytes is unlimited a ridicoulosly large value, such as Integer.MAX_VALUE,
is equivalent.</p>
<pre><code>       &lt;p&gt;Data writting to the codestream can be simulated. In this case, no byto
       is effectively written to the codestream but the resulting number of bytes
       is calculated and returned (although it is not accounted in the bit
       stream). This can be used in rate control loops.&lt;/p&gt;&lt;p&gt;Implementing classes should write the header of the bit stream before
       writing any packets. The bit stream header can be written with the help of
       the HeaderEncoder class.&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">CodestreamWriter</span></div>
      <div class="level2"><a class="xref" href="CSJ2K.j2k.codestream.writer.FileCodestreamWriter.html">FileCodestreamWriter</a></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_CodestreamWriter_syntax">Syntax</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public abstract class CodestreamWriter</code></pre>
  </div>
  <div class="codewrapper">
    <pre><code class="lang-vbnet hljs">Public MustInherit Class CodestreamWriter</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_CodestreamWriter__ctor_System_Int32_" data-uid="CSJ2K.j2k.codestream.writer.CodestreamWriter.#ctor(System.Int32)">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.CodestreamWriter.-ctor.html#CSJ2K_j2k_codestream_writer_CodestreamWriter__ctor_System_Int32_">CodestreamWriter(int)</a>
        </td>
        <td class="markdown level1 summary"><p>Allocates this object and initializes the maximum number of bytes.</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_CodestreamWriter_maxBytes" data-uid="CSJ2K.j2k.codestream.writer.CodestreamWriter.maxBytes">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.CodestreamWriter.maxBytes.html">maxBytes</a>
        </td>
        <td class="markdown level1 summary"><p>The maximum number of bytes that can be written to the bit stream</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_CodestreamWriter_ndata" data-uid="CSJ2K.j2k.codestream.writer.CodestreamWriter.ndata">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.CodestreamWriter.ndata.html">ndata</a>
        </td>
        <td class="markdown level1 summary"><p>The number of bytes already written to the bit stream</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_CodestreamWriter_Length" data-uid="CSJ2K.j2k.codestream.writer.CodestreamWriter.Length">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.CodestreamWriter.Length.html#CSJ2K_j2k_codestream_writer_CodestreamWriter_Length">Length</a>
        </td>
        <td class="markdown level1 summary"><p>Returns the current length of the entire codestream.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_CodestreamWriter_MaxAvailableBytes" data-uid="CSJ2K.j2k.codestream.writer.CodestreamWriter.MaxAvailableBytes">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.CodestreamWriter.MaxAvailableBytes.html#CSJ2K_j2k_codestream_writer_CodestreamWriter_MaxAvailableBytes">MaxAvailableBytes</a>
        </td>
        <td class="markdown level1 summary"><p>Returns the number of bytes remaining available in the codestream. This
is the maximum allowed number of bytes minus the number of bytes that
have already been written to the bit stream. If more bytes have been
written to the bit stream than the maximum number of allowed bytes,
then a negative value is returned.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_CodestreamWriter_OffLastROIPkt" data-uid="CSJ2K.j2k.codestream.writer.CodestreamWriter.OffLastROIPkt">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.CodestreamWriter.OffLastROIPkt.html#CSJ2K_j2k_codestream_writer_CodestreamWriter_OffLastROIPkt">OffLastROIPkt</a>
        </td>
        <td class="markdown level1 summary"><p>Gives the offset of the end of last packet containing ROI information</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_CodestreamWriter_close" data-uid="CSJ2K.j2k.codestream.writer.CodestreamWriter.close">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.CodestreamWriter.close.html#CSJ2K_j2k_codestream_writer_CodestreamWriter_close">close()</a>
        </td>
        <td class="markdown level1 summary"><p>Closes the underlying resource (file, stream, network connection,
etc.). After a CodestreamWriter is closed no more data can be written
to it.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_CodestreamWriter_commitBitstreamHeader_CSJ2K_j2k_codestream_writer_HeaderEncoder_" data-uid="CSJ2K.j2k.codestream.writer.CodestreamWriter.commitBitstreamHeader(CSJ2K.j2k.codestream.writer.HeaderEncoder)">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.CodestreamWriter.commitBitstreamHeader.html#CSJ2K_j2k_codestream_writer_CodestreamWriter_commitBitstreamHeader_CSJ2K_j2k_codestream_writer_HeaderEncoder_">commitBitstreamHeader(HeaderEncoder)</a>
        </td>
        <td class="markdown level1 summary"><p>Writes the header data to the bit stream, if it has not been already
done. In some implementations this method can be called only once, and
an IllegalArgumentException is thrown if called more than once.</p>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_CodestreamWriter_writePacketBody_System_Byte___System_Int32_System_Boolean_System_Boolean_System_Int32_" data-uid="CSJ2K.j2k.codestream.writer.CodestreamWriter.writePacketBody(System.Byte[],System.Int32,System.Boolean,System.Boolean,System.Int32)">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.CodestreamWriter.writePacketBody.html#CSJ2K_j2k_codestream_writer_CodestreamWriter_writePacketBody_System_Byte___System_Int32_System_Boolean_System_Boolean_System_Int32_">writePacketBody(byte[], int, bool, bool, int)</a>
        </td>
        <td class="markdown level1 summary"><p>Writes a packet body to the codestream and returns the number of bytes
used by this body. If in simulation mode then no data is written to the
bit stream but the number of bytes is calculated. This can be used for
iterative rate allocation.</p>
<pre><code>       &lt;p&gt;If the number of bytes that has to be written to the codestream is
       more than the space left (as returned by getMaxAvailableBytes()), only
       the data that does not exceed the allowed length is effectively written
       and the rest is discarded. However the value returned by the method is
       the total length of the packet, as if all of it was written to the bit
       stream.&lt;/p&gt;
</code></pre>
</td>
      </tr>
      <tr>
        <td id="CSJ2K_j2k_codestream_writer_CodestreamWriter_writePacketHead_System_Byte___System_Int32_System_Boolean_System_Boolean_System_Boolean_" data-uid="CSJ2K.j2k.codestream.writer.CodestreamWriter.writePacketHead(System.Byte[],System.Int32,System.Boolean,System.Boolean,System.Boolean)">
          <a class="xref" href="CSJ2K.j2k.codestream.writer.CodestreamWriter.writePacketHead.html#CSJ2K_j2k_codestream_writer_CodestreamWriter_writePacketHead_System_Byte___System_Int32_System_Boolean_System_Boolean_System_Boolean_">writePacketHead(byte[], int, bool, bool, bool)</a>
        </td>
        <td class="markdown level1 summary"></td>
      </tr>
    </tbody>
  </table>
  <h3 id="seealso">See Also</h3>
  <div class="seealso">
      <div><a class="xref" href="CSJ2K.j2k.codestream.writer.HeaderEncoder.html">HeaderEncoder</a></div>
  </div>

</div>
