我有一个点数组,范围从x(0-512)和y(0-384),这意味着纵横比为4:3。
如果我想在16:9显示器上完美地显示每个点,那么实现这一点需要什么数学?
让我们说" ee"是我的4:3点和"点"是我需要的16:9点。
我想是因为我试图在1920:1080显示器上进行缩放,这是一个16:9的宽高比
point = new PointF(ee.x * (1920 / 512), ee.y * (1080 / 384));
但这似乎是因为abit而已。
有任何帮助吗?感谢。
答案 0 :(得分:1)
除了将每个维度乘以整数之外,您无法将完全与方面匹配。这里唯一适合的整数是2(因为384 * 3> 1080)......
所以你必须这样做:
point = new Point (ee.x * 2, ee.y * 2);
你可以把它集中在:
point = new Point (ee.x * 2 + ((1920 - 512*2)/2), ee.y * 2 + ((1080 - 384*2)/2)));
希望有帮助...
编辑:使用浮点数,您必须采用乘数的最小值:
var multiplier = Math.Min(1920.0/512, 1080.0/384);
point = new Point (ee.x * multiplier + ((1920 - 512*multiplier)/2), ee.y * multiplier + ((1080 - 384*multiplier)/2)));
答案 1 :(得分:0)
你能详细说明你的意思吗?" off"?
如果您的意思是图像看起来水平拉伸,那是因为纵横比比以前大。如果您希望图像看起来像之前(但更大),您需要按宽高比缩放一个轴来修复它。
aspect_ratio_before = 4.0f / 3.0f;
aspect_ratio_after = 16.0f / 9.0f;
// This is equal to 4/3.
aspect_ratio_difference = aspect_ratio_after / aspect_ratio_before;
// I squish the X axis here.
point.x /= aspect_ratio_difference;
// Alternatively, you can also multiply point.y by the
// aspect_ratio_difference, though that will stretch the Y axis instead.
// Use only one!
// point.y *= aspect_ratio_difference;
免责声明:之前我没有使用.net,所以我不知道其渲染引擎的所有细节。这是基于我使用OpenGL和扩展的经验。