Example #1
0
        private DicomNCreateResponse CreateFilmBox(DicomNCreateRequest request)
        {
            if (_filmSession == null)
            {
                LogManager.Instance.Error("A basic film session does not exist for this association {0}", CallingAE);
                SendAbort(DicomAbortSource.ServiceProvider, DicomAbortReason.NotSpecified);
                return(new DicomNCreateResponse(request, DicomStatus.NoSuchObjectInstance));
            }

            FilmBox filmBox = _filmSession.CreateFilmBox(request.SOPInstanceUID, request.Dataset);

            if (!filmBox.Initialize())
            {
                LogManager.Instance.Error("Failed to initialize requested film box {0}", filmBox.SOPInstanceUID.UID);
                SendAbort(DicomAbortSource.ServiceProvider, DicomAbortReason.NotSpecified);
                return(new DicomNCreateResponse(request, DicomStatus.ProcessingFailure));
            }

            LogManager.Instance.Info("Created new film box {0}", filmBox.SOPInstanceUID.UID);

            var response = new DicomNCreateResponse(request, DicomStatus.Success);

            response.Command.Add(DicomTag.AffectedSOPInstanceUID, filmBox.SOPInstanceUID);
            response.Dataset = filmBox;
            return(response);
        }
Example #2
0
        public static DataSet RenderPage(FilmBox page, Size size)
        {
            string film = (string)page[t.FilmSizeID].Value;         // e.g., 14INX17IN

            Size filmsize = ParseFilmSizeID(film);
            Size resize   = Constrain(filmsize, size);

            Bitmap bitmap = new Bitmap(resize.Width, resize.Height);

            string format = (string)page[t.ImageDisplayFormat].Value;   // e.g., ROW\2,2,2,2,1 or STANDARD\1,1

            int[] items = null;
            ParseImageDisplayFormat(ref format, ref items);

            // for each item , there are a number of columns
            // the item count determines the number
            // the image position

            double factor = (double)resize.Width / (double)filmsize.Width;

            using (Graphics graphics = Graphics.FromImage(bitmap))
            {
                using (SolidBrush brush = new SolidBrush(Color.White))
                {
                    graphics.FillRectangle(brush, 0, 0, resize.Width, resize.Height);
                }
                FillRows(graphics, page, factor, items);
            }

            DataSet dicom = GetImage(bitmap);

            return(dicom);
        }
Example #3
0
        private DicomNSetResponse SetFilmBox(DicomNSetRequest request)
        {
            if (_filmSession == null)
            {
                LogManager.Instance.Error("A basic film session does not exist for this association {0}", CallingAE);
                return(new DicomNSetResponse(request, DicomStatus.NoSuchObjectInstance));
            }

            LogManager.Instance.Info("Set film box {0}", request.SOPInstanceUID.UID);
            FilmBox filmBox = _filmSession.FindFilmBox(request.SOPInstanceUID);

            if (filmBox == null)
            {
                LogManager.Instance.Error(
                    "Received N-SET request for invalid film box {0} from {1}",
                    request.SOPInstanceUID.UID,
                    CallingAE);
                return(new DicomNSetResponse(request, DicomStatus.NoSuchObjectInstance));
            }

            request.Dataset.CopyTo(filmBox);

            filmBox.Initialize();
            ReplaceTag(filmBox);

            var response = new DicomNSetResponse(request, DicomStatus.Success);

            response.Command.Add(DicomTag.AffectedSOPInstanceUID, filmBox.SOPInstanceUID);
            response.Command.Add(DicomTag.CommandDataSetType, (ushort)0x0202);
            response.Dataset = filmBox;
            return(response);
        }
Example #4
0
        public FilmBox StartFilmBox(string format, string orientation, string filmSize)
        {
            var filmBox = new FilmBox(FilmSession, null, DicomTransferSyntax.ExplicitVRLittleEndian)
            {
                ImageDisplayFormat
                    = format,
                FilmOrienation
                    =
                        orientation,
                FilmSizeID =
                    filmSize,
                MagnificationType
                              = "NONE",
                BorderDensity =
                    "BLACK",
                EmptyImageDensity
                    = "BLACK"
            };

            filmBox.Initialize();
            FilmSession.BasicFilmBoxes.Add(filmBox);

            _currentFilmBox = filmBox;
            return(filmBox);
        }
Example #5
0
        public void PresentationLut_NoReferencedPresentationLutSequence_GetterReturnsNull()
        {
            var session = new FilmSession(DicomUID.BasicFilmSession);
            var box     = new FilmBox(session, null, DicomTransferSyntax.ImplicitVRLittleEndian);

            Assert.Null(box.PresentationLut);
        }
