diff options
| author | Michael <[email protected]> | 2017-07-03 15:56:24 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-07-03 15:56:24 -0400 |
| commit | 70f56a5f2fff23e5aca50b0268d0368d044be544 (patch) | |
| tree | a63bb1651b7d5575e9352a944bc331d3e4d65ba5 | |
| parent | 15b3b356b0b7be41bd7d975528c46b30c3558988 (diff) | |
| download | shiftos_thereturn-70f56a5f2fff23e5aca50b0268d0368d044be544.tar.gz shiftos_thereturn-70f56a5f2fff23e5aca50b0268d0368d044be544.tar.bz2 shiftos_thereturn-70f56a5f2fff23e5aca50b0268d0368d044be544.zip | |
Possibly fix desktop backgrounds I think
| -rw-r--r-- | ShiftOS.Frontend/GraphicsSubsystem/UIManager.cs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/ShiftOS.Frontend/GraphicsSubsystem/UIManager.cs b/ShiftOS.Frontend/GraphicsSubsystem/UIManager.cs index 97ad52d..046e53c 100644 --- a/ShiftOS.Frontend/GraphicsSubsystem/UIManager.cs +++ b/ShiftOS.Frontend/GraphicsSubsystem/UIManager.cs @@ -83,6 +83,8 @@ namespace ShiftOS.Frontend.GraphicsSubsystem FocusedControl?.ProcessKeyEvent(e); } + private static Texture2D DesktopBackground = null; + public static void DrawBackgroundLayer(GraphicsDevice graphics, SpriteBatch batch, int width, int height) { if (SkinEngine.LoadedSkin == null) @@ -91,9 +93,21 @@ namespace ShiftOS.Frontend.GraphicsSubsystem var desktopbg = SkinEngine.GetImage("desktopbackground"); if(desktopbg != null) { - var tex2 = new Texture2D(graphics, desktopbg.Width, desktopbg.Height); - tex2.SetData<byte>(SkinEngine.LoadedSkin.DesktopBackgroundImage); - batch.Draw(tex2, new Rectangle(0, 0, width, height), Color.White); + var bmp = (System.Drawing.Bitmap)SkinEngine.GetImage("desktopbackground"); + GUI.Control.ResizeImage(bmp, width, height); + var _lock = bmp.LockBits(new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); + var rgb = new byte[Math.Abs(_lock.Stride) * _lock.Height]; + Marshal.Copy(_lock.Scan0, rgb, 0, rgb.Length); + bmp.UnlockBits(_lock); + bmp.Dispose(); + if(DesktopBackground == null) + { + DesktopBackground = new Texture2D(graphics, width, height); + } + + DesktopBackground.SetData<byte>(rgb); + + batch.Draw(DesktopBackground, new Rectangle(0, 0, width, height), Color.White); } } |
