Beispiel #1
0
        private void CopyImage()
        {
            var cs        = _jp2.OpenCodestream();
            int tileparts = cs.OpenChildren().Count();
            var markers   = cs.Markers.Values
                            .Where(ms => ms.Type != MarkerType.TLM);
            var csout = new JP2Codestream(markers, tileparts);

            csout.Bind(_mem, 0);
            JP2TilePart tpin  = cs.OpenTilePart(0, 0);
            JP2TilePart tpout = csout.CreateTilePart(0, true);

            tpout.AddPacketLengths(
                tpin.GetPacketLengths(0, tpin.Packets));
            tpout.Flush();
            uint dataCount =
                JP2TilePart.BulkTransferData(tpout, 0, tpin, 0, tpin.Packets);

            csout.Flush();
        }
Beispiel #2
0
        public void Initialize()
        {
            _fs   = File.OpenRead("test.jp2");
            _mem  = new MemoryStream();
            _csin = Jp2File.Open(_fs).OpenCodestream();
            var siz   = _csin.Markers[MarkerType.SIZ] as SizMarker;
            var cod   = _csin.Markers[MarkerType.COD] as CodMarker;
            var qcd   = _csin.Markers[MarkerType.QCD] as QcdMarker;
            var tpin  = _csin.OpenTilePart(0, 0);
            var csout = new JP2Codestream(new List <MarkerSegment>()
            {
                siz, cod, qcd
            }, 1);

            csout.Bind(_mem, 0);
            var tpout   = csout.CreateTilePart(0, true);
            var lengths = tpin.GetPacketLengths(0, tpin.Packets);

            tpout.AddPacketLengths(lengths);
            tpout.Flush();
            csout.Flush();
            _mem.Seek(0, SeekOrigin.Begin);
        }