home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / dev / e / amigae / src / tools / ilbm / showpic.e < prev   
Text File  |  1992-09-02  |  1KB  |  71 lines

  1. /*
  2.  
  3.     showpic.e                          Michael Zucchi 1994
  4.  
  5.     Simple IFF ILBM picture viewer
  6.     Demonstrates use of the ILBM module, and the asl file requester
  7.  
  8.     This program may be freely distributed only among registered
  9.     AmigaE owners.
  10.  */
  11.  
  12.  
  13. MODULE 'tools/ilbm', 'tools/ilbmdefs',
  14.     'intuition/intuition',
  15.     'asl', 'libraries/ASL'
  16.  
  17. DEF scr,
  18.     buffer[256]:ARRAY
  19.  
  20. PROC main()
  21. DEF ilbm,filename
  22.  
  23. IF filename:=requestfile('Select picture')
  24.     IF ilbm:=ilbm_New(filename,0)
  25.         ilbm_LoadPicture(ilbm,[ILBML_GETSCREEN,{scr},0])
  26.         ilbm_Dispose(ilbm)    -> no longer needed ...
  27.  
  28.         -> this is only an example!  In a real application, always use IDCMP ports,
  29.         -> and windows
  30.  
  31.         IF scr            -> only if one was created.
  32.             WHILE Mouse()<>1
  33.                 Delay(4)
  34.             ENDWHILE
  35.             CloseScreen(scr)
  36.         ENDIF
  37.     ENDIF
  38. ENDIF
  39.  
  40. ENDPROC
  41.  
  42. /*
  43.     Presents an ASL load-file requester.  If the user selected a file, it is
  44.     expanded to a full path-name.
  45.  */
  46. PROC requestfile(title)
  47. DEF name=0,fr:PTR TO filerequester
  48.  
  49. IF aslbase:=OpenLibrary('asl.library',36)
  50.     IF fr:=AllocAslRequest(ASL_FILEREQUEST,[ASLFR_TITLETEXT,title,0])
  51.         IF AslRequest(fr,0)
  52.  
  53.             -> sorry, a bit of ASM here.  Well ... how ELSE?
  54.             -> this does a strcpy() ...
  55.             MOVE.L    fr,A0
  56.             MOVE.L    8(A0),A0    -> directory pointer from 'filerequester'
  57.             MOVE.L    buffer,A1
  58.         cp:    MOVE.B    (A0)+,(A1)+
  59.             BNE.S    cp
  60.  
  61.             AddPart(buffer,fr.file,256)
  62.             name:=buffer
  63.         ENDIF
  64.         FreeAslRequest(fr)
  65.     ENDIF
  66.     CloseLibrary(aslbase)
  67. ENDIF
  68.  
  69. ENDPROC name
  70.  
  71.