• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Media.DrawingVisual类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Windows.Media.DrawingVisual的典型用法代码示例。如果您正苦于以下问题:C# DrawingVisual类的具体用法?C# DrawingVisual怎么用?C# DrawingVisual使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DrawingVisual类属于System.Windows.Media命名空间,在下文中一共展示了DrawingVisual类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CreateBitmap

        public void CreateBitmap()
        {
            int width = 100;
            int height = 100;
            int dpi = 96;

            Tracing.Log(">> CreateBitmap");
            var thread = new Thread(new ThreadStart(() => 
            {
                Tracing.Log(">> CreateBitmap - Thread start; creating drawing visual");
                //Dispatcher.Invoke(new Action(() => {
                _drawingVisual = new DrawingVisual();
                _drawingContext = _drawingVisual.RenderOpen();
                //}));

                Tracing.Log(">> CreateBitmap - Drawing to context");
                _drawingContext.DrawRectangle(new SolidColorBrush(Colors.HotPink), new Pen(), new Rect(0, 0, 50, 50));
                _drawingContext.DrawRectangle(new SolidColorBrush(Colors.Blue), new Pen(), new Rect(50, 0, 50, 50));
                _drawingContext.DrawRectangle(new SolidColorBrush(Colors.Orange), new Pen(), new Rect(0, 50, 50, 50));
                _drawingContext.DrawRectangle(new SolidColorBrush(Colors.DarkRed), new Pen(), new Rect(50, 50, 50, 50));
                _drawingContext.Close();

                Tracing.Log(">> CreateBitmap - Finished drawing; creating render target bitmap");
                _bitmap = new RenderTargetBitmap(width, height, dpi, dpi, PixelFormats.Default);
                _bitmap.Render(_drawingVisual);
                Tracing.Log(">> CreateBitmap - Finished work");
                _bitmap.Freeze();
            }));
            //thread.IsBackground = true;
            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
        }
开发者ID:pascalfr,项目名称:MPfm,代码行数:32,代码来源:TestControl.cs


示例2: ButtonSave_Click

        private void ButtonSave_Click(object sender, RoutedEventArgs e)
        {
            var rect = new Rect { Width = 512, Height = 384 };
            var dv = new DrawingVisual();

            var dc = dv.RenderOpen();
            dc.PushTransform(new TranslateTransform(-rect.X, -rect.Y));
            dc.DrawRectangle(InkCanvasMain.Background, null, rect);
            InkCanvasMain.Strokes.Draw(dc);
            dc.Close();

            var rtb = new RenderTargetBitmap((int)rect.Width, (int)rect.Height, 96, 96, PixelFormats.Default);
            rtb.Render(dv);
            var enc = new PngBitmapEncoder();
            enc.Frames.Add(BitmapFrame.Create(rtb));

            var fn = TextBoxFileName.Text;
            if (!fn.EndsWith(".png", StringComparison.OrdinalIgnoreCase)) fn += ".png";
            using (Stream s = File.Create(TegakiImageFolder + "/" + fn))
            {
                enc.Save(s);
            }
            ((TegakiWindowViewModel)DataContext).AddToMediaList(System.IO.Path.GetFullPath(TegakiImageFolder + "/" + fn));
            Close();
        }
开发者ID:kb10uy,项目名称:Kbtter4,代码行数:25,代码来源:TegakiWindow.xaml.cs


示例3: RenderMyVisual

 private void RenderMyVisual(DrawingVisual v)
 {
     using (var dc = v.RenderOpen())
     {
         RenderRectangles(dc);
     }
 }
开发者ID:JamesDunne,项目名称:LanCaster,代码行数:7,代码来源:SectorCompletionBar.cs


示例4: DrawGraphicsOnBitmap

        public DrawGraphicsOnBitmap()
        {
            Title = "Draw Graphics on Bitmap";

            // ��Ʈ���� ������� �����ϱ� ���� ����� ������.
            Background = Brushes.Khaki;

            // RenderTargetBitmap ������.
            RenderTargetBitmap renderbitmap = new RenderTargetBitmap(100, 100, 96, 96, PixelFormats.Default);

            // DrawingVisual ��ü�� ������.
            DrawingVisual drawvis = new DrawingVisual();
            DrawingContext dc = drawvis.RenderOpen();      // Render �޼ҵ� ȣ��
            dc.DrawRoundedRectangle(Brushes.Blue, new Pen(Brushes.Red, 10),
                                    new Rect(25, 25, 50, 50), 10, 10);
            dc.Close();

            // RenderTargetBitmap ���� DrawingVisual ��ü�� �׸�.
            renderbitmap.Render(drawvis);

            // �̹��� ��ä ���� -> ������Ƽ ����
            Image img = new Image();
            img.Source = renderbitmap;

            // ���
            Content = img;
        }
