如何在 DrawingImage/DrawingContext 中绘制不模糊/模糊的线? [英] How to draw none fuzzy/blurry line in DrawingImage/DrawingContext?

查看:32
本文介绍了如何在 DrawingImage/DrawingContext 中绘制不模糊/模糊的线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看图.我希望中间线是一条脆脆的 1 像素线.您可以将示例标记复制并粘贴到 kaxaml 中.

替代文字 http://img832.imageshack.us/img832/1704/lines.png

<预><代码><页面 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"><Image SnapsToDevicePixels="True" Stretch="None"><图片来源><绘图图像><DrawingImage.Drawing><绘图组><几何图形><GeometryDrawing.Pen><钢笔刷=红色"厚度=1"/></GeometryDrawing.Pen><GeometryDrawing.Geometry><LineGeometry StartPoint="0,0" EndPoint="50,0"/></GeometryDrawing.Geometry></几何绘图><几何图形><GeometryDrawing.Pen><钢笔刷=黑色"厚度=1"/></GeometryDrawing.Pen><GeometryDrawing.Geometry><LineGeometry StartPoint="0,5.860" EndPoint="50,5.860"/></GeometryDrawing.Geometry></几何绘图><几何图形><GeometryDrawing.Pen><钢笔刷=黑色"厚度=1"/></GeometryDrawing.Pen><GeometryDrawing.Geometry><LineGeometry StartPoint="0,12" EndPoint="50,12"/></GeometryDrawing.Geometry></几何绘图></绘图组></DrawingImage.Drawing></DrawingImage></Image.Source></图片></页面>

解决方案

我在以下位置找到了解决方案:http://msdn.microsoft.com/en-us/library/system.windows.media.renderoptions.setedgemode.aspx

RenderOptions.SetEdgeMode(this, EdgeMode.Aliased);

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 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>

解决方案

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);

这篇关于如何在 DrawingImage/DrawingContext 中绘制不模糊/模糊的线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