Click here to Skip to main content
15,666,844 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I want load any type of (i.e, .png,.bmp,.jpg or any) by using a path into a picture control or static control

Thanks in advance for any help!
[no name] 13-Jul-13 14:36pm    
Help for what? What is the question and/or problem?


If you are working on C# Winform application, then what you are looking for is known
PictureBox control[^]
Picture box needs an instane of Image which can be created using following code:

var MyImage = new Bitmap(fileToDisplay);   
pictureBox1.Image = (Image) MyImage ;

In WPF you can use Image control[^]
You can use Image control as below:

Option 1:

<image width="200">
Source="C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Water Lilies.jpg"/></image>

Option 2

<image width="200">
    <bitmapimage decodepixelwidth="200">
     UriSource="C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Water Lilies.jpg" />

Ankush Bansal
Share this answer
[no name] 14-Jul-13 10:03am    
How does your solution work for question that is clearly tagged "MFC"?
Have a look at Liviu Birjegas article: Thumbnails viewer and image processing using GDI+ and MFC[^]

Best regards
Espen Harlinn
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900