2010-07-20 67 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"