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

commitBitstreamHeader() public method

Writes the header data in the codestream and actualize ndata with the header length. The header is either a MainHeaderEncoder or a TileHeaderEncoder.
If an I/O error occurs while writing the data. /// ///
public commitBitstreamHeader ( HeaderEncoder he ) : void
he HeaderEncoder The current header encoder. /// ///
return void
        public override void commitBitstreamHeader(HeaderEncoder he)
        {
            // Actualize ndata
            ndata += he.Length;
            he.writeTo(out_Renamed); // Write the header
            // Reset packet index used for SOP markers
            packetIdx = 0;

            // Deal with ROI information
            lenLastNoROI += he.Length;
        }

Usage Example

Exemplo n.º 1
0
        public static byte[] EncodeJPEG(Image jpgImage)
        {
            Tiler imgtiler;
            ForwCompTransf fctransf;
            ImgDataConverter converter;
            EncoderSpecs encSpec;
            ForwardWT dwt;
            Quantizer quant;
            ROIScaler rois;
            EntropyCoder ecoder;
            PostCompRateAllocator ralloc;
            HeaderEncoder headenc;
            CodestreamWriter bwriter;

            float rate = Single.MaxValue;

            ImgReaderGDI imgsrc = new ImgReaderGDI(jpgImage);

            imgtiler = new Tiler(imgsrc, 0, 0, 0, 0, jpgImage.Width, jpgImage.Height);
            int ntiles = imgtiler.getNumTiles();

            encSpec = new EncoderSpecs(ntiles, 3, imgsrc, pl);

            fctransf = new ForwCompTransf(imgtiler, encSpec);
            converter = new ImgDataConverter(fctransf);
            dwt = ForwardWT.createInstance(converter, pl, encSpec);
            quant = Quantizer.createInstance(dwt, encSpec);
            rois = ROIScaler.createInstance(quant, pl, encSpec);
            ecoder = EntropyCoder.createInstance(rois, pl, encSpec.cblks,
                encSpec.pss, encSpec.bms,
                encSpec.mqrs, encSpec.rts,
                encSpec.css, encSpec.sss,
                encSpec.lcs, encSpec.tts);

            using (MemoryStream stream = new MemoryStream())
            {
                bwriter = new FileCodestreamWriter(stream, Int32.MaxValue);
                ralloc = PostCompRateAllocator.createInstance(ecoder, pl, rate, bwriter, encSpec);

                headenc = new HeaderEncoder(imgsrc, new bool[3], dwt, imgtiler, encSpec, rois, ralloc, pl);
                ralloc.HeaderEncoder = headenc;
                headenc.encodeMainHeader();
                ralloc.initialize();
                headenc.reset();
                headenc.encodeMainHeader();
                bwriter.commitBitstreamHeader(headenc);

                ralloc.runAndWrite();
                bwriter.close();

                return stream.ToArray();
            }
        }
All Usage Examples Of CSJ2K.j2k.codestream.writer.FileCodestreamWriter::commitBitstreamHeader