Example #6
0
        private void OpenFilmBox()
        {
            var filmBox = new FilmBox(FilmSession, null, DicomTransferSyntax.ExplicitVRLittleEndian)
            {
                AnnotationDisplayFormatID = AnnotationDisplayFormatID,
                ConfigurationInformation  = ConfigurationInformation,
                BorderDensity             = BorderDensity,
                FilmOrientation           = FilmOrientation,
                FilmSizeID            = FilmSizeID,
                Illumination          = Illumination,
                ImageDisplayFormat    = ImageDisplayFormat,
                MagnificationType     = MagnificationType,
                MaxDensity            = MaxDensity,
                MinDensity            = MinDensity,
                ReflectedAmbientLight = ReflectedAmbientLight,
                RequestedResolutionID = RequestedResolutionID,
                SmoothingType         = SmoothingType,
                Trim = Trim
            };

            if (!SpecifyReferenceSequance)
            {
                filmBox.EmptyImageDensity = EmptyImageDensity;
            }

            filmBox.Initialize();
            FilmSession.BasicFilmBoxes.Add(filmBox);

            _currentFilmBox = filmBox;
        }
Example #7
0
        public static DataSet ReadFilmBox(FileStream stream, Size size)
        {
            System.Runtime.Serialization.Formatters.Soap.SoapFormatter formatter = new System.Runtime.Serialization.Formatters.Soap.SoapFormatter();
            FilmBox page = (FilmBox)formatter.Deserialize(stream);

            return(RenderPage(page, size));
        }
Example #8
0
            internal void OnCreated(DicomUid filmSessionUid)
            {
                this.SopInstanceUid = filmSessionUid;

                // Move to the first element.
                _filmBoxes.Add(_currentFilmBox = _createFilmBoxCallback.Invoke(new List <IPrintItem>(_printItemQueue).AsReadOnly()));
                this.PrintScu.CreateFilmBox(this, _currentFilmBox);
            }
Example #9
0
        public void ImageSequence_NoSequenceInImageBox_ReturnsNull(DicomUID sopClassUid)
        {
            var session  = new FilmSession(DicomUID.BasicFilmSession);
            var filmBox  = new FilmBox(session, null, DicomTransferSyntax.ImplicitVRLittleEndian);
            var imageBox = new ImageBox(filmBox, sopClassUid, null);

            Assert.Null(imageBox.ImageSequence);
        }
Example #10
0
        private void NewViewer(FilmBox page)
        {
            Viewer child = new Viewer(page);

            child.MdiParent   = this;
            child.WindowState = FormWindowState.Maximized;
            child.Show();
        }
Example #11
0
        void OnQueryPageSettings(object sender, QueryPageSettingsEventArgs e)
        {
            OnStatusUpdate(string.Format("Printing film {0} of {1}", _currentPage + 1, FilmBoxList.Count));
            _currentFilmBox = FilmBoxList[_currentPage];

            e.PageSettings.Margins.Left   = 25;
            e.PageSettings.Margins.Right  = 25;
            e.PageSettings.Margins.Top    = 25;
            e.PageSettings.Margins.Bottom = 25;

            e.PageSettings.Landscape = _currentFilmBox.FilmOrientation == "LANDSCAPE";
        }
Example #12
0
 public Viewer(FilmBox page)
     : this("")
 {
     try
     {
         this.dicom = OtherImageFormats.RenderPage(page, PictureBox.Size);
     }
     catch (Exception ex)
     {
         MessageBox.Show(Logging.Log(ex));
     }
 }
Example #13
0
        protected void DeleteFilmBox(FilmBox filmBox)
        {
            var message = new DicomMessage(null, null)
            {
                RequestedSopInstanceUid = filmBox.SopInstanceUid.UID,
                RequestedSopClassUid    = SopClass.BasicFilmBoxSopClassUid
            };

            this.Client.SendNDeleteRequest(GetPresentationContextId(this.AssociationParameters), this.Client.NextMessageID(), message);
            _eventObject = EventObject.FilmBox;
            Platform.Log(LogLevel.Debug, "Deleting film box...");
        }
Example #14
0
        protected void PrintFilmBox(FilmBox filmBox)
        {
            var message = new DicomMessage(null, null)
            {
                RequestedSopInstanceUid = filmBox.SopInstanceUid.UID,
                RequestedSopClassUid    = SopClass.BasicFilmBoxSopClassUid,
                ActionTypeId            = 1
            };

            this.Client.SendNActionRequest(GetPresentationContextId(this.AssociationParameters), this.Client.NextMessageID(), message);
            _eventObject = EventObject.FilmBox;
            LogAdapter.Logger.Warn("Printing film box...");
        }
