Rendering sharp lines in WPF

后端 未结 2 582
名媛妹妹
名媛妹妹 2020-12-16 03:24

If I render the following:


    
    

        
2条回答
  •  爱一瞬间的悲伤
    2020-12-16 04:00

    Remember that SnapsToDevicePixels only controls that individual points do not lie on fractional pixel values. For horizontal and vertical lines this is most easily observed. In your case you are seeing an entirely different problem. The edges of your shapes are anti-aliased and therefore blended with the background. Since your shapes are exactly adjacent to each other both will be blended with the white background of the window. You can try putting one shape behind the other instead:

      
          
          
          
               
          
    
    

    which should render correctly. You see similar rendering errors in many vector file formats that render primarily to screen, such as SVG.

    The other option would be to turn off anti-aliasing but that will make your edges jaggy which may not be what you want (anti-aliasing turned off in the upper half):

提交回复
热议问题