View Single Post
Old 09-17-2008   #4 (permalink)
Art


64bit
 
 

Re: Save WPF Control as PNG image

Quote  Quote: Originally Posted by Jon Harrop View Post
I'd like to save a WPF control as a PNG image. I've tried using the
following code:

http://dvuyka.spaces.live.com/blog/cns!305B02907E9BE19A!240.entry

but the calls the Measure and Arrange screw up the layout of the control
which is then drawn incorrectly until the user resizes the window. I don't
understate what state they've changed but I am unable to fix it. I've tried
adding calls to InvalidateMeasure and InvalidateArrange and UpdateLayout
but they do not fix the problem.

I just discovered that you can use the backwards compatibility with WinForms
stuff in "Forms.Integration" to create an ElementHost that has a
DrawToBitmap method for Win32 bitmaps.

What is the recommended way to do this? Am I really supposed to resort to
calling the backwards compatibility stuff and using WinForms?

--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Flying Frog Consultancy Ltd.
Try this "image" converter...

Pixillion Free Image File Converter - Convert jpeg, gif pdf and more.

It's free and works great.................................... ART
My System SpecsSystem Spec