开发者ID:gawallsibya,项目名称:BIT_MFC-CShap-DotNet,代码行数:27,代码来源:DrawGraphicsOnBitmap.cs


示例5: GetEffect

        protected override Effect GetEffect(FastBitmap source)
        {
            // Fill temporary graphics buffer with mask (currently always a rectangle).
            DrawingVisual dv = new DrawingVisual
            {
                Effect = new BlurEffect
                {
                    Radius = Radius,
                    KernelType = KernelType.Gaussian
                }
            };

            DrawingContext dc = dv.RenderOpen();
            dc.DrawImage(source.InnerBitmap, new Rect(0, 0, source.Width, source.Height));
            dc.Close();

            RenderTargetBitmap rtb = RenderTargetBitmapUtility.CreateRenderTargetBitmap(source.Width, source.Height);
            rtb.Render(dv);

            Brush blurredImage = new ImageBrush(rtb);

            return new UnsharpMaskEffect
            {
                BlurMask = blurredImage,
                Amount = Amount / 100.0,
                Threshold = Threshold
            };
        }
开发者ID:sitdap,项目名称:dynamic-image,代码行数:28,代码来源:UnsharpMaskFilter.cs


示例6: GetImage

        public static RenderTargetBitmap GetImage(UIElement fe, Brush background = null, Size sz = default(Size), int dpi = 144)
        {
            if (sz.Width < alib.Math.math.ε || sz.Height < alib.Math.math.ε)
            {
                fe.Measure(util.infinite_size);
                sz = fe.DesiredSize; //VisualTreeHelper.GetContentBounds(fe).Size; //
            }

            DrawingVisual dv = new DrawingVisual();
            RenderOptions.SetEdgeMode(dv, EdgeMode.Aliased);

            using (DrawingContext ctx = dv.RenderOpen())
            {
                Rect r = new Rect(0, 0, sz.Width, sz.Height);
                if (background != null)
                    ctx.DrawRectangle(background, null, r);

                VisualBrush br = new VisualBrush(fe);
                br.AutoLayoutContent = true;
                ctx.DrawRectangle(br, null, r);
            }

            Double f = dpi / 96.0;

            RenderTargetBitmap bitmap = new RenderTargetBitmap(
                (int)(sz.Width * f) + 1,
                (int)(sz.Height * f) + 1,
                dpi,
                dpi,
                PixelFormats.Pbgra32);
            bitmap.Render(dv);
            return bitmap;
        }
开发者ID:hehaotian,项目名称:igt-editor,代码行数:33,代码来源:misc.cs


示例7: CreateImage

        protected override sealed void CreateImage()
        {
            base.CreateImage();

            Rect bounds = new Rect(StrokeWidth / 2, StrokeWidth / 2,
                CalculatedWidth - StrokeWidth,
                CalculatedHeight - StrokeWidth);
            Brush brush = Fill.GetBrush();

            PointCollection points = GetPoints(bounds);
            PathGeometry geometry = CanonicalSplineHelper.CreateSpline(points, Roundness / 100.0, null, true, true, 0.25);

            Pen pen = GetPen();

            DrawingVisual dv = new DrawingVisual();
            DrawingContext dc = dv.RenderOpen();

            // Draw polygon.
            dc.DrawGeometry(brush, pen, geometry);

            dc.Close();

            RenderTargetBitmap rtb = RenderTargetBitmapUtility.CreateRenderTargetBitmap(CalculatedWidth, CalculatedHeight);
            rtb.Render(dv);
            Bitmap = new FastBitmap(rtb);
        }
开发者ID:dbre2,项目名称:dynamic-image,代码行数:26,代码来源:PolygonShapeLayer.cs


