Exporting a Chart to a JPEG

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
stevelw
Newbie
Newbie
Posts: 6
Joined: Thu Feb 12, 2004 5:00 am
Location: Manchester, U.K.

Exporting a Chart to a JPEG

Post by stevelw » Tue Mar 09, 2004 8:37 pm

I can export a graph from within the IDE to JPEG, but I can't work out how to do it programatically.

I need to specify the image size as well as the location\filename. Can anyone point me in the right direction?

Thanks

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Tue Mar 09, 2004 9:12 pm

Hi,.

There is an example available at our FAQ pages. Check the following
link
The example is for GIF format, but very similar code can be used with JPEG format:

Code: Select all

 Uses TeeJPEG;
  begin
    With TJPEGExportFormat.Create(Self) do
    begin
      Panel := Chart1;
      Width := 300;
      Height := 300;
      SaveToFile('ChartImage.jpg');
    finally
      Free;
    end
  end
Marjan Slatinek,
http://www.steema.com

stevelw
Newbie
Newbie
Posts: 6
Joined: Thu Feb 12, 2004 5:00 am
Location: Manchester, U.K.

Post by stevelw » Sat Mar 13, 2004 11:12 am

Great. This work just fine. Thanks.

One further, and hopefully equally simple, followup. How can I modify the code to save all pages of a multi-page chart to separate JPG files?

Thanks

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Sun Mar 14, 2004 4:15 pm

Hi, Steve.

Save each page to a seperate file ? If this is the case then simply call the export for each page.
If on the other hand you're trying to save multiple charts to a sigle jpeg file (image), then the only solution is to create a temporary bitmap, then paint each page on section of this bitmap and then finally convert/export this temporary bitmap to jpeg file. I think a similar problem has been discussed and solved in this forum (for metafiles, but the same approach can be used for other formats).
Marjan Slatinek,
http://www.steema.com

Post Reply