code_junkie

Silverlight: Getting image (from OpenFileDialog) width/height

Nov 14th, 2011
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. private void LoadImage(Uri uri)
  2. {
  3. this.ResetProgressImage();
  4. BitmapImage image = new BitmapImage();
  5. image.DownloadProgress += new EventHandler<DownloadProgressEventArgs>(LoadImageDownloadProgress);
  6. image.UriSource = uri;
  7. this.ImageFull.Source = image;
  8. }
  9.  
  10. private void LoadImageDownloadProgress(object sender, DownloadProgressEventArgs e)
  11. {
  12. this.Dispatcher.BeginInvoke(delegate
  13. {
  14. this.ProgressImage.Value = e.Progress;
  15. if (e.Progress == 100)
  16. {
  17. ImageHelper.Current.Width = Math.Round(this.ImageFull.ActualWidth);
  18. ImageHelper.Current.Height = Math.Round(this.ImageFull.ActualHeight);
  19. }
  20. });
  21. }
  22.  
  23. private void LoadImage(Stream stream)
  24. {
  25. this.ResetProgressImage();
  26. BitmapImage image = new BitmapImage();
  27. image.DownloadProgress += new EventHandler<DownloadProgressEventArgs>(LoadImageDownloadProgress);
  28. image.SetSource(stream);
  29. this.ImageFull.Source = image;
  30. }
Add Comment
Please, Sign In to add comment