图像缩放图片框 [英] image Scaling of picture box

查看:141
本文介绍了图像缩放图片框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C#中出现图像缩放问题。



我有一张给定尺寸的图片框:例如width = 800px height = 600px



我将不同的图片加载到该图片框中,小图片(400x400)和大图片(800 + x 600 +)



如果我的图片不适合框,则会调整大小。但它们总是调整为PictureBox的MAX宽度和高度。所以宽高比是被破坏



有人可以帮助识别/解决问题吗?



课程:




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

解决方案

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

这篇关于图像缩放图片框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