示例8: ApplyFilter

        /// <summary>
        /// Applies the filter to the specified <paramref name="bitmap"/>. This method
        /// first calls <see cref="ImageReplacementFilter.GetDestinationDimensions(FastBitmap, out Int32, out Int32)" />
        /// to calculate the size of the destination image. Then it calls
        /// <see cref="ImageReplacementFilter.ApplyFilter(FastBitmap, DrawingContext, int, int)" /> 
        /// which is where the overridden class implements its filter algorithm.
        /// </summary>
        /// <param name="bitmap">
        /// Image to apply the <see cref="ImageReplacementFilter" /> to.
        /// </param>
        public override sealed void ApplyFilter(FastBitmap bitmap)
        {
            OnBeginApplyFilter(bitmap);

            // get destination dimensions
            int width, height;
            bool shouldContinue = GetDestinationDimensions(bitmap, out width, out height);
            if (!shouldContinue)
                return;

            DrawingVisual dv = new DrawingVisual();
            ConfigureDrawingVisual(bitmap, dv);

            DrawingContext dc = dv.RenderOpen();

            ApplyFilter(bitmap, dc, width, height);
            dc.Close();

            RenderTargetBitmap rtb = RenderTargetBitmapUtility.CreateRenderTargetBitmap(width, height);
            rtb.Render(dv);
            FastBitmap destination = new FastBitmap(rtb);

            // copy metadata
            // TODO
            /*foreach (PropertyItem propertyItem in bitmap.InnerBitmap.PropertyItems)
                destination.InnerBitmap.SetPropertyItem(propertyItem);*/

            // set new image
            bitmap.InnerBitmap = destination.InnerBitmap;

            OnEndApplyFilter();
        }
开发者ID:jaytwo,项目名称:dynamic-image,代码行数:42,代码来源:ImageReplacementFilter.cs


示例9: VisualPaginator

 public VisualPaginator(DrawingVisual source, Size printSize, Thickness pageMargins, Thickness originalMargin)
 {
     DrawingVisual = source;
     _printSize = printSize;
     PageMargins = pageMargins;
     _originalMargin = originalMargin;
 }
开发者ID:serbrech,项目名称:wpfprintengine,代码行数:7,代码来源:VisualPaginator.cs


示例10: CreateImage

        private ImageSource CreateImage(CustomMaterial material)
        {
            var bitmapSourceBackground = material.FlyerFrontSide.ToBitmapImage();

            var visual = new DrawingVisual();
            using (var drawingContext = visual.RenderOpen())
            {
                drawingContext.PushClip(new RectangleGeometry(new Rect(0, 0, bitmapSourceBackground.Width, bitmapSourceBackground.Height)));

                drawingContext.DrawImage(bitmapSourceBackground, new Rect(0, 0, bitmapSourceBackground.Width, bitmapSourceBackground.Height));

                foreach (var textField in material.MaterialFields.Select(materialToTextFieldConverter.CreateTextField))
                {
                    drawingContext.DrawText(textField.FormattedText, textField.Origin);
                }

                if (material.CustomLogo.HasLogo)
                {
                    var flyerLogo = material.CustomLogo.Logo.ToBitmapImage();
                    drawingContext.DrawImage(flyerLogo, new Rect(material.CustomLogo.LogoLeftMargin, material.CustomLogo.LogoTopMargin, material.CustomLogo.LogoWidth, material.CustomLogo.LogoHeight));
                }
            }
            var image = new DrawingImage(visual.Drawing);

            image.Freeze();
            return image;
        }
开发者ID:Jo3-16,项目名称:FMA,代码行数:27,代码来源:FlyerCreator.cs


示例11: DrawContextualMenu

        internal static void DrawContextualMenu(DrawingVisual drawingVisual, Dictionary<int, string> itemsList)
        {
            //draw the stuff

            //3 cases
            //menu items == 7
            //menu items < 7
            //menu items > 7

            DrawingContext context = drawingVisual.RenderOpen();
            int itemsCount = itemsList.Count;
            if (itemsCount == 7)
            {

            }

            if (itemsCount < 7)
            {

            }

            if (itemsCount > 7)
            {

            }
            // position the menu correctly
        }
开发者ID:samuto,项目名称:designscript,代码行数:27,代码来源:DrawingUtilities.cs


