aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Frontend/GraphicsSubsystem
diff options
context:
space:
mode:
authorRogueAI42 <[email protected]>2017-07-31 19:43:25 +1000
committerRogueAI42 <[email protected]>2017-07-31 19:43:25 +1000
commitd953797369cd72a718b801e0036ce9ebb181f24f (patch)
treefd9e4ea684d0312b8913c6a240d5e7c312cad5ae /ShiftOS.Frontend/GraphicsSubsystem
parent60e5451c3b0d0c7d8ba99a0c47df0f783a6d9274 (diff)
downloadshiftos_thereturn-d953797369cd72a718b801e0036ce9ebb181f24f.tar.gz
shiftos_thereturn-d953797369cd72a718b801e0036ce9ebb181f24f.tar.bz2
shiftos_thereturn-d953797369cd72a718b801e0036ce9ebb181f24f.zip
readable text render
yeah yeah the project is "deprecated" but I can't be bothered waiting for Mike to change his mind again
Diffstat (limited to 'ShiftOS.Frontend/GraphicsSubsystem')
-rw-r--r--ShiftOS.Frontend/GraphicsSubsystem/GraphicsContext.cs10
1 files changed, 8 insertions, 2 deletions
diff --git a/ShiftOS.Frontend/GraphicsSubsystem/GraphicsContext.cs b/ShiftOS.Frontend/GraphicsSubsystem/GraphicsContext.cs
index d8e447c..8e83324 100644
--- a/ShiftOS.Frontend/GraphicsSubsystem/GraphicsContext.cs
+++ b/ShiftOS.Frontend/GraphicsSubsystem/GraphicsContext.cs
@@ -126,7 +126,7 @@ namespace ShiftOS.Frontend.GraphicsSubsystem
public Vector2 MeasureString(string text, System.Drawing.Font font, int wrapWidth = int.MaxValue)
{
- using(var gfx = System.Drawing.Graphics.FromImage(new System.Drawing.Bitmap(1, 1)))
+ using(var gfx = System.Drawing.Graphics.FromHwnd(IntPtr.Zero))
{
var s = gfx.SmartMeasureString(text, font, wrapWidth);
return new Vector2((float)Math.Ceiling(s.Width), (float)Math.Ceiling(s.Height));
@@ -154,14 +154,20 @@ namespace ShiftOS.Frontend.GraphicsSubsystem
var sFormat = System.Drawing.StringFormat.GenericTypographic;
sFormat.FormatFlags |= System.Drawing.StringFormatFlags.NoClip;
+ /*gfx.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
+ gfx.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
+ gfx.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;*/
gfx.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
- gfx.DrawString(text, font, System.Drawing.Brushes.White, new System.Drawing.RectangleF(0, 0, bmp.Width, bmp.Height), sFormat);
+ gfx.DrawString(text, font, System.Drawing.Brushes.Black, new System.Drawing.RectangleF(0, 0, bmp.Width, bmp.Height), sFormat);
}
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);
+ for (int i = 0; i < data.Length; i++)
+ if (i % 4 != 3)
+ data[i] = (byte)(255 - data[i]); // invert colours
var tex2 = new Texture2D(_graphicsDevice, bmp.Width, bmp.Height);
tex2.SetData<byte>(data);
fontcache = new TextCache();