【问题标题】:Finding the correct scale value within a scaled object to maintain the aspect ratio of a video在缩放对象中找到正确的缩放值以保持视频的纵横比
【发布时间】:2011-01-07 11:43:47
【问题描述】:

我在另一个影片剪辑中有一个视频。当我进入全屏模式时,我会放大外部影片剪辑以适应屏幕。这样 OuterMovieClip.width 就等于 screenWidth 等。如何保持视频的纵横比不失真?正确的数学公式是什么?

谢谢。

【问题讨论】:

    标签: flash video scaling aspect-ratio


    【解决方案1】:

    我相信你需要一些东西(下面的代码未经测试)......

    var screen_aspect_ratio = Screen.Width / Screen.Height;
    var outer_aspect_ratio = OuterMovieClip.Width / OuterMovieClip.Height;
    var new_outer_width;
    var new_outer_height;
    
    if (screen_aspect_ratio > outer_aspect_ratio) {
      new_outer_height = Screen.Height;
      new_outer_width = (Screen.Height * OuterMovieClip.Width) / OuterMovieClip.Height;
    } else {
      new_outer_width = Screen.Width;
      new_outer_height = (Screen.Width * OuterMovieClip.Height) / OuterMovieClip.Width;
    }
    
    OuterMovieClip.Width = new_outer_width;
    OuterMovieClip.Height = new_outer_height;
    

    【讨论】:

    • 谢谢。它并不完全有效,但我认为这让我朝着正确的方向前进。您能否简要解释一下将 Screen.Height 与 OuterMovieClip.Width 相乘到底是做什么的?谢谢。
    • 看看这篇维基百科文章...en.wikipedia.org/wiki/Cross_multiplication#Use
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-03-04
    • 1970-01-01
    • 2017-04-12
    • 2016-04-22
    • 1970-01-01
    • 2011-08-24
    • 2021-11-26
    相关资源
    最近更新 更多