home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / TRSICAT.LZX / CATS_CD2_TRSI / Reference_Library / lib_examples / simpleimage.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-21  |  3.0 KB  |  99 lines

  1. /* simpleimage.c - program to show the use of a simple Intuition Image.
  2. **
  3. ** compiled with:
  4. ** lc -b1 -cfist -v -y simpleimage.c
  5. ** blink FROM LIB:c.o+"simpleimage.o" TO "simpleimage" LIB LIB:lc.lib LIB:amiga.lib
  6. */
  7. #define INTUI_V36_NAMES_ONLY
  8.  
  9. #include <exec/types.h>
  10. #include <intuition/intuition.h>
  11. #include <intuition/intuitionbase.h>
  12.  
  13. #include <clib/exec_protos.h>
  14. #include <clib/dos_protos.h>
  15. #include <clib/intuition_protos.h>
  16.  
  17. #include <stdio.h>
  18.  
  19. #ifdef LATTICE
  20. int CXBRK(void)    { return(0); }  /* Disable Lattice CTRL/C handling */
  21. int chkabort(void) { return(0); }  /* really */
  22. #endif
  23.  
  24. struct IntuitionBase *IntuitionBase = NULL;
  25.  
  26. #define MYIMAGE_LEFT    (0)
  27. #define MYIMAGE_TOP     (0)
  28. #define MYIMAGE_WIDTH   (24)
  29. #define MYIMAGE_HEIGHT  (10)
  30. #define MYIMAGE_DEPTH   (1)
  31.  
  32. /* This is the image data.  It is a one bit-plane open rectangle which is 24
  33. ** pixels wide and 10 high.  Make sure that it is in CHIP memory, or allocate
  34. ** a block of chip memory with a call like this: AllocMem(data_size,MEMF_CHIP),
  35. ** and then copy the data to that block.  See the Exec chapter on Memory
  36. ** Allocation for more information on AllocMem().
  37. */
  38. UWORD __chip myImageData[] =
  39.     {
  40.     0xFFFF, 0xFF00,
  41.     0xC000, 0x0300,
  42.     0xC000, 0x0300,
  43.     0xC000, 0x0300,
  44.     0xC000, 0x0300,
  45.     0xC000, 0x0300,
  46.     0xC000, 0x0300,
  47.     0xC000, 0x0300,
  48.     0xC000, 0x0300,
  49.     0xFFFF, 0xFF00,
  50.     };
  51.  
  52. /*
  53. ** main routine. Open required library and window and draw the images.
  54. ** This routine opens a very simple window with no IDCMP.  See the
  55. ** chapters on "Windows" and "Input and Output Methods" for more info.
  56. ** Free all resources when done.
  57. */
  58. VOID main(int argc, char *argv[])
  59. {
  60. struct Window *win;
  61. struct Image myImage;
  62.  
  63. IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",37);
  64. if (IntuitionBase != NULL)
  65.     {
  66.     if (NULL != (win = OpenWindowTags(NULL,
  67.                         WA_Width,       200,
  68.                         WA_Height,      100,
  69.                         WA_RMBTrap,     TRUE,
  70.                         TAG_END)))
  71.         {
  72.         myImage.LeftEdge    = MYIMAGE_LEFT;
  73.         myImage.TopEdge     = MYIMAGE_TOP;
  74.         myImage.Width       = MYIMAGE_WIDTH;
  75.         myImage.Height      = MYIMAGE_HEIGHT;
  76.         myImage.Depth       = MYIMAGE_DEPTH;
  77.         myImage.ImageData   = myImageData;
  78.         myImage.PlanePick   = 0x1;              /* use first bit-plane     */
  79.         myImage.PlaneOnOff  = 0x0;              /* clear all unused planes */
  80.         myImage.NextImage   = NULL;
  81.  
  82.         /* Draw the 1 bit-plane image into the first bit-plane (color 1) */
  83.         DrawImage(win->RPort,&myImage,10,10);
  84.  
  85.         /* Draw the same image at a new location */
  86.         DrawImage(win->RPort,&myImage,100,10);
  87.  
  88.         /* Wait a bit, then quit.
  89.         ** In a real application, this would be an event loop, like the
  90.         ** one described in the Intuition Input and Output Methods chapter.
  91.         */
  92.         Delay(200);
  93.  
  94.         CloseWindow(win);
  95.         }
  96.     CloseLibrary((struct Library *)IntuitionBase);
  97.     }
  98. }
  99.