Exemple #1
0
        private void SaveImagePrintBtn_Click(object sender, RoutedEventArgs e)
        {
            SaveImagePopup.IsOpen = false;
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.Filter       = "Bitmap files (*.bmp)|*.bmp|Jpeg files (*.jpg)|*.jpg|Tiff files (*.tif)|*.tif|PNG files (*.png)|*.png";
            dlg.AddExtension = true;
            dlg.DefaultExt   = "jpg";
            dlg.FilterIndex  = 2;
            BitmapEncoder be;
            FileStream    fs;

            if (dlg.ShowDialog() == true)//System.Windows.Forms.DialogResult.OK)
            {
                var          bsource = MainImage.Source as BitmapSource;
                BitmapSource bms     = XRayImageRenderer.GetRenderedXrayImage(bsource,
                                                                              m_SourceObject,
                                                                              m_ViewObject,
                                                                              (ShaderEffect)XrayImage_Panel.Effect,
                                                                              GetListOfEffects(),
                                                                              bsource.Width,
                                                                              bsource.Height,
                                                                              _AdornerLayerManager,
                                                                              ImagePreview.IsAnnotationShown,
                                                                              ImagePreview.IsMeasurementShown);

                string fname = dlg.FileName;
                string ext   = System.IO.Path.GetExtension(fname).ToLower();

                fs = new FileStream(fname, FileMode.Create);
                switch (ext)
                {
                case ".bmp":
                    be = new BmpBitmapEncoder();
                    be.Frames.Add(BitmapFrame.Create(bms));
                    be.Save(fs);
                    break;

                case ".jpg":
                    be = new JpegBitmapEncoder();
                    be.Frames.Add(BitmapFrame.Create(bms));
                    be.Save(fs);
                    break;

                case ".png":
                    be = new PngBitmapEncoder();
                    be.Frames.Add(BitmapFrame.Create(bms));
                    be.Save(fs);
                    break;

                case ".tif":
                    be = new TiffBitmapEncoder();
                    be.Frames.Add(BitmapFrame.Create(bms));
                    be.Save(fs);
                    break;
                }
                fs.Close();
            }
        }
Exemple #2
0
        private BitmapSource GetRenderedXrayImage()
        {
            BitmapSource bsource = MainImage.Source as BitmapSource;

            return(XRayImageRenderer.GetRenderedXrayImage(bsource,
                                                          m_SourceObject,
                                                          m_ViewObject,
                                                          (ShaderEffect)XrayImage_Panel.Effect,
                                                          GetListOfEffects(),
                                                          PanZoom_Border.ActualWidth,
                                                          PanZoom_Border.ActualHeight,
                                                          _AdornerLayerManager,
                                                          IsAnnotationsShowing(),
                                                          IsMeasurementsShowing()));
        }