Problem while saving ink presenter content to png image
Last post 05-13-2008 4:08 AM by RamsZone. 5 replies.
Sort Posts:
05-08-2008 7:14 AM
Problem while saving ink presenter content to png image

Hi All,

I have designed one application using Silver Light Ink.

I have done pen and erase functionality and its working fine.

Now I want to capture and save that image.

I have added this code for that

 RenderTargetBitmap target = new RenderTargetBitmap((int)inkCtrl.ActualWidth, (int)inkCtrl.ActualHeight, 96d, 96d, PixelFormats.Default);
            target.Render(inkCtrl);
            PngBitmapEncoder encoder = new PngBitmapEncoder();

            encoder.Frames.Add(BitmapFrame.Create(target));
            FileStream fs = File.Open(@"c:\stuff\InkWithEffects.png", FileMode.OpenOrCreate);
            encoder.Save(fs);
            fs.Close();

It is throwing error that assembly reference not added.

But I have added library System.windows.media.imaging;

Please help me.

Thanks in Advance.

Rams.

RamsZone

Joined on 05-08-2008
Posts 4
05-11-2008 10:00 PM
Re: Problem while saving ink presenter content to png image

Hi:

  PngBitmapEncoder  is not supported currently. Also we could only store files in isolated storage for the security reason.

http://silverlight.net/Quickstarts/Other/StoreData.aspx

  You may refer to this article:

http://www.thedatafarm.com/blog/2008/01/31/ConvertingSilverlightInkPresenterImagesToAPNGFile.aspx

Regards

Sincerely,
Allen Chen
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.

Allen Chen – MSFT

Joined on 03-16-2007
Posts 717
05-11-2008 11:39 PM
Re: Problem while saving ink presenter content to png image

Have you checked-out this article? Converting Silverlight InkPresenter images to a PNG file 

RamsZone:
FileStream fs = File.Open(@"c:\stuff\InkWithEffects.png", FileMode.OpenOrCreate);

I doubt that we can write the file in C: drive from Silverlight.  

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Best Regards,
Michael Sync

Blog : http://michaelsync.net
Feed : http://michaelsync.net/feed

mchlSync

Joined on 09-16-2005
Singapore
Posts 2,021
05-12-2008 8:08 AM
Re: Problem while saving ink presenter content to png image

 Hi Allen,

Thanks for your reply.

I have already visited that article( http://www.thedatafarm.com/blog/2008/01/31/ConvertingSilverlightInkPresenterImagesToAPNGFile.aspx) you suggested me to refer.

But in that also they are using  pngbitmapencoder to  encode as png in the 4 th step.

I have also checked the quick start. I am not getting any idea. Actually I am new to silverlight.

Could you please help me, how to  store images in isolated storage for my application.

I am waiting for your valuable reply. 

Thanks and Regards,

Rams.

 

 


RamsZone

Joined on 05-08-2008
Posts 4
05-12-2008 9:43 PM
Marked as Answer
Re: Problem while saving ink presenter content to png image

Hello:

  We can use pngbitmapencoder in WPF but not in current Silverlight. The basic idea to do this is to pass the xaml to server and save it at server end. Then we can use http to download that image. If you need to use isolated storage please refer to:

http://silverlight.net/Quickstarts/Other/StoreData.aspx

Regards

Sincerely,
Allen Chen
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.

Allen Chen – MSFT

Joined on 03-16-2007
Posts 717
05-13-2008 4:08 AM
Re: Problem while saving ink presenter content to png image

 Thanks I will tryout.

RamsZone

Joined on 05-08-2008
Posts 4