Example #15
0
        void OnPrintPage(object sender, PrintPageEventArgs e)
        {
            e.Graphics.InterpolationMode = _currentFilmBox.MagnificationType == "CUBIC"
                ? InterpolationMode.HighQualityBicubic
                : InterpolationMode.HighQualityBilinear;

            var format = _currentFilmBox.ImageDisplayFormat;

            if (String.IsNullOrEmpty(format))
            {
                return;
            }

            var parts = _currentFilmBox.ImageDisplayFormat.Split('\\', ',');

            if (parts.Length >= 3)
            {
                var columns = int.Parse(parts[1]);
                var rows    = int.Parse(parts[2]);

                var boxSize = new SizeF(e.MarginBounds.Width / columns, e.MarginBounds.Height / rows);


                var boxes = new List <RectangleF>();
                for (int r = 0; r < rows; r++)
                {
                    for (int c = 0; c < columns; c++)
                    {
                        boxes.Add(new RectangleF
                        {
                            X      = e.MarginBounds.X + c * boxSize.Width,
                            Y      = e.MarginBounds.Y + r * boxSize.Height,
                            Width  = boxSize.Width,
                            Height = boxSize.Height
                        });
                    }
                }

                for (int i = 0; i < _currentFilmBox.BasicImageBoxes.Count; i++)
                {
                    DrawImageBox(_currentFilmBox.BasicImageBoxes[i], e.Graphics, boxes[i], 100);
                }
            }

            _currentFilmBox = null;
            _currentPage++;

            e.HasMorePages = _currentPage < FilmBoxList.Count;
        }
Example #16
0
        protected void CreateFilmBox(FilmSession filmSession, FilmBox filmBox)
        {
            var referencedFilmSessionSequence = new ReferencedInstanceSequenceIod
            {
                ReferencedSopClassUid    = SopClass.BasicFilmSessionSopClassUid,
                ReferencedSopInstanceUid = filmSession.SopInstanceUid.UID
            };

            filmBox.ReferencedFilmSessionSequenceList.Add(referencedFilmSessionSequence);

            var message = new DicomMessage(null, (DicomAttributeCollection)filmBox.DicomAttributeProvider);

            this.Client.SendNCreateRequest(null, GetPresentationContextId(this.AssociationParameters), this.Client.NextMessageID(), message, DicomUids.BasicFilmBoxSOP);
            _eventObject = EventObject.FilmBox;
            Platform.Log(LogLevel.Debug, "Creating film box...");
        }
Example #17
0
            internal void OnFilmBoxDeleted()
            {
                _currentFilmBox.SopInstanceUid = null;

                if (_printItemQueue.Count == 0)
                {
                    // No more items to create filmBox for.
                    this.PrintScu.DeleteFilmSession(this);
                }
                else
                {
                    // Create the next filmBox
                    _filmBoxes.Add(_currentFilmBox = _createFilmBoxCallback.Invoke(new List <IPrintItem>(_printItemQueue).AsReadOnly()));
                    this.PrintScu.CreateFilmBox(this, _currentFilmBox);
                }
            }
Example #18
0
        protected void CreateFilmBox(FilmSession filmSession, FilmBox filmBox)
        {
            var referencedFilmSessionSequence = new ReferencedInstanceSequenceIod
            {
                ReferencedSopClassUid    = SopClass.BasicFilmSessionSopClassUid,
                ReferencedSopInstanceUid = filmSession.SopInstanceUid.UID
            };

            filmBox.ReferencedFilmSessionSequenceList.Add(referencedFilmSessionSequence);

            var message = new DicomMessage(null, (DicomDataset)filmBox.DicomElementProvider);

            this.Client.SendNCreateRequest(null, GetPresentationContextId(this.AssociationParameters), this.Client.NextMessageID(), message, DicomUids.BasicFilmBoxSOP);
            _eventObject = EventObject.FilmBox;
            LogAdapter.Logger.Warn("Creating film box...");
        }
Example #19
0
        /**
         * 添加重载函数
         */
        public FilmBox StartFilmBox(PrintOptions options)
        {
            FilmBox filmBox = new FilmBox(FilmSession, null, DicomTransferSyntax.ExplicitVRLittleEndian)
            {
                ImageDisplayFormat = options.ImageDisplayFormat,
                FilmOrientation    = options.Orientation.ToStringEx(),
                FilmSizeID         = options.FilmSize.ToStringEx(),
                MagnificationType  = options.MagnificationType.ToStringEx(),
                BorderDensity      = options.BorderDensity.ToStringEx(),
                EmptyImageDensity  = options.EmptyImageDensity.ToStringEx(),
                MinDensity         = 0,
                MaxDensity         = 256,
            };

            filmBox.Initialize();
            FilmSession.BasicFilmBoxes.Add(filmBox);

            _currentFilmBox = filmBox;
            return(filmBox);
        }
