locked
How do I get the right scale for my SurfaceImageSource at high DPI?

Answers

  • I assume you're drawing text with Direct2D/DirectWrite? In general XAML layout is device-independent, but the app is responsible for the sizing of any custom D2D content. 

    Depending on the details of your scenario, there are a couple potential options to prevent double-scaling.

    Setting D2D's unit mode to pixels may be easiest:

    m_d2dContext->SetUnitMode(D2D1_UNIT_MODE::D2D1_UNIT_MODE_PIXELS);

    Alternatively you can account for the plateau scale by setting D2D's DPI to a fixed value via IDirect2DContext::SetDpi, or possibly by inverting the scale by applying a ScaleTransform to the XAML ImageBrush hosting the SurfaceImageSource.

    Monday, July 22, 2013 5:02 PM