public virtual void ReadFile(Stream ins, FileFormat format, uint stopTag) { var Parser = new DcmParser(ins); Parser.DcmHandler = DcmHandler; Parser.ParseDcmFile(format, stopTag); }
public virtual void ReadDataset(Stream ins, DcmDecodeParam param, uint stopTag) { var Parser = new DcmParser(ins); Parser.DcmHandler = DcmHandler; Parser.ParseDataset(param, stopTag); }
public FileDataSource(DcmParser parser, DataSet dataSet, byte[] buffer) { _parser = parser; _dataSet = dataSet; _buffer = buffer; }
private void StoreToFile(DcmParser parser, DataSet ds, FileInfo file, DcmEncodeParam encParam) { Stream outputStream = OpenOutputStream(file); try { ds.WriteFile(outputStream, encParam); if (parser.ReadTag == Tags.PixelData) { ds.WriteHeader(outputStream, encParam, parser.ReadTag, parser.ReadVR, parser.ReadLength); Copy(parser.InputStream, outputStream); } } finally { try { outputStream.Close(); } catch (IOException ignore) { Logger.Error(ignore); } } }
private FutureDimseResponse SendDataset(IActiveAssociation activeAssociation, DcmParser parser, DataSet dataSet) { String sopInstUniqueId = dataSet.GetString(Tags.SOPInstanceUniqueId); if (string.IsNullOrEmpty(sopInstUniqueId)) { Logger.Error("SOP instance UniqueId is null or empty"); return null; } String sopClassUniqueId = dataSet.GetString(Tags.SOPClassUniqueId); if (string.IsNullOrEmpty(sopClassUniqueId)) { Logger.Error("SOP class UniqueId is null or empty"); return null; } PresentationContext pc = null; IAssociation association = activeAssociation.Association; if (parser != null) { if (parser.DcmDecodeParam.encapsulated) { String tsUniqueId = dataSet.FileMetaInfo.TransferSyntaxUniqueId; if ((pc = association.GetAcceptedPresContext(sopClassUniqueId, tsUniqueId)) == null) { Logger.Error(SOP_CLASS_UNIQUEID_NOT_SUPPORTED); return null; } } else if (IsSopClassUniqueIdNotSupported(association, sopClassUniqueId, out pc)) { Logger.Error(SOP_CLASS_UNIQUEID_NOT_SUPPORTED); return null; } DicomCommand cStoreRequest = _dcmObjectFactory.NewCommand().InitCStoreRQ(association.NextMsgID(), sopClassUniqueId, sopInstUniqueId, Priority.HIGH); return activeAssociation.Invoke(_associationFactory.NewDimse(pc.pcid(), cStoreRequest, new FileDataSource(parser, dataSet, new byte[2048]))); } if ((dataSet.FileMetaInfo != null) && (dataSet.FileMetaInfo.TransferSyntaxUniqueId != null)) { String tsUniqueId = dataSet.FileMetaInfo.TransferSyntaxUniqueId; if ((pc = association.GetAcceptedPresContext(sopClassUniqueId, tsUniqueId)) == null) { Logger.Error(SOP_CLASS_UNIQUEID_NOT_SUPPORTED); return null; } } else if (IsSopClassUniqueIdNotSupported(association, sopClassUniqueId, out pc)) { Logger.Error(SOP_CLASS_UNIQUEID_NOT_SUPPORTED); return null; } DicomCommand cStoreRq = _dcmObjectFactory.NewCommand().InitCStoreRQ(association.NextMsgID(), sopClassUniqueId, sopInstUniqueId, Priority.HIGH); IDimse dimse = _associationFactory.NewDimse(pc.pcid(), cStoreRq, dataSet); return activeAssociation.Invoke(dimse); }