3 Replies Latest reply on Feb 19, 2007 12:35 PM by raschko

    4:3 and 16:9 aspect ratio

    raschko
      Ive been producing a video editor using the free tool AVISYNTH.
      But would like to do most of the math processing in director since its faster.

      My problem is, lets say I have an image whose dimensions are 576x409
      I want to cut out a part of that image; that portion could equal 720X480 if enlarged.

      So far the only math I can think of is: (the images width*720)/720..and changing it to 480 for height.
      (this although, yields incorrect results for height)

      Has anyone dealt with this type of situation..or could atleast point me in the right direction.
      Other math formulas are appreciated as well.

      Thank you.

      (if I am unclear please specify )
        • 1. Re: 4:3 and 16:9 aspect ratio
          James Newton, ACP Level 3
          on GetWidthFromHeight(aHeight, aRatio) --------------------------------
          -- INPUT: <aHeight> should be an integer or floating point number
          -- <aRatio> may be #_4_3 or #_16_9, or a floating point number
          -- OUTPUT: Returns the width associated with the given height, as a
          -- floating point number
          ---------------------------------------------------------------------

          case ilk(aHeight) of
          #float, #integer:
          -- Continue

          otherwise:
          return #numberExpected
          end case

          case aRatio of
          #_4_3:
          aRatio = 4.0 / 3.0

          #_16_9:
          aRatio = 16.0 / 9.0

          otherwise:
          case ilk(aRatio) of
          #float, #integer:
          -- Continue

          otherwise:
          return #ratioExpected
          end case
          end case

          return aHeight * aRatio
          end GetWidthFromHeight
          • 2. Re: 4:3 and 16:9 aspect ratio
            Level 7
            A subtle but very effective convention when creating a function: set a
            local variable to the output of the function at the various points where
            you'd normally use "return"

            Then return that local variable at the end of the handler. Among other
            things it allows you to put just one break point on the return, when
            debugging, to easily see the returned value. Plus, for those who like to
            follow the rules, it's what decent coding books teach.

            For the most part it makes no difference in performance.

            --
            Craig Wollman
            Lingo Specialist
            Word of Mouth Productions
            212-928-9581

            www.wordofmouthpros.com
            "openspark" <webforumsuser@macromedia.com> wrote in message
            news:erb7ls$rdg$1@forums.macromedia.com...
            > on GetWidthFromHeight(aHeight, aRatio) --------------------------------
            > -- INPUT: <aHeight> should be an integer or floating point number
            > -- <aRatio> may be #_4_3 or #_16_9, or a floating point number
            > -- OUTPUT: Returns the width associated with the given height, as a
            > -- floating point number
            > ---------------------------------------------------------------------
            >
            > case ilk(aHeight) of
            > #float, #integer:
            > -- Continue
            >
            > otherwise:
            > return #numberExpected
            > end case
            >
            > case aRatio of
            > #_4_3:
            > aRatio = 4.0 / 3.0
            >
            > #_16_9:
            > aRatio = 16.0 / 9.0
            >
            > otherwise:
            > case ilk(aRatio) of
            > #float, #integer:
            > -- Continue
            >
            > otherwise:
            > return #ratioExpected
            > end case
            > end case
            >
            > return aHeight * aRatio
            > end GetWidthFromHeight
            >


            • 3. Re: 4:3 and 16:9 aspect ratio
              raschko Level 1
              Your formula gave me and idea that seems to be working.

              To reiterate we have a 576/409 image.
              - for height: (width*480)/720
              - for width: (height*720)/480

              Both yield the desired results; was close in my
              original assumption, and am puzzled as to why I never thought of this before!

              Now it's just determining which side to use as a reference: longer or shorter.
              Maybe some type of percentage calculation.

              hmm..