home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
001-099
/
ff005.lzh
/
printer
/
printer.c
next >
Wrap
C/C++ Source or Header
|
1986-01-11
|
5KB
|
123 lines
/*
*
* DISCLAIMER:
*
* This program is provided as a service to the programmer
* community to demonstrate one or more features of the Amiga
* personal computer. These code samples may be freely used
* for commercial or noncommercial purposes.
*
* Commodore Electronics, Ltd ("Commodore") makes no
* warranties, either expressed or implied, with respect
* to the program described herein, its quality, performance,
* merchantability, or fitness for any particular purpose.
* This program is provided "as is" and the entire risk
* as to its quality and performance is with the user.
* Should the program prove defective following its
* purchase, the user (and not the creator of the program,
* Commodore, their distributors or their retailers)
* assumes the entire cost of all necessary damages. In
* no event will Commodore be liable for direct, indirect,
* incidental or consequential damages resulting from any
* defect in the program even if it has been advised of the
* possibility of such damages. Some laws do not allow
* the exclusion or limitation of implied warranties or
* liabilities for incidental or consequential damages,
* so the above limitation or exclusion may not apply.
*
*/
/* printer.c - program to do a raster dump to whatever printer is specified
* by Preferences, of the Workbench Screen.
*
* Author: Rob Peck, 12/1/85
*
* This code may be freely utilized to develop programs for the Amiga
*/
#include "exec/types.h"
#include "intuition/intuition.h"
#include "devices/printer.h"
#define INTUITION_WONT_OPEN 1000
union printerIO {
struct IOStdReq ios;
struct IODRPReq iodrp;
struct IOPrtCmdReq iopc;
};
union printerIO *request; /* a pointer to a request block */
extern int DumpRPort();
extern struct IORequest *CreateExtIO();
extern struct Window *OpenWindow();
extern struct Port *CreatePort();
struct IntuitionBase *IntuitionBase;
struct NewWindow nw = {
0, 0, 100, 40, 0, 1, 0, 0, NULL, NULL, NULL, NULL, NULL,
0, 0, 0, 0, WBENCHSCREEN
};
main()
{
struct Window *w;
struct Screen *screen;
struct RastPort *rp;
struct ViewPort *vp;
struct ColorMap *cm;
union printerIO sizeDummy;
int modes,width,height,error;
struct Port *printerPort; /* at which to receive reply */
IntuitionBase = (struct IntuitionBase *)OpenLibrary(
"intuition.library", 0);
if (IntuitionBase == NULL) exit(INTUITION_WONT_OPEN);
w = OpenWindow(&nw);
if(w == NULL) goto cleanup1;
screen = w->WScreen; /* get screen address from window */
CloseWindow(w); /* once have screen address, no
* more need for window, close it.
*/
vp = &screen->ViewPort; /* get screen's ViewPort, from
* which the colormap will be gotten */
rp = &screen->RastPort; /* get screen's RastPort, which
* is what gets dumped to printer */
cm = vp->ColorMap; /* retrieve pointer to colormap for
* the printer dump */
modes = vp->Modes; /* retrieve the modes variable */
width = vp->DWidth; /* retrieve width to print */
height = vp->DHeight; /* retrieve height to print */
printerPort = CreatePort("my.print.port",0);
request = (union printerIO *)CreateExtIO(printerPort,
sizeof(sizeDummy));
error = OpenPrinter(request);
if(error != 0) goto cleanup2;
Delay(300); /* 300/60 = 6 seconds delay before it starts */
error = DumpRPort(
request,/* pointer to initialized request */
rp, /* rastport pointer */
cm, /* color map pointer */
modes, /* low, high res, etc (display modes)*/
0, 0, /* x and y offsets into rastport */
width,height, /* source size */
width,(height * 2), /* dest rows, columns */
SPECIAL_FULLROWS
| SPECIAL_FULLCOLS
| SPECIAL_ASPECT /* io Special value, says print
* as pixels only, direct copy */
);
ClosePrinter(request);
cleanup2:
DeleteExtIO(request, sizeof(sizeDummy));
DeletePort(printerPort);
cleanup1:
CloseLibrary(IntuitionBase);
} /* end of demo screen dump */