Example #20
0
        public void Save_BasicFilmBox_CreatesRelevantFilesAndFolders()
        {
            var path = TestData.Resolve("Film Box Test 1");

            if (Directory.Exists(path))
            {
                Directory.Delete(path, true);
            }
            Directory.CreateDirectory(path);

            var session = new FilmSession(DicomUID.BasicFilmSession);
            var box     = new FilmBox(session, null, DicomTransferSyntax.ImplicitVRLittleEndian);

            box.BasicImageBoxes.Add(new ImageBox(box, DicomUID.BasicGrayscaleImageBox, null));
            box.Save(path);

            Assert.True(File.Exists(Path.Combine(path, "FilmBox.dcm")));
            Assert.True(File.Exists(Path.Combine(path, "FilmBox.txt")));
            Assert.True(Directory.Exists(Path.Combine(path, "Images")));
            Assert.True(Directory.GetFiles(Path.Combine(path, "Images")).Length > 0);
        }
Example #21
0
 private void OnPagePrinted(object sender, PrintJobEventArgs e)
 {
     if (this.InvokeRequired)
     {
         this.Invoke(new PrintJobEventHandler(OnPagePrinted), new object[] { sender, e });
     }
     else
     {
         FilmBox page = e.Session.FilmBoxes[0];
         //try
         //{
         //    if (File.Exists("delete.me"))
         //    {
         //        int temp = accession++;
         //        page.Dicom.Write(String.Format("filmbox{0}.dcm", temp));
         //        foreach (ImageBox image in page.ImageBoxes)
         //        {
         //            ushort position = (ushort)image.Dicom[t.ImageBoxPosition].Value;
         //            image.Dicom.Write(String.Format("imagebox{0}.{1}.dcm", temp, position));
         //        }
         //        return;
         //    }
         //}
         //catch (Exception ex)
         //{
         //    MessageBox.Show(Logging.Log(ex));
         //}
         try
         {
             NewViewer(page);
         }
         catch (Exception ex)
         {
             MessageBox.Show(Logging.Log(ex));
         }
     }
 }
Example #22
0
        public void Load_BasicFilmBox_ExpectedSopClassFound()
        {
            var path = TestData.Resolve("Film Box Test 2");

            if (Directory.Exists(path))
            {
                Directory.Delete(path, true);
            }
            Directory.CreateDirectory(path);

            var expected = DicomUID.Generate();

            var session = new FilmSession(DicomUID.BasicFilmSession);
            var box     = new FilmBox(session, expected, DicomTransferSyntax.ImplicitVRLittleEndian);

            box.BasicImageBoxes.Add(new ImageBox(box, DicomUID.BasicGrayscaleImageBox, null));
            box.Save(path);

            var loaded = FilmBox.Load(session, path);
            var actual = loaded.SOPInstanceUID;

            Assert.Equal(expected, actual);
            Assert.True(loaded.BasicImageBoxes.Count > 0);
        }
Example #23
0
        public void PrintFromPartsTest()
        {
            try
            {
                DataSet dicom = new DataSet();
                dicom.Read("FilmSession.dcm");
                string      instance = Element.NewUid();
                FilmSession session  = new FilmSession(instance, dicom);

                dicom = new DataSet();
                dicom.Read("FilmBox.dcm");
                dicom[t.ReferencedFilmSessionSequence + t.ReferencedSOPInstanceUID].Value = instance;
                FilmBox filmbox = session.NewFilmBox(Element.NewUid(), dicom);

                dicom = new DataSet();
                dicom.Read("ImageBox.dcm");
                ImageBox imagebox = filmbox.NewImageBox(Element.NewUid(), dicom);

                print(session, new ApplicationEntity("NER_8900", IPAddress.Parse("127.0.0.1"), 2008));
            }
            finally
            {
            }
        }
Example #24
0
		protected void DeleteFilmBox(FilmBox filmBox)
		{
			var message = new DicomMessage(null, null)
			{
				RequestedSopInstanceUid = filmBox.SopInstanceUid.UID,
				RequestedSopClassUid = SopClass.BasicFilmBoxSopClassUid
			};

			this.Client.SendNDeleteRequest(GetPresentationContextId(this.AssociationParameters), this.Client.NextMessageID(), message);
			_eventObject = EventObject.FilmBox;
			Platform.Log(LogLevel.Debug, "Deleting film box...");
		}
