CSJ2K.j2k.codestream.writer.FileCodestreamWriter.writePacketBody C# (CSharp) Method

writePacketBody() public method

Writes a packet body to the bit stream 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.

If the length of the data that is to be written to the bit stream is more than the space left (as returned by getMaxAvailableBytes()) only the data that does not exceed the allowed length is written, the rest is discarded. However the value returned by the method is the total length of the packet body , as if all of it was written to the bit stream.

If an I/O error occurs while writing to the /// output stream. /// ///
public writePacketBody ( byte body, int blen, bool sim, bool roiInPkt, int roiLen ) : int
body byte The packet body data. /// ///
blen int The number of bytes in the packet body. /// ///
sim bool Simulation mode flag. If true nothing is written to the bit /// stream, but the number of bytes that would be written is returned. /// ///
roiInPkt bool Whether or not this packet contains ROI information /// ///
roiLen int Number of byte to read in packet body to get all the ROI /// information /// ///
return int
        public override int writePacketBody(byte[] body, int blen, bool sim, bool roiInPkt, int roiLen)
        {
            int len = blen;

            // If not in simulation mode write the data
            if (!sim)
            {
                // Write the body bytes
                len = blen;
                if (MaxAvailableBytes < len)
                {
                    len = MaxAvailableBytes;
                }
                if (blen > 0)
                {
                    out_Renamed.Write(body, 0, len);
                }
                // Update data length
                ndata += len;

                // Deal with ROI information
                if (roiInPkt)
                {
                    offLastROIPkt += lenLastNoROI + roiLen;
                    lenLastNoROI = len - roiLen;
                }
                else
                {
                    lenLastNoROI += len;
                }
            }
            return len;
        }