tags:

views:

18

answers:

2

See the image. I would like the middle line to be a crispy 1 pixel line. You can copy and paste the sample markup into kaxaml .

alt text


<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt;
   <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>

A: 

Change the middle line to:

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

You can get a crisp line on a pixel boundary by placing the line on a whole numbered unit.

John Bowen
I am looking for a general solution, like a flag. I had a similar problem in CoreGraphics and the solution was to translate transform my context 0.5,0.5
phi
+1  A: 

I found the solution at: http://msdn.microsoft.com/en-us/library/system.windows.media.renderoptions.setedgemode.aspx

<Image Stretch="None" RenderOptions.EdgeMode="Aliased">
RenderOptions.SetEdgeMode(this, EdgeMode.Aliased);
phi