Copy chart image to memory

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
serge wautier
Newbie
Newbie
Posts: 22
Joined: Tue Dec 16, 2008 12:00 am

Copy chart image to memory

Post by serge wautier » Tue Jan 20, 2009 7:43 am

Hi,

My app contains a chart whose data is updated in real-time. In some corner of this app, I need to display a copy of this chart on graphics panel (aka canvas). This must be done several times per second.

Therefore I need to copy the image of the chart into an internal bitmap. NOT a file! (Well, saving a bitmap to file worked as a proof of concept but is not acceptable as a long term solution. Not efficient enough).

I have some old Delphi sample code that uses

Code: Select all

MyChart.TeeCreateBitmap()
. But I can't find this method in TChart .NET v3.5. The closest thing I could find is:

Code: Select all

TeeChart.Export.ImageExportFormat.Save(stream [, bitmap,width,height])
How can I use these 2 overrides? Am I on the right track?

TIA,

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

Post by Narcís » Tue Jan 20, 2009 8:54 am

Hi Serge,

In the .NET version you can do this:

Code: Select all

			Bitmap bmp = tChart1.Bitmap;
Or you can also draw directly to your own canvas using one of Draw method's overrides (tChart1.Draw(System.Drawing.Graphics)).

Hope this helps!
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

serge wautier
Newbie
Newbie
Posts: 22
Joined: Tue Dec 16, 2008 12:00 am

Post by serge wautier » Tue Jan 20, 2009 9:48 am

Ha! Amazingly simple!

I have a little issue though with transparency: chart.Bitmap doesn't reflect the transparent background of my chart. On the bitmap, the background is black.

I have a good enough workaround though: before drawing the bitmap, I specify that the top left corner pixel's color must be used as the transparent color.
However, if you know of a better solution, please let me know.

Thanks very much for your help.

serge wautier
Newbie
Newbie
Posts: 22
Joined: Tue Dec 16, 2008 12:00 am

Post by serge wautier » Tue Jan 20, 2009 9:50 am

I forgot to add that in my specific case, chart.Draw() cannot be used because rendering of the image occurs in a different UI thread.

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

Post by Narcís » Tue Jan 20, 2009 10:03 am

Hi Serge,
I have a little issue though with transparency: chart.Bitmap doesn't reflect the transparent background of my chart. On the bitmap, the background is black.

I have a good enough workaround though: before drawing the bitmap, I specify that the top left corner pixel's color must be used as the transparent color.
However, if you know of a better solution, please let me know.
I'm afraid not. This is a known issue (TF02013744), which was reported last week here.
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:

Post by Narcís » Mon Jan 26, 2009 3:06 pm

Hi Serge,

Please have a look at the status update I posted for this issue here:

http://www.teechart.net/support/viewtop ... 7173#37173

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

serge wautier
Newbie
Newbie
Posts: 22
Joined: Tue Dec 16, 2008 12:00 am

Post by serge wautier » Mon Jan 26, 2009 3:26 pm

Seems to work. Great!
Thanks for your help.

Post Reply