From 38774ba7930f9d6fa2111c8b71f1056125ab75b5 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 5 Jul 2017 22:24:17 -0400 Subject: all the work I've done for the day --- .../GraphicsSubsystem/GraphicsContext.cs | 26 ++++++++++++---------- 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'ShiftOS.Frontend/GraphicsSubsystem/GraphicsContext.cs') diff --git a/ShiftOS.Frontend/GraphicsSubsystem/GraphicsContext.cs b/ShiftOS.Frontend/GraphicsSubsystem/GraphicsContext.cs index 1ab45db..867d18a 100644 --- a/ShiftOS.Frontend/GraphicsSubsystem/GraphicsContext.cs +++ b/ShiftOS.Frontend/GraphicsSubsystem/GraphicsContext.cs @@ -148,33 +148,35 @@ namespace ShiftOS.Frontend.GraphicsSubsystem measure = MeasureString(text, font); else measure = MeasureString(text, font, wrapWidth); - using(var bmp = new System.Drawing.Bitmap((int)measure.X, (int)measure.Y)) + using (var bmp = new System.Drawing.Bitmap((int)measure.X, (int)measure.Y)) { - using(var gfx = System.Drawing.Graphics.FromImage(bmp)) + using (var gfx = System.Drawing.Graphics.FromImage(bmp)) { var textformat = new System.Drawing.StringFormat(System.Drawing.StringFormat.GenericTypographic); textformat.FormatFlags = System.Drawing.StringFormatFlags.MeasureTrailingSpaces; textformat.Trimming = System.Drawing.StringTrimming.None; textformat.FormatFlags |= System.Drawing.StringFormatFlags.NoClip; - gfx.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; + gfx.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel; gfx.DrawString(text, font, new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(color.A, color.R, color.G, color.B)), 0, 0, textformat); } var lck = bmp.LockBits(new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); var data = new byte[Math.Abs(lck.Stride) * lck.Height]; System.Runtime.InteropServices.Marshal.Copy(lck.Scan0, data, 0, data.Length); bmp.UnlockBits(lck); - var tex2 = new Texture2D(_graphicsDevice, bmp.Width, bmp.Height); - for(int i = 0; i < data.Length; i += 4) + using (var tex2 = new Texture2D(_graphicsDevice, bmp.Width, bmp.Height)) { - byte r = data[i]; - byte b = data[i + 2]; - data[i] = b; - data[i + 2] = r; + for (int i = 0; i < data.Length; i += 4) + { + byte r = data[i]; + byte b = data[i + 2]; + data[i] = b; + data[i + 2] = r; + } + + tex2.SetData(data); + _spritebatch.Draw(tex2, new Rectangle(x, y, bmp.Width, bmp.Height), Color.White); } - - tex2.SetData(data); - _spritebatch.Draw(tex2, new Rectangle(x, y, bmp.Width, bmp.Height), Color.White); } } -- cgit v1.2.3