Пример #1
0
        //文件解码
        public override List <DCMAbstractType> Decode(byte[] data, ref uint idx)
        {
            //打开filename文件,将文件内容读到缓冲区byte[] data
            data = File.ReadAllBytes(filename);
            //跳过128字节前导符(idx=128)
            idx += 128;
            //读取四字节标识,如不为“DICM”则结束
            string s = Encoding.Default.GetString(data, (int)idx, 4);

            if (s == "DICM")
            {
                idx += 4;
                //用ExplicitVRLittleEndian对象实例化filemeta对象
                filemeta = new DCMFileMeta(new ExplicitVRLittleEndian());
                //通过其Decode方法从data中读取头元素
                filemeta.Decode(data, ref idx);
                //读取(0002,0010)头元素
                string uid = Encoding.Default.GetString(filemeta[DCMLIB.DicomTags.TransferSyntaxUid].value);
                //在tsFactory中找到对应的数据集传输语法对象赋给基类的syntax字段
                foreach (TransferSyntax syn in tsFactory.TSs)
                {
                    if ((syn.uid + "\0") == uid)
                    {
                        base.syntax = syn;
                        break;
                    }
                }
                //调用base.Decode方法解码数据集
                return(base.Decode(data, ref idx));
            }
            else
            {
                return(base.Decode(data, ref idx));
            }
        }
Пример #2
0
        public override List <DCMAbstractType> Decode(byte[] data, ref uint idx)
        {
            //打开filename文件,将文件内容读到缓冲区byte[] data
            using (FileStream fs = File.OpenRead(filename))
            {
                data = new byte[fs.Length];
                fs.Read(data, 0, (int)fs.Length);
            }

            //跳过128字节前导符(idx=128),读取4字节的”DICM”
            idx = 128;
            //***
            idx += 4;
            //用ExplicitVRLittleEndian对象实例化filemeta对象,通过其Decode方法从data中读取头元素
            syntax   = new ExplicitVRLittleEndian();
            filemeta = new DCMFileMeta(syntax);
            filemeta.Decode(data, ref idx);
            //读取(0002,0010)头元素即filemeta[DicomTags.TransferSyntaxUid]的值,
            //在tsFactory中找到对应的数据集传输语法对象赋给基类的syntax字段
            DCMDataElement synelem = (DCMDataElement)filemeta[DicomTags.TransferSyntaxUid];

            syntax = tsFactory[synelem.ReadValue <String>()[0].Replace("\0", "")];


            //调用base.Decode方法解码数据集
            base.Decode(data, ref idx);
            return(items);
        }
Пример #3
0
        public override List <DCMAbstractType> Decode(byte[] data, ref uint idx)
        {
            filemete = new DCMFileMeta(new ExplicitVRLittleEndian());
            DCMAbstractType uid  = filemete.Decode(data, ref idx).Find((DCMAbstractType type) => type.etag == 0x0010 && type.gtag == 0x0002);
            string          uid1 = uid.GetValue <string>();
            TransferSyntax  syn  = TransferSyntaxs.All[uid1];

            Data = new DCMDataSet(syn);
            Data.Decode(data, ref idx);

            return(items);
        }