page 1 of 1
Comments: 14 | Views: 4001
Hi,
Is there a way to save a Silverlight canvas to disk or to retrieve the XAML of the current canvas after you have programmatically added objects?

I have a diagram users can annotate and need to save it as Jpg, PNG or GIF.

I found this link below that implies you can do this with an InkPresenter but is there a another better way?:
http://www.thedatafarm.com/blog/2008/01/31/ConvertingSilverlightInkPresenterImagesToAPNGFile.aspx

Thanks,

Alex
stevo_
stevo_
Human after all

I would imagine theres an object that lets you render any visual object into a buffer.. this should give you a bitmap you could probably encode to jpeg or something..

figuerres
figuerres
???
Question:  what did not allow it to work??  the file I/O I can see as an issue but the basic steps to get an in-memory bitmap should work.
stevo_
stevo_
Human after all

Because the RenderTargetBitmap (which allows you to render a visual as a bitmap), is marked as security critical in silverlight.. which means that transparent (user) code cannot directly call it.

Shame, but as you've found- theres somewhat of a workaround.. even if its pretty bizare!

stevo_
stevo_
Human after all

gif and png support transparency, jpeg doesn't.. so the jpeg has to have a background colour.. the default is probably black.. you can change this to whatever you require.

and you'll get various issues using the built in dev host.. if you have iis, you can configure the project to launch the iis site and attach a debugger to it.

I have a simialr problem, where I have a canvas and i have multipe Image place holders in it. User has an option to change the contents of the Image place holders and I need to save the over lapping pictue that is created. any help on this...

thanks in advacne
thanks for the reply alex.


This seems to be lot of work, as I will have multiple images.

I have one question and one ask.

1. can i make a silverlight canvas a WPF canvas, I mean by passing the XAML string. since WPF also works based on this, is possible or doable.

the ask is, alex I did not understand what you mean by passing the image to a webservice, can you throw somelight on it please. pseudo or sample code will be of great help.

page 1 of 1
Comments: 14 | Views: 4001
Microsoft Communities