绘制和缩放外部图像

时间:2016-01-21 09:03:58

标签: c# wpf

我发现已下载并转换为XAML的一些顶点图片:

        <Canvas Width="0" Height="0" ClipToBounds="True">
            <Path Fill="#FF000000" Stroke="#FF000000" StrokeMiterLimit="4" Name="path26">
                <Path.Data>
                    <PathGeometry FillRule="Nonzero" Figures="M51.688,5.25C46.261,5.1091 ... 51.344,83.125z" />
                </Path.Data>
            </Path>
        </Canvas>

现在,我想在我的自定义绘图上绘制这张照片:

    private void Draw()
    {
        DrawingGroup aDrawingGroup = new DrawingGroup();

        for (int DrawingStage = 0; DrawingStage < 10; DrawingStage++)
        {
            GeometryDrawing drw = new GeometryDrawing();
            GeometryGroup gg = new GeometryGroup();

            if (DrawingStage == 1)
            {
                drw.Brush = Brushes.Beige;
                drw.Pen = new Pen(Brushes.LightGray, 0.01);

                RectangleGeometry myRectGeometry = new RectangleGeometry();
                myRectGeometry.Rect = new Rect(0, 0, 3, 2.3);
                gg.Children.Add(myRectGeometry);
            }

            if (DrawingStage == 2)
            {
                drw.Pen = new Pen(Brushes.Black, 0.02);

                for (int i = 5; i < 16; i++)
                {
                    LineGeometry myRectGeometry = new LineGeometry(new Point(2.9, i * 0.1), new Point(0.1, i * 0.1));
                    gg.Children.Add(myRectGeometry);
                }

            }

            drw.Geometry = gg;
            aDrawingGroup.Children.Add(drw);
        }

        noteImage.Source = new DrawingImage(aDrawingGroup);
    }

我如何绘制和缩放外部图片?

0 个答案:

没有答案