Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF text rendering inconsistencies
    primarykey
    data
    text
    <p>WPF 4.0 notoriously fixed the <a href="http://blogs.msdn.com/b/text/archive/2009/08/24/wpf-4-0-text-stack-improvements.aspx" rel="nofollow noreferrer">blurry text issue</a>. Setting <code>TextOptions.TextFormattingMode="Display"</code> uses pixel hints to line up characters, which works really well to improve clarity.</p> <p>However, it does not work while the program is running as a Windows service in session 0; the text goes back to "Ideal" rendering, which at small sizes is completely unreadable. Below is a comparison of the two renderings.</p> <p>Not running as a service:</p> <p><img src="https://i.imgur.com/HDpmD.png" alt="Good text"></p> <p>Running as a service:</p> <p><img src="https://i.imgur.com/osEEA.png" alt="Good text"></p> <p>Rendering code:</p> <pre><code>//rtb is a RenderTargetBitmap //c is a FormatConvertedBitmap with rtb as it's source while (displayRunning) { if (lcd != null) { Dispatcher.Invoke(new ThreadStart(delegate() { if (dv == null) { dv = new DrawingVisual(); using (DrawingContext dc = dv.RenderOpen()) { dc.DrawRectangle(Brushes.White, new Pen(), new Rect(0, 0, 256, 64)); dc.Close(); } } rtb.Render(dv); rtb.Render((Visual)Content); //bitmap output just for testing PngBitmapEncoder e = new PngBitmapEncoder(); e.Frames.Add(BitmapFrame.Create(c)); using (FileStream f = File.Open("C:\\test.png", FileMode.Create)) e.Save(f); WriteableBitmap bitmapdata = new WriteableBitmap(c); srcdata = new byte[bitmapdata.BackBufferStride * bitmapdata.PixelHeight]; System.Runtime.InteropServices.Marshal.Copy(bitmapdata.BackBuffer, srcdata, 0, srcdata.Length); })); try { framesender.Send(new PicoLCDFrame(srcdata, lcd.OutputReportLength), lcd); } catch (NullReferenceException) { } // device was unplugged } Thread.Sleep(33); } </code></pre> <p>I realize there are no screen pixels for hints when rendering the fonts as a service, but shouldn't it get the pixel hints from the bitmap it is rendering to? Is there anything I can do about this?</p> <p><strong>EDIT:</strong> Apparently, it <em>IS</em> using pixel hints, but it is anti-aliasing for some reason. Below is the rendered bitmap before it is downsampled to 1 bits/pxel.</p> <p><img src="https://i.imgur.com/r5PS9.png" alt="Bad text again"></p> <p>I do have <code>TextOptions.TextRenderingMode="Aliased"</code> set and it seems that WPF is ignoring that when running as a service? It needs to be on to look good when downsampled. How can I force it?</p> <p><strong>EDIT2:</strong> It may have something to do with WPF rendering in Tier 0 (software mode) when running as a service and Tier 2 (hardware) when not.</p> <p><strong>EDIT3:</strong> On Windows XP, as a service, it renders like this:</p> <p><img src="https://i.imgur.com/caSdu.png" alt="Good, kinda"></p> <p>Notice the margin difference, the font size difference, and an otherwise perfect rendering. WTF?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload