Page 1 of 1

Save charts as a bmp files without redrawing on screen?

Posted: Tue Jul 26, 2011 3:03 pm
by 16459883
Hello!

My application has a feature to allow the users to save a group of graphs as BMP files. Prior to calling Chart.SaveToBitmapFile, the code must redraw the chart on the screen. This goes slowly and we would like to eliminate the need to draw each graph prior to saving as a BMP.

Is there any way to update the canvas (or whatever is appropriate within the Chart object) and then save to a BMP without redrawing the graph on the screen?

Thanks,

Erzsebet

Re: Save charts as a bmp files without redrawing on screen?

Posted: Thu Jul 28, 2011 10:21 am
by yeray
Hello Erzsebet,

Do you have a testing application where the behavior is reproduced?

Re: Save charts as a bmp files without redrawing on screen?

Posted: Thu Jul 28, 2011 2:00 pm
by 16459883
Hello, Yeray -

No, I don't have an application where I'm doing this; I just wanted to know if it can be done. Right now our application goes through ever user selection and redraws the chart on the monitor before saving it to the BMP. This means that if the user has 100 selections, they have to sit and wait while 100 different charts are drawn on screen just for those charts to get sent to file. I was wondering if there was a way to go through the selections, update whatever TChart components need to be updated, and then send that information to file without having to redraw on the screen. Does that help clarify things any?

Thanks for thinking about my (sort of oddball!) question!

-erzsebet

Re: Save charts as a bmp files without redrawing on screen?

Posted: Fri Jul 29, 2011 9:55 am
by yeray
Hello Erzsebet,
erzsebet_carmean wrote:Thanks for thinking about my (sort of oddball!) question!
We've heard worse, you can believe me! ;)
erzsebet_carmean wrote: Does that help clarify things any?
Yes! Let me try to explain. First of all, TeeChart needs a parent to be drawn, and it needs to be drawn at least once to be exportable to an image. After it, if you don't modify the chart, the image generated internally should be reused everytime you export the chart.
But if you find any problem with it, please, don't hesitate to let us know.

Re: Save charts as a bmp files without redrawing on screen?

Posted: Fri Jul 29, 2011 2:24 pm
by 16459883
Yeray, hi!

Thanks for making me feel right at home here on the Steema forum & thanks, too, for the explanation of the TeeChart export to file mechanism.

-erzsebet

Re: Save charts as a bmp files without redrawing on screen?

Posted: Mon Aug 01, 2011 8:50 am
by yeray
Hi Erzsebet,

You're welcome!

Re: Save charts as a bmp files without redrawing on screen?

Posted: Sat Feb 25, 2017 9:30 pm
by 16879532
Well after some trial and error I understand that I first have to "actually see" the chart before I can successfully use SaveToBitmapFile.

The issue is that my application has different tabs. One of the tabs is the chart, another tab has a button with which I save, among other things, the chart to a file with SaveToBitmapFile. It works fine except when the chart is not "seen" before.

Apparently you have to draw the chart first. But I do not know how to do that. the aChart.draw(). Does not what I expect it should do. Do I have to add something to that command? What? Can you give a clear example?
Your help is appreciated.

Re: Save charts as a bmp files without redrawing on screen?

Posted: Mon Feb 27, 2017 7:27 am
by yeray
Hello,

With the current version the chart doesn't need a parent to be exported. This means you can export a chart that hasn't been seen. Ie, in a form with just a TButton you can do this:

Code: Select all

uses Chart, Series;

var Chart1: TChart;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1:=TChart.Create(Self);
  Chart1.AddSeries(TBarSeries).FillSampleValues();
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Chart1.SaveToBitmapFile('E:\tmp\Chart_NoParent.bmp');
end;