示例12: SelectionRectVisual

        /// <summary>
        /// Construct new SelectionRectVisual object for the given rectangle
        /// </summary>
        public SelectionRectVisual(Point firstPointP, Point secondPointP, double zoomP)
        {
            DrawingGroup drawing = new DrawingGroup();
            DrawingContext context = drawing.Open();
            context.DrawRectangle(Brushes.White, null, new Rect(-1, -1, 3, 3));
            context.DrawRectangle(Brushes.Black, null, new Rect(0.25, -1, 0.5, 3));
            context.Close();
            drawing.Freeze();

            // Create a drawing brush that tiles the unit square from the drawing created above.
            // The size of the viewport and the rotation angle will be updated as we use the
            // dashed pen.
            DrawingBrush drawingBrush = new DrawingBrush(drawing);
            drawingBrush.ViewportUnits = BrushMappingMode.Absolute;
            drawingBrush.Viewport = new Rect(0, 0, _dashRepeatLength, _dashRepeatLength);
            drawingBrush.ViewboxUnits = BrushMappingMode.Absolute;
            drawingBrush.Viewbox = new Rect(0, 0, 1, 1);
            drawingBrush.Stretch = Stretch.Uniform;
            drawingBrush.TileMode = TileMode.Tile;

            // Store the drawing brush and a copy that's rotated by 90 degrees.
            _horizontalDashBrush = drawingBrush;
            _verticalDashBrush = drawingBrush.Clone();
            _verticalDashBrush.Transform = new RotateTransform(90);

            this._firstPoint = firstPointP;
            this._secondPoint = secondPointP;
            this._zoom = zoomP;
            _visualForRect = new DrawingVisual();
            this.AddVisualChild(_visualForRect);
            this.AddLogicalChild(_visualForRect);      
        }
开发者ID:hultqvist,项目名称:Eto,代码行数:35,代码来源:SelectionRectVisual.cs


示例13: OnDrawMouseHover

        protected override void OnDrawMouseHover()
        {
            if (this.mouseHoverVisual != null)
            {
                this.Visuals.Remove(this.mouseHoverVisual);
                this.RemoveVisualChild(this.mouseHoverVisual);
            }

            var mouseHoverTileCoords = this.HoverTile;
            if (mouseHoverTileCoords.X < 0 || mouseHoverTileCoords.Y < 0)
            {
                this.mouseHoverVisual = null;
            }
            else
            {
                this.mouseHoverVisual = new DrawingVisual();
                var tileRect = this.GetTileRectangleFromTilePoint(mouseHoverTileCoords);

                using (var drawingContext = this.mouseHoverVisual.RenderOpen())
                {
                    if (this.DrawPressedTile)
                    {
                        drawingContext.DrawImage(this.tileSetImage, tileRect);
                    }
                    else
                    {
                        drawingContext.DrawRectangle(this.HoverBrush, null, tileRect);
                    }
                }

                this.Visuals.Add(this.mouseHoverVisual);
                this.AddVisualChild(this.mouseHoverVisual);
            }
        }
开发者ID:jcrout,项目名称:WPF-MVVM-Minesweeper,代码行数:34,代码来源:TileBoardOld.cs


示例14: WaveGraph

        public WaveGraph()
        {
            InitializeComponent();
            DrawingVisual ghostVisual;

            Width = 300;
            Height = 350;
            ghostVisual = new DrawingVisual();
            using (DrawingContext dc = ghostVisual.RenderOpen())
            {

                dc.DrawEllipse(Brushes.Black, new Pen(Brushes.Red, 10),
                new Point(95, 95), 15, 15);

                dc.DrawEllipse(Brushes.Black, new Pen(Brushes.Red, 10),
                new Point(170, 105), 15, 15);

                Pen p = new Pen(Brushes.Black, 10);
                p.StartLineCap = PenLineCap.Round;
                p.EndLineCap = PenLineCap.Round;
                dc.DrawLine(p, new Point(75, 160), new Point(175, 150));
            }

            this.AddVisualChild(ghostVisual);
            this.AddLogicalChild(ghostVisual);
        }
开发者ID:ShallYu,项目名称:mood_massage,代码行数:26,代码来源:WaveGraph.xaml.cs