Example #25
0
		protected void CreateFilmBox(FilmSession filmSession, FilmBox filmBox)
		{
			var referencedFilmSessionSequence = new ReferencedInstanceSequenceIod
			{
				ReferencedSopClassUid = SopClass.BasicFilmSessionSopClassUid,
				ReferencedSopInstanceUid = filmSession.SopInstanceUid.UID
			};

			filmBox.ReferencedFilmSessionSequenceList.Add(referencedFilmSessionSequence);

			var message = new DicomMessage(null, (DicomAttributeCollection)filmBox.DicomAttributeProvider);
			this.Client.SendNCreateRequest(null, GetPresentationContextId(this.AssociationParameters), this.Client.NextMessageID(), message, DicomUids.BasicFilmBoxSOP);
			_eventObject = EventObject.FilmBox;
			Platform.Log(LogLevel.Debug, "Creating film box...");
		}
Example #26
0
 public void EndFilmBox()
 {
     _currentFilmBox = null;
 }
Example #27
0
        public static string SendPrintTask(string callingAE, string calledAE, string calledIP, int calledPort, string taskPath)
        {
            PrintTaskInfo task = new PrintTaskInfo()
            {
                CallingAETitle = callingAE, TaskPath = taskPath
            };

            string strErr = string.Empty;

            LogManager.Instance.Log("Start to send print task: " + taskPath);
            try
            {
                DirectoryInfo dirTask = new DirectoryInfo(taskPath);
                if (!dirTask.Exists)
                {
                    throw new Exception("invalid task path");
                }

                string filmSessionFile = Path.Combine(taskPath, "FilmSession.dcm");
                if (!File.Exists(filmSessionFile))
                {
                    throw new Exception("can't find film session file");
                }

                //load filmSession from dcmFile
                FilmSession filmSession = FilmSession.Load(filmSessionFile);

                //load filmBox from dcmFiles
                var subDirs = dirTask.EnumerateDirectories();
                foreach (DirectoryInfo dirFilmBox in subDirs)
                {
                    FilmBox filmBox = FilmBox.Load(filmSession, dirFilmBox.FullName);
                    filmSession.BasicFilmBoxes.Add(filmBox);
                }

                var dicomClient = new DicomClient();

                var filmSessionRequest = new DicomNCreateRequest(filmSession.SOPClassUID, filmSession.SOPInstanceUID);
                filmSessionRequest.Dataset = filmSession;

                dicomClient.AddRequest(filmSessionRequest);

                foreach (var filmbox in filmSession.BasicFilmBoxes)
                {
                    var imageBoxRequests = new List <DicomNSetRequest>();

                    var filmBoxRequest = new DicomNCreateRequest(FilmBox.SOPClassUID, filmbox.SOPInstanceUID);
                    filmBoxRequest.Dataset = filmbox;

                    filmBoxRequest.OnResponseReceived = (request, response) =>
                    {
                        if (response.HasDataset)
                        {
                            var seq = response.Dataset.Get <DicomSequence>(DicomTag.ReferencedImageBoxSequence);
                            for (int i = 0; i < seq.Items.Count; i++)
                            {
                                var req            = imageBoxRequests[i];
                                var imageBox       = req.Dataset;
                                var sopInstanceUid = seq.Items[i].Get <string>(DicomTag.ReferencedSOPInstanceUID);
                                imageBox.AddOrUpdate(DicomTag.SOPInstanceUID, sopInstanceUid);
                                req.Command.AddOrUpdate(DicomTag.RequestedSOPInstanceUID, sopInstanceUid);
                            }
                        }
                    };
                    dicomClient.AddRequest(filmBoxRequest);

                    foreach (var image in filmbox.BasicImageBoxes)
                    {
                        var req = new DicomNSetRequest(image.SOPClassUID, image.SOPInstanceUID)
                        {
                            Dataset = image
                        };

                        imageBoxRequests.Add(req);
                        dicomClient.AddRequest(req);
                    }
                }

                dicomClient.AddRequest(new DicomNActionRequest(filmSession.SOPClassUID, filmSession.SOPInstanceUID, 0x0001));

                dicomClient.Send(calledIP, calledPort, false, callingAE, calledAE);

                task.HasError = false;
                if (PrintTaskEvent != null)
                {
                    PrintTaskEvent(task);
                }
            }
            catch (Exception e)
            {
                strErr = e.Message;
                LogManager.Instance.Log("Send task failed due to " + e.Message);

                task.HasError     = true;
                task.ErrorMessage = e.Message;
                if (PrintTaskEvent != null)
                {
                    PrintTaskEvent(task);
                }
            }

            return(strErr);
        }
