예제 #1
0
 private void buttonRestoreDefaults_Click(object sender, EventArgs e)
 {
     _getImageFlags = _defaultImageFlags;
     _initializing  = true;
     GetImageFlagsToCheckBoxes();
     _initializing = false;
     UpdateImageViewer();
 }
예제 #2
0
        private void LoadOptionsDlg_Load(object sender, EventArgs e)
        {
            _initializing = true;
            if (_firstLoad)
            {
                _defaultImageFlags = _getImageFlags;
                _firstLoad         = false;
            }
            GetImageFlagsToCheckBoxes();

            _initializing = false;
        }
예제 #3
0
        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();
            }
        }
예제 #4
0
        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);
        }
예제 #5
0
        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;
            }
        }
예제 #6
0
        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;
                }
            }
        }
예제 #7
0
        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);
            }
        }
예제 #8
0
 public static bool IsFlagged(this DicomGetImageFlags flags, DicomGetImageFlags flag)
 {
     return((flags & flag) == (flag));
 }
예제 #9
0
 private void buttonOK_Click(object sender, EventArgs e)
 {
     _getImageFlags = CheckBoxesToGetImageFlags();
 }