2010-07-20 4 views
3

Voir l'image. Je voudrais que la ligne médiane soit une ligne croustillante de 1 pixel. Vous pouvez copier et coller l'exemple de marquage dans kaxaml.Comment dessiner aucune ligne floue/floue dans 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> 

Répondre

1

Changer la ligne médiane à:

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

Vous pouvez obtenir une ligne nette sur une limite de pixel en plaçant la ligne sur une unité numérotée entière.

+0

Je cherche une solution générale, comme un drapeau. J'ai eu un problème similaire dans CoreGraphics et la solution consistait à traduire transformer mon contexte 0.5,0.5 – phi

0

J'ai vu un problème semblable avec le contrôle des frontières, bien que @phi votre solution a travaillé dans la plupart des cas, je devais aussi ajouter ce qui suit pour l'obtenir complètement travail:

SnapsToDevicePixels="True" 
Questions connexes