Merge pull request #443 from Vocaluxe/AutomaticAspectRatioSwitch
Automatic switch of aspect ratio for background video & image on sing screen
This commit is contained in:
4 files changed
+22
-12
No files matched your search
@@ -1,4 +1,4 @@
|
|||||||
#region license
|
#region license
|
||||||
// This file is part of Vocaluxe.
|
// This file is part of Vocaluxe.
|
||||||
//
|
//
|
||||||
// Vocaluxe is free software: you can redistribute it and/or modify
|
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||||
@@ -112,7 +112,7 @@ namespace Vocaluxe.Screens
|
|||||||
private float _Length = -1f;
|
private float _Length = -1f;
|
||||||
|
|
||||||
private CVideoStream _CurrentVideo;
|
private CVideoStream _CurrentVideo;
|
||||||
private EAspect _VideoAspect = EAspect.Crop;
|
private EAspect _VideoAspect = EAspect.Automatic;
|
||||||
private CTextureRef _CurrentWebcamFrameTexture;
|
private CTextureRef _CurrentWebcamFrameTexture;
|
||||||
private CTextureRef _Background;
|
private CTextureRef _Background;
|
||||||
|
|
||||||
@@ -794,18 +794,21 @@ namespace Vocaluxe.Screens
|
|||||||
if (_CurrentVideo != null && CConfig.Config.Video.VideosInSongs == EOffOn.TR_CONFIG_ON && !_Webcam)
|
if (_CurrentVideo != null && CConfig.Config.Video.VideosInSongs == EOffOn.TR_CONFIG_ON && !_Webcam)
|
||||||
{
|
{
|
||||||
background = _CurrentVideo.Texture;
|
background = _CurrentVideo.Texture;
|
||||||
aspect = _VideoAspect;
|
|
||||||
}
|
}
|
||||||
else if (_Webcam)
|
else if (_Webcam)
|
||||||
{
|
{
|
||||||
background = _CurrentWebcamFrameTexture;
|
background = _CurrentWebcamFrameTexture;
|
||||||
aspect = _VideoAspect;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
background = _Background;
|
background = _Background;
|
||||||
if (background != null)
|
if (background != null)
|
||||||
{
|
{
|
||||||
SRectF bounds = CSettings.RenderRect;
|
SRectF bounds = CSettings.RenderRect;
|
||||||
|
|
||||||
|
if (_VideoAspect == EAspect.Automatic)
|
||||||
|
_VideoAspect = (background.OrigAspect <= 1.5 ? EAspect.LetterBox : EAspect.Crop);
|
||||||
|
aspect = _VideoAspect;
|
||||||
|
|
||||||
SRectF rect = CHelper.FitInBounds(bounds, background.OrigAspect, aspect);
|
SRectF rect = CHelper.FitInBounds(bounds, background.OrigAspect, aspect);
|
||||||
CDraw.DrawTexture(background, rect, background.Color, bounds);
|
CDraw.DrawTexture(background, rect, background.Color, bounds);
|
||||||
}
|
}
|
||||||
@@ -1087,7 +1090,7 @@ namespace Vocaluxe.Screens
|
|||||||
{
|
{
|
||||||
_CurrentVideo = CVideo.Load(Path.Combine(song.Folder, song.VideoFileName));
|
_CurrentVideo = CVideo.Load(Path.Combine(song.Folder, song.VideoFileName));
|
||||||
CVideo.Skip(_CurrentVideo, song.Start, song.VideoGap);
|
CVideo.Skip(_CurrentVideo, song.Start, song.VideoGap);
|
||||||
_VideoAspect = song.VideoAspect;
|
_VideoAspect = EAspect.Automatic;
|
||||||
}
|
}
|
||||||
|
|
||||||
CDraw.RemoveTexture(ref _Background);
|
CDraw.RemoveTexture(ref _Background);
|
||||||
@@ -1828,4 +1831,4 @@ namespace Vocaluxe.Screens
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#region license
|
#region license
|
||||||
// This file is part of Vocaluxe.
|
// This file is part of Vocaluxe.
|
||||||
//
|
//
|
||||||
// Vocaluxe is free software: you can redistribute it and/or modify
|
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||||
@@ -101,6 +101,7 @@ namespace VocaluxeLib
|
|||||||
|
|
||||||
switch (aspect)
|
switch (aspect)
|
||||||
{
|
{
|
||||||
|
case EAspect.Automatic:
|
||||||
case EAspect.Crop:
|
case EAspect.Crop:
|
||||||
if (boundsAspectRatio >= aspectRatio)
|
if (boundsAspectRatio >= aspectRatio)
|
||||||
{
|
{
|
||||||
@@ -138,7 +139,12 @@ namespace VocaluxeLib
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EAspect.LetterBox:
|
case EAspect.LetterBox:
|
||||||
if (boundsAspectRatio <= aspectRatio)
|
if (boundsAspectRatio == aspectRatio) // Pillarbox
|
||||||
|
{
|
||||||
|
scaledWidth = bounds.W * 0.77f;
|
||||||
|
scaledHeight = bounds.W / aspectRatio;
|
||||||
|
}
|
||||||
|
else if (boundsAspectRatio < aspectRatio)
|
||||||
{
|
{
|
||||||
scaledWidth = bounds.W;
|
scaledWidth = bounds.W;
|
||||||
scaledHeight = bounds.W / aspectRatio;
|
scaledHeight = bounds.W / aspectRatio;
|
||||||
@@ -306,4 +312,4 @@ namespace VocaluxeLib
|
|||||||
return bmp;
|
return bmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,6 +64,7 @@ namespace VocaluxeLib
|
|||||||
#region Fonts
|
#region Fonts
|
||||||
public enum EAspect
|
public enum EAspect
|
||||||
{
|
{
|
||||||
|
Automatic,
|
||||||
Crop,
|
Crop,
|
||||||
LetterBox,
|
LetterBox,
|
||||||
Stretch,
|
Stretch,
|
||||||
@@ -436,4 +437,4 @@ namespace VocaluxeLib
|
|||||||
TR_USERROLE_PROFILEEDITOR = 32
|
TR_USERROLE_PROFILEEDITOR = 32
|
||||||
// ReSharper restore InconsistentNaming
|
// ReSharper restore InconsistentNaming
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,7 @@ namespace VocaluxeLib.Songs
|
|||||||
public readonly List<string> BackgroundFileNames = new List<string>();
|
public readonly List<string> BackgroundFileNames = new List<string>();
|
||||||
public string VideoFileName = String.Empty;
|
public string VideoFileName = String.Empty;
|
||||||
|
|
||||||
public EAspect VideoAspect = EAspect.Crop;
|
public EAspect VideoAspect = EAspect.Automatic;
|
||||||
|
|
||||||
public bool NotesLoaded { get; private set; }
|
public bool NotesLoaded { get; private set; }
|
||||||
|
|
||||||
@@ -518,4 +518,4 @@ namespace VocaluxeLib.Songs
|
|||||||
ShortEnd.Source = EDataSource.Calculated;
|
ShortEnd.Source = EDataSource.Calculated;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user