public void RenewBitmap()
        {
            pixels = DicomUtils.CreateBitmap(newpix);


            var bmp = DicomUtils.RotateImg(pixels, angle, System.Drawing.Color.Black);

            rotpixels = bmp;

            MemoryStream ms = new MemoryStream();

            bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
            ms.Position = 0;
            BitmapImage bi = new BitmapImage();

            bi.BeginInit();
            bi.StreamSource = ms;
            bi.EndInit();

            image.Source = bi;
        }
        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;
            }
        }