Adding a graphic
The basic idea is to
procedure TWebModule1.PlotSpectra();
var
i : integer ;
ar : array[0..315] of single ;
xx : TMemoryStream ;
image1 : TBitMap ;
JPEG_image : TJpegImage ;
begin
xx := TMemoryStream.Create;
image1 := TBitMap.create;
image1.Height := 200;
image1.Width := 400;
JPEG_image := TJpegImage.Create ;
try
// Read the data and place it in an array
(IBTable2.FieldByName('SPECTRUM_Y') as TBlobField).SaveToStream(xx) ; // read a blob
xx.Position := 0;
xx.Read(ar, 316*4);
// Draw the plot
image1.Canvas.FillRect(Rect(0,0,image1.Width, image1.Height));
Image1.Canvas.MoveTo(0, 0);
for i := 0 to 315 do begin
Image1.Canvas.LineTo(i, trunc(ar[i] * image1.Height/50));
end;
// Save the jpeg file
JPEG_image.Assign(Image1) ;
JPEG_image.SaveToFile('Image_Path/spectra.jpeg');
finally
// if you create it, you must free it
image1.Free ;
JPEG_image.Free ;
xx.Free ;
end; // try
end;
This displays the spectra
' +
'
';
end;
In this example, only a single filename is used over and over. In reality, this won't work ... the new data will never be seen because the first image is stored in a cache and only the cached copy will be displayed. In the real code, each image is given a unique filename - then additional code is necessary to delete images which are over 2 hours old.
Image_Path