Example #28
0
			internal void OnCreated(DicomUid filmSessionUid)
			{
				this.SopInstanceUid = filmSessionUid;

				// Move to the first element.
				_filmBoxes.Add(_currentFilmBox = _createFilmBoxCallback.Invoke(new List<IPrintItem>(_printItemQueue).AsReadOnly()));
				this.PrintScu.CreateFilmBox(this, _currentFilmBox);
			}
Example #29
0
			public ImageBox(FilmBox filmBox, IPrintItem printItem)
			{
				this.FilmBox = filmBox;
				this.PrintItem = printItem;
			}
Example #30
0
			internal void OnFilmBoxDeleted()
			{
				_currentFilmBox.SopInstanceUid = null;

				if (_printItemQueue.Count == 0)
				{
					// No more items to create filmBox for.
					this.PrintScu.DeleteFilmSession(this);
				}
				else
				{
					// Create the next filmBox
					_filmBoxes.Add(_currentFilmBox = _createFilmBoxCallback.Invoke(new List<IPrintItem>(_printItemQueue).AsReadOnly()));
					this.PrintScu.CreateFilmBox(this, _currentFilmBox);
				}
			}
Example #31
0
 public ImageBox(FilmBox filmBox, IPrintItem printItem)
 {
     this.FilmBox   = filmBox;
     this.PrintItem = printItem;
 }
Example #32
0
        // each column must have its height calculated and the width verified
        // once the width and height are known, we can then resize bitmaps into the image
        private static void FillRows(Graphics graphics, FilmBox page, double factor, int[] bands)
        {
            int position = 1;
            int top      = 0;

            foreach (int column in bands)
            {
                // the row is divided into imageboxes of equal width
                int width  = (int)(graphics.VisibleClipBounds.Width / column);
                int height = Int32.MinValue;

                // the height of the row is calcuated as the maximum height of each image
                // based on RequestedImageSize or the height implied by the width and aspect ratio.
                for (int p = 0; p < column; p++)
                {
                    ImageBox imagebox = page.FindImageBox(position + p);
                    if (imagebox != null)
                    {
                        ushort columns = (ushort)imagebox[t.BasicGrayscaleImageSequence + t.Columns].Value;
                        ushort rows    = (ushort)imagebox[t.BasicGrayscaleImageSequence + t.Rows].Value;
                        if (imagebox.Dicom.ValueExists(t.RequestedImageSize))
                        {
                            int requested = (int)(Double.Parse((string)imagebox[t.RequestedImageSize].Value) * 10.0 * factor);
                            if (requested <= width)
                            {
                                int temp = requested * rows / columns;
                                if (temp > height)
                                {
                                    height = temp;
                                }
                            }
                            else
                            {
                                throw new Exception("Width exceeded!");
                                //string behavior = (string)imagebox[t.RequestedDecimateCropBehavior].Value;
                                //if (behavior != "DECIMATE")
                                //    throw new Exception("Width exceeded!");
                            }
                        }
                        else
                        {
                            int temp = width * rows / columns;
                            if (temp > height)
                            {
                                height = temp;
                            }
                        }
                    }
                }

                // limit the height to what is left, important for STANDARD\1,1 LLI
                if (top + height > graphics.VisibleClipBounds.Height)
                {
                    height = (int)graphics.VisibleClipBounds.Height;
                }

                // once the width and height are known each column in this row is fit into the imagebox.
                for (int p = 0; p < column; p++)
                {
                    ImageBox imagebox = page.FindImageBox(position + p);
                    if (imagebox != null)
                    {
                        DrawImageBox(imagebox, new Rectangle(p * width, top, width, height), graphics);
                    }
                }
                // move the to the top of the next row
                top += height;
                // move to the imagebox o
                position += column;
            }
        }
Example #33
0
 private void CloseFilmBox()
 {
     _currentFilmBox = null;
 }
