Controls to images

Hello all,

 

Recently there has been a great demand for the XamDataCharts to be exported outside their respectful applications as images. Usually WPF provides the functionality that is needed to extract an image of any control that inherits from the Visual class. Also with the help of the Infragistics Excel engine and I have been able to gather in a singles sample project (XamDataChart_to_Image.zip) exporting to: Excel, *.png, *jpg and the Clipboard.

 

The XamDataChart is a cross-platform control (meaning it is available for both Silverlight and WPF) and of course this causes some difference in implementation.  

Because of the difference in accessibility to the user’s machine between WPF and Silverlight I have only been able to get the WPF XamDataChart to be saved to the Clipboard (like with print screen).

 

The other major issue in Silverlight is the lack of the RenderTargetBitmap class that is used in WPF to extract the visual and also the PngBitmapEncoder and JpegBitmapEncoder classes is used in WPF to convert the extracted data to the needed format.  This where the Infragistics Reporting team steps in with the InfragisticsSL4.Reports.Imaging.v11.2 assembly. This has been created mainly to serve the NetAdvantage Reporting package in creating its xaml based reports, however I’ve managed to put it to another good use as per your demands. Actually the assembly provides simplified version of the above mentioned classes to be used in Silverlight and they go respectively: WriteableBitmap, PngImageEncoder, JpegImageEncoder. Using all that, I have created another sample project (XamPieChart_to_image.zip) that creates images out of the XamPieChart and exports them to: Excel, *.png and *jpg.

Also in the Silverlight sample I decided to create an image out of the containing Grid control and not from the XamPieChart directly. That way I am able to also include the XamPieChart’s ItemLegend control in the exported images.

Hope you like all this.

 


Attachment: Samples.zip

Comments  (9 )

philip wyatt
on Sat, Mar 24 2012 6:57 AM

like this

ahunot
on Mon, Jul 16 2012 8:04 AM

I am getting a number of compile errors probably as I only have the 12.1 dll files.

Do you have a more recent version of this project just using 12.1 files?

Thanks

Andrew Hunot (ah@commercialsoftware.co.uk)

[Infragistics] Petar Monov
on Wed, Oct 3 2012 10:38 AM

Hello Andrew,

I have updated the samples per your requirement and there are even some good news.

Since 12.1 the NetAdvantage for Silverlight includes all the needed assemblies, there is no longer need to install the NetAdvantage Reporting only for one assembly. Here is the new version of the project: users.infragistics.com/.../Samples_12.1.zip

Hope you like it.

Petar Monov
on Mon, Feb 25 2013 6:47 AM

Hi, This is a follow-up on a blog that I had done a while back for creating images from controls: http

sanjeev agarwal
on Tue, Jul 30 2013 6:35 AM

hi,

I tried the same in my project but i am getting some errors:

1. i can't found  System.Drawing under reference, in order to add it

2. getting error for      RenderTargetBitmap

3. getting error for      PixelFormats

4. getting error for      FormatConvertedBitmap

5. getting error for      BmpBitmapEncoder

6. getting error for      BitmapFrame

7. getting error for      PointF

8.getting error for       Process

Can you help me to solve the same.Thanks in advance.

Regards,

Sanju

sanjeev agarwal
on Tue, Jul 30 2013 6:37 AM

hi,

I tried the same in my project but i am getting some errors:

1. i can't found  System.Drawing under reference, in order to add it

2. getting error for      RenderTargetBitmap

3. getting error for      PixelFormats

4. getting error for      FormatConvertedBitmap

5. getting error for      BmpBitmapEncoder

6. getting error for      BitmapFrame

7. getting error for      PointF

8.getting error for       Process

Can you help me to solve the same.Thanks in advance.

Regards,

Sanju

sanjeev agarwal
on Tue, Jul 30 2013 6:41 AM

not able to work.:(

sanjeev agarwal
on Tue, Jul 30 2013 6:44 AM

i am using Infragistic12.1 and  Silverlight5

[Infragistics] Petar Monov
on Thu, May 22 2014 6:48 AM

Hello Sanjeev,

This exact situation is explained in the post: "The other major issue in Silverlight is the lack of the RenderTargetBitmap class that is used in WPF to extract the visual and also the PngBitmapEncoder and JpegBitmapEncoder classes is used in WPF to convert the extracted data to the needed format.  This where the Infragistics Reporting team steps in with the InfragisticsSL4.Reports.Imaging.v11.2 assembly. This has been created mainly to serve the NetAdvantage Reporting package in creating its xaml based reports, however I’ve managed to put it to another good use as per your demands. Actually the assembly provides simplified version of the above mentioned classes to be used in Silverlight and they go respectively: WriteableBitmap, PngImageEncoder, JpegImageEncoder. Using all that, I have created another sample project (XamPieChart_to_image.zip) that creates images out of the XamPieChart and exports them to: Excel, *.png and *jpg."

For this to work with Silverlight you need the Infragistics Reporting tools.