2010-07-20 39 views
3

查看图片。我想中间线是一个脆皮的1像素线。 您可以将示例标记复制并粘贴到kaxaml如何在DrawingImage/DrawingContext中绘制没有模糊/模糊的线条?

alt text http://img832.imageshack.us/img832/1704/lines.png


<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> 
    <Image SnapsToDevicePixels="True" Stretch="None"> 
     <Image.Source> 
     <DrawingImage> 
      <DrawingImage.Drawing> 
       <DrawingGroup> 
        <GeometryDrawing> 
        <GeometryDrawing.Pen> 
         <Pen Brush="Red" Thickness="1"/> 
        </GeometryDrawing.Pen> 
        <GeometryDrawing.Geometry> 
         <LineGeometry StartPoint="0,0" EndPoint="50,0"/> 
        </GeometryDrawing.Geometry> 
        </GeometryDrawing> 
        <GeometryDrawing> 
        <GeometryDrawing.Pen> 
         <Pen Brush="Black" Thickness="1"/> 
        </GeometryDrawing.Pen> 
        <GeometryDrawing.Geometry> 
         <LineGeometry StartPoint="0,5.860" EndPoint="50,5.860"/> 
        </GeometryDrawing.Geometry> 
        </GeometryDrawing> 
        <GeometryDrawing> 
        <GeometryDrawing.Pen> 
         <Pen Brush="Black" Thickness="1"/> 
        </GeometryDrawing.Pen> 
        <GeometryDrawing.Geometry> 
         <LineGeometry StartPoint="0,12" EndPoint="50,12"/> 
        </GeometryDrawing.Geometry> 
        </GeometryDrawing> 
       </DrawingGroup> 
      </DrawingImage.Drawing> 
     </DrawingImage> 
     </Image.Source> 
    </Image> 
</Page> 

回答

1

更改中间线:

<LineGeometry StartPoint="0,6" EndPoint="50,6"/> 

您可以通过将线整体编号单元上获得的像素边界上一个清晰的线。

+0

我正在寻找一个通用的解决方案,像一个标志。我在CoreGraphics中遇到了类似的问题,解决方案是将transform转换为我的上下文0.5,0.5 – phi 2010-07-20 01:07:30

0

我看到了类似的问题与边境控制,虽然@phi您的解决方案在大多数情况下工作,我也不得不添加以下让它完全工作:

SnapsToDevicePixels="True"