Using draw functions in reports

Sculptor’s draw functions are an interface to the Windows GDI (Graphics Device Interface) API. They can be used to draw figures, bitmaps, text and icons in a printed report.

A common use of the Windows GDI on a printer is to draw a pre-defined form, with company logos and other illustrations as required, without the need to use pre-printed paper. The design can be previewed on the screen by specifying a window_id. The draw operation is then performed in this window. The DrawImage() function is used to draw a graphic image at a specified location.

It is recommended that sys.Unit, the unit used to measure length and position for drawing operations, be set to UNIT_CMS (centimetres) or UNIT_INS (inches), and not to UNIT_DEV (device units, the default value), when drawing lines and other shapes on a printer. If device units are used, then, for example, a line that is 400 device units long will turn out 2 inches long on a printer whose resolution is 200 dots per inch, but 4 inches long on a printer whose resolution is 100 dots per inch. See Device unit.

In order that draw functions can be easily mixed with Sculptor print[h] commands in reports, the getprintxy() and setprintxy() functions are provided to retrieve and set the current print position. Note that sys.Unit must be set to UNIT_DEV (0) if these functions are to work correctly.


EXAMPLE

This example illustrates the use of the ImageSize() and DrawImage() functions in a report:

!temp Height,,r8
!temp Width,,r8
!temp Ratio,,r8
!temp Image,,a255

     sys.Unit = UNIT_INS
     Image = "C:/graphics/Logo.bmp"
     ImageSize(NULL, Image, Width, Height)
     Ratio = Width / Height

     if (Width > 8) {
          Ratio = Width / Height
          Width = 8
          Height = Width / Ratio
    }

     DrawImage(NULL, (8.0 - Width) / 2, 0, Width, Height, Image)

RELATED TOPICS

Reports

Drawing operations

Draw functions