Page 1 of 1

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

Posted: Wed Jan 02, 2013 2:35 am
by 17364373
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

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

Posted: Wed Jan 02, 2013 8:22 am
by narcis
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.

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

Posted: Wed Jan 02, 2013 11:46 am
by narcis
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!

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

Posted: Tue Jan 08, 2013 11:39 pm
by 17364373
Sorry for the delay, your solution works just fine!!!!

I really appreciate it.

Thanks

Bernard

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

Posted: Wed Jan 09, 2013 8:04 am
by narcis
Hi Bernard,

You're welcome. I'm glad to hear that, thanks for the feedback.

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

Posted: Tue Feb 12, 2013 1:15 am
by 17364964
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

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

Posted: Tue Feb 12, 2013 8:09 am
by narcis
Hello Brian,

Yes, I just sent you an email with the URL to download that assembly.

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

Posted: Wed Feb 13, 2013 1:21 am
by 17364964
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.

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

Posted: Wed Feb 13, 2013 9:43 am
by narcis
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.

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

Posted: Thu Feb 14, 2013 1:03 am
by 17364964
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.

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

Posted: Thu Feb 14, 2013 8:12 am
by narcis
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.