help
 
--> GROWTH CHARTS | Back to startpage
Program
Growth Charts - All
Date of support information
2004-11-15
Support #
 
Topic
Example: How to export a JPG file
   
Introduction
This example source code shows you how to ask the GrowthChart control to export a JPG image with a given size.


Note!
This is not a standard feature of the component, and may not be available in your version.
 
Source code example, Delphi
procedure TMyApplication.BtnExportJpgClick(Sender: TObject);
//Export a JPG image of the graph
Var
  myFileName : String;
  myWidth, myHeight : integer;
  myLineDrawStyle : integer;
begin
  myFileName := 'c:\temp\chart.jpg';
  myWidth := 210;
  myHeight := 297;
  myLineDrawStyle := 0;  //0=ldsDefault, 1=ldsDotted or 2=ldsDithered
  GrowthChart.ExportAsJPEG(myFileName, myWidth, myHeight, myLineDrawStyle);
end;
Source code example, Visual Basic
Private Sub CommandButton1_Click()
XUSGraph1.ExportAsJPEG "c:\temp\usgraph.jpeg", 210, 297,ldsDithered
End Sub



Note!
In order to maintain a good print result of the gray lines used in the background three options are provided. These options are normally available in the lower left corner of the Print dialog, but when you call the ExportAsJpeg method you must specify which type of line drawing emulation you would like to use.

ldsDefault Gray colors are printed as gray and the printer will do it's own conversion. This mode means that the light gray lines are sometimes translated into dotted lines of different widths. In some cases the lines may even disappear completely. The light gray lines may even come out as solid black. HP printers are particularly difficult with this option set to Default. 
ldsDithered With this option set the growth chart component will do the translation of light gray into a B&W pattern which looks like light gray. The advantage of this mode over the Dotted is that the background appears somewhat lighter.
ldsDotted With this option set light gray lines will be printed using equally sized dots, approximately 0.5 mm long. This is the mode used by the original paper growth charts provided by Socialstyrelsen.

Display in an HTML page

If you wish to display the JPG image in an HTML page it is important to generate a JPG file which corresponds to the size in which you would like to display the image. If you do not respect this rule your browser will resize the image and the result may not be accurate.

For display on screen a width of 550 pixels may be appropriate.

If you want to print the image and come as close as possible to the original quality of the growth chart you will need to specify a much larger image. An image size such as 2100 x 2970 pixels generates an image of acceptable quality for A4 printouts.

Generate the image and present it in an HTML page similar to the example below:

<html>
<body>
<img border="0" src="c:\temp\chart.jpg" align="left" width="770" height="1100">
</body>
</html>

In order to obtain an image of maximum size you will have to adapt the margins set in your browser.