New screen ratio for 16:9 screens - Zoom to 14:9 (1 Viewer)

Grunt

New Member
December 30, 2005
4
0
Bucharest, Romania
First of all, I want to thank everyone involved in this project, the ones who made MediaPortal the best HTPC program by far and it is still evolving.
I have been following these forums for more than 7 months now, but I have never posted a message here so far, so here’s my first post.
I am using MediaPortal mainly for its TV features and I always felt it was missing some screen ratios. I can only use “Normal†or “Zoomâ€. “Normal†maximizes the height of the 4:3 image on my 16:9 screen and leaves two thick black bars each side, while “Zoom†maximizes the width of the image, but crops too much from the upper and lower part of the image, so the subtitles and logo don’t show anymore. “Stretch†alters the aspect ratio too much. There are also some shows, mainly on the Discovery and Viasat channels which are transmitted in 14:9 aspect ratio and “Normal†would yield an image with black bars at all sides, while “Zoom†will magnify too much and subtitles won’t be shown.
Something in between “Normal†and “Zoom†was definitely needed, so I decided to do something myself about this, because I’ve seen several topics about this, without any outcome. I also know that devs are busy fixing bugs, rather than bringing in any new functionality.
So I’ve downloaded the sources and I’ve added a new screen ratio called “Zoom to 14:9â€, which is a perfect trade off to watch 12:9 (4:3) shows on a 16:9 screen, because the black bars at the sides are half the width they were with “Normal†and the amount of image cropped from top and bottom is non essential, the logo and the subtitles still fit nicely on the screen. Also the 14:9 shows will no longer have black bars at top and bottom. This new screen ratio can also be used to enlarge the 2.35:1 movies on a 16:9 screen, so the black bars at top and bottom will be half-size.

Here’s the code that handles the image conversion in Core\guilib\Geometry.cs
Code:
        case Type.Zoom149:
        {
            // fit the image to screen size
            float fNewWidth = (float)ScreenWidth;
            float fNewHeight = (float)(fNewWidth / fOutputFrameRatio);

            if (fNewHeight > ScreenHeight)
            {
                fNewHeight = ScreenHeight;
                fNewWidth = fNewHeight * fOutputFrameRatio;
            }

            float iPosX = 0;
            float iPosY = 0;
            float fVertBorder = 0;
            float fHorzBorder = 0;
            float fFactor = fNewWidth / ((float)ImageWidth);
            // increase the image size by 12.5% and crop or pad if needed
            fNewHeight = fNewHeight * 1.125f;
            fNewWidth = fNewHeight * fOutputFrameRatio;

            if ((int)fNewHeight < ScreenHeight)
            {
                fHorzBorder = (fNewWidth - (float)ScreenWidth) / 2.0f;
                fHorzBorder = fHorzBorder / fFactor;
                iPosY = (ScreenHeight - fNewHeight) / 2;
            }

            if ((int)fNewWidth <ScreenWidth> ScreenWidth && (int)fNewHeight > ScreenHeight)
            {
                fHorzBorder = (fNewWidth - (float)ScreenWidth) / 2.0f;
                fHorzBorder = fHorzBorder / fFactor;
                fVertBorder = (fNewHeight - (float)ScreenHeight) / 2.0f;
                fVertBorder = fVertBorder / fFactor;
            }

            rSource = new System.Drawing.Rectangle((int)fHorzBorder,
                                                 (int)fVertBorder,
                                                 (int)((float)ImageWidth - 2.0f * fHorzBorder),
                                                 (int)((float)ImageHeight - 2.0f * fVertBorder));
            rDest = new System.Drawing.Rectangle((int)iPosX, (int)iPosY, (int)(fNewWidth  - (2.0f * fHorzBorder * fFactor) + 0.5f), (int)(fNewHeight - (2.0f * fVertBorder * fFactor) + 0.5f));
        }
        break;
Remember that I'm not a programmer, so if you think that the code can be further optimised, please feel free to suggest any modifications.

Here's a patch file for TortoiseSVN which will modify all the 19 files needed for this to work: LINK (right-click and choose "save target as" to download).

Of course this modification can be further developed. The code which handles the conversion can be reused to add even more ratios beside 14:9 (1.55:1), like 13:9 (1.44:1) and 15:9 (1.66:1) and maybe assign a new key which toggles the ratios in zoom mode to 13, 14, 15, 16:9.

