Page 1 of 1

Exporting a Chart to a JPEG

Posted: Tue Mar 09, 2004 8:37 pm
by 8442827
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

Posted: Tue Mar 09, 2004 9:12 pm
by Marjan
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

Posted: Sat Mar 13, 2004 11:12 am
by 8442827
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

Posted: Sun Mar 14, 2004 4:15 pm
by Marjan
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).