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

  1. /*
  2.  
  3.     picwindow.e                          Michael Zucchi 1994
  4.  
  5.     Loads a picture into a window on workbench (without colours ...)
  6.     Demonstrates use of the ILBM MODULE - loading into bitmaps, and obtaining
  7.     picture information.  It also demonstrates asl file requester
  8.  
  9.     This program may be freely distributed only among registered
  10.     AmigaE owners.
  11.  */
  12.  
  13.  
  14. MODULE 'tools/ilbm', 'tools/ilbmdefs',
  15.     'intuition/intuition',
  16.     'asl', 'libraries/ASL'
  17.  
  18. DEF bm,win:PTR TO window,
  19.     buffer[256]:ARRAY
  20.  
  21. PROC main()
  22. DEF ilbm,filename,width,height,bmh:PTR TO bmhd,pi:PTR TO picinfo
  23.  
  24. IF filename:=requestfile('Select picture')
  25.     IF ilbm:=ilbm_New(filename,0)
  26.         ilbm_LoadPicture(ilbm,[ILBML_GETBITMAP,{bm},0])
  27.  
  28.         -> get a pointer TO the images picture-info, we extract the bitmap header,
  29.         -> and read the picture's size.
  30.         pi:=ilbm_PictureInfo(ilbm)
  31.         bmh:=pi.bmhd;
  32.         width:=bmh.w;
  33.         height:=bmh.h;
  34.  
  35.         -> the ilbm-handle is no longer needed, we can free it
  36.         ilbm_Dispose(ilbm)
  37.  
  38.         -> if a bitmap actually opened, open a window, and blit it in
  39.         IF bm
  40.             IF win:=OpenWindowTagList(0,[WA_INNERWIDTH,width,WA_INNERHEIGHT,height,
  41.                 WA_AUTOADJUST,-1,
  42.                 WA_IDCMP,IDCMP_CLOSEWINDOW,
  43.                 WA_FLAGS,WFLG_CLOSEGADGET+WFLG_DRAGBAR+WFLG_DEPTHGADGET,
  44.                 WA_TITLE,filename,
  45.                 WA_SCREENTITLE,'Pic-Window 0.1 1994 Michael Zucchi',0])
  46.  
  47.                 -> bit into actual dimensions the OS could give us (the window might not be as big as the picture)
  48.                 BltBitMapRastPort(bm,0,0,win.rport,
  49.                     win.borderleft,win.bordertop,
  50.                     win.width-win.borderright-win.borderleft,
  51.                     win.height-win.borderbottom-win.bordertop,$c0);
  52.  
  53.                 WaitPort(win.userport)
  54.                 CloseWindow(win)
  55.  
  56.             ENDIF
  57.             ilbm_FreeBitMap(bm)
  58.         ENDIF
  59.     ENDIF
  60. ENDIF
  61.  
  62. ENDPROC
  63.  
  64. /*
  65.     Presents an ASL load-file requester.  If the user selected a file, it is
  66.     expanded to a full path-name.
  67.  */
  68. PROC requestfile(title)
  69. DEF name=0,fr:PTR TO filerequester
  70.  
  71. IF aslbase:=OpenLibrary('asl.library',36)
  72.     IF fr:=AllocAslRequest(ASL_FILEREQUEST,[ASLFR_TITLETEXT,title,0])
  73.         IF AslRequest(fr,0)
  74.  
  75.             -> sorry, a bit of ASM here.  Well ... how ELSE?
  76.             -> this does a strcpy() ...
  77.             MOVE.L    fr,A0
  78.             MOVE.L    8(A0),A0    -> directory pointer from 'filerequester'
  79.             MOVE.L    buffer,A1
  80.         cp:    MOVE.B    (A0)+,(A1)+
  81.             BNE.S    cp
  82.  
  83.             AddPart(buffer,fr.file,256)
  84.             name:=buffer
  85.         ENDIF
  86.         FreeAslRequest(fr)
  87.     ENDIF
  88.     CloseLibrary(aslbase)
  89. ENDIF
  90.  
  91. ENDPROC name
  92.  
  93.