title: why the direct2d line and wpf line always take two pixel on the screen?
body: <p><a href="https://i.stack.imgur.com/DZLHa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DZLHa.png" alt="enter image description here"></a></p>
  
  <p>I have create a simple test for display this question, this is the demo code with C# winform:</p>
  
  <pre><code>private void Form1_Paint(object sender, PaintEventArgs e)
      {
          e.Graphics.Clear(Color.FromArgb(255, 41, 41, 41));
  
          float distance = 20;
  
          for (int i = 1; i &lt; 25; ++i)
          {
              if (i &lt;= 10)
              {
                  using (Pen p = new Pen(Color.White, ((float)i) / 10))
                  {
                      e.Graphics.DrawLine(p, new PointF(0, i * distance + 10), new PointF(this.Width, i * distance + 10));
                  }
  
              }
              else if (i == 11)
              {
                  using (Pen p = new Pen(Color.Red, 1.0f))
                  {
                      e.Graphics.DrawLine(p, new PointF(0, i * distance + 10), new PointF(this.Width, i * distance + 10));
                  }
              }
              else
              {
                  using (Pen p = new Pen(Color.White, i-11))
                  {
                      e.Graphics.DrawLine(p, new PointF(0, i * distance + 10), new PointF(this.Width, i * distance + 10));
                  }
              }
          }
      }
  </code></pre>
  
  <p>this is the code use sharpdx do the same thing:</p>
  
  <pre><code> private void renderControl_Paint(object sender, PaintEventArgs e)
      {
          try
          {
              RenderTarget2D.BeginDraw();
  
              RenderTarget2D.Clear(new Color(41, 41, 41, 255));
  
              float distance = 20;
  
              for(int i=1; i&lt;25; ++i)
              {
                  if(i&lt;=10)
                  {
                      RenderTarget2D.DrawLine(new RawVector2(0, i * distance + 10), new RawVector2(renderControl.Width, i * distance + 10),
                          SceneColorBrush,
                          ((float)i) / 10.0f
                          );
                  }
                  else if (i == 11)
                  {
                      RenderTarget2D.DrawLine(new RawVector2(0, i * distance + 10), new RawVector2(renderControl.Width, i * distance + 10),
                      FlagSceneColorBrush,
                      i - 10
                      );
                  }
                  else
                  {
                      RenderTarget2D.DrawLine(new RawVector2(0, i * distance + 10), new RawVector2(renderControl.Width, i * distance + 10),
                          SceneColorBrush,
                          i - 11
                          );
                  }
              }
  
              RenderTarget2D.EndDraw();
          }
          catch (Exception ex)
          {
              LogException(ex);
          }
      }
  </code></pre>
  
  <p>wpf test code:</p>
  
  <pre><code>protected override void OnRender(DrawingContext drawingContext)
      {
          base.OnRender(drawingContext);
  
          drawingContext.DrawRectangle(BackgroundBrush, BackgroundPen, new Rect(0, 0, Width, Height));
  
          float distance = 20;
  
          for (int i = 1; i &lt; 25; ++i)
          {
              if (i &lt;= 10)
              {
                  Pen p = new Pen( myLineBrush, ((float)i) / 10 );
                  drawingContext.DrawLine(p, new Point(0, i * distance + 10), new Point(this.Width, i * distance + 10));                    
              }
              else if (i == 11)
              {                    
                  Pen p = new Pen(myFlagLineBrush, 1.0f);
                  drawingContext.DrawLine(p, new Point(0, i * distance + 10), new Point(this.Width, i * distance + 10));
              }
              else
              {
                  myLineBrush.Color = Color.FromArgb(255, 255, 255, 255);
  
                  Pen p = new Pen(myLineBrush, i - 11);
                  drawingContext.DrawLine(p, new Point(0, i * distance + 10), new Point(this.Width, i * distance + 10));
              }
          }
  
      }
  </code></pre>
  
  <p>please view this picture i have scaled it :
  <a href="https://i.stack.imgur.com/W7z2g.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W7z2g.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/mup5X.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mup5X.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/tK8HT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tK8HT.png" alt="enter image description here"></a>
     you can see, the direct2d draw all the lines use two pixels, and gdi+ use one pixel.so it make the line which is drawed by direct2d looks like more thicker than gid+ lines.
     i have test this code in wpf and draw lines with DrawingContext, it has the same result with direct2d.
     i found there is a parameter in direct2d drawline function.</p>
  
  <pre><code>virtual void DrawLine(
               D2D1_POINT_2F    point0,
               D2D1_POINT_2F    point1,
               ID2D1Brush       *brush,
               FLOAT            strokeWidth = 1.0f,
               ID2D1StrokeStyle *strokeStyle = NULL ) = 0;
  </code></pre>
  
  <p>when i change the strokewith to less than 1.0, it only make the line dark,and not make it more thinner。
    so i want to know, how to change the default pixel width of direct2d/wpf lines? make it only take one pixel on screen like GDI+, thank you.</p>