private void image2_Click(object sender, RoutedEventArgs e) { try { currImgHandler2 = new CurrentImageHandler(); OpenFileDialog ImageDialog = new OpenFileDialog(); ImageDialog.RestoreDirectory = true; ImageDialog.FilterIndex = 1; ImageDialog.Filter = "bmp Files (*.bmp)|*.bmp|jpeg Files (*.jpeg)|*.jpeg|gif Files (*.gif)|*.gif|png Files (*.png)|*.png |jpg Files (*.jpg)|*.jpg|" + "All files (*.*)|*.*"; if (ImageDialog.ShowDialog().Value) { src2.Text = ImageDialog.FileName; currImgHandler2.CurrentFileHandler.Load(ImageDialog.FileName); FileInfo fileInfo2 = new FileInfo(currImgHandler2.CurrentBitmapPath); if (fileInfo2.Extension == ".bmp") { img2.Source = new BitmapImage(new Uri(currImgHandler2.CurrentBitmapPath)); } else { int dev; if (currImgHandler2.CurrentBitmap.Width > currImgHandler2.CurrentBitmap.Height) { dev = currImgHandler2.CurrentBitmap.Width / 193; } else { dev = currImgHandler2.CurrentBitmap.Height / 193; } currImgHandler2.Resize(Convert.ToInt32(currImgHandler2.CurrentBitmap.Width / dev), Convert.ToInt32(currImgHandler2.CurrentBitmap.Height / dev)); System.IO.MemoryStream stream = new System.IO.MemoryStream(); currImgHandler2.CurrentBitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp); stream.Position = 0; byte[] data = new byte[stream.Length]; stream.Read(data, 0, Convert.ToInt32(stream.Length)); BitmapImage bmapImage = new BitmapImage(); bmapImage.BeginInit(); bmapImage.StreamSource = stream; bmapImage.EndInit(); img2.Source = bmapImage; } this.Height = 396.88; dest.Text = ""; } } catch { } }
public BitmapViewWindow(CurrentImageHandler currImageHandler) { InitializeComponent(); this.currImageHandler = currImageHandler; }