Example #34
0
        static FilmSession CreateFourUpFilmSession()
        {
            DataSet     dicom   = null;
            FilmSession session = new FilmSession();

            session[t.NumberofCopies].Value   = "1";
            session[t.PrintPriority].Value    = "MED";
            session[t.MediumType].Value       = "BLUE FILM";
            session[t.FilmDestination].Value  = "BIN_1";
            session[t.FilmSessionLabel].Value = "";

            FilmBox filmbox = session.NewFilmBox();

            filmbox[t.ImageDisplayFormat].Value = @"STANDARD\2,2";
            filmbox[t.FilmOrientation].Value    = "PORTRAIT";
            filmbox[t.FilmSizeID].Value         = "14INX17IN";
            filmbox[t.BorderDensity].Value      = "330";
            filmbox[t.MinDensity].Value         = "23";
            filmbox[t.MaxDensity].Value         = "331";
            filmbox[t.Trim].Value                  = "NO";
            filmbox[t.Illumination].Value          = "2007";
            filmbox[t.ReflectedAmbientLight].Value = "9";

            dicom = new DataSet();
            dicom.Read(Path.Combine(Tools.RootFolder, @"EK\Capture\Dicom\DicomToolkit\Test\Data\DicomDir\THGLUZ5J.dcm"));

            ImageBox imagebox = filmbox.NewImageBox();

            imagebox[t.MagnificationType].Value             = "MAG_UNKNOWN";
            imagebox[t.SmoothingType].Value                 = "0";
            imagebox[t.ImagePosition].Value                 = "1";
            imagebox[t.Polarity].Value                      = "NORMAL";
            imagebox[t.RequestedDecimateCropBehavior].Value = "DECIMATE";

            imagebox[t.BasicGrayscaleImageSequence + t.SamplesperPixel].Value           = dicom[t.SamplesperPixel].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.PhotometricInterpretation].Value = dicom[t.PhotometricInterpretation].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.Rows].Value                = dicom[t.Rows].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.Columns].Value             = dicom[t.Columns].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.PixelAspectRatio].Value    = dicom[t.PixelAspectRatio].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.BitsAllocated].Value       = dicom[t.BitsAllocated].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.BitsStored].Value          = dicom[t.BitsStored].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.HighBit].Value             = dicom[t.HighBit].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.PixelRepresentation].Value = dicom[t.PixelRepresentation].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.PixelData].Value           = dicom[t.PixelData].Value;

            dicom = new DataSet();
            dicom.Read(Path.Combine(Tools.RootFolder, @"EK\Capture\Dicom\DicomToolkit\Test\Data\DicomDir\WNGVU1P1.dcm"));

            imagebox = filmbox.NewImageBox();

            Size truesize = new Size(949, 1210);
            Size original = new Size((ushort)dicom[t.Columns].Value, (ushort)dicom[t.Rows].Value);

            imagebox[t.MagnificationType].Value             = "MAG_UNKNOWN";
            imagebox[t.SmoothingType].Value                 = "0";
            imagebox[t.ImagePosition].Value                 = "2";
            imagebox[t.RequestedImageSize].Value            = "159.431997850537";
            imagebox[t.Polarity].Value                      = "NORMAL";
            imagebox[t.RequestedDecimateCropBehavior].Value = "FAIL";

            imagebox[t.BasicGrayscaleImageSequence + t.SamplesperPixel].Value           = dicom[t.SamplesperPixel].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.PhotometricInterpretation].Value = dicom[t.PhotometricInterpretation].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.Rows].Value                = (ushort)truesize.Height;
            imagebox[t.BasicGrayscaleImageSequence + t.Columns].Value             = (ushort)truesize.Width;
            imagebox[t.BasicGrayscaleImageSequence + t.PixelAspectRatio].Value    = dicom[t.PixelAspectRatio].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.BitsAllocated].Value       = dicom[t.BitsAllocated].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.BitsStored].Value          = dicom[t.BitsStored].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.HighBit].Value             = dicom[t.HighBit].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.PixelRepresentation].Value = dicom[t.PixelRepresentation].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.PixelData].Value           = CenterCrop((short[])dicom[t.PixelData].Value, new Size((ushort)dicom[t.Columns].Value, (ushort)dicom[t.Rows].Value), truesize);

            dicom = new DataSet();
            dicom.Read(Path.Combine(Tools.RootFolder, @"EK\Capture\Dicom\DicomToolkit\Test\Data\DicomDir\Y2ASNFDS.dcm"));

            imagebox = filmbox.NewImageBox();

            imagebox[t.MagnificationType].Value             = "MAG_UNKNOWN";
            imagebox[t.SmoothingType].Value                 = "0";
            imagebox[t.ImagePosition].Value                 = "3";
            imagebox[t.RequestedImageSize].Value            = "159.431997850537";
            imagebox[t.Polarity].Value                      = "NORMAL";
            imagebox[t.RequestedDecimateCropBehavior].Value = "FAIL";

            imagebox[t.BasicGrayscaleImageSequence + t.SamplesperPixel].Value           = dicom[t.SamplesperPixel].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.PhotometricInterpretation].Value = dicom[t.PhotometricInterpretation].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.Rows].Value                = (ushort)truesize.Height;
            imagebox[t.BasicGrayscaleImageSequence + t.Columns].Value             = (ushort)truesize.Width;
            imagebox[t.BasicGrayscaleImageSequence + t.PixelAspectRatio].Value    = dicom[t.PixelAspectRatio].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.BitsAllocated].Value       = dicom[t.BitsAllocated].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.BitsStored].Value          = dicom[t.BitsStored].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.HighBit].Value             = dicom[t.HighBit].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.PixelRepresentation].Value = dicom[t.PixelRepresentation].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.PixelData].Value           = CenterCrop((short[])dicom[t.PixelData].Value, original, truesize);

            dicom = new DataSet();
            dicom.Read(Path.Combine(Tools.RootFolder, @"EK\Capture\Dicom\DicomToolkit\Test\Data\DicomDir\THGLUZ5J.dcm"));

            imagebox = filmbox.NewImageBox();

            imagebox[t.MagnificationType].Value             = "MAG_UNKNOWN";
            imagebox[t.SmoothingType].Value                 = "0";
            imagebox[t.ImagePosition].Value                 = "4";
            imagebox[t.RequestedImageSize].Value            = "159.431997850537";
            imagebox[t.Polarity].Value                      = "NORMAL";
            imagebox[t.RequestedDecimateCropBehavior].Value = "DECIMATE";

            imagebox[t.BasicGrayscaleImageSequence + t.SamplesperPixel].Value           = dicom[t.SamplesperPixel].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.PhotometricInterpretation].Value = dicom[t.PhotometricInterpretation].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.Rows].Value                = dicom[t.Columns].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.Columns].Value             = dicom[t.Rows].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.PixelAspectRatio].Value    = dicom[t.PixelAspectRatio].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.BitsAllocated].Value       = dicom[t.BitsAllocated].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.BitsStored].Value          = dicom[t.BitsStored].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.HighBit].Value             = dicom[t.HighBit].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.PixelRepresentation].Value = dicom[t.PixelRepresentation].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.PixelData].Value           = Rotate((short[])dicom[t.PixelData].Value, original);

            return(session);
        }
