Check video size on open and change zoom level to 50% or 25% if the video is greater than some proportions of the window size.

Updates #1054.

Originally committed to SVN as r3858.
This commit is contained in:
Niels Martin Hansen 2009-12-12 01:38:09 +00:00
parent dd0da6744b
commit eb938aa5ed
1 changed files with 13 additions and 2 deletions

View File

@ -1159,11 +1159,22 @@ void FrameMain::LoadVideo(wxString file,bool autoload) {
wxMessageBox(_T("Unknown error"), _T("Error opening video file"), wxOK | wxICON_ERROR, this);
}
// Check that the video size matches the script video size specified
if (VideoContext::Get()->IsLoaded()) {
int vidx = VideoContext::Get()->GetWidth(), vidy = VideoContext::Get()->GetHeight();
// Set zoom level based on video resolution and window size
int target_zoom = 7; // 100%
wxSize windowSize = GetSize();
if (vidx*3 > windowSize.GetX()*2 || vidy*4 > windowSize.GetY()*3)
target_zoom = 3; // 50%
if (vidx*3 > windowSize.GetX()*4 || vidy*4 > windowSize.GetY()*6)
target_zoom = 1; // 25%
videoBox->videoDisplay->zoomBox->SetSelection(target_zoom);
videoBox->videoDisplay->SetZoomPos(target_zoom);
// Check that the video size matches the script video size specified
int scriptx = SubsBox->ass->GetScriptInfoAsInt(_T("PlayResX"));
int scripty = SubsBox->ass->GetScriptInfoAsInt(_T("PlayResY"));
int vidx = VideoContext::Get()->GetWidth(), vidy = VideoContext::Get()->GetHeight();
if (scriptx != vidx || scripty != vidy) {
switch (Options.AsInt(_T("Video Check Script Res"))) {
case 1: