From f64f7640e3ff066b8feaa2a685b65429b1a49c66 Mon Sep 17 00:00:00 2001 From: Stephan Sundermann Date: Mon, 5 Mar 2012 19:38:51 +0100 Subject: [PATCH] Use new Draw method --- Vocaluxe/Base/CBackgroundMusic.cs | 8 +++++--- Vocaluxe/Base/CDraw.cs | 13 +++++++++++++ Vocaluxe/Screens/CPopupScreenPlayerControl.cs | 10 ++++++++-- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/Vocaluxe/Base/CBackgroundMusic.cs b/Vocaluxe/Base/CBackgroundMusic.cs index 0daad6f6..333bbcac 100644 --- a/Vocaluxe/Base/CBackgroundMusic.cs +++ b/Vocaluxe/Base/CBackgroundMusic.cs @@ -8,6 +8,7 @@ using System.Diagnostics; using Vocaluxe.Lib.Song; using Vocaluxe.Lib.Draw; using System.Drawing; +using Vocaluxe.Menu; namespace Vocaluxe.Base { @@ -307,15 +308,16 @@ namespace Vocaluxe.Base LoadVideo(); } - public static STexture UploadNewFrame() + public static bool UploadNewFrame(CStatic bounds) { if (_Video != -1) { float vtime = 0f; CVideo.VdGetFrame(_Video, ref _CurrentVideoTexture, CSound.GetPosition(_CurrentMusicStream), ref vtime); - return _CurrentVideoTexture; + CDraw.DrawTexture(bounds, _CurrentVideoTexture, EAspect.Crop); + return true; } - return _CurrentVideoTexture; + return false; } public static int GetSongNr() diff --git a/Vocaluxe/Base/CDraw.cs b/Vocaluxe/Base/CDraw.cs index 514d3adc..5c1129dd 100644 --- a/Vocaluxe/Base/CDraw.cs +++ b/Vocaluxe/Base/CDraw.cs @@ -289,6 +289,19 @@ namespace Vocaluxe.Base } } + public static void DrawTexture(CStatic StaticBounds, STexture Texture, EAspect Aspect) + { + RectangleF bounds = new RectangleF(StaticBounds.Rect.X, StaticBounds.Rect.Y, StaticBounds.Rect.W, StaticBounds.Rect.H); + RectangleF rect = new RectangleF(0f, 0f, Texture.width, Texture.height); + + if (rect.Height <= 0f) + return; + + CHelper.SetRect(bounds, ref rect, rect.Width / rect.Height, Aspect); + DrawTexture(Texture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, StaticBounds.Rect.Z), + Texture.color, new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f), false); + } + public static void DrawTextureReflection(STexture Texture, SRectF rect, SColorF color, SRectF bounds, float space, float height) { lock (mutex) diff --git a/Vocaluxe/Screens/CPopupScreenPlayerControl.cs b/Vocaluxe/Screens/CPopupScreenPlayerControl.cs index 0dee558a..fc41a0c0 100644 --- a/Vocaluxe/Screens/CPopupScreenPlayerControl.cs +++ b/Vocaluxe/Screens/CPopupScreenPlayerControl.cs @@ -136,10 +136,16 @@ namespace Vocaluxe.Screens Buttons[htButtons(ButtonPause)].Visible = CBackgroundMusic.IsPlaying(); Buttons[htButtons(ButtonPlay)].Visible = !CBackgroundMusic.IsPlaying(); Texts[htTexts(TextCurrentSong)].Text = CBackgroundMusic.GetSongArtistAndTitle(); - if(CBackgroundMusic.IsVideoEnabled() && CBackgroundMusic.HasVideo()) - Statics[htStatics(StaticCover)].Texture = CBackgroundMusic.UploadNewFrame(); + if (CBackgroundMusic.IsVideoEnabled() && CBackgroundMusic.HasVideo()) + { + CBackgroundMusic.UploadNewFrame(Statics[htStatics(StaticCover)]); + Statics[htStatics(StaticCover)].Visible = true; + } else + { + Statics[htStatics(StaticCover)].Visible = true; Statics[htStatics(StaticCover)].Texture = CBackgroundMusic.GetCover(); + } return true; }