locked
how to render an external image RRS feed

  • Question

  • i know this openFileDialog to input a file. Say i want to input an image and display it. how can i do that ??

    Thanks for ur time.

    Tuesday, April 26, 2011 2:40 PM

Answers

  • http://msdn.microsoft.com/en-us/library/ms605065(v=VS.100).aspx

    Once you have the image's path in the filesystem, just set the .Source property of an Image control to the path.

     

    var bi = new BitmapImage();
    			bi.BeginInit();
    			bi.UriSource = new Uri(@"C:\Users\charhays\Pictures\IMG_0798.JPG");
    			bi.EndInit();
    
    
    			this.MyImage.Source = bi;
    

    • Proposed as answer by Chuck HaysModerator Wednesday, April 27, 2011 2:10 PM
    • Marked as answer by Max Steel Wednesday, April 27, 2011 7:41 PM
    Wednesday, April 27, 2011 2:10 PM
    Moderator

All replies

  • Hi Max

    Have you tried Project>Add Existing Item> Your Image File? It will appear in your Project panel after chosen. Here you can select it for display.

    Tuesday, April 26, 2011 2:52 PM
  • i want it to be dynamic. the user specifies the image file using openfiledialog and i need the further code to display that image.
    Tuesday, April 26, 2011 3:48 PM
  • What platform are you using? WPF or Silverlight?
    Tuesday, April 26, 2011 4:37 PM
    Moderator
  • WPF using expression blend.
    Wednesday, April 27, 2011 5:27 AM
  • http://msdn.microsoft.com/en-us/library/ms605065(v=VS.100).aspx

    Once you have the image's path in the filesystem, just set the .Source property of an Image control to the path.

     

    var bi = new BitmapImage();
    			bi.BeginInit();
    			bi.UriSource = new Uri(@"C:\Users\charhays\Pictures\IMG_0798.JPG");
    			bi.EndInit();
    
    
    			this.MyImage.Source = bi;
    

    • Proposed as answer by Chuck HaysModerator Wednesday, April 27, 2011 2:10 PM
    • Marked as answer by Max Steel Wednesday, April 27, 2011 7:41 PM
    Wednesday, April 27, 2011 2:10 PM
    Moderator
  • THANK YOU

     

    THANK YOU
    THANK YOU
    THANK YOU
    THANK YOU
       THANK YOU.
     IT WORKED

     


    Wednesday, April 27, 2011 7:40 PM