public override List <DCMAbstractType> Decode(byte[] data, ref uint idx) { //a) 用ExplicitVRLittleEndian对象实例化filemeta对象,通过其Decode方法从data中读取头元素 filemeta = new DCMFileMeta(new ExplicitVRLittleEndian()); filemeta.Decode(data, ref idx); //b) 读取(0002,0010)头元素 DCMAbstractType head = filemeta.items.Find(x => ((x.gtag == 0x0002) && (x.etag == 0x0010))); //得到数据集传输语法的uid, String uid = head.GetValue <string>(); //在TransferSyntaxes中找到对应的传输语法对象赋给基类的syn字段 base.syn = TransferSyntaxs.All[uid]; //c) 调用base.Decode方法解码数据集。 return(base.Decode(data, ref idx)); }
public override List <DCMAbstractType> Decode(byte[] data, ref uint idx) { DCMAbstractType elem = syn.Decode(data, ref idx); if (elem.gtag == 0x0002 && elem.etag == 0x0000) { uint ulidx = 0; int glen = (int)elem.GetValue <UInt32>(); byte[] val = new byte[glen]; Array.Copy(data, idx, val, 0, glen); base.Decode(val, ref ulidx); idx += ulidx; } return(items); }
public override List <DCMAbstractType> Decode(byte[] data, ref uint idx) { DCMAbstractType item = syn.Decode(data, ref idx); if (item.gtag == 0xfffe && item.etag == 0xe000) //item start { uint ulidx = 0; byte[] val = (byte[])item.value; base.Decode(val, ref ulidx); //todo:修正idx位置 if (item.length == 0xffffffff) //修正idx位置 { idx -= (uint)(val.Length - ulidx); } } return(base.items); }
/// <param name="data">数据流</param> /// <param name="idx">位置索引</param> public virtual List <DCMAbstractType> Decode(byte[] data, ref uint idx) { items = new List <DCMAbstractType>(); while (idx < data.Length) { DCMAbstractType item = null; //此处调用传输语法对象解码一条数据元素 item = syn.Decode(data, ref idx); //判断特殊标记 if (item.gtag == 0xfffe && item.etag == 0xe0dd) { break; } if (item.gtag == 0xfffe && item.etag == 0xe00d) { break; } if (item.vr == "SQ") { DCMDataSequence sq = new DCMDataSequence(syn); uint ulidx = 0; byte[] val = (byte[])item.value; sq.Decode(val, ref ulidx); item.value = sq; //todo:修正idx位置 if (item.length == 0xffffffff) //修正idx位置 { idx -= (uint)(val.Length - ulidx); } } Console.WriteLine(idx); items.Add(item); } return(items); }