Env.: VS2008 / .NET 2.0 / C# / TChart 3.5.3330.21114
Hi,
I have 3D tower chart that continuously receives new points.
I need to periodically (every 1 second) take a copy of the chart image (in memory) to asynchronously display it elsewhere in my app. It must be fast because I'm also displaying live video and the video image must keep smooth.
Using your advice, I use this kind of code:
public Bitmap screenShot;
In my timer handler:
screenShot= tChart1.Bitmap;
It appears that this bitmap copy is farily slow. Typically 100 msec, which is not acceptable because it affects the smoothness of video rendering.
Can you recommend another method to make this image copies faster?
FWIW, I sent a sample project to show the problem at your upload page. Clicking button1 takes a screenshot and display the time consumed by the operation.
TIA,
Serge.
fast chart screenshot needed
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Serge,
Thanks for the example project. I checked that drawing a chart takes twice as long as capturing a Bitmap of it (see code below). TeeChart is pretty quick here. This is basic TeeChart functionality, performance is always in mind and profiling software is used regularly to optimise it.
Thanks for the example project. I checked that drawing a chart takes twice as long as capturing a Bitmap of it (see code below). TeeChart is pretty quick here. This is basic TeeChart functionality, performance is always in mind and profiling software is used regularly to optimise it.
Code: Select all
private System.Diagnostics.Stopwatch stopWatch;
void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
stopWatch.Stop();
TimeSpan elapsedTime = stopWatch.Elapsed;
label1.Text = elapsedTime.TotalMilliseconds.ToString();
}
void tChart1_BeforeDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
stopWatch = new System.Diagnostics.Stopwatch();
stopWatch.Reset();
stopWatch.Start();
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Newbie
- Posts: 22
- Joined: Tue Dec 16, 2008 12:00 am
Narcís,
I'm afraid I don't get you!? In my case, performance is an issue. And clearly, 100msec to take a copy of a bitmap is not acceptable.
Let me re-state my requirements:
- The program continously fills in the tower chart with real time data (1 point added or modified every 100 msec).
- Every second, I need to take a screenshot of the chart to display it in a video image that is being recorded.
- In order to avoid redrawing the whole chart every second (obviously, that would take some time), I maintain a chart object in a hidden form so that when it's time to take a screenshot of the chart, the whole drawing is already there, ready to be blitted into a bitmap. Roughly, nothing more than a video memory buffer copy.
How can I achieve this efficiently
TIA,
Serge.
I'm afraid I don't get you!? In my case, performance is an issue. And clearly, 100msec to take a copy of a bitmap is not acceptable.
Let me re-state my requirements:
- The program continously fills in the tower chart with real time data (1 point added or modified every 100 msec).
- Every second, I need to take a screenshot of the chart to display it in a video image that is being recorded.
- In order to avoid redrawing the whole chart every second (obviously, that would take some time), I maintain a chart object in a hidden form so that when it's time to take a screenshot of the chart, the whole drawing is already there, ready to be blitted into a bitmap. Roughly, nothing more than a video memory buffer copy.
How can I achieve this efficiently
TIA,
Serge.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Serge,
You should note that a copy of a bitmap is not taken. There is no bitmap to copy. The time taken is for the chart to draw itself to a bitmap, which is not the same as "taking a copy of a bitmap". Also, TeeChart is faster exporting itself to a bitmap than it is drawing itself to the screen as it does on a WinForm, for example. This indicates that the code that exports to bitmap is already highly optimised.
Performance will also depend on the hardware you are using. For example, in the tests I made here, using a machine with an Intel Core 2 Quad 6600 CPU, 4 GB RAM and NVIDIA GeForce 8500 GT graphic card, drawing the chart to a bitmap took around 70 ms. and drawing to the screen took around 140 ms.
Finally, TeeChart can easily generate a video by itself using new VideoTool which will be included in next TeeChart for .NET major release. I'll send you an e-mail with the details to download the beta version.
You should note that a copy of a bitmap is not taken. There is no bitmap to copy. The time taken is for the chart to draw itself to a bitmap, which is not the same as "taking a copy of a bitmap". Also, TeeChart is faster exporting itself to a bitmap than it is drawing itself to the screen as it does on a WinForm, for example. This indicates that the code that exports to bitmap is already highly optimised.
Performance will also depend on the hardware you are using. For example, in the tests I made here, using a machine with an Intel Core 2 Quad 6600 CPU, 4 GB RAM and NVIDIA GeForce 8500 GT graphic card, drawing the chart to a bitmap took around 70 ms. and drawing to the screen took around 140 ms.
Finally, TeeChart can easily generate a video by itself using new VideoTool which will be included in next TeeChart for .NET major release. I'll send you an e-mail with the details to download the beta version.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Newbie
- Posts: 22
- Joined: Tue Dec 16, 2008 12:00 am
Narcís,
Thanks for your reply.
Regarding the video, the app does more than that: It captures and combine the input from 2 cameras (720x576 pixels each) + sound from a microphone. It also collects data from a measurement equipment. It adds various texts and drawing to each video frame (including a copy of the chart). And it encodes the whole thing as a DIVX movie. And all this goes fairly fine on a 1.5GHz Tablet PC.
25 frames/sec, that's 1 frame every 40msec.
Hence I'm surprised to read that "simply" copying a chart takes nearly as much time as the whole processing of 3 frames (and it's measured on my big dev machine, not on the much lighter Tablet PC). OK, you tell me that copying the chart is actually drawing the chart.
In addition, a former version of this program writen in Delphi5 and using the free version of TChart never suffered from this problem (it was not using a tower series but a set of 41 lines series to simulate the tower).
Any idea you may have to help optimize this will be much appreciated.
Thanks for your reply.
Regarding the video, the app does more than that: It captures and combine the input from 2 cameras (720x576 pixels each) + sound from a microphone. It also collects data from a measurement equipment. It adds various texts and drawing to each video frame (including a copy of the chart). And it encodes the whole thing as a DIVX movie. And all this goes fairly fine on a 1.5GHz Tablet PC.
25 frames/sec, that's 1 frame every 40msec.
Hence I'm surprised to read that "simply" copying a chart takes nearly as much time as the whole processing of 3 frames (and it's measured on my big dev machine, not on the much lighter Tablet PC). OK, you tell me that copying the chart is actually drawing the chart.
In addition, a former version of this program writen in Delphi5 and using the free version of TChart never suffered from this problem (it was not using a tower series but a set of 41 lines series to simulate the tower).
Any idea you may have to help optimize this will be much appreciated.
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Serge,
We don't think TeeChart for .NET will be able to perform like this. In that case you could try using TeeChart Pro v8 ActiveX, which can be used in Visual Studio .NET, and may be quicker in that field. You can download a fully functional evaluation version here:
http://www.steema.com/downloads/form_ax_eval.html
We don't think TeeChart for .NET will be able to perform like this. In that case you could try using TeeChart Pro v8 ActiveX, which can be used in Visual Studio .NET, and may be quicker in that field. You can download a fully functional evaluation version here:
http://www.steema.com/downloads/form_ax_eval.html
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |