NSRect to carbon Rect conversion

  • Hi,

    My application uses a quicktime movie (QTMovieView) contained within
    an NSView within an NSWindow. We are trying to echo this movie to a
    video output device. The movie is displayed correctly on the video
    output device but incorrectly on the main monitor.

    I get the co-ordinates of the movie view as an NSRect and convert
    these to a Rect, see below, so I can use the SetMovieBox() method.

    However there seems to be a problem in converting from NSRect co-
    ordinates to Rect co-ordinates. The movie co-ordinates do not match
    the movie view co-ordinates after the following conversion:

    Rect theMovieFrame;
    NSRect i_MovieFrame;
    ...
    theMovieFrame.top = 15;
    theMovieFrame.left = 100;
    theMovieFrame.bottom = (short)i_MovieFrame.size.height;
    theMovieFrame.right = (short)i_MovieFrame.size.width;

    The movie view values obtained are as follows - {x = 0, y = 0, w =
    643, h =  381} but  the following values {t = 15, l = 100, b = 396 , r
    = 577} are the ones which SetMovieBox needs to display the movie
    correctly.

    The following screenshot demonstrates the problem:
    http://img167.imageshack.us/my.php?image=picture1jl4.png

    Any help would be greatly appreciated!

    Thanks,
    Cormac

    --
    Cormac Daly
    <cormac...>
  • On Jan 3, 2008 9:04 AM, Cormac Daly <cormac...> wrote:

    > theMovieFrame.top = 15;
    > theMovieFrame.left = 100;
    > theMovieFrame.bottom = (short)i_MovieFrame.size.height;
    > theMovieFrame.right = (short)i_MovieFrame.size.width;

    One is working in terms of a top left point and bottom right point
    while the other is working in terms of an origin and extent (size).
    What you are doing above doesn't convert correctly between these two
    concepts.

    For example if left starts at 100 then right would be 100 + width.

    Also you may have to flip the y-axis (not sure if that is needed or not).

    -Shawn
  • > Date: Thu, 3 Jan 2008 17:04:03 +0000
    > From: Cormac Daly <cormac...>
    > ...
    > theMovieFrame.top = 15;
    > theMovieFrame.left = 100;
    > theMovieFrame.bottom = (short)i_MovieFrame.size.height;
    > theMovieFrame.right = (short)i_MovieFrame.size.width;

    Cormac,
    you seem to have misunderstood the geometry of the Rect structure
    Quicktime expects.
    while you haver appropriate values in the "top" and "left", your not
    right in the "bottom" and the "right"

    lets take a second and look at the docs to see why...

    bottom
    The vertical coordinate of the lower-right point of the rectangle.

    right
    The horizontal coordinate of the lower-right point of the rectangle.

    those coordinates should be... the dimension Plus the offset!

      so for "right" you need "left" + "width"

    and for "bottom" its "top" + "height"

    good luck,

    -eblu
previous month january 2008 next month
MTWTFSS
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Go to today