示例15: RadialMenu

        public RadialMenu(uint nodeId, Point worldCoords, double radius, Dictionary<int, string> items,
            double startAngle, NodePart part)
        {
            this.startAngle = startAngle * Math.PI / 180;
            this.endAngle = (startAngle - 90) * Math.PI / 180; // 90: the radial menu is a quadrant
            this.nodePart = part;
            this.worldCoords = worldCoords;
            this.nodeId = nodeId;
            this.radius = radius;

            radialMenuVisual = new DrawingVisual();
            radialMenuVisual.Transform = new TranslateTransform(worldCoords.X, worldCoords.Y);

            SetAnchor();
            itemsList = items;
            reducedList = items;

            InitializeMenuItems();

            UpdateItemsArrangement(-1);
            InitializeItemWeight();

            ValidateScrollers();
            Compose();
        }
开发者ID:samuto,项目名称:designscript,代码行数:25,代码来源:RadialMenu.cs


示例16: GetRenderTargetBitmap

        public static RenderTargetBitmap GetRenderTargetBitmap(this UIElement source, double scale)
        {
            if (source.RenderSize.Height == 0 || source.RenderSize.Width == 0)
                return null;

            double actualHeight = source.RenderSize.Height;
            double actualWidth = source.RenderSize.Width;

            double renderHeight = actualHeight*scale;
            double renderWidth = actualWidth*scale;

            var renderTarget = new RenderTargetBitmap((int) renderWidth, (int) renderHeight, 96, 96,
                                                      PixelFormats.Pbgra32);
            var sourceBrush = new VisualBrush(source);

            var drawingVisual = new DrawingVisual();
            DrawingContext drawingContext = drawingVisual.RenderOpen();

            using (drawingContext)
            {
                drawingContext.PushTransform(new ScaleTransform(scale, scale));
                drawingContext.DrawRectangle(sourceBrush, null,
                                             new Rect(new Point(0, 0), new Point(actualWidth, actualHeight)));
            }
            renderTarget.Render(drawingVisual);
            return renderTarget;
        }
开发者ID:afrog33k,项目名称:eAd,代码行数:27,代码来源:Screenshot.cs


示例17: SetPreviewElement

        public void SetPreviewElement(FrameworkElement element)
        {
            double x = 0;
              double y = 0;
              GetCurrentDPI(out x, out y);

              // Does the DrawingBrush thing seem a little hacky? Yeah, it's a necessary hack.  See:
              // http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=364041

              Rect bounds = VisualTreeHelper.GetDescendantBounds(element);

              RenderTargetBitmap r = new RenderTargetBitmap((int)(element.ActualWidth * x / 96), (int)(element.ActualHeight * y / 96), (int)x, (int)y, PixelFormats.Pbgra32);

              DrawingVisual dv = new DrawingVisual();
              using (DrawingContext ctx = dv.RenderOpen()) {
            VisualBrush vb = new VisualBrush(element);

            ctx.DrawRectangle(vb, null, new Rect(new Point(), bounds.Size));
              }
              r.Render(dv);

              DragImage = r;

              InvalidateMeasure();
        }
开发者ID:edealbag,项目名称:bot,代码行数:25,代码来源:DragPreviewAdorner.cs


示例18: Draw

        public void Draw( EdgeLayout layoutState )
        {
            var styleState = myPresentation.GetPropertySetFor<EdgeStyle>().Get( Owner.Id );

            var stream = new StreamGeometry();
            var context = stream.Open();

            context.BeginFigure( layoutState.Points.First(), false, false );

            context.PolyBezierTo( layoutState.Points.Skip( 1 ).ToList(), true, false );

            // draw arrow head
            var start = layoutState.Points.Last();
            var v = start - layoutState.Points.ElementAt( layoutState.Points.Count() - 2 );
            v.Normalize();

            start = start - v * 0.15;
            context.BeginFigure( start + v * 0.28, true, true );
            double t = v.X; v.X = v.Y; v.Y = -t;  // Rotate 90°
            context.LineTo( start + v * 0.08, true, true );
            context.LineTo( start + v * -0.08, true, true );
            context.Close();

            var pen = new Pen( styleState.Color, 0.016 );

            // http://stackoverflow.com/questions/1755520/improve-drawingvisual-renders-speed
            Visual = new DrawingVisual();
            var dc = Visual.RenderOpen();
            dc.DrawGeometry( pen.Brush, pen, stream );
            dc.Close();

            Visual.SetValue( GraphItemProperty, Owner );
        }
开发者ID:mwidmeyer,项目名称:Plainion.GraphViz,代码行数:33,代码来源:EdgeVisual.cs


