Save charts as a bmp files without redrawing on screen?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
erzsebet_carmean
Newbie
Newbie
Posts: 5
Joined: Fri Jul 22, 2011 12:00 am

Save charts as a bmp files without redrawing on screen?

Post by erzsebet_carmean » Tue Jul 26, 2011 3:03 pm

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

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

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

Post by Yeray » Thu Jul 28, 2011 10:21 am

Hello Erzsebet,

Do you have a testing application where the behavior is reproduced?
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

erzsebet_carmean
Newbie
Newbie
Posts: 5
Joined: Fri Jul 22, 2011 12:00 am

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

Post by erzsebet_carmean » Thu Jul 28, 2011 2:00 pm

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

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

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

Post by Yeray » Fri Jul 29, 2011 9:55 am

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.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

erzsebet_carmean
Newbie
Newbie
Posts: 5
Joined: Fri Jul 22, 2011 12:00 am

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

Post by erzsebet_carmean » Fri Jul 29, 2011 2:24 pm

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

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

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

Post by Yeray » Mon Aug 01, 2011 8:50 am

Hi Erzsebet,

You're welcome!
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

JCG_NL
Newbie
Newbie
Posts: 2
Joined: Fri Nov 04, 2016 12:00 am

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

Post by JCG_NL » Sat Feb 25, 2017 9:30 pm

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.

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

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

Post by Yeray » Mon Feb 27, 2017 7:27 am

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;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply