Exemplo n.º 1
0
        private void Viewer_Load(object sender, EventArgs e)
        {
            try
            {
                // we should either have a filename or dataset
                if (filename != null && filename.Length > 0)
                {
                    Cursor.Current = Cursors.WaitCursor;
                    try
                    {
                        dicom = OtherImageFormats.Read(filename);
                    }
                    finally
                    {
                        SetStatus("");
                        Cursor.Current = Cursors.Default;
                    }
                }
                if (dicom == null)
                {
                    throw new ArgumentException("No filename or dataset.");
                }

                SetIsCtImage();
                SetPixelRepresentation();
                voilut = GetVOILUT(dicom.Elements);

                attributes = Utilities.GetAttributes(dicom.Elements);
                // if the image is large, lets reduce memory consumption and decimate the source
                if (attributes.buffer.Length > 20000000)
                {
                    ReduceImage(dicom.Elements);
                }

                // extract overlays, if any
                overlay  = ExtractOverlays(dicom.Elements);
                overlays = (overlay != null);

                GetPicture();
            }
            catch (Exception ex)
            {
                MessageBox.Show(Logging.Log(ex));
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Runs the conversion if configured.
        /// </summary>
        /// <param name="args">The command line arguments</param>
        /// <returns>Returns -1 if not run, 1 if run successfully and a return value of 0 indicates
        /// a problem.</returns>
        public static int Run(string[] args)
        {
            int  result   = -1;
            bool attached = false;

            try
            {
                if (Setup(args))
                {
                    if (verbose)
                    {
                        AttachConsole();
                        attached = true;
                    }

                    Viewer  viewer = new Viewer();
                    DataSet dicom  = OtherImageFormats.Read(input);
                    viewer.SaveAs(dicom, output, invert, rotation, flip);

                    result = 0;
                }
            }
            catch (Exception ex)
            {
                result = 1;
                Console.WriteLine(ex.Message);
            }
            finally
            {
                if (attached)
                {
                    FreeConsole();
                }
            }
            return(result);
        }