home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 262.lha / IffLibrary_v1.3 / shoimg.c < prev    next >
C/C++ Source or Header  |  1989-07-04  |  2KB  |  105 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. 0L,          /* 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.  
  35. main(argc,argv)
  36. short argc;
  37. char *argv[];
  38. {
  39. extern void *OpenLibrary(), CloseLibrary();
  40. extern struct Window *OpenWindow();
  41. extern struct Screen *OpenScreen();
  42. extern struct ViewPort *ViewPortAddress();
  43. extern void *GetMsg();
  44. extern long Wait();
  45.  
  46. extern short QueryIFF();
  47. BitMapHeader hdr;
  48. struct ViewPort *vp;
  49. struct IntuiMessage *i;
  50. struct Window *w = 0L;
  51. struct Screen *s = 0L;
  52. UWORD *clrs = 0L;
  53. struct Image *img = 0L;
  54. UWORD ncolors;
  55.  
  56.  
  57. if( !(GfxBase = OpenLibrary("graphics.library",0L)) )
  58.    goto abort;
  59. if( !(IntuitionBase = OpenLibrary("intuition.library",0L)) )
  60.    goto abort;
  61. if( !(IFFBase = OpenLibrary(IFFNAME,1L)) )
  62.    goto abort;
  63.  
  64. if( argc > 1 )
  65.    if( !QueryIFF(argv[1],&hdr) )
  66.       {
  67.       printf("cmp: %d\n",(short)hdr.compression);
  68.       if( (ns.Width = hdr.pageWidth) > 320 )
  69.      ns.ViewModes |= HIRES;
  70.       if( (ns.Height = hdr.pageHeight) > 200 )
  71.      ns.ViewModes |= LACE;
  72.       if( (ns.Depth = hdr.nPlanes) > 5 )
  73.      ns.ViewModes |= HAM;
  74.       nw.MaxWidth = nw.MinWidth = nw.Width = hdr.w;
  75.       nw.MinHeight = nw.MaxHeight = nw.Height = hdr.h;
  76.       if( GetIFF_image(argv[1],&img,&clrs,&ncolors,1) )
  77.      {
  78.      img = 0L;
  79.      clrs = 0L;
  80.      goto abort;
  81.      }
  82.       if( !(s = OpenScreen(&ns)) )
  83.      goto abort;
  84.       ShowTitle(s,0L);
  85.       nw.Screen = s;
  86.       if( !(w = OpenWindow(&nw)) )
  87.      goto abort;
  88.       vp = ViewPortAddress(w);
  89.       LoadRGB4(vp,clrs,(long)ncolors);
  90.       DrawImage(w->RPort,img,0L,0L);
  91.       Wait(1L<<w->UserPort->mp_SigBit);
  92.       while( i = GetMsg(w->UserPort) )
  93.      ReplyMsg(i);
  94.       }
  95.  
  96. abort:
  97. if( w )             CloseWindow(w);
  98. if( s )             CloseScreen(s);
  99. if( img )           RlsImage(img);
  100. if( clrs )          IFFfree(clrs);
  101. if( IFFBase )       CloseLibrary(IFFBase);
  102. if( IntuitionBase ) CloseLibrary(IntuitionBase);
  103. if( GfxBase )       CloseLibrary(GfxBase);
  104. }
  105.