Click here to Skip to main content
15,895,840 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using

ImageViewer1.Image = new Bitmap(dlg.FileName);
ImageViewer1.SizeMode = PictureBoxSizeMode.StretchImage;


Can there is any method to fit the image in picture box witout using above code?

dlg is open file dialog.
Posted
Comments
dan!sh 13-Jan-15 2:22am    
And the issue with this code is?
Member 11276226 13-Jan-15 2:24am    
This code stretch the image and i don't want to stretch the image. Please tell if any other way.

 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 13-Jan-15 11:09am    
5ed, but there is more to it. Please see Solution 2.
—SA
Mehdi Gholam 13-Jan-15 11:12am    
Well the above link is from a guy named SA which should be good ;)
Sergey Alexandrovich Kryukov 13-Jan-15 11:29am    
Oops! But in that answer I did not directly mentioned about the danger of up-scaling the image (maybe in referenced answers), so I won't remove Solution 2 from this page.
Thank you.
—SA
In addition to Solution 1:

You can stretch whatever you want, but you should understand: when you re-sample images, you can have good quality only if you scale it down, or scale up just slightly. If you considerably scale it up, you will get too ugly pixellated image. Therefore, it's always better to have the original image of biggest usable size and scale it only down when required.

Vector graphics is much better, never gets pixellated and is processed very fast on all modern system, so prefer it in all cases except very small images.

—SA
 
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