# CSJ2K.j2k.codestream.writer.FileCodestreamWriter.writePacketBody

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="CSJ2K_j2k_codestream_writer_FileCodestreamWriter_writePacketBody_" data-uid="CSJ2K.j2k.codestream.writer.FileCodestreamWriter.writePacketBody*">writePacketBody Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="CSJ2K_j2k_codestream_writer_FileCodestreamWriter_writePacketBody_" data-uid="CSJ2K.j2k.codestream.writer.FileCodestreamWriter.writePacketBody*"></a>
<h4 id="CSJ2K_j2k_codestream_writer_FileCodestreamWriter_writePacketBody_System_Byte___System_Int32_System_Boolean_System_Boolean_System_Int32_" data-uid="CSJ2K.j2k.codestream.writer.FileCodestreamWriter.writePacketBody(System.Byte[],System.Int32,System.Boolean,System.Boolean,System.Int32)">writePacketBody(byte[], int, bool, bool, int)</h4>
<div 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>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public override int writePacketBody(byte[] body, int blen, bool sim, bool roiInPkt, int roiLen)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Overrides Function writePacketBody(body As Byte(), blen As Integer, sim As Boolean, roiInPkt As Boolean, roiLen As Integer) As Integer</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.byte">byte</a>[]</td>
      <td><span class="parametername">body</span></td>
      <td><p>The packet body data.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">blen</span></td>
      <td><p>The number of bytes in the packet body.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></td>
      <td><span class="parametername">sim</span></td>
      <td><p>Simulation mode flag. If true nothing is written to the bit
stream, but the number of bytes that would be written is returned.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></td>
      <td><span class="parametername">roiInPkt</span></td>
      <td><p>Whether or not there is ROI information in this packet</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">roiLen</span></td>
      <td><p>Number of byte to read in packet body to get all the ROI
information</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><p>The number of bytes spent by the packet body.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="overrides">Overrides</h5>
<div><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_">CodestreamWriter.writePacketBody(byte[], int, bool, bool, int)</a></div>
<h5 id="CSJ2K_j2k_codestream_writer_FileCodestreamWriter_writePacketBody_System_Byte___System_Int32_System_Boolean_System_Boolean_System_Int32__seealso">See Also</h5>
<div class="seealso">
    <div><a class="xref" href="CSJ2K.j2k.codestream.writer.CodestreamWriter.commitBitstreamHeader.html#CSJ2K_j2k_codestream_writer_CodestreamWriter_commitBitstreamHeader_CSJ2K_j2k_codestream_writer_HeaderEncoder_">commitBitstreamHeader</a>(<a class="xref" href="CSJ2K.j2k.codestream.writer.HeaderEncoder.html">HeaderEncoder</a>)</div>
</div>
</div>
