Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Dec 24th, 2012  |  syntax: None  |  size: 0.77 KB  |  views: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Canvas imageCanvas = new Canvas { Width = 1651, Height = 2551, Background = Brushes.White };
  2.  
  3. Canvas Test = new Canvas();
  4.  
  5. System.Windows.Shapes.Path Path = new System.Windows.Shapes.Path();
  6. Path.Data = Geometry.Parse("M 0,0 H 287 V 287 H 0 Z");
  7. Path.Stretch = Stretch.Fill;
  8. Path.Stroke = Brushes.Black;
  9. Path.StrokeThickness = 1;
  10.  
  11. Test.Width = 500;
  12. Test.Height = 500;
  13. Test.Children.Add(Path);
  14.  
  15. imageCanvas.Children.Add(Test);
  16.  
  17. Canvas.SetTop(Test, 10);
  18. Canvas.SetLeft(Test, 10);
  19.  
  20. // Update layout
  21. Size size = new Size(imageCanvas.Width, imageCanvas.Height);
  22. imageCanvas.Measure(size);
  23. imageCanvas.Arrange(new Rect(size));
  24.  
  25. RenderTargetBitmap bitmapRenderer = new RenderTargetBitmap((int)size.Width, (int)size.Height, 96, 96, PixelFormats.Pbgra32);
  26. bitmapRenderer.Render(imageCanvas);
clone this paste RAW Paste Data