Bartl,
You never entirely master this subject!
If you have a %gr area on the screen, then you have a whole set of subroutine calls to draw to it. In my case, I have these wrapped up in a nested set of subroutines. Once you have opened the printer for graphics output, then basically all you have to do is to select the graphics object that is the printout, go through all the graphics commands again, and then update or close the printer. If all the graphics commands are obtained by calling the entry point to that nested set of subroutines, then it is in principle a very simple activity.
What makes it difficult is that the printer page contains a lot more pixels than the screen, and has a higher resolution. All printers are different, but there are fewer options for dots per inch (dpi).
Here is a code fragment:
IB = OPEN_PRINTER@ (jHDC)
IF (IB .EQ. 0) GO TO 5
CALL SET_CLEARWIN_STRING@(PRINTER_DOCUMENT, 'Bartl graphic')
CALL GET_CURRENT_DC@ (jHDC)
CALL USE_RGB_COLOURS@(0,1)
C CALL USE_RGB_COLOURS@(0,.true.) ! this is the same !
C
C This is a printer. It would like to use colour indices 0..15. To
C force it to use RGB colours, we need the above call. Now it is
C the same as the screen. (Not obvious!!!!) .
C
ixdpi = GetDeviceCaps(jHDC, LOGPIXELSX)
iydpi = GetDeviceCaps(jHDC, LOGPIXELSY)
jXRES = GetDeviceCaps(jHDC, HORZRES)
jYRES = GetDeviceCaps(jHDC, VERTRES)
C This is about very hi-res printers. Since the line thickness is
C specified in pixels, lines get very thin with 1200 or 1440 dpi
C modes. I haven't looked at all modes, but have gone for more
C than Epson 720 dpi mode. This should be OK for HP printers
C which have 150, 300, 600 and possibly 1200 dpi modes
C .
ISCALE = 1
IF (IXDPI .GT. 700) THEN
ISCALE = 5
ELSE IF (IXDPI .GT. 1100) THEN
ISCALE = 9
ENDIF
CALL SET_LINE_WIDTH@(ISCALE) ! one pixel lines are rubbish !
C At this point, you need to work out how many of the available
C pixels you want to use - all of them or is the image taking up
C only part of the page? At some point you need to work out the
C scaling factors (units per pixel) for this. There may be
C multiple scales e.g. m/pixel, kN/pixel etc
C ... New_Page@ flashes the image to the printer, as
C does Close_Printer@
CALL IMAGE (jHDC, jXRES, jYRES, SCALE) ! also add position
CALL CLOSE_PRINTER@ (jHDC)
CALL POPOK ('Image sent to printer')
Bitmap_FUNCTION=1
RETURN
IMAGE is my routine for drawing an image. I find it useful to tell the user that the print has been done - after all, the printer might even be in a different room ...
SUBROUTINE POPOK(TEXT)
C ----------------------
INCLUDE <WINDOWS.INS>
CHARACTER*(*) TEXT
IA=WINIO@('%ca[For Information]&')
IA=WINIO@('%bg[white]&')
IA = WINIO@('%cn%si*'//TEXT//'&')
IA=WINIO@('%2nl%cn%`7bt[OK]')
RETURN
END
I'll post the continuation in a new post ...