Microsoft KB Archive/42979
Article ID: 42979
Article Last Modified on 11/21/2006
This article was previously published under Q42979
The program below gives an example of how to store a large graphics image permanently to a disk file and then read it back and print it to a full page on a printer. The purpose of this example is to combine various programming ideas into one practical illustration.
The program below has been successfully tested in QuickBASIC Version 1.00 for Macintosh on Finder Version 6.0 and System Version 4.2, with both normal and sideways (landscape) options on the following printers:
- Apple ImageWriter II, using ImageWriter driver Version 2.7
- Apple LaserWriter II NTX, using LaserWriter driver Version 5.2
' The output window must be defined large enough for the image, or ' else printer output will truncate to the size of the window: WINDOW 1,,(1,1)-(510,750) PICTURE ON ' Turns on recording of a picture WIDTH 255 SHOWPEN ' Lets you see picture as you draw and record it. TEXTFONT 5 : TEXTSIZE 12 ' Font 5 is Venice if installed. PRINT "This draws a big X on a full printer page" LINE (1,1)-(500,740) LINE (500,1)-(1,740) PICTURE OFF temp$=PICTURE$ ' 32K is largest allowed image string. REM This section writes the image string to a sequential file. OPEN "imagefile" FOR OUTPUT AS #1 PRINT #1,temp$; CLOSE TEMP$="" ' Clears the string which stores the image in memory. REM This section retrieves the image from the disk file "imagefile" OPEN "imagefile" FOR INPUT AS #2 b$=INPUT$(LOF(2),2) ' Input all bytes into a string, b$ CLOSE CLS ' Clear the screen PICTURE,b$ ' Redraw stored image REM This section writes the retrieved image to the printer: OPEN "LPT1:PROMPT" FOR OUTPUT AS #3 ' At the printer prompt, click normal or sideways printing, etc. WINDOW OUTPUT #3 ' Redirects subsequent screen output to device #3 PICTURE,B$ ' Draw the picture. CLOSE ' Picture is sent to printer after you CLOSE #3.
Additional query words: MQuickB