home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 216.lha / IFFLib / shopict.c < prev    next >
C/C++ Source or Header  |  1996-02-15  |  3KB  |  115 lines

  1. #include <intuition/intuition.h>
  2. #include "ifflib.h"
  3.  
  4. void *IntuitionBase, *GfxBase, *IFFBase;
  5.  
  6. struct NewScreen ns =
  7. {
  8. 0,0, 0,0, 0,  /* LE, TE, W, H, D */
  9. 0,0,          /* pns */
  10. 0,            /* ViewModes */
  11. CUSTOMSCREEN, /* type */
  12. 0L,           /* font */
  13. (UBYTE *)"View",       /* title */
  14. 0L,           /* gadgets */
  15. 0L,           /* bitmap */
  16. };
  17.  
  18. struct NewWindow nw =
  19. {
  20. 0,0,0,0,       /* LE,TE,W,H */
  21. 0,0,           /* pns */
  22. RAWKEY,        /* IDCMP */
  23. SIMPLE_REFRESH | BACKDROP | BORDERLESS | ACTIVATE, /* flags */
  24. 0L,            /* Gadget */
  25. 0L,            /* checkmark */
  26. (UBYTE *)"",   /* title */
  27. 0L,            /* screen */
  28. 0L,            /* bitmap */
  29. 0,0,           /* min */
  30. 0,0,           /* max */
  31. CUSTOMSCREEN,  /* type */
  32. };
  33.  
  34. UWORD colors[4096];
  35. UWORD ncolors;
  36.  
  37. /* p(hdr)
  38. BitMapHeader *hdr;
  39. {
  40. printf("width: %d,  height: %d\n",hdr->w,hdr->h);
  41. printf("x: %d, y: %d\n",hdr->x,hdr->y);
  42. printf("nPlanes %d\n",(short)hdr->nPlanes);
  43. printf("masking: %d\n",(short)hdr->masking);
  44. printf("compression: %d\n",(short)hdr->compression);
  45. printf("transparentColor: %d\n",hdr->transparentColor);
  46. printf("xAspect: %d, yAspect:%d\n",
  47.    (short)hdr->xAspect,(short)hdr->yAspect);
  48. printf("pageWidth: %d, pageHeight: %d\n",
  49.    hdr->pageWidth,hdr->pageHeight);
  50. }  */
  51.  
  52.  
  53. main(argc,argv)
  54. short argc;
  55. char *argv[];
  56. {
  57. extern void *OpenLibrary(), CloseLibrary();
  58. extern struct Window *OpenWindow();
  59. extern struct Screen *OpenScreen();
  60. extern struct ViewPort *ViewPortAddress();
  61. extern void *GetMsg();
  62. extern long Wait();
  63.  
  64. extern short QueryIFF();
  65. BitMapHeader hdr;
  66. struct ViewPort *vp;
  67. struct IntuiMessage *i;
  68. struct Window *w = 0L;
  69. struct Screen *s = 0L;
  70. UWORD *clrs = colors;
  71. struct BitMap *bm;
  72.  
  73.  
  74. if( !(GfxBase = OpenLibrary("graphics.library",0L)) )
  75.    goto abort;
  76. if( !(IntuitionBase = OpenLibrary("intuition.library",0L)) )
  77.    goto abort;
  78. if( !(IFFBase = OpenLibrary(IFFNAME,1L)) )
  79.    goto abort;
  80.  
  81. if( argc > 1 )
  82.    if( !QueryIFF(argv[1],&hdr) )
  83.       {
  84.       /* p(&hdr); */
  85.       if( (ns.Width = hdr.pageWidth) > 320 )
  86.          ns.ViewModes |= HIRES;
  87.       if( (ns.Height = hdr.pageHeight) > 200 )
  88.          ns.ViewModes |= LACE;
  89.       if( (ns.Depth = hdr.nPlanes) > 5 )
  90.          ns.ViewModes |= HAM;
  91.       nw.MaxWidth = nw.MinWidth = nw.Width = hdr.w;
  92.       nw.MinHeight = nw.MaxHeight = nw.Height = hdr.h;
  93.       if( !(s = OpenScreen(&ns)) )
  94.          goto abort;
  95.       bm = &s->BitMap;
  96.       nw.Screen = s;
  97.       if( !(w = OpenWindow(&nw)) )
  98.          goto abort;
  99.       ShowTitle(s,0L);
  100.       GetIFF_bitmap(argv[1],&bm,&clrs,&ncolors,0);
  101.       vp = ViewPortAddress(w);
  102.       LoadRGB4(vp,clrs,(long)ncolors);
  103.       Wait(1L<<w->UserPort->mp_SigBit);
  104.       while( i = GetMsg(w->UserPort) )
  105.          ReplyMsg(i);
  106.       }
  107.  
  108. abort:
  109. if( w ) CloseWindow(w);
  110. if( s ) CloseScreen(s);
  111. if( IFFBase ) CloseLibrary(IFFBase);
  112. if( IntuitionBase ) CloseLibrary(IntuitionBase);
  113. if( GfxBase ) CloseLibrary(GfxBase);
  114. }
  115.