Search Locate Previous Next Contents

ch.Bitmap – add images to charts

This function allows you to add raster images anywhere on the chart. It takes the image filename and the required (x,y) position as argument:


ch.Plot ¼12              
ch.Bitmap'ettons' (5 5)
View ch.Close

This will position the bitmap with the lower left corner at x=5, y=5 reference the chart axes. The extension ‘.bmp’ is assumed if you do not specify the filetype. For SVG output, you should use .PNG or .JPG only here; for PDF output, .BMP is the only supported format for PDFs.

This assumes that the picture is a screen shot at 96dpi – if you have a photograph scanned at 300dpi, pass this as the third element in the second argument:

ch.Bitmap'backdrop' (5 5 300)

The picture will now be much smaller. Note that if you call this function before you have plotted any charts, the entire chart area has notional axes of x=0–432, y=0–324. This is probably the most convenient point to call ch.Bitmap to add an element such as a company logo to your chart. However you will need to set the ‘nowipe’ style to prevent the first chart from clearing the plotting region:

ch.Bitmap'mylogo' (2 2 300)
ch.Set 'nowipe' ª ch.Plot ¼12

This adds the logo in the lower left corner of the chart. If you use -ve positions they are interpreted as the distance from the opposite corner of the chart area, so to place your logo in the top left corner:

ch.Bitmap 'mylogo' 10 ¯10

Note that you may omit the extra level of nesting in the function argument if you prefer.

Including images with VML or SVG
When the finished chart is saved as an SVG or VML graphic, the image is not actually included in the generated file. Instead, RainPro builds a link tag so that the browser will call back to the server to retrieve the image. The path that is required for this file may well be quite different to the name of the physical file which RainPro also needs in order to extract the width and height information from it. To allow for both possibilities, you can include two names here, separated with the ‘pipe’ character:

ch.Bitmap 'c:\realpath\pix\mylogo.png|../pix/mylogo.png' 10 ¯10

RainPro will use the first name to check the file, and the second as the reference in the link tag for SVG and VML. In the case of a rendered PNG image or PDF output for the finished chart, the first file will always be used. Of course you could give a completely different filename here, but if you do this, be sure it has the same size otherwise SVG will scale it to fit the wrong width and height.



Continue to: ch.Bookmark – add outline entry for chart
© Copyright Causeway Graphical Systems Ltd 2003