WriteableBitmap形状渲染

时间:2011-11-08 09:16:01

标签: silverlight drawing

我正在尝试在Silverlight中渲染一些Shape对象(Line,Rectangle),而我正在使用WriteableBitmap.Render(myShape,transform)。问题是Render函数似乎缺少抗锯齿功能。我错过了什么,或者使用WriteableBitmap这是不可能的?

    private void UserControl_Loaded(object sender, RoutedEventArgs e)
    {
        bmp = new WriteableBitmap(800, 600);
        testImage.Source = bmp;
        line = new Line() { X1 = 10, X2 = 500, Y1 = 10, Y2 = 300 };
        line.Stroke = new SolidColorBrush(Colors.Red);
        line.StrokeStartLineCap = PenLineCap.Round;
        line.StrokeEndLineCap = PenLineCap.Round;
        line.StrokeLineJoin = PenLineJoin.Round;
        line.StrokeThickness = 1;
        CompositionTarget.Rendering += new EventHandler(CompositionTarget_Rendering);
    }

    private void CompositionTarget_Rendering(object sender, EventArgs e)
    {
        bmp.Render(line, line.GeometryTransform);
        bmp.Invalidate();
    }

0 个答案:

没有答案