[英]Automatically re-size images to fit screen resolution in Visual Studio
I am designing a welcome screen for a desktop application using forms in Visual Studio 2005. I have run into a bit of a problem with the splash image. 我正在使用Visual Studio 2005中的表单设计用于桌面应用程序的欢迎屏幕。我在启动图像方面遇到了一些问题。 I'd like it to automatically re-size according to the screen resolution of the user. 我希望它能够根据用户的屏幕分辨率自动调整大小。 As it stands I have a source image at a high resolution that I have been shrinking in Photoshop to fit the form design window, but when I build and run the application the image is tiny compared to my screen (1920 x 1080). 就目前而言,我有一个高分辨率的源图像,在Photoshop中我一直在缩小它以适合表单设计窗口,但是当我构建并运行该应用程序时,与我的屏幕(1920 x 1080)相比,该图像很小。 Right now it is placed inside a panel. 现在,它已放置在面板中。 I tried messing around with the AutoSize options but that didn't do much. 我试着弄乱了AutoSize选项,但是并没有做太多事情。
The question: How can I set the image to automatically re-size according to the screen resolution of the end user? 问题:如何设置图像以根据最终用户的屏幕分辨率自动调整大小?
The picturebox already has this feature. 图片框已具有此功能。 Load the picture and set the property SizeMode. 加载图片并设置属性SizeMode。
// correct proportions
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
// or
// larger, but distorted
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
in code or via the property window and the image will fill the complete picturebox. 通过代码或通过属性窗口,图像将填充完整的图片框。 Set the height/width of the picturebox to scale the image like so: 设置图片框的高度/宽度以缩放图像,如下所示:
pictureBox1.Width = Screen.FromControl(this).WorkingArea.Width / 3;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.