home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 106 / EnigmaAmiga106CD.iso / www / afc / afc-dir / afc_examples.lha / super_picture_Examples.lha / Examples / SuperPic_Example1.e < prev   
Text File  |  1997-09-09  |  2KB  |  82 lines

  1. /*
  2.  
  3.     $VER: Super Picture Example no. 1 (V1.00) - By Fabio Rotondo
  4.  
  5.     (C)Copyright Amiga Foundation Classes
  6.  
  7.     This example is Public Domain.
  8.  
  9. */
  10.  
  11. MODULE 'afc/super_picture', 'afc/explain_exception',
  12.        'dos/rdargs',
  13.        'intuition/screens'
  14.  
  15. PROC main() HANDLE
  16.   DEF myargs:PTR TO LONG, rda=NIL
  17.   DEF pic=NIL:PTR TO super_picture            -> The SuperPic OBJECT
  18.   DEF scr=NIL:PTR TO screen, w, h, sw, sh
  19.  
  20.   WriteF('PView V1.00 - By Fabio Rotondo.\n')
  21.  
  22.   myargs:=[0,0,0,0,0,0]:LONG
  23.   IF (rda:=ReadArgs('PICNAME/A,VERBOSE/S', myargs, NIL))=NIL THEN Raise("args")
  24.  
  25.   NEW pic.super_picture()                    -> Here we init the class
  26.  
  27.   pic.load(myargs[0])                        -> Just a load command (Supports DataTypes!) 8-)
  28.  
  29.   w:=pic.width()           -> Here we obtain pic's width and height
  30.   h:=pic.height()
  31.  
  32.   IF w<320 THEN sw:=320 ELSE sw:=w  -> And here we compute screen sizes
  33.   IF h<256 THEN sh:=256 ELSE sh:=h
  34.  
  35.   -> If the user set the VERBOSE flag in the Shell parameters, we just show
  36.   -> some more info about the picture before displaying it.
  37.   IF myargs[1]
  38.     WriteF('Picture:\s\nWidth: \d\nHeight: \d\nDepth:\d\nModeID: $\h\n',
  39.                                                           myargs[0],
  40.                                                           w,h,pic.depth(),
  41.                                                           pic.modeid())
  42.   ENDIF
  43.  
  44.   -> Here we open a screen
  45.   IF (scr:=OpenScreenTagList(NIL,
  46.                             [SA_WIDTH,     sw,
  47.                              SA_HEIGHT,    sh,
  48.                              SA_DEPTH,     pic.depth(),
  49.                              SA_DISPLAYID, pic.modeid(),
  50.                             0,0]))=NIL THEN Raise("scr")
  51.  
  52.   pic.paltoscr(scr)       -> Just to set the right palette
  53.  
  54.  
  55.   -> We blit it all!
  56.   BltBitMapRastPort(pic.bitmap(), 0,0, scr.rastport, 0,0, w, h, $C0)
  57.  
  58.  
  59.   -> Waiting for a mouse click...
  60.   REPEAT
  61.     Delay(5)
  62.   UNTIL Mouse()
  63.  
  64. EXCEPT DO
  65.   SELECT exception
  66.     CASE "args"
  67.       WriteF('Bad args!\n')
  68.     CASE "scr"
  69.       WriteF('Could not open screen!\n')
  70.     DEFAULT
  71.       explain_exception()
  72.   ENDSELECT
  73.  
  74.   IF scr THEN CloseScreen(scr)   -> Close the screen
  75.  
  76.   IF rda THEN FreeArgs(rda)      -> Free ReadArgs structure
  77.  
  78.   END pic                        -> Close the object
  79.  
  80.   CleanUp(0)                     -> General cleaning up...
  81. ENDPROC
  82.