Page 1 of 1

Copy chart image to memory

Posted: Tue Jan 20, 2009 7:43 am
by 13051164
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,

Posted: Tue Jan 20, 2009 8:54 am
by narcis
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!

Posted: Tue Jan 20, 2009 9:48 am
by 13051164
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.

Posted: Tue Jan 20, 2009 9:50 am
by 13051164
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.

Posted: Tue Jan 20, 2009 10:03 am
by narcis
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.

Posted: Mon Jan 26, 2009 3:06 pm
by narcis
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.

Posted: Mon Jan 26, 2009 3:26 pm
by 13051164
Seems to work. Great!
Thanks for your help.