Ejemplo n.º 1
0
        public PDataTF(DICOMObject dicom, bool isLastItem, bool isCommandObject, PresentationContext context)
            : this()
        {
            byte[] data;
            using (var stream = new MemoryStream())
            {
                using (var dw = new DICOMBinaryWriter(stream))
                {
                    var settings = new DICOMWriteSettings();
                    settings.TransferSyntax = isCommandObject
                        ? TransferSyntax.IMPLICIT_VR_LITTLE_ENDIAN
                        : TransferSyntaxHelper.GetSyntax(context.TransferSyntaxes[0]);
                    DICOMObjectWriter.Write(dw, settings, dicom);
                    data = stream.ToArray();
                }
            }
            var frag = new PDVItemFragment();

            frag.Data            = data;
            frag.IsLastItem      = isLastItem;
            frag.IsCommandObject = isCommandObject;
            var item = new PDVItem();

            item.Fragment = frag;
            item.PresentationContextID = context.Id;
            Items.Add(item);
        }
Ejemplo n.º 2
0
        public static Message <PDataTF> ReadPDFData(NetworkBinaryReader dr, bool firstByteRead = false, int i = 0)
        {
            PDataTF pdata = null;

            pdata = new PDataTF();
            if (!firstByteRead)
            {
                dr.Skip(1);
            }
            dr.Skip(1); // PDU ID and Reserved Null Byte
            var lengthBytes = dr.Take(4);
            int length      = LengthReader.ReadBigEndian(lengthBytes);

            using (DICOMBinaryReader dbr = dr.GetSubStream(length))
            {
                while (dbr.StreamPosition < dbr.StreamLength)
                {
                    PDVItem item = ItemReader.ReadPDVItem(dbr);
                    pdata.Items.Add(item);
                }
            }
            return(new Message <PDataTF> {
                Payload = pdata, Type = MessageType.PDATA_TF
            });
        }
Ejemplo n.º 3
0
        public PDataTF(byte[] data, bool isLastItem, bool isCommandObject, PresentationContext context)
            : this()
        {
            var frag = new PDVItemFragment();

            frag.Data            = data;
            frag.IsLastItem      = isLastItem;
            frag.IsCommandObject = isCommandObject;
            var item = new PDVItem();

            item.Fragment = frag;
            item.PresentationContextID = context.Id;
            Items.Add(item);
        }