If there are enough people that like this modification and find it useful, maybe it will find it's way, some day, into the SVN. I am now using "Zoom to 14:9" as the default screen ratio when watching TV.
 

Inker

Retired Team Member
  • Premium Supporter
  • December 6, 2004
    2,055
    318
    Nice, hope this get's incorperated as I have also been wanting somethign like this

    Strech a little, but not enough to be clearly visible, and then zoom just a little to minimize crop. Did I understand correctly that this is what it does, or does it leave out the strech part completely and just zoom a little? If so, perhaps a little streching could be added as well?

    Inker
     

    Grunt

    New Member
    December 30, 2005
    4
    0
    Bucharest, Romania
    It only enlarges the image by 12.5%, keeping the original aspect ratio intact. So there's only zoom and no horizontal strech, because I wanted this code to be usable on 4:3 screens as well when watching 14:9 shows, it will maximize the image height to screen height and will crop a little at the sides. If a little strech was used, more would be croped at sides on a 4:3 screen. Also, more would be cropped at sides on a 16:9 screen if watching a 2.35:1 movie using this screen ratio.

    If anyone wants to add a little horizontal strech, just multiply the new image width by the amount of strech needed. For example, for a 5% strech:
    Code:
    fNewWidth = fNewHeight * fOutputFrameRatio * 1.05f;
     

    EMKO

    Portal Pro
    May 4, 2006
    175
    3
    I dont understand this


    will this stretch a widescreen video on a 4:3 tv so that its more 4:3
    but still widescreen

    on the xbox i think i used 10:9 and it made my widescreen videos fit more of the 4:3 tv but not the completly witch didnt make it look to stretched. but then again on xbmc u can change the pixel size while playing the video in the osd.

    anyways good work

    i would want to try it but i dont know how to make it work so i hope it gets included into MP
     

    trosty

    MP Donator
  • Premium Supporter
  • October 6, 2004
    161
    0
    Zurich/Switzerland
    Home Country
    Switzerland Switzerland
    Grunt said:
    This new screen ratio can also be used to enlarge the 2.35:1 movies on a 16:9 screen, so the black bars at top and bottom will be half-size.
    (...)
    Of course this modification can be further developed. The code which handles the conversion can be reused to add even more ratios beside 14:9 (1.55:1), like 13:9 (1.44:1) and 15:9 (1.66:1) and maybe assign a new key which toggles the ratios in zoom mode to 13, 14, 15, 16:9.
    (...)
    If there are enough people that like this modification and find it useful, maybe it will find it's way, some day, into the SVN. I am now using "Zoom to 14:9" as the default screen ratio when watching TV.

    This is a great modification and I would really love to have that feature added into MP!!! The reason I currenty use ZoomPlayer as external Player for DVDs and movies is that I can zoom the 4:3-movies to 14:9 and also fit the 2.35:1-movies onto the 16:9-screen. With that patch different zoom modes could be defined and assigend so it is easy to switch between them depending on the original source format :shock: .

    Great job, thank you. I hope this will be implementet into the program in the future :D .
     

    trosty

    MP Donator
  • Premium Supporter
  • October 6, 2004
    161
    0
    Zurich/Switzerland
    Home Country
    Switzerland Switzerland
    Any advise how to get that feature running with the 0.2 Final? I am totally interested, but have absolutely no idea about programming :( .
     

    rtv

    Retired Team Member
  • Premium Supporter
  • April 7, 2005
    3,622
    301
    Osnabruck
    Home Country
    Germany Germany
    There are also some shows, mainly on the Discovery and Viasat channels which are transmitted in 14:9 aspect ratio and “Normal†would yield an image with black bars at all sides

    This is a missing "feature" atm - I'll see if I can get that implemented to keep correct AR AND use the full width of the TV...

    I'll also look at your patch - please don't expect this soon, as planescene crashes were baaad in the past..
     

    rtv

    Retired Team Member
  • Premium Supporter
  • April 7, 2005
    3,622
    301
    Osnabruck
    Home Country
    Germany Germany
    “Normal†would yield an image with black bars at all sides
    This is just the scenario where "zoom" comes into place - stretching horizontally to fit the screen and then increase the height accordingly..
     

    Users who are viewing this thread

    Top Bottom