home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 351.lha / iff.library_v1.6 / shoimg.c < prev    next >
C/C++ Source or Header  |  1990-02-26  |  3KB  |  106 lines

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