home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / gfx / piccon-2.50.lha / PicCon / Sources / C / imageexample.c < prev   
C/C++ Source or Header  |  1994-08-22  |  2KB  |  96 lines

  1. #include <stdio.h>
  2. #include <proto/intuition.h>
  3. #include <proto/dos.h>
  4. #include <proto/exec.h>
  5. #include <proto/graphics.h>
  6.  
  7. #define DEPTH 3
  8.  
  9. /*
  10.  
  11. Insert any other image struct below (of any size, but change the DEPTH
  12. define above to get correct depth on your screen). Also remember to insert
  13. the keyword 'chip' between 'ULONG' and 'myData'.
  14.  
  15. You may also want to change the screens palette according to that of the
  16. image. Do this by inserting a new LoadRGB4 palette below the image struct
  17. data.
  18.  
  19. This source compiles fine with SAS/C and any other C compiler that has
  20. library autoinitialization code.
  21.  
  22. */
  23.  
  24. /* Start image struct data */
  25.  
  26. ULONG chip myData[] =
  27. {
  28.     0x000903e9,0x0e7918f9,0x1cf93ef9,0x3bf93de9,0x3f091f08,0x8f9887f8,
  29.     0x87f877f8,0x0ff00700,
  30.     0x00060006,0x03c60f86,0x0f061b06,0x15171297,0x18f709f7,0x07f700ef,
  31.     0x001f01ff,0x03ff03ff,
  32.     0xfff0fc10,0xf3c0ef80,0xef40db40,0xd510d690,0xd8f0e9f0,0x77f078e0,
  33.     0x78000800,0x00000000,
  34. };
  35.  
  36.  
  37. struct Image myimage =
  38. {
  39.     0x0,0x0,
  40.     0x0010, 0x0010, 0x0003,
  41.     (UWORD *)myData,
  42.     0x07,0x0,
  43.     NULL
  44. };
  45.  
  46. /* End image struct data */
  47.  
  48. /* Start palette data */
  49.  
  50. UWORD palette[] =
  51. {
  52.     0x0000,0x0225,0x006d,0x0049,0x01a0,0x0fff,0x0ecb,0x0b99,
  53. };
  54.  
  55. /* End palette data */
  56.  
  57. void main(void)
  58. {
  59.     struct Screen *myscreen;
  60.     struct Window *mywindow;
  61.     BOOL quit = FALSE;
  62.     struct IntuiMessage *msg;
  63.     int x = 100, y = 100;
  64.  
  65.     if(myscreen = OpenScreenTags(NULL, SA_Width, 320, SA_Height, 200, SA_Depth, DEPTH, SA_Title, "Hit spacebar to quit", TAG_END))
  66.     {
  67.         if(mywindow = OpenWindowTags(NULL, WA_Top, myscreen->BarHeight + 1, WA_Width, 320, WA_Height, 200 - myscreen->BarHeight - 1, WA_IDCMP, IDCMP_VANILLAKEY, WA_CustomScreen, myscreen, WA_Flags, WFLG_BACKDROP|WFLG_NOCAREREFRESH|WFLG_BORDERLESS|WFLG_ACTIVATE|WFLG_RMBTRAP, TAG_END))
  68.         {
  69.             LoadRGB4(&myscreen->ViewPort, palette, 8);
  70.             DrawImage(mywindow->RPort, &myimage, x, y);
  71.  
  72.             while(!quit)
  73.             {
  74.                 WaitTOF();
  75.                 EraseImage(mywindow->RPort, &myimage, x, y);
  76.                 x++; if(x > 320) x = 0;
  77.                 y++; if(y > 200) y = 0;
  78.                 DrawImage(mywindow->RPort, &myimage, x, y);
  79.  
  80.                 msg = (struct IntuiMessage *)GetMsg(mywindow->UserPort);
  81.                 if(msg)
  82.                 {
  83.                     if((msg->Class == IDCMP_VANILLAKEY) && (msg->Code == ' ')) quit = TRUE;
  84.                 }
  85.             }
  86.             CloseWindow(mywindow);
  87.         }
  88.         else puts("Couldn't open window.");
  89.  
  90.         while(!CloseScreen(myscreen)) puts("Can't close screen!");;
  91.     }
  92.     else puts("Couldn't open screen.");
  93.  
  94.     return;
  95. }
  96.