TeeChart MFA - How to Save Chart as Jpeg/Png Image

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
BVSimmons
Newbie
Newbie
Posts: 6
Joined: Wed Dec 12, 2012 12:00 am

TeeChart MFA - How to Save Chart as Jpeg/Png Image

Post by BVSimmons » Wed Jan 02, 2013 2:35 am

Hi,

Maybe I just missed this, but what I need to be able to do is to save the Chart as a .png or .jpeg image files so that I can e-mail as an attachment using TeeChart Mono for Android 2012 ?

I am open to alternative approaches.

Thanks

Bernard

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: TeeChart MFA - How to Save Chart as Jpeg/Png Image

Post by Narcís » Wed Jan 02, 2013 8:22 am

Hello Bernard,

This is not supported yet. Bitmap generation was implemented for the following maintenance release. No other image formats have been implemented yet. If you are interested I can send you a test version of the Bitmap export.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: TeeChart MFA - How to Save Chart as Jpeg/Png Image

Post by Narcís » Wed Jan 02, 2013 11:46 am

Hello Bernard,

Actually TChart.Bitmap had already been implemented in the assembly I sent you on 14th December 2012. A usage example can be found in ChartView.cs in the demo attached. That demo converts the Bitmap into a JPEG.

Hope this helps!
Attachments
MonoAndroidDemo.zip
(239 KiB) Downloaded 611 times
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

BVSimmons
Newbie
Newbie
Posts: 6
Joined: Wed Dec 12, 2012 12:00 am

Re: TeeChart MFA - How to Save Chart as Jpeg/Png Image

Post by BVSimmons » Tue Jan 08, 2013 11:39 pm

Sorry for the delay, your solution works just fine!!!!

I really appreciate it.

Thanks

Bernard

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: TeeChart MFA - How to Save Chart as Jpeg/Png Image

Post by Narcís » Wed Jan 09, 2013 8:04 am

Hi Bernard,

You're welcome. I'm glad to hear that, thanks for the feedback.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

BrianG
Newbie
Newbie
Posts: 5
Joined: Fri Feb 08, 2013 12:00 am

Re: TeeChart MFA - How to Save Chart as Jpeg/Png Image

Post by BrianG » Tue Feb 12, 2013 1:15 am

Hello Narcís,

If you have a build that allows exporting to bitmap and fixes defect TM63016457 (the pinch/zoom crash), I would be interested to try it out.

Regards,
Brian

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: TeeChart MFA - How to Save Chart as Jpeg/Png Image

Post by Narcís » Tue Feb 12, 2013 8:09 am

Hello Brian,

Yes, I just sent you an email with the URL to download that assembly.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

BrianG
Newbie
Newbie
Posts: 5
Joined: Fri Feb 08, 2013 12:00 am

Re: TeeChart MFA - How to Save Chart as Jpeg/Png Image

Post by BrianG » Wed Feb 13, 2013 1:21 am

Hello Narcís,

Thanks! The build seems to allow me to get the bitmap nicely, but after I get the bitmap the view no long seems to draw to the android device screen. Do I need to do something to the chart after getting the bitmap to make it draw to the screen again? I noticed the .Draw(canvas) method seems to have similar behavior across several of the builds I tried; after it is called I don't see anything on the device screen.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: TeeChart MFA - How to Save Chart as Jpeg/Png Image

Post by Narcís » Wed Feb 13, 2013 9:43 am

Hello Brian,

Which Zoom.Style setting are you using to reproduce this? Is your chart set to ZoomStyles.Classic? Does this occur with ZoomStyles.FullChart or ZoomStyles.InChart? You should create the bitmap after the chart has been added and painted to the view so that it has valid View dimensions the CreateBitmap method can use, for example: in a button, a touch event, menu option, etc.

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

BrianG
Newbie
Newbie
Posts: 5
Joined: Fri Feb 08, 2013 12:00 am

Re: TeeChart MFA - How to Save Chart as Jpeg/Png Image

Post by BrianG » Thu Feb 14, 2013 1:03 am

Hello Narcís,

I set Zoom.Style to ZoomStyles.FullChart and found that when I set up the chart and draw the bitmap in my activity OnCreate, the chart view appears to be empty (no chart background, title, etc). When I instead give data to the chart later from a button press and follow this with bitmap creation through the .Draw(canvas, Rect) method, the chart's view is present but appears as it did before I added data (the title and background show), where the bitmap looks correct; when I remove the .Draw call, the data appears on the device again.

I did find that of course simply creating a new chart and disposing of the old one after creating a bitmap makes the chart appear again on the device, so this is the approach I am using for now.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: TeeChart MFA - How to Save Chart as Jpeg/Png Image

Post by Narcís » Thu Feb 14, 2013 8:12 am

Hello Brian,

Creating the Bitmap as in the code below works fine for me. Does it work at your end? Could you please attach a simple example project we can run "as-is" to reproduce the problem here?

Code: Select all

    void tChart1_Touch(object sender, View.TouchEventArgs e)
    {
      Android.Graphics.Bitmap bmp = tChart1.Bitmap;
    }
Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply