This operation code prints a bitmap in the current report.
CALL "WIN$PRINTER" USING WINPRINT-PRINT-BITMAP, WINPRINT-DATA GIVING RESULT
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. |
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, 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 handle can be the same as the handle of the bitmap you have displayed on the screen.
The dimensions of the bitmap are specified by WPRTDATA-BITMAP-HEIGHT and WPRTDATA-BITMAP-WIDTH. The unit of measurement by which the size of the bitmap is calculated is set with WPRTDATA-BITMAP-FLAGS. One of the following values is used:
WPRTBITMAP-SCALE-CELLS | the height and width of a cell depends on the number of rows and columns in the report. The currently selected font for the printer determines the number of rows and columns on a page. The top left corner of a report is row 1, column 1. You may 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. |
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 based on the resolution of the output device. This is measured in dots-per-inch (DPI). Fractional values are ignored. |
The location of the top left corner of a bitmap is specified by WPRTDATA-BITMAP-ROW and WPRTDATA-BITMAP-COL. By default, this coordinate is specified in cells. You may choose to use another unit of measurement by setting WPRTDATA-BITMAP-FLAGS to one of the following values (defined in winprint.def):
WPRTBITMAP-UNITS-INCHES | Values are measured in inches. |
WPRTBITMAP-UNITS-CENTIMETERS | Values are measured in centimeters. |
WPRTBITMAP-UNITS-PIXELS | Values are measured using the dots-per-inch (DPI) resolution of the output device. Only integer values are allowed.
The actual size of this measurement varies depending on the target printer's resolution. Consider the unit of measure relative to the resolution of the targeting printer before printing. |
WPRTBITMAP-UNITS-CELLS-ABS | Values are measured in cells, and the position of the bitmap is based on the left edge of the paper, regardless of the physical left margin determined by the printer (even if the absolute position is smaller). |
WPRTBITMAP-UNITS-INCHES-ABS | Values are measured in inches and the position of the bitmap is based on the left edge of the paper, regardless of the physical left margin determined by the printer (even if the absolute position is smaller). |
WPRTBITMAP-UNITS-CENTIMETERS-ABS | Values are measured in centimeters and the position of the bitmap is based on the left edge of the paper, regardless of the physical left margin determined by the printer (even if the absolute position is smaller). |
This is illustrated in Example 2, below.
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.
To scale a bitmap to a particular size, you must set WPRTDATA-BITMAP-FLAGS to the desired unit of measure (cells, inches, centimeters, or pixels). Then set the desired dimensions 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, the relative proportions of the image are unchanged after the scaling of the other dimension is complete.
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.
The following sample code prints the AcuBench 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-BITMAP 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
The following example code scales a bitmap to be 3-by-3 inches square, and places the top left corner 10 centimeters away from both the left and top margins. This example assumes that the printer is already open:
77 LOGO-HANDLE PIC S9(9) COMP-4. : : CALL "W$BITMAP" USING WBITMAP-LOAD, "your_bitmap.bmp" GIVING LOGO-HANDLE INITIALIZE WPRTDATA-PRINT-BITMAP MOVE LOGO-HANDLE TO WPRTDATA-BITMAP MOVE 10 TO WPRTDATA-BITMAP-ROW WPRTDATA-BITMAP-COL. MOVE 3 TO WPRTDATA-BITMAP-HEIGHT WPRTDATA-BITMAP-WIDTH. MOVE WPRTBITMAP-SCALE-INCHES TO WPRTDATA-BITMAP-FLAGS. ADD WPRTBITMAP-UNITS-CENTIMETERS TO WPRTDATA-BITMAP-FLAGS. CALL "WIN$PRINTER" USING WINPRINT-PRINT-BITMAP, WINPRINT-DATA CALL "W$BITMAP" USING WBITMAP-DESTROY, LOGO-HANDLE