private void buttonRestoreDefaults_Click(object sender, EventArgs e) { _getImageFlags = _defaultImageFlags; _initializing = true; GetImageFlagsToCheckBoxes(); _initializing = false; UpdateImageViewer(); }
private void LoadOptionsDlg_Load(object sender, EventArgs e) { _initializing = true; if (_firstLoad) { _defaultImageFlags = _getImageFlags; _firstLoad = false; } GetImageFlagsToCheckBoxes(); _initializing = false; }
private void OpenDataset(string filename) { try { _DataSet.Load(filename, DicomDataSetLoadFlags.LoadAndClose); // Find Pixel Data _PixelElement = _DataSet.FindFirstElement(null, DicomTag.PixelData, true); if (_PixelElement != null) { // Load Base Image #if !LEADTOOLS_V20_OR_LATER DicomGetImageFlags getImageFlags = DicomGetImageFlags.AutoApplyModalityLut | DicomGetImageFlags.AutoApplyVoiLut | DicomGetImageFlags.AutoScaleModalityLut | DicomGetImageFlags.AutoScaleVoiLut | DicomGetImageFlags.AutoDectectInvalidRleCompression | DicomGetImageFlags.AutoLoadOverlays; #else DicomGetImageFlags getImageFlags = DicomGetImageFlags.AutoApplyModalityLut | DicomGetImageFlags.AutoApplyVoiLut | DicomGetImageFlags.AutoScaleModalityLut | DicomGetImageFlags.AutoScaleVoiLut | DicomGetImageFlags.AutoDetectInvalidRleCompression | DicomGetImageFlags.AutoLoadOverlays; #endif // #if !LEADTOOLS_V20_OR_LATER _rasterImageViewer.Image = _DataSet.GetImage(_PixelElement, 0, 0, RasterByteOrder.Gray, getImageFlags); LoadOverlays(); _mnuOverlaysInsertOverlay.Enabled = true; _mnuFileSave.Enabled = true; } else { Messager.ShowError(this, "NO Pixel Data"); _mnuOverlaysInsertOverlay.Enabled = false; _mnuFileSave.Enabled = false; } EnableOverlayOptions(); } catch (Exception ex) { Messager.ShowError(this, ex); } finally { EnableOverlayOptions(); } }
private DicomGetImageFlags CheckBoxesToGetImageFlags() { DicomGetImageFlags flags = DicomGetImageFlags.None; if (checkBoxAutoApplyModalityLut.Checked) { flags |= DicomGetImageFlags.AutoApplyModalityLut; } if (checkBoxAutoApplyVoiLut.Checked) { flags |= DicomGetImageFlags.AutoApplyVoiLut; } if (checkBoxAutoScaleModalityLut.Checked) { flags |= DicomGetImageFlags.AutoScaleModalityLut; } if (checkBoxAutoScaleVoiLut.Checked) { flags |= DicomGetImageFlags.AutoScaleVoiLut; } if (checkBoxAutoDetectInvalidRleCompression.Checked) { flags |= DicomGetImageFlags.AutoDetectInvalidRleCompression; } if (checkBoxKeepColorPalette.Checked) { flags |= DicomGetImageFlags.KeepColorPalette; } if (checkBoxLoadCorrupted.Checked) { flags |= DicomGetImageFlags.LoadCorrupted; } if (checkBoxRleSwapSegments.Checked) { flags |= DicomGetImageFlags.RleSwapSegments; } if (checkBoxAutoLoadOverlays.Checked) { flags |= DicomGetImageFlags.AutoLoadOverlays; } return(flags); }
private void LoadImage(RasterImage image) { int count = 0; Clear(); if (image == null) { count = _DataSet.GetImageCount(null); if (count > 0) { #if !LEADTOOLS_V20_OR_LATER DicomGetImageFlags getImageFlags = DicomGetImageFlags.AutoApplyModalityLut | DicomGetImageFlags.AutoApplyVoiLut | DicomGetImageFlags.AutoScaleModalityLut | DicomGetImageFlags.AutoScaleVoiLut | DicomGetImageFlags.AutoDectectInvalidRleCompression; #else DicomGetImageFlags getImageFlags = DicomGetImageFlags.AutoApplyModalityLut | DicomGetImageFlags.AutoApplyVoiLut | DicomGetImageFlags.AutoScaleModalityLut | DicomGetImageFlags.AutoScaleVoiLut | DicomGetImageFlags.AutoDetectInvalidRleCompression; #endif // #if !LEADTOOLS_V20_OR_LATER image = _DataSet.GetImages(null, 0, count, 0, RasterByteOrder.Rgb | RasterByteOrder.Gray, getImageFlags); } animationToolStripMenuItem.Enabled = count > 1; } if (image != null) { MedicalViewerCell cell = _MedicalViewer.Cells[0] as MedicalViewerCell; cell.Image = image; cell.FitImageToCell = true; if (image.GrayscaleMode != RasterGrayscaleMode.None) { cell.SetTag(2, MedicalViewerTagAlignment.BottomLeft, MedicalViewerTagType.WindowLevelData); cell.SetTag(0, MedicalViewerTagAlignment.TopRight, MedicalViewerTagType.Frame); } animationToolStripMenuItem.Enabled = image.PageCount > 1; } }
private void UpdateImageViewer() { _getImageFlags = CheckBoxesToGetImageFlags(); DicomElement element = ds.FindFirstElement(null, DicomTag.PixelData, true); int bitmapCount = ds.GetImageCount(element); if (bitmapCount > 0) { try { RasterImage _image = ds.GetImage(element, 0, 0, RasterByteOrder.Gray, _getImageFlags); Viewer.Image = _image; } catch (Exception) { Viewer.Image = null; } } }
private void LoadImage(object data) { DicomDataSet ds = data as DicomDataSet; int count = 0; RasterImage image = null; if (Dataset == null) { Cell.Image = null; return; } bool isStructuredDisplay = IsStructuredDisplay(ds); DicomElement pixelData = ds.FindFirstElement(null, DicomTag.PixelData, true); if (pixelData == null) { if (isStructuredDisplay) { count = 1; } } else { count = ds.GetImageCount(pixelData); } SetLoadProgress(count > 0, count); string exceptionMessage = string.Empty; for (int i = 0; i < count; i++) { RasterImage img = null; try { if (pixelData != null) { img = ds.GetImage(pixelData, i, 0, RasterByteOrder.Rgb | RasterByteOrder.Gray, DicomGetImageFlags.AutoApplyModalityLut | DicomGetImageFlags.AutoApplyVoiLut | DicomGetImageFlags.AutoScaleModalityLut | DicomGetImageFlags.AutoScaleVoiLut | DicomGetImageFlags.AutoDetectInvalidRleCompression); } else if (isStructuredDisplay) { StructuredDisplayImageOptions sdOptions = new StructuredDisplayImageOptions(); sdOptions.ShowOverlay = _optionsAgent.Get <bool>("ExportLayoutIncludeMetadata", true); DicomGetImageFlags getImageFlags = DicomGetImageFlags.AutoScaleModalityLut | DicomGetImageFlags.AutoScaleVoiLut | DicomGetImageFlags.AutoApplyModalityLut | DicomGetImageFlags.AutoApplyVoiLut; img = ds.GetStructuredDisplayImage(GetSopInstanceCallBack, getImageFlags, sdOptions);; } } catch (Exception ex) { exceptionMessage = ex.Message; } if (img != null) { if (image == null) { image = img.Clone(); } else { image.AddPage(img); } } SetProgressValue(i + 1); Thread.Sleep(0); } string photometricInterpretation = GetDicomTag(ds, DicomTag.PhotometricInterpretation); if (!string.IsNullOrEmpty(photometricInterpretation)) { Cell.PhotometricInterpretation = photometricInterpretation; } SetCellInfo(image, ds.GetValue <string>(DicomTag.PatientID, string.Empty), ds.GetValue <string>(DicomTag.PatientName, string.Empty), ds.GetValue <string>(DicomTag.WindowWidth, string.Empty), ds.GetValue <string>(DicomTag.WindowCenter, string.Empty), isStructuredDisplay); if (!string.IsNullOrEmpty(exceptionMessage)) { string errorMessage = string.Format("Failed to show image.\n{0}", exceptionMessage); if (count > 1) { errorMessage = string.Format("Failed to load one or more image frames.\n{0}", exceptionMessage); } Messager.ShowError(this, errorMessage); } }
public static bool IsFlagged(this DicomGetImageFlags flags, DicomGetImageFlags flag) { return((flags & flag) == (flag)); }
private void buttonOK_Click(object sender, EventArgs e) { _getImageFlags = CheckBoxesToGetImageFlags(); }