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); }
public TransferSyntaxes() { TSs[0] = new ImplicitVRLittleEndian(); TSs[1] = new ExplicitVRLittleEndian(); TSs[2] = new ExplicitVRBigEndian(); }