home *** CD-ROM | disk | FTP | other *** search
- #include <intuition/intuition.h>
- #include "ifflib.h"
-
- void *IntuitionBase, *GfxBase, *IFFBase;
-
- struct NewScreen ns =
- {
- 0,0, 0,0, 0, /* LE, TE, W, H, D */
- 0,0, /* pns */
- 0, /* ViewModes */
- CUSTOMSCREEN, /* type */
- 0L, /* font */
- 0L, /* title */
- 0L, /* gadgets */
- 0L, /* bitmap */
- };
-
- struct NewWindow nw =
- {
- 0,0,0,0, /* LE,TE,W,H */
- 0,0, /* pns */
- RAWKEY, /* IDCMP */
- SIMPLE_REFRESH | BACKDROP | BORDERLESS | ACTIVATE, /* flags */
- 0L, /* Gadget */
- 0L, /* checkmark */
- (UBYTE *)"", /* title */
- 0L, /* screen */
- 0L, /* bitmap */
- 0,0, /* min */
- 0,0, /* max */
- CUSTOMSCREEN, /* type */
- };
-
-
- main(argc,argv)
- short argc;
- char *argv[];
- {
- extern void *OpenLibrary(), CloseLibrary();
- extern struct Window *OpenWindow();
- extern struct Screen *OpenScreen();
- extern struct ViewPort *ViewPortAddress();
- extern void *GetMsg();
- extern long Wait();
-
- extern short QueryIFF();
- BitMapHeader hdr;
- struct ViewPort *vp;
- struct IntuiMessage *i;
- struct Window *w = 0L;
- struct Screen *s = 0L;
- UWORD *clrs = 0L;
- struct Image *img = 0L;
- UWORD ncolors;
-
-
- if( !(GfxBase = OpenLibrary("graphics.library",0L)) )
- goto abort;
- if( !(IntuitionBase = OpenLibrary("intuition.library",0L)) )
- goto abort;
- if( !(IFFBase = OpenLibrary(IFFNAME,1L)) )
- goto abort;
-
- if( argc > 1 )
- if( !QueryIFF(argv[1],&hdr) )
- {
- printf("cmp: %d\n",(short)hdr.compression);
- if( (ns.Width = hdr.pageWidth) > 320 )
- ns.ViewModes |= HIRES;
- if( (ns.Height = hdr.pageHeight) > 200 )
- ns.ViewModes |= LACE;
- if( (ns.Depth = hdr.nPlanes) > 5 )
- ns.ViewModes |= HAM;
- nw.MaxWidth = nw.MinWidth = nw.Width = hdr.w;
- nw.MinHeight = nw.MaxHeight = nw.Height = hdr.h;
- if( GetIFF_image(argv[1],&img,&clrs,&ncolors,1) )
- {
- img = 0L;
- clrs = 0L;
- goto abort;
- }
- if( !(s = OpenScreen(&ns)) )
- goto abort;
- ShowTitle(s,0L);
- nw.Screen = s;
- if( !(w = OpenWindow(&nw)) )
- goto abort;
- vp = ViewPortAddress(w);
- LoadRGB4(vp,clrs,(long)ncolors);
- DrawImage(w->RPort,img,0L,0L);
- Wait(1L<<w->UserPort->mp_SigBit);
- while( i = GetMsg(w->UserPort) )
- ReplyMsg(i);
- }
-
- abort:
- if( w ) CloseWindow(w);
- if( s ) CloseScreen(s);
- if( img ) RlsImage(img);
- if( clrs ) IFFfree(clrs);
- if( IFFBase ) CloseLibrary(IFFBase);
- if( IntuitionBase ) CloseLibrary(IntuitionBase);
- if( GfxBase ) CloseLibrary(GfxBase);
- }
-