Off-screen graphics in WPF

  • Thread starter Thread starter John Mott
  • Start date Start date
J

John Mott

Hi all,

I've been doing some WPF work and wondered if there is an off-screen
'canvas' that I can draw things to. I'd like to do some batch processing
where I render images into a memory area using WPF. Is there a Virtual Canvas
or some such construct?

Thanks,

John
(e-mail address removed)
 
When we worked with the DOM using HTML/CSS/JavaScript we often
positioned --whatever-- off-screen to the left and brought --whatever-- back
into view if and when wanted by modifying its absolute position values. This
is how the SkipLinks methodology came about for Accessibility. There should
be no reason that type of little trick cannot be used with WPF.
 
Thanks, but I'm looking for the ability to write a console program with no UI
and be able to render the XAML graphics into a PNG file (part of background
processing started from a cron-type job) I think the answer is to create an
XPS document and render that into a file but if there is another way I'd love
to hear it.

john
 
System.Windows.Media.Imaging namespace allows you to work with pixels and
bitmaps in formats BMP, JPEG, PNG, TIFF, GIF, and others.

You can create a bitmap from any visual:

RenderTargetBitmap bmp = new
RenderTargetBitmap(300,150,300,300,PixelFormats.Pbgra32);
Elipse e = new Ellipse();
e.Fill = Brushes.Red;
e.Measure(new Size(96,48));
e.Arrange(new Rect(0,0,96,48);
bmp.Render(e);

This comes from the book: "Programming WPF", by Sells and Griffiths,
O'Reilly Aug 2007.
 
Back
Top