Esempio n. 1
0
        public static SpineStorage GenerateStorageForAddedFile(DicomFile file)
        {
            var storage = new SpineStorage();

            var window_params = DicomUtils.GetWindowParameters(file);

            storage.windowWidth  = window_params.Item1;
            storage.windowCenter = window_params.Item2;

            storage.SetRotatingAngle(0);

            storage.direction      = 0;
            storage.imageDirection = 0;

            return(storage);
        }
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            if (openFileDialog.ShowDialog() == true)
            {
                var filename = openFileDialog.FileName;
                fname = Path.GetFileName(filename);

                var dicom = DicomFile.Open(filename);

                var raw = DicomUtils.ExtractRawValues(dicom);

                var wc = DicomUtils.GetWindowParameters(dicom);

                newpix = DicomUtils.ChangeWindowWidthCenter(raw, wc.Item1, wc.Item2);

                rotpixels = pixels = DicomUtils.CreateBitmap(newpix);

                angle = 0;
                group.Children.Add(new ScaleTransform(2, 2));
                myCanvas.LayoutTransform = group;


                //image.Source = this.imageSourceForImageControl(pixels); //image1 is your control

                MemoryStream ms = new MemoryStream();
                pixels.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                ms.Position = 0;
                BitmapImage bi = new BitmapImage();
                bi.BeginInit();
                bi.StreamSource = ms;
                bi.EndInit();

                image.Source = bi;
            }
        }