ContentsIndexPreviousNext

WINPRINT-PRINT-BITMAP

This operation code prints a bitmap in the current report.

Usage

CALL "WIN$PRINTER"
    USING WINPRINT-PRINT-BITMAP, WINPRINT-DATA
    GIVING RESULT

Parameters

WINPRINT-DATA Group item defined in "winprint.def" as follows:

01 WINPRINT-DATA.
   03 WPRTDATA-SET-STD-FONT.
   03 WPRTDATA-PRINT-BITMAP REDEFINES
      WPRTDATA-SET-STD-FONT.
      05 WPRTDATA-BITMAP               PIC X(4) COMP-N.
      05 WPRTDATA-BITMAP-ROW           PIC 9(7)V99 COMP-5.
      05 WPRTDATA-BITMAP-COL           PIC 9(7)V99 COMP-5.
      05 WPRTDATA-BITMAP-HEIGHT        PIC 9(7)V99 COMP-5.
      05 WPRTDATA-BITMAP-WIDTH         PIC 9(7)V99 COMP-5.
      05 WPRTDATA-BITMAP-FLAGS         UNSIGNED-SHORT.

Description

The print file must be open when you are using this function. The bitmap is printed according to the data contained in WPRTDATA-PRINT-BITMAP. To ensure that elements are initialized to their default values, you should always INITIALIZE WPRTDATA-PRINT-BITMAP before filling in the elements.

WPRTDATA-BITMAP should contain the handle of the bitmap you want to print. You can obtain this handle by calling the library routine W$BITMAP with the WBITMAP-LOAD option. This can be the same handle as the handle of the bitmap you have displayed on the screen.

The upper left corner of the bitmap is located at the position specified by WPRTDATA-BITMAP-ROW and WPRTDATA-BITMAP-COL. These elements identify the row and column of the report. The currently selected font for the printer determine the rows and columns. The top left corner of the report is row 1, column 1. You can also use fractional rows and columns, but if you specify a row or column less than 1, then the bitmap is placed at row 1, column 1.

Many printers have much higher resolution than screens do. For example, many laser printers can print 300 or 600 dots per inch while most screens display less than 100 pixels per inch. An image that is 1024 pixels wide would fill or overflow many screens, but would be less than 2 inches wide on a 600 DPI printer. For this reason, bitmaps are usually scaled when they are printed. By default, the runtime scales the image so that the relative proportions of the printed image match those of the same image when it is viewed on the screen.

Scaling a bitmap

You can scale a bitmap to a particular size. First you must select a unit of measurement by which to calculate the bitmap's dimensions. The units are determined by WPRTDATA-BITMAP-FLAGS settings. One of the following values is used:

WPRTBITMAP-SCALE-CELLS - the height and width correspond to rows and column in the report.

WPRTBITMAP-SCALE-INCHES - the units represent inches on the printed page.

WPRTBITMAP-SCALE-CENTIMETERS - the units represent centimeters on the printed page.

WPRTBITMAP-SCALE-PIXELS - the units are printer pixels. In this case, fractional values are ignored.

Then you can set the desired size of the bitmap in WPRTDATA-BITMAP-WIDTH and WPRTDATA-BITMAP-HEIGHT.

You can either set both dimensions or leave one dimension at zero. When one of the dimensions is set to zero, it is computed to keep the relative proportions of the image unchanged after scaling in the other dimension.

You can inhibit the scaling done by the runtime by setting WPRTDATA-BITMAP-FLAGS to WPRTBITMAP-PRINTER-BITMAP. This informs the runtime that the bitmap was designed directly for printing on the current printer and should not be scaled. You can also add the value of WPRTDATA-BITMAP-FLAGS to the other scaling options discussed above to prevent the runtime from performing an adjustment to the scaling. Adjustments are usually done to account for the difference in the relative proportions of the screen's X and Y density in comparison to the printer's X and Y density. Some devices have a much higher resolution in one dimension than the other. This adjustment handles the changes needed when you are viewing a screen image on a printer. Most applications, however, should avoid this option because most bitmaps are meant to be displayed on the screen only.

Colors in the bitmap image are preserved by the runtime. It is up to the printer's driver to decide how to print color images on a black-and-white device. Most drivers turn colors into varying shades of gray.

Example:

The following sample code prints the ACUCOBOL-GT workbench logo in the center of an 80-character print line. It scales the image to be 30 characters wide to simplify the centering computation. This example assumes that the printer is already open:

77  LOGO-HANDLE  PIC S9(9) COMP-4.
        :
        :
CALL "W$BITMAP" USING WBITMAP-LOAD, "devsuite.bmp"
     GIVING LOGO-HANDLE
INITIALIZE WPRTDATA-PRINT-BITAMP
MOVE LOGO-HANDLE TO WPRTDATA-BITMAP
MOVE 1 TO WPRTDATA-BITMAP-ROW
MOVE 26 TO WPRTDATA-BITMAP-COL
MOVE 30 TO WPRTDATA-BITMAP-WIDTH

*Height left at zero

MOVE WPRTBITMAP-SCALE-CELLS
     TO WPRTDATA-BITMAP-FLAGS
CALL "WIN$PRINTER" USING WINPRINT-PRINT-BITMAP,
     WINPRINT-DATA
CALL "W$BITMAP" USING WBITMAP-DESTROY, LOGO-HANDLE