建议一种解决图形应用程序中分辨率变化的方法 [英] Suggest a means to handle resolution variation in graphic applications

查看:39
本文介绍了建议一种解决图形应用程序中分辨率变化的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用c#启动一个微型项目,该项目模拟移动的LED显示屏.
我想对如何处理各种系统的分辨率提出一些建议.

当应用程序以不同的分辨率运行时,表单大小会发生变化,因此绘图位置也会发生变化.

由于我是图形编程的新手,并且对C#有一定的了解,所以
我真的很感激任何建议.

I am starting a mini-project in c# which simulates a moving LED display.
I would like some suggestion on how to handle the resolution across various systems.

When the application runs under different resolutions the form size changes and hence the drawing position also changes.

As i am new to graphics programming and moderate knowledge of c#,
i would really appreciate any suggestions.

推荐答案

最重要的问题是在内部使用浮点数并在绘图之前应用舍入.在内部,您可以通过乘以一些计算的屏幕比例来轻松缩放.如果您为800x600创建了应用程序,并且现在在1920x1080上运行,则可以执行以下操作:

水平乘数=(1920/800)= 2.4
垂直乘数=(1080/600)= 1,8

当您将x轴上的每个值乘以2.4,并将y轴上的每个值乘以1.8时,将缩放到新的分辨率.您可以简单地通过假设您从(0,0)绘制到(800,600)进行检查,然后将两者相乘就可以得到(0,0)到(1920,1080).

如前所述,您需要将内部计算和工程图分开,仅此而已.您还可以轻松地轻松应用其他种类的效果,例如旋转.

祝你好运!
The most important issue is to use floating point numbers internally and apply rounding just before drawing. Internally you can then scale very easily by multiplying with some calculated screen ratio. If you created your application for 800x600 and now running on 1920x1080 you would do:

horizontal multiplier = (1920 / 800) = 2.4
vertical multiplier = (1080 / 600) = 1,8

When you multiply every value on the x axis by 2.4 and every value on the y axis by 1.8 you scale to the new resolution. You can simply check this by simply assume you draw from (0,0) to (800,600) and when multiplying both you will get (0,0) to (1920, 1080).

As mentioned you need to separate internal calculation and drawing and thats it. You can the also easily apply other kind of effects rather easy, like rotation for example.

Good luck!


我尝试了我们的建议,效果很好.然后我创建了2个比例因子
将其应用于包括图形和控件在内的所有元素.
谢谢,真的很有帮助.
I tried ur suggestion and it worked ok.I created 2 scale factors then
applied it to all the elements including graphics and controls.
Thanks, it really helped.


这篇关于建议一种解决图形应用程序中分辨率变化的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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