Example #35
0
        static void print(string path, ApplicationEntity host)
        {
            DataSet dicom = new DataSet();

            dicom.Read(path);

            FilmSession session = new FilmSession();

            session[t.NumberofCopies].Value  = "1";
            session[t.PrintPriority].Value   = "MED";
            session[t.MediumType].Value      = "BLUE FILM";
            session[t.FilmDestination].Value = "PROCESSOR";

            PresentationLUT plut = session.NewPresentationLUT();

            plut[t.PresentationLUTShape].Value = "IDENTITIY";

            FilmBox filmbox = session.NewFilmBox();

            filmbox[t.ImageDisplayFormat].Value        = @"STANDARD\1,1";
            filmbox[t.AnnotationDisplayFormatID].Value = "COMBINED";
            filmbox[t.FilmOrientation].Value           = "PORTRAIT";
            filmbox[t.FilmSizeID].Value        = "14INX17IN";
            filmbox[t.MagnificationType].Value = "CUBIC";
            filmbox[t.SmoothingType].Value     = "5";
            filmbox[t.BorderDensity].Value     = "BLACK";
            filmbox[t.MinDensity].Value        = "21";
            filmbox[t.MaxDensity].Value        = "360";
            filmbox[t.Trim].Value                  = "NO";
            filmbox[t.Illumination].Value          = "2500";
            filmbox[t.ReflectedAmbientLight].Value = "2";

            Annotation annotation = filmbox.NewAnnotation();

            annotation[t.AnnotationPosition].Value = 0;
            annotation[t.TextString].Value         = "bottom";

            annotation = filmbox.NewAnnotation();
            annotation[t.AnnotationPosition].Value = 1;
            annotation[t.TextString].Value         = "label";

            ImageBox imagebox = filmbox.NewImageBox();

            imagebox[t.MagnificationType].Value             = "CUBIC";
            imagebox[t.SmoothingType].Value                 = "5";
            imagebox[t.ImageBoxPosition].Value              = "1";
            imagebox[t.Polarity].Value                      = "NORMAL";
            imagebox[t.RequestedDecimateCropBehavior].Value = "DECIMATE";

            imagebox[t.BasicGrayscaleImageSequence + t.SamplesperPixel].Value           = dicom[t.SamplesperPixel].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.PhotometricInterpretation].Value = dicom[t.PhotometricInterpretation].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.Rows].Value                = dicom[t.Rows].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.Columns].Value             = dicom[t.Columns].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.PixelAspectRatio].Value    = dicom[t.PixelAspectRatio].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.BitsAllocated].Value       = dicom[t.BitsAllocated].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.BitsStored].Value          = dicom[t.BitsStored].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.HighBit].Value             = dicom[t.HighBit].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.PixelRepresentation].Value = dicom[t.PixelRepresentation].Value;
            imagebox[t.BasicGrayscaleImageSequence + t.PixelData].Value           = dicom[t.PixelData].Value;

            imagebox.PresentationLUT = plut;

            print(session, host);
        }