示例19: Init_DrawLT

        public void Init_DrawLT(int running_train)
        {
            int i;
            int temp;
            int late_time_range;
            late_time_range = 1000;
            temp = 0;
            x1 = 30;
            y1 = 10;
            x2 = 700;
            y2 = 580;
            narrow_x = (double)running_train / (x2 - x1);
            narrow_y = (double)late_time_range / (y2 - y1);
            drawingVisual = new DrawingVisual();
            dc = drawingVisual.RenderOpen();
            dc.DrawLine(new Pen(Brushes.Black, 1.5), new Point(x1, x1), new Point(x1, y2));
            dc.DrawLine(new Pen(Brushes.Black, 1.5), new Point(x1, y2), new Point(x2, y2));
            dc.DrawText(new FormattedText("N",
                    CultureInfo.GetCultureInfo("en-us"),
                    FlowDirection.LeftToRight,
                    new Typeface("Verdana"),
                    12, System.Windows.Media.Brushes.Black),
                    new System.Windows.Point(x2 - 30, y2 + 6));
            dc.DrawText(new FormattedText("T",
                      CultureInfo.GetCultureInfo("en-us"),
                      FlowDirection.LeftToRight,
                      new Typeface("Verdana"),
                      12, System.Windows.Media.Brushes.Black),
                      new System.Windows.Point(x1 - 10, y1 - 8));

            for (i = 0; i < (x2 - x1); i++)
            {
                if (i % ((x2 - x1) / 5) == 0)
                {
                    dc.DrawLine(new Pen(Brushes.Black, 1.5), new Point(x1 + i, y2), new Point(x1 + i, y2 - 3));
                    dc.DrawText(new FormattedText((temp * running_train / 5).ToString(),
                      CultureInfo.GetCultureInfo("en-us"),
                      FlowDirection.LeftToRight,
                      new Typeface("Verdana"),
                      12, System.Windows.Media.Brushes.Black),
                      new System.Windows.Point(i + x1 - 5, y2 + 7));
                    temp++;
                }
            }
            temp = 0;
            for (i = 0; i < (y2 - y1); i++)
            {
                if (i % ((y2 - y1) / 5) == 0)
                {
                    dc.DrawLine(new Pen(Brushes.Black, 1.5), new Point(x1, y2 - i), new Point(x1 + 3, y2 - i));
                    dc.DrawText(new FormattedText((temp * late_time_range / 5).ToString(),
                      CultureInfo.GetCultureInfo("en-us"),
                      FlowDirection.LeftToRight,
                      new Typeface("Verdana"),
                      12, System.Windows.Media.Brushes.Black),
                      new System.Windows.Point(x1 - 28, y2 - i - 9));
                    temp++;
                }
            }
        }
开发者ID:sonicrang,项目名称:Train_TS,代码行数:60,代码来源:drawLT.cs


示例20: SaveToPng

        public void SaveToPng( Canvas surface, string file )
        {
            // Save current canvas transform
            var transform = surface.LayoutTransform;
            // reset current transform (in case it is scaled or rotated)
            surface.LayoutTransform = null;

            var size = new Size( 1600, 900 );

            // Attentation: Measure and arrange the surface !
            surface.Measure( size );
            surface.Arrange( new Rect( size ) );

            var renderBitmap = new RenderTargetBitmap( (int)size.Width, (int)size.Height, 96d, 96d, PixelFormats.Pbgra32 );

            var bounds = VisualTreeHelper.GetDescendantBounds( surface );
            var dv = new DrawingVisual();
            using ( var ctx = dv.RenderOpen() )
            {
                var vb = new VisualBrush( surface );
                ctx.DrawRectangle( vb, null, new Rect( new Point(), bounds.Size ) );
            }

            renderBitmap.Render( dv );
            using ( var outStream = new FileStream( file, FileMode.OpenOrCreate, FileAccess.Write ) )
            {
                var encoder = new PngBitmapEncoder();
                encoder.Frames.Add( BitmapFrame.Create( renderBitmap ) );
                encoder.Save( outStream );
            }

            // Restore previously saved layout
            surface.LayoutTransform = transform;
        }
开发者ID:JackWangCUMT,项目名称:Plainion.Whiteboard,代码行数:34,代码来源:PersistenceService.cs



注:本文中的System.Windows.Media.DrawingVisual类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Media.EllipseGeometry类代码示例发布时间:2022-05-26
下一篇:
C# Media.DrawingImage类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap