image Scaling of picture box

 ̄綄美尐妖づ 提交于 2019-12-03 04:51:53

问题


i got a problem with image scaling in C#.

I have a picture Box with given Size : e.g. width = 800px height = 600px

I am loading different images into that picture box, small ones ( 400x400) and big ones (800+ x 600+)

My images are getting resized if they do not fit into box. But they are always resized to MAX width and height of PictureBox. So the aspect ratio is destroyed.

Can anybody help to identify / fix the problem?

Classes:

Form1.cs

ImageHandling.cs (commented out)

ImageUtilities.cs

Examples:

Problem 1: My Version

vs Original Source

Problem 2:
My Version

vs Original Source

How i want it:

Solution


回答1:


this.PictureBox1.SizeMode = PictureBoxSizeMode.Zoom;

Set that property to your PictureBox and the size of the image will increased or decreased to fit the PictureBox maintaining the size ratio.

For more info: http://msdn.microsoft.com/en-us/library/system.windows.forms.picturebox.sizemode.aspx



来源:https://stackoverflow.com/questions/12646287/image-scaling-of-picture-box

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!