home *** CD-ROM | disk | FTP | other *** search
/ World of A1200 / World_Of_A1200.iso / datafiles / text / c_manual / devices / printerdevice / example4.c < prev    next >
C/C++ Source or Header  |  1995-02-27  |  26KB  |  658 lines

  1. /***********************************************************/
  2. /*                                                         */
  3. /* Amiga C Encyclopedia (ACE) V3.0      Amiga C Club (ACC) */
  4. /* -------------------------------      ------------------ */
  5. /*                                                         */
  6. /* Book:    ACM Devices                 Amiga C Club       */
  7. /* Chapter: Printer Device              Tulevagen 22       */
  8. /* File:    Example4.c                  181 41  LIDINGO    */
  9. /* Author:  Anders Bjerin               SWEDEN             */
  10. /* Date:    92-04-27                                       */
  11. /* Version: 1.00                                           */
  12. /*                                                         */
  13. /*   Copyright 1992, Anders Bjerin - Amiga C Club (ACC)    */
  14. /*                                                         */
  15. /* Registered members may use this program freely in their */
  16. /*     own commercial/noncommercial programs/articles.     */
  17. /*                                                         */
  18. /***********************************************************/
  19.  
  20.  
  21.  
  22. /* This example demonstrates how you can print graphics. */
  23. /* It will dump the workbench's Rastport to the printer. */
  24.  
  25.  
  26.  
  27. #include <intuition/intuition.h>
  28. #include <intuition/intuitionbase.h>
  29.  
  30. #include <exec/types.h>       /* Data types.             */
  31. #include <exec/errors.h>      /* Exec error messages.    */
  32. #include <devices/printer.h>  /* Printer Device.         */
  33. #include <exec/io.h>          /* Standard request block. */
  34.  
  35.  
  36.  
  37. /* Pointer to the Intuition Library: */
  38. struct IntuitionBase *IntuitionBase = NULL;
  39.  
  40. /* Declare how the printer request block look like: */
  41. union printerIO
  42. {
  43.   struct IOStdReq ios;
  44.   struct IODRPReq iodrp;
  45.   struct IOPrtCmdReq iopc;
  46. };
  47.  
  48. /* Declare a pointer to our reply port: */
  49. struct MsgPort *replymp = NULL;
  50.  
  51. /* Declare a pointer our printer request block: */
  52. union printerIO *printer_req = NULL;
  53.  
  54. /* Store the printer device error here: */
  55. UWORD printer_dever = TRUE;
  56.  
  57. /* Declare our data buffer: (7 bytes) */
  58. BYTE buffer[7];
  59.  
  60.  
  61.  
  62. /* Declare our functions: */
  63.  
  64. /* Our main function: */
  65. void main();
  66.  
  67. /* Clears and removes everything nice and neatly: */
  68. void clean_up( BYTE error, STRPTR text );
  69.  
  70. /* Prints some information about the error: */
  71. void PrtError( BYTE error );
  72.  
  73. /* Sends characters (which are translated) to the printer: */
  74. BYTE PrintText(
  75.   union printerIO *ioreq,
  76.   BYTE *data,
  77.   ULONG length
  78. );
  79.  
  80. /* Sends raw (untranslated) characters to the printer: */
  81. BYTE PrintRaw(
  82.   union printerIO *ioreq,
  83.   BYTE *data,
  84.   ULONG length
  85. );
  86.  
  87. /* Dumps a RastPort to the printer: */
  88. BYTE PrintRastPort(
  89.   union printerIO *ioreq,
  90.   struct RastPort *rp,
  91.   struct ColorMap *cm,
  92.   ULONG modes,
  93.   UWORD source_x,
  94.   UWORD source_y,
  95.   UWORD source_w,
  96.   UWORD source_h,
  97.   LONG dest_w,
  98.   LONG dest_h,
  99.   UWORD special
  100. );
  101.  
  102.  
  103.  
  104. void main()
  105. {
  106.   /* The lock number: */
  107.   ULONG lock;
  108.   
  109.   /* Error number: */
  110.   BYTE error;
  111.  
  112.   /* Width of the screen: */
  113.   UWORD width;
  114.  
  115.   /* Height of the screen: */
  116.   UWORD height;
  117.  
  118.   /* Pointer to a Screen structure: */
  119.   struct Screen *screen;
  120.  
  121.   /* Pointer to a RastPort structure: */
  122.   struct RastPort *rast_port;
  123.  
  124.   /* Pointer to a ViewPort structure: */
  125.   struct ViewPort *view_port;
  126.  
  127.   /* Pointer to a ColorMap structure: */
  128.   struct ColorMap *colour_map;
  129.   
  130.   /* The ViewPort's special display modes: */
  131.   UWORD modes;
  132.   
  133.   
  134.   
  135.   
  136.   /* Open the Intuition Library: */
  137.   IntuitionBase = (struct IntuitionBase *)
  138.     OpenLibrary( "intuition.library", 0 );
  139.   if( !IntuitionBase )
  140.     clean_up( 0, "Could NOT open the Intuition Library!" );
  141.  
  142.  
  143.  
  144.   /* Get a reply port: (No name, priority 0) */
  145.   replymp = (struct MsgPort *)
  146.     CreatePort( NULL, 0 );
  147.   if( !replymp )
  148.     clean_up( 0, "Could not create the reply port!" );
  149.  
  150.  
  151.  
  152.   /* Create the printer request block: */
  153.   printer_req = (union printerIO *)
  154.     CreateExtIO( replymp, sizeof(union printerIO) );
  155.   if( !printer_req )
  156.     clean_up( 0, "Not enough memory for the printer request block!" );
  157.  
  158.  
  159.  
  160.   /* Open the Printer Device: */
  161.   printer_dever = OpenDevice( "printer.device", 0, printer_req, 0 );
  162.   if( printer_dever )
  163.     clean_up( 0, "Could not open the Printer Device!" );
  164.  
  165.  
  166.  
  167.   /* Since this example should demonstrate how to print grahpics */
  168.   /* we need something to print. To make this example simple we  */
  169.   /* will try to print the current screen (ViewPort). To do this */
  170.   /* we have to ask Intuition where the current screen is.       */
  171.   /*                                                             */
  172.   /* If you look in header file "intuition/intuitionbase.h" you  */
  173.   /* will see how the IntuitionBase structure looks like. As you */
  174.   /* will see there exist a lot of useful information about      */
  175.   /* Intuition here. Among many things there exist a pointer to  */
  176.   /* the current active screen, which we will print.             */
  177.   /*                                                             */
  178.   /* NOTE! You are only allowed to look at some of the fields,   */
  179.   /* and you are NOT allowed to change any values!!! I know you  */
  180.   /* can do a lot of nice workbench hacks by modifying these     */
  181.   /* values but that can crash the system!                       */
  182.   /*                                                             */
  183.   /* Since other programs may run at the same time as your       */
  184.   /* program, the values in the IntuitionBase structure may      */
  185.   /* change while you are looking at them. To prevent this       */
  186.   /* you should always "lock" the IntuitionBase with the special */
  187.   /* LockIBase() function. Once the IntuitionBase is locked you  */
  188.   /* may start to examine the values. Remember to "unlock" the   */
  189.   /* IntuitionBase, with an UnlockIBase() call, as soon as you   */
  190.   /* have finished reading.                                      */
  191.  
  192.   /* "Lock" the IntuitionBase structure: */
  193.   lock = LockIBase( 0 );
  194.  
  195.   /* Get a pointer to the currently active screen: */
  196.   screen = IntuitionBase->ActiveScreen;
  197.  
  198.   /* "Unlock" the Intuition Base structure: */
  199.   UnlockIBase( lock );
  200.  
  201.  
  202.  
  203.   /* Get the width of the screen: */
  204.   width = screen->Width;
  205.  
  206.   /* Get the height of the screen: */
  207.   height = screen->Height;
  208.  
  209.   /* Get a pointer to the Screen's RastPort: */
  210.   rast_port = &(screen->RastPort);
  211.  
  212.   /* Get a pointer to the screen's ViewPort: */
  213.   view_port = &(screen->ViewPort);
  214.  
  215.   /* Get a pointer to the ViewPort's ColorMap: */
  216.   colour_map = view_port->ColorMap;
  217.  
  218.   /* Get the ViewPort's display modes: */
  219.   modes = view_port->Modes;
  220.  
  221.  
  222.  
  223.   /* Test 1:                                 */
  224.   /* Print the picture as large as possible. */
  225.  
  226.   /* Put some text into our buffer: */
  227.   strcpy( buffer, "Test 1" );
  228.  
  229.   /* Set a line feed (LF) at the end of our buffer: */
  230.   buffer[6]=10; /* 10 = LF (ASCII) */
  231.  
  232.   /* Send some text to the printer: (Will be translated) */
  233.   error = PrintText( printer_req, buffer, 7 );
  234.   if( error )
  235.     PrtError( error );
  236.  
  237.   /* Dump a RastPort to the printer: */
  238.   error = PrintRastPort
  239.   (
  240.     printer_req,      /* Pointer to the printer request block. */
  241.     rast_port,        /* Pointer to the RastPort.              */
  242.     colour_map,       /* Pointer to the ColorMap structure.    */
  243.     modes,            /* Special display modes.                */
  244.     0,                /* Start at X position 0.                */
  245.     0,                /* Start at Y position 0.                */
  246.     width,            /* The width of the display.             */
  247.     height,           /* The height of the display.            */
  248.     0,                /* The width of the printout.            */
  249.     0,                /* The height of the printout.           */
  250.     /* Since we set the sice below with help of the special    */
  251.     /* printing modes, we do not need to set any width or      */
  252.     /* height of the printout.                                 */
  253.     SPECIAL_FULLCOLS| /* Special printing modes. Full width,   */
  254.     SPECIAL_ASPECT    /* and correct aspect ratio.             */
  255.   );
  256.   if( error )
  257.     PrtError( error );
  258.  
  259.  
  260.  
  261.   /* Test 2:                          */
  262.   /* Use our own (very strange) size. */
  263.   buffer[5]='2';
  264.  
  265.   /* Send some text to the printer: (Will be translated) */
  266.   error = PrintText( printer_req, buffer, 7 );
  267.   if( error )
  268.     PrtError( error );
  269.  
  270.   /* Dump a RastPort to the printer: */
  271.   error = PrintRastPort
  272.   (
  273.     printer_req,      /* Pointer to the printer request block. */
  274.     rast_port,        /* Pointer to the RastPort.              */
  275.     colour_map,       /* Pointer to the ColorMap structure.    */
  276.     modes,            /* Special display modes.                */
  277.     0,                /* Start at X position 0.                */
  278.     0,                /* Start at Y position 0.                */
  279.     width,            /* The width of the display.             */
  280.     height,           /* The height of the display.            */
  281.     200,              /* The width of the printout.            */
  282.     600,              /* The height of the printout.           */
  283.     SPECIAL_CENTER    /* Special printing modes. Center the    */
  284.                       /* picture on the paper.                 */
  285.   );
  286.   if( error )
  287.     PrtError( error );
  288.  
  289.  
  290.  
  291.   /* Clean up and quit: */
  292.   clean_up( 0, "The End!" );
  293. }
  294.  
  295.  
  296.  
  297. /* Close and return everything that has been */
  298. /* opened and allocated before we quit:      */
  299.  
  300. void clean_up( BYTE error, STRPTR text )
  301. {
  302.   /* Print some information about the problem: */
  303.   if( error )
  304.     PrtError( error );
  305.  
  306.   /* Close the Printer Device: */ 
  307.   if( !printer_dever )
  308.     CloseDevice( printer_req );
  309.  
  310.   /* Deallocate the printer request block: */
  311.   if( printer_req )
  312.     DeleteExtIO( printer_req, sizeof(union printerIO) );
  313.  
  314.   /* Remove the replyport: */
  315.   if( replymp )
  316.     DeletePort( replymp);
  317.  
  318.   /* Close the Intuition Library: */
  319.   if( IntuitionBase )
  320.     CloseLibrary( IntuitionBase );
  321.  
  322.  
  323.   /* Print the message: */
  324.   printf( "\n%s\n", text );
  325.  
  326.   /* Quit: */
  327.   exit( 0 );
  328. }
  329.  
  330.  
  331. /* PrtError() tells the user what went wrong. You give it the error code */
  332. /* you received, and PrtError() will print a short description of the    */
  333. /* problem. Useful when debugging. (Printer errors)                      */
  334. /*                                                                       */
  335. /* Synopsis: PrtError( error );                                          */
  336. /*                                                                       */
  337. /* error:    (BYTE) The error value you want to have explained.          */
  338.  
  339. void PrtError( BYTE error )
  340. {
  341.   switch( error )
  342.   {
  343.     /* EXEC error messages: (defined in "exec/errors.h") */
  344.     case IOERR_OPENFAIL:
  345.       printf( "Could not open the device!\n" );
  346.       break;
  347.  
  348.     case IOERR_ABORTED:
  349.       printf( "The request was aborted!\n" );
  350.       break;
  351.  
  352.     case IOERR_NOCMD:
  353.       printf( "Unknown Command!\n" );
  354.       break;
  355.  
  356.     case IOERR_BADLENGTH:
  357.       printf( "Bad length of the command - data!\n" );
  358.  
  359.  
  360.     /* Printer Device errors: (defined in "devices/printer.h") */
  361.     case PDERR_CANCEL:
  362.       printf( "User cancelled the request!\n" );
  363.       break;
  364.       
  365.     case PDERR_NOTGRAPHICS:
  366.       printf( "The printer does not support graphics!\n" );
  367.       break;
  368.  
  369.     case PDERR_BADDIMENSION:
  370.       printf( "The printer dimension is not valid!\n" );
  371.       break;
  372.       
  373.  
  374.     case PDERR_INTERNALMEMORY:
  375.       printf( "Not enough memory for the internal printer functions!\n" );
  376.       break;
  377.  
  378.     case PDERR_BUFFERMEMORY:
  379.       printf( "Not enough memory for the print buffer!\n" );
  380.       break;
  381.  
  382.     default:
  383.       printf( "An unknown error was reported! Error nr: %d\n", error );
  384.   }
  385. }
  386.  
  387.  
  388. /* PrintText() sends characters (which will be translated) to the */
  389. /* printer. Since the printer device will use the Preference's    */
  390. /* settings, it will know to which port (parallel or serial) the  */
  391. /* printer is connected to, what type of printer it is, and what  */
  392. /* special settings (margins, density, quality mode etc) the user */
  393. /* have defined.                                                  */
  394. /*                                                                */
  395. /* Note! All characters which are sent with this function may be  */
  396. /* translated by Preferences before it is passed on to the        */
  397. /* printer.                                                       */
  398. /*                                                                */
  399. /* Synopsis: error = PrintText( io, data, length );               */
  400. /*                                                                */
  401. /* error:    (BYTE) PrintWrite() returns 0 if everything was OK,  */
  402. /*           else an error number is returned.                    */
  403. /*                                                                */
  404. /* io:       (union printerIO *) Pointer to a printer request     */
  405. /*           block.                                               */
  406. /*                                                                */
  407. /* data:     (BYTE *) Pointer to the first character that should  */
  408. /*           be printed.                                          */
  409. /*                                                                */
  410. /* length    (ULONG) How many characters (bytes) you want to send */
  411. /*           to the printer.                                      */
  412.  
  413. BYTE PrintText(
  414.   union printerIO *ioreq, /* Pointer to the printer request block.          */
  415.   BYTE *data,             /* Pointer to the data which should be printed.   */
  416.   ULONG length            /* How many characters (bytes) should be printed. */
  417. )
  418. {
  419.   /* We want to print some text: (send data to PRT:) */
  420.   ioreq->ios.io_Command = CMD_WRITE;
  421.  
  422.   /* Give the start address of our data: */
  423.   ioreq->ios.io_Data = (APTR) data;
  424.  
  425.   /* Set number of chracters that should be printed: */
  426.   ioreq->ios.io_Length = length;
  427.  
  428.   /* Do our request, and return 0 if everything is OK, else */
  429.   /* return an error number: (This is a task sleep.)        */
  430.   return( (BYTE) DoIO( ioreq ) );
  431. }
  432.  
  433.  
  434.  
  435. /* PrintRaw() sends untranslated characters to the printer. Note   */
  436. /* that this is usually not a very good idea. Since the characters */
  437. /* will not be translated by Preferences, you can not be sure that */
  438. /* the characters you send will be the same when printed.          */ 
  439. /*                                                                 */
  440. /* Synopsis: error = PrintRaw( io, data, length );                 */
  441. /*                                                                 */
  442. /* error:    (BYTE) PrintRaw() returns 0 if everything was OK,     */
  443. /*           else an error number is returned.                     */
  444. /*                                                                 */
  445. /* io:       (union printerIO *) Pointer to a printer request      */
  446. /*           block.                                                */
  447. /*                                                                 */
  448. /* data:     (BYTE *) Pointer to the first character that should   */
  449. /*           be printed.                                           */
  450. /*                                                                 */
  451. /* length    (ULONG) How many characters (bytes) you want to send  */
  452. /*           to the printer.                                       */
  453.  
  454. BYTE PrintRaw(
  455.   union printerIO *ioreq, /* Pointer to the printer request block.          */
  456.   BYTE *data,             /* Pointer to the data which should be printed.   */
  457.   ULONG length            /* How many characters (bytes) should be printed. */
  458. )
  459. {
  460.   /* We want to print some raw (untranslated) text: */
  461.   ioreq->ios.io_Command = PRD_RAWWRITE;
  462.  
  463.   /* Give the start address of our data: */
  464.   ioreq->ios.io_Data = (APTR) data;
  465.  
  466.   /* Set number of chracters that should be printed: */
  467.   ioreq->ios.io_Length = length;
  468.  
  469.   /* Do our request, and return 0 if everything is OK, else */
  470.   /* return an error number: (This is a task sleep.)        */
  471.   return( (BYTE) DoIO( ioreq ) );
  472. }
  473.  
  474.  
  475.  
  476. /* PrintRastPort() helps you with printing graphics. It takes a    */
  477. /* pointer to a RastPort, and dumps that RastPort to the printer.  */
  478. /* Note that some printers does not support graphics. If the user  */
  479. /* has a printer that can not handle graphics, this function will  */
  480. /* return immediately with the error number "PDERR_NOTGRAPHICS".   */
  481. /*                                                                 */
  482. /* Synopsis: error = PrintRastPort( io, rp, cm, modes, sx, sy,     */
  483. /*                                  sw, sh, dw, dh, special );     */
  484. /*                                                                 */
  485. /* error:   (BYTE) PrintRastPort() returns 0 if everything was OK, */
  486. /*          else an error number is returned.                      */
  487. /*                                                                 */
  488. /* io:      (union printerIO *) Pointer to a printer request       */
  489. /*          block.                                                 */
  490. /*                                                                 */
  491. /* rp:      (struct RastPort *) Pointer to the RastPort which      */
  492. /*          should be printed.                                     */
  493. /*                                                                 */
  494. /* cm:      (struct ColorMap *) Pointer to a ColorMap structure    */
  495. /*          which contains the colour information.                 */
  496. /*                                                                 */
  497. /* modes:   (ULONG) The ViewPort's display modes.The information   */
  498. /*          is used to convert the picture which will be printed   */
  499. /*          to the correct aspects. (On a low resolution screen    */
  500. /*          each pixels is equally wide as tall. However, on a     */
  501. /*          high resolution screen, each pixel is only half as     */
  502. /*          wide as it is tall. The same applies for interlaced    */
  503. /*          and non interlaced screens.) The printer device must   */
  504. /*          also know if you want to print a "normal" picture, or  */
  505. /*          a picture with one of the special display modes like   */
  506. /*          "HAM" or "Extrahalf Brite". The following flags may    */
  507. /*          be used:                                               */
  508. /*                                                                 */
  509. /*            HIRES:  Set this flag if you want to print a high    */
  510. /*                    resolution screen. If this flag is not set,  */
  511. /*                    the printer device assumes that you are      */
  512. /*                    using a low resolution screen.               */
  513. /*                                                                 */
  514. /*            LACE:   Set this flag if you want to print an inter- */
  515. /*                    laced picture. If this flag is not set, the  */
  516. /*                    printer device assumes that you are using a  */
  517. /*                    noninterlaced picture.                       */
  518. /*                                                                 */
  519. /*            HAM:    Set this flag if you want to print a "HAM"   */
  520. /*                    picture.                                     */
  521. /*                                                                 */
  522. /*            EXTRA_HALFBRITE: Set this flag if you want to print  */
  523. /*                    an "extra halfbrite" picture.                */
  524. /*                                                                 */
  525. /*            PUALPF: Set this flag if you want to print a dual    */
  526. /*                    playfields screen.                           */
  527. /*                                                                 */
  528. /*          Note that the simplest way is to copy the Viewport     */
  529. /*          structure's "modes" field. You will then not risk to   */
  530. /*          forget one or more display flags.                      */
  531. /*                                                                 */
  532. /* sx:      (UWORD) X offset of the source picture.                */
  533. /*                                                                 */
  534. /* sy:      (UWORD) Y offset of the source picture.                */
  535. /*                                                                 */
  536. /* sw:      (UWORD) Width of the source picture.                   */
  537. /*                                                                 */
  538. /* sh:      (UWORD) Height of the source picture.                  */
  539. /*                                                                 */
  540. /* dw:      (LONG) Width of the printed picture.                   */
  541. /*                                                                 */
  542. /* dh:      (LONG) Height of the printed picture.                  */
  543. /*                                                                 */
  544. /* special: (UWORD) Special graphical printing modes. Here is the  */
  545. /*          complete list of flags that may be used:               */
  546. /*                                                                 */
  547. /*            SPECIAL_MILCOLS:    If this flag is set the "dw"     */
  548. /*                                parameter is in 1/1000".         */
  549. /*                                                                 */
  550. /*            SPECIAL_MILROWS:    If this flag is set the "dh"     */
  551. /*                                parameter is in 1/1000".         */
  552. /*                                                                 */
  553. /*            SPECIAL_FULLCOLS:   Set this flag if you want the    */
  554. /*                                width of the printed picture to  */
  555. /*                                be as wide as possible.          */ 
  556. /*                                                                 */
  557. /*            SPECIAL_FULLROWS:   Set this flag if you want the    */
  558. /*                                height of the printed picture to */
  559. /*                                be as tall as possible.          */
  560. /*                                                                 */
  561. /*            SPECIAL_FRACCOLS:   If this flag is set the "dw"     */
  562. /*                                parameter specifies a fraction   */
  563. /*                                of the maximum width.            */ 
  564. /*                                                                 */
  565. /*            SPECIAL_FRACROWS:   If this flag is set the "dh"     */
  566. /*                                parameter specifies a fraction   */
  567. /*                                of the maximum height.           */ 
  568. /*                                                                 */
  569. /*            SPECIAL_CENTER:     Set this flag if you want the    */
  570. /*                                picture to be centered on the    */
  571. /*                                paper.                           */
  572. /*                                                                 */
  573. /*            SPECIAL_ASPECT:     Set this flag if you want to use */
  574. /*                                the correct aspect ratio of the  */
  575. /*                                picture.                         */
  576. /*                                                                 */
  577. /*            SPECIAL_DENSITY1:   Set this flag if you want the    */
  578. /*                                picture to be printed with the   */
  579. /*                                printer's lowest resolution.     */
  580. /*                                Lowest resolution.               */
  581. /*                                                                 */
  582. /*            SPECIAL_DENSITY2:   Next resolution.                 */
  583. /*                                                                 */
  584. /*            SPECIAL_DENSITY3:   Next resolution.                 */
  585. /*                                                                 */
  586. /*            SPECIAL_DENSITY4:   Next resolution.                 */
  587. /*                                                                 */
  588. /*            SPECIAL_DENSITY5:   Next resolution.                 */
  589. /*                                                                 */
  590. /*            SPECIAL_DENSITY6:   Next resolution.                 */
  591. /*                                                                 */
  592. /*            SPECIAL_DENSITY7:   Use the printer's highest        */
  593. /*                                resolution.                      */
  594. /*                                                                 */
  595. /*            SPECIAL_NOFORMFEED: Set this flag if you do not want */
  596. /*                                that the paper is ejected after  */
  597. /*                                each time you have printed       */
  598. /*                                graphics.                        */
  599. /*                                                                 */
  600. /*            SPECIAL_TRUSTME:    Set this flag if you do not want */
  601. /*                                the printer to reset any param-  */
  602. /*                                eters while printing.            */
  603.  
  604. BYTE PrintRastPort(
  605.   union printerIO *ioreq,
  606.   struct RastPort *rp,
  607.   struct ColorMap *cm,
  608.   ULONG modes,
  609.   UWORD source_x,
  610.   UWORD source_y,
  611.   UWORD source_w,
  612.   UWORD source_h,
  613.   LONG dest_w,
  614.   LONG dest_h,
  615.   UWORD special
  616. )
  617. {
  618.   /* We want to dump a RastPort to the printer: */
  619.   ioreq->iodrp.io_Command = PRD_DUMPRPORT;
  620.  
  621.   /* Set a pointer to the RastPort structure: */
  622.   ioreq->iodrp.io_RastPort = rp;
  623.  
  624.   /* Set a pointer to the ColorMap structure: */
  625.   ioreq->iodrp.io_ColorMap = cm;
  626.  
  627.   /* Set the "display" modes: */
  628.   ioreq->iodrp.io_Modes = modes;
  629.  
  630.   /* X position of the source: */
  631.   ioreq->iodrp.io_SrcX = source_x;
  632.  
  633.   /* Y position of the source: */
  634.   ioreq->iodrp.io_SrcY = source_y;
  635.  
  636.   /* Width of the source: */
  637.   ioreq->iodrp.io_SrcWidth = source_w;
  638.  
  639.   /* Height of the source: */
  640.   ioreq->iodrp.io_SrcHeight = source_h;
  641.  
  642.   /* The width of the printed picture: */
  643.   ioreq->iodrp.io_DestCols = dest_w;
  644.  
  645.   /* The height of the printed picture: */
  646.   ioreq->iodrp.io_DestRows = dest_h;
  647.  
  648.   /* Set the special printing commands: */
  649.   ioreq->iodrp.io_Special = special;
  650.  
  651.  
  652.   /* Do our request, and return 0 if everything is OK, else */
  653.   /* return an error number: (This is a task sleep.)        */
  654.   return( (BYTE) DoIO( ioreq ) );
  655. }
  656.  
  657.  
  658.