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

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!
Posted
Comments
[no name] 13-Jul-13 14:36pm    
Help for what? What is the question and/or problem?

Hi,

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:

C#
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:

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



Option 2

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


Thanks
Ankush Bansal
 
Share this answer
 
Comments
[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