static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); DicomCodec.RegisterCodecs(); DicomCodec.RegisterExternalCodecs(".", "Dicom.Codec*.dll"); if (File.Exists("dicom.dic")) { DcmDictionary.ImportDictionary("dicom.dic"); } else { DcmDictionary.LoadInternalDictionary(); } if (File.Exists("private.dic")) { DcmDictionary.ImportDictionary("private.dic"); } DicomDumpForm form = new DicomDumpForm(); foreach (string file in args) { form.AddFile(file); } Application.Run(form); }
public void OnLoad(object sender, EventArgs e) { InitializeLog(); DicomCodec.RegisterCodecs(); DicomCodec.RegisterExternalCodecs(".", "Dicom.Codec*.dll"); if (File.Exists("dicom.dic")) { DcmDictionary.ImportDictionary("dicom.dic"); } else { DcmDictionary.LoadInternalDictionary(); } if (File.Exists("private.dic")) { DcmDictionary.ImportDictionary("private.dic"); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { DicomCodec.RegisterCodecs(); DicomCodec.RegisterExternalCodecs(".", "Dicom.Codec*.dll"); if (File.Exists("dicom.dic")) { DcmDictionary.ImportDictionary("dicom.dic"); } else { DcmDictionary.LoadInternalDictionary(); } if (File.Exists("private.dic")) { DcmDictionary.ImportDictionary("private.dic"); } Debug.InitializeConsoleDebugLogger(); }
/// <summary> /// Loads the DICOM file and changes the transfer syntax if needed. (Internal) /// </summary> /// <param name="client">C-Store Client</param> public void Load(CStoreClient client) { if (_loaded) { return; } try { DicomTransferSyntax tx = null; foreach (DcmPresContext pc in client.Associate.GetPresentationContexts()) { if (pc.Result == DcmPresContextResult.Accept && pc.AbstractSyntax == _sopClass) { tx = pc.AcceptedTransferSyntax; break; } } if (tx == null) { throw new DicomNetworkException("No accepted presentation contexts for abstract syntax: " + _sopClass.Description); } // Possible to stream from file? if (!client.DisableFileStreaming && tx == TransferSyntax) { using (FileStream fs = DicomFileFormat.GetDatasetStream(_fileName)) { _datasetSize = Convert.ToUInt32(fs.Length - fs.Position); fs.Close(); } return; } DcmCodecParameters codecParams = null; if (tx == client.PreferredTransferSyntax) { codecParams = client.PreferredTransferSyntaxParams; } DicomFileFormat ff = new DicomFileFormat(); ff.Load(FileName, DicomReadOptions.DefaultWithoutDeferredLoading); if (_originalTransferSyntax != tx) { if (_originalTransferSyntax.IsEncapsulated) { // Dataset is compressed... decompress try { ff.ChangeTransferSytnax(DicomTransferSyntax.ExplicitVRLittleEndian, null); } catch { client.Log.Error("{0} -> Unable to change transfer syntax:\n\tclass: {1}\n\told: {2}\n\tnew: {3}\n\treason: {4}\n\tcodecs: {5} - {6}", client.LogID, SOPClassUID.Description, _originalTransferSyntax, DicomTransferSyntax.ExplicitVRLittleEndian, #if DEBUG HasError ? "Unknown" : Error.ToString(), #else HasError ? "Unknown" : Error.Message, #endif DicomCodec.HasCodec(_originalTransferSyntax), DicomCodec.HasCodec(DicomTransferSyntax.ExplicitVRLittleEndian)); throw; } } if (tx.IsEncapsulated) { // Dataset needs to be compressed try { ff.ChangeTransferSytnax(tx, codecParams); } catch { client.Log.Error("{0} -> Unable to change transfer syntax:\n\tclass: {1}\n\told: {2}\n\tnew: {3}\n\treason: {4}\n\tcodecs: {5} - {6}", client.LogID, SOPClassUID.Description, ff.Dataset.InternalTransferSyntax, tx, #if DEBUG HasError ? "Unknown" : Error.ToString(), #else HasError ? "Unknown" : Error.Message, #endif DicomCodec.HasCodec(ff.Dataset.InternalTransferSyntax), DicomCodec.HasCodec(tx)); throw; } } } _dataset = ff.Dataset; _datasetSize = _dataset.CalculateWriteLength(tx, DicomWriteOptions.Default); _transferSyntax = tx; } catch (Exception e) { _dataset = null; _transferSyntax = _originalTransferSyntax; _status = DcmStatus.ProcessingFailure; _exception = e; } finally { _loaded = true; } }