home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / fish / applications / xlispstat / src / src1.lzh / Amiga / misc.c < prev    next >
C/C++ Source or Header  |  1990-10-11  |  3KB  |  71 lines

  1. /* Misc.c - miscellaneous Amiga specific routines                      */
  2. /* Copyright (c) 1990 by J.K. Lindsey                                  */
  3. /* Additions to XLISP-STAT 2.1 Copyright (c) 1990, by Luke Tierney     */
  4. /* Additions to Xlisp 2.1, Copyright (c) 1989 by David Michael Betz    */
  5. /* You may give out copies of this software; for conditions see the    */
  6. /* file COPYING included with this distribution.                       */
  7.  
  8. #include <proto/intuition.h>
  9. #include <proto/icon.h>
  10. #include <workbench/workbench.h>
  11. #include <proto/dos.h>
  12. #include <proto/graphics.h>
  13.  
  14. #define FDwAT
  15. #include <iff/ilbm.h>
  16. #include "plot2.h"
  17. #include "autil2.h"
  18.  
  19. typedef struct {ULONG ViewModes;} CamgChunk;
  20. #define PutCAMG(context,camg) \
  21.         PutCk(context,ID_CAMG,sizeof(CamgChunk),(BYTE *)camg)
  22. #define CkErr(expression) {if(ifferr==IFF_OKAY)ifferr=(expression);}
  23.  
  24. SaveWindow(window,fname,leftedge,topedge,width,height)
  25. int leftedge,topedge,width,height;
  26. struct Window *window;
  27. char fname[];{
  28.    LONG file;
  29.    BYTE buffer[512];
  30.    BitMapHeader bmHdr;
  31.    IFFP ifferr;
  32.    struct BitMap *bitmap;
  33.    struct ViewPort *viewport;
  34.    GroupContext fileContext,formContext;
  35.    if(!(file=Open(fname,MODE_NEWFILE)))return(1);
  36.    Write(file,"x",1);
  37.    viewport=&(window->WScreen->ViewPort);
  38.    bitmap=(window->RPort)->BitMap;
  39.    if(width%2)width++;
  40.    if((RowBytes(width)<<3)-width<(window->LeftEdge+leftedge)%8)width+=16;
  41.    ifferr=InitBMHdr(&bmHdr,bitmap,mskNone,cmpByteRun1,0,(short)width,
  42.    (short)height,(window->WScreen)->Width,(window->WScreen)->Height);
  43.    CkErr(OpenWIFF(file,&fileContext,szNotYetKnown));
  44.    CkErr(StartWGroup(&fileContext,FORM,szNotYetKnown,ID_ILBM,&formContext));
  45.    CkErr(PutBMHD(&formContext,&bmHdr));
  46.    bmHdr.x=leftedge; bmHdr.y=topedge; bmHdr.w=width;
  47.    CkErr(PutCMAP(&formContext,(WORD *)viewport->ColorMap->ColorTable,bitmap->Depth));
  48.    CkErr(PutBODY(window,&formContext,bitmap,0,&bmHdr,buffer,512));
  49.    CkErr(EndWGroup(&formContext));
  50.    CkErr(CloseWGroup(&fileContext));
  51.    Close(file);
  52.    return(ifferr!=IFF_OKAY);}
  53.  
  54. MakeIcon(imagedata,w,h,deftool,fname,stack)
  55. UWORD imagedata[];
  56. int w,h,stack;
  57. char *deftool,*fname;{ 
  58.    static struct Image iconimage={0,0,0,0,2,0,3,0};
  59.    static struct DiskObject iconobject={WB_DISKMAGIC,WB_DISKVERSION,0,0,0,0,0,
  60.                  GADGHBOX|GADGIMAGE,RELVERIFY|GADGIMMEDIATE,BOOLGADGET,0,0,0,0,
  61.                  0,0,0,4,0,0,NO_ICON_POSITION,NO_ICON_POSITION,0,0,0};
  62.    iconimage.Width=w;
  63.    iconimage.Height=h;
  64.    iconimage.ImageData=&imagedata[0];
  65.    iconobject.do_Gadget.Width=w;
  66.    iconobject.do_Gadget.Height=h;
  67.    iconobject.do_Gadget.GadgetRender=(APTR)&iconimage;
  68.    iconobject.do_DefaultTool=deftool;
  69.    iconobject.do_StackSize=stack;
  70.    return(!PutDiskObject(fname,&iconobject));}
  71.