/***************************************
 *                                     *
 * Program: DrawImage.c                *
 * =================================== *
 *                                     *
 * Author:  Date:      Comments:       *
 * ------  ----------  ----------      *
 * Wgb     10/16/1987  Use +C linker   *
 *                     option (Aztec)  *
 *                                     *
 ***************************************/


#include <exec/types.h>
#include <intuition/intuition.h>


struct IntuitionBase *IntuitionBase;
struct Window        *FirstWindow;


struct NewWindow FirstNewWindow =
   {
   160, 50,             /* LeftEdge, TopEdge   */
   320, 150,            /* Width, Height       */
   0, 1,                /* DetailPen, BlockPen */
   NULL,                /* IDCMP Flags         */
   WINDOWDEPTH |        /* Flags               */
   WINDOWSIZING |
   WINDOWDRAG |
   WINDOWCLOSE |
   SMART_REFRESH,
   NULL,                /* First Gadget        */
   NULL,                /* CheckMark           */
   (UBYTE *)"System programming test",
   NULL,                /* Screen              */
   NULL,                /* BitMap              */
   100, 50,             /* Min Width, Height   */
   640, 200,            /* Max Width, Height   */
   WBENCHSCREEN,        /* Typ                 */
   };

USHORT ExampleData[] =
   {
   /* first BitPlane */
   0x07F8, 0x0000,
   0x07F0, 0x0000,
   0x1E1E, 0x0000,
   0x1E1E, 0x0000,
   0x7800, 0xFE00,
   0x7800, 0xF800,
   0x7800, 0x0000,
   0x7800, 0x0000,
   0x7800, 0xF800,
   0x7800, 0xFE00,
   0x1E1E, 0x0000,
   0x1E1E, 0x0000,
   0x07F8, 0x0000,
   0x07F8, 0x0000,
   0x0000, 0x0000,
   0x0000, 0x0000,
   /* second BitPlane */
   0x0000, 0x0000,
   0x0000, 0x0000,
   0x0000, 0x0000,
   0x0000, 0x0000,
   0x0000, 0xFE00,
   0x0000, 0xF800,
   0x0000, 0x0000,
   0x0000, 0x0000,
   0x0000, 0xF800,
   0x0000, 0xFE00,
   0x0000, 0x0000,
   0x0000, 0x0000,
   0x0000, 0x0000,
   0x0000, 0x0000,
   0x0000, 0x0000,
   0x0000, 0x0000
   };

struct Image Example =
   {
   20, 10,
   32, 16,
   2,
   &ExampleData[0],
   3, 0,
   NULL
   };



main()
   {
   struct RastPort *MyWindowsRastPort;

   Open_All();
   
   MyWindowsRastPort = FirstWindow->RPort;

   DrawImage(MyWindowsRastPort, &Example, 10L, 10L);

   Delay(180L);
   
   Close_All();
   }


/***************************************
 *                                     *
 * Function: Library and Window open   *
 * =================================== *
 *                                     *
 ***************************************/

Open_All()

   {
   void          *OpenLibrary();
   struct Window *OpenWindow();
   
   if (!(IntuitionBase = (struct IntuitionBase *)
       OpenLibrary("intuition.library", 0L)))
      {
      printf("Intuition Library not found!\n");
      Close_All();
      exit(FALSE);
      }
   
   if (!(FirstWindow = (struct Window *)
       OpenWindow(&FirstNewWindow)))
      {
      printf("Window will not open!\n");
      Close_All();
      exit(FALSE);
      }
   }


/***************************************
 *                                     *
 * Function: Close all                 *
 * =================================== *
 *                                     *
 ***************************************/

Close_All()

   {
   if (FirstWindow)     CloseWindow(FirstWindow);
   if (IntuitionBase)   CloseLibrary(IntuitionBase);
   }

