diff options
author | Christian A. Weber <chris@gna.ch> | 1993-05-24 15:43:21 +0000 |
---|---|---|
committer | Christian A. Weber <chris@gna.ch> | 1993-05-24 15:43:21 +0000 |
commit | 5a9b9a491af1dd7b1a0a9bf9241d6e67b40bee0f (patch) | |
tree | 10461c3ab017d892df93ff4c15d2576447891aa3 /Examples | |
parent | 7d8886fbc4c9616cad689785c876825d8114b040 (diff) | |
download | iff-library-5a9b9a491af1dd7b1a0a9bf9241d6e67b40bee0f.tar.gz iff-library-5a9b9a491af1dd7b1a0a9bf9241d6e67b40bee0f.tar.bz2 iff-library-5a9b9a491af1dd7b1a0a9bf9241d6e67b40bee0f.zip |
*** empty log message ***
Diffstat (limited to 'Examples')
-rw-r--r-- | Examples/AnimExample.c | 6 | ||||
-rw-r--r-- | Examples/EasyExample.c | 8 | ||||
-rw-r--r-- | Examples/GrabScreen.c | 93 | ||||
-rw-r--r-- | Examples/Grabber.S | 6 | ||||
-rw-r--r-- | Examples/Makefile | 6 |
5 files changed, 64 insertions, 55 deletions
diff --git a/Examples/AnimExample.c b/Examples/AnimExample.c index e45696d..1505a34 100644 --- a/Examples/AnimExample.c +++ b/Examples/AnimExample.c @@ -1,12 +1,12 @@ /* ** -** $Id: AnimExample.c,v 21.1 92/05/28 17:09:27 chris Exp $ +** $Id: AnimExample.c,v 21.1 92/06/02 18:08:33 chris Exp $ ** $Revision: 21.1 $ ** ** $Filename: Examples/AnimExample.c $ ** $Author: Christian A. Weber $ -** $Release: 21.1 $ -** $Date: 92/05/28 17:09:27 $ +** $Release: 23.2 $ +** $Date: 92/06/02 18:08:33 $ ** ** A simple DPaint ANIM player. To compile with Lattice C 5.x, just ** type 'lmk'. For other compilers you may have to do minor changes. diff --git a/Examples/EasyExample.c b/Examples/EasyExample.c index c4cca07..11772f9 100644 --- a/Examples/EasyExample.c +++ b/Examples/EasyExample.c @@ -1,12 +1,12 @@ /* ** -** $Id: EasyExample.c,v 21.1 92/05/28 17:09:27 chris Exp $ -** $Revision: 21.1 $ +** $Id: EasyExample.c,v 21.2 92/06/02 18:08:10 chris Exp $ +** $Revision: 21.2 $ ** ** $Filename: Examples/EasyExample.c $ ** $Author: Christian A. Weber $ -** $Release: 21.1 $ -** $Date: 92/05/28 17:09:27 $ +** $Release: 23.2 $ +** $Date: 92/06/02 18:08:10 $ ** ** A simple ILBM file viewer. To compile with Lattice C 5.x, just ** type 'lmk'. For other compilers you may have to do minor changes. diff --git a/Examples/GrabScreen.c b/Examples/GrabScreen.c index fde0bf2..a3eca8d 100644 --- a/Examples/GrabScreen.c +++ b/Examples/GrabScreen.c @@ -1,20 +1,20 @@ /* ** -** $Id: GrabScreen.c,v 21.1 92/05/18 01:05:18 chris Exp $ -** $Revision: 21.1 $ +** $Id: GrabScreen.c,v 22.4 93/02/03 02:06:54 chris Exp $ +** $Revision: 22.4 $ ** ** $Filename: Examples/GrabScreen.c $ ** $Author: Christian A. Weber $ -** $Release: 21.1 $ -** $Date: 92/05/18 01:05:18 $ +** $Release: 23.2 $ +** $Date: 93/02/03 02:06:54 $ ** -** IFF library example program. Compile with Lattice C 5.x. +** IFF library example program. Compile with SAS/C 5.x or newer. ** This program saves the contents of the frontmost screen as an IFF file ** with filename 'RAM:grabscreen.pic'. ** This example makes use of the IFFL_PushChunk() / IFFL_WriteChunkBytes() / ** IFFL_PopChunk() functions, it does not use IFFL_SaveBitMap(). ** -** COPYRIGHT (C) 1987-1992 BY CHRISTIAN A. WEBER, BRUGGERWEG 2, +** COPYRIGHT (C) 1987-1993 BY CHRISTIAN A. WEBER, BRUGGERWEG 2, ** CH-8037 ZUERICH, SWITZERLAND. ** THIS FILE MAY BE FREELY DISTRIBUTED. USE AT YOUR OWN RISK. ** @@ -62,7 +62,7 @@ */ struct Library *IFFBase; -char version[] = "\0$VER: GrabScreen 21.2 by Christian A. Weber"; +char version[] = "\0$VER: GrabScreen 22.4 by Christian A. Weber"; /**************************************************************************** @@ -82,7 +82,7 @@ BOOL MySaveScreen(struct Screen *screen,char *filename) /* ** Open the file for writing */ - if(iff = IFFL_OpenIFF(filename,IFFL_MODE_WRITE)) + if (iff = IFFL_OpenIFF(filename, IFFL_MODE_WRITE) ) { struct IFFL_BMHD bmhd; ULONG modeid; @@ -109,15 +109,15 @@ BOOL MySaveScreen(struct Screen *screen,char *filename) /* ** Create the BMHD chunk. (goto considered useful :-)) */ - if(IFFL_PushChunk(iff,ID_ILBM,ID_BMHD)) + if (IFFL_PushChunk(iff, ID_ILBM, ID_BMHD) ) { - if(!IFFL_WriteChunkBytes(iff,&bmhd,sizeof(bmhd))) + if (!IFFL_WriteChunkBytes(iff, &bmhd, sizeof(bmhd)) ) { printf("Error writing BMHD data.\n"); goto error; } - if(!IFFL_PopChunk(iff)) + if (!IFFL_PopChunk(iff) ) { printf("Error closing BMHD chunk.\n"); goto error; @@ -133,13 +133,13 @@ BOOL MySaveScreen(struct Screen *screen,char *filename) ** Create the CMAP chunk. */ count = screen->ViewPort.ColorMap->Count; - if(colortable = AllocMem(count * 3, MEMF_ANY)) + if (colortable = AllocMem(count * 3, MEMF_ANY)) { int i; - for(i=0; i<count; ++i) + for (i=0; i<count; ++i) { - UWORD rgb4 = GetRGB4(screen->ViewPort.ColorMap,i); + UWORD rgb4 = GetRGB4(screen->ViewPort.ColorMap, i); colortable[i*3+0] = (rgb4 >> 4) & 0xF0; colortable[i*3+0] |= colortable[i*3+0] >> 4; @@ -151,15 +151,15 @@ BOOL MySaveScreen(struct Screen *screen,char *filename) colortable[i*3+2] |= colortable[i*3+2] >> 4; } - if(IFFL_PushChunk(iff,ID_ILBM,ID_CMAP)) + if (IFFL_PushChunk(iff, ID_ILBM, ID_CMAP) ) { - if(!IFFL_WriteChunkBytes(iff,colortable,count * 3)) + if (!IFFL_WriteChunkBytes(iff, colortable, count * 3) ) { printf("Error writing CMAP data.\n"); goto error; } - if(!IFFL_PopChunk(iff)) + if (!IFFL_PopChunk(iff) ) { printf("Error closing CMAP chunk.\n"); goto error; @@ -171,24 +171,24 @@ BOOL MySaveScreen(struct Screen *screen,char *filename) goto error; } - FreeMem(colortable,count * 3); + FreeMem(colortable, count * 3); } /* ** Get the viewport's modes for the CAMG chunk. */ modeid = (GfxBase->LibNode.lib_Version >= 36) ? - GetVPModeID(&screen->ViewPort) : (screen->ViewPort.Modes&OLDCAMGMASK); + GetVPModeID(&screen->ViewPort) : (screen->ViewPort.Modes & OLDCAMGMASK); - if(IFFL_PushChunk(iff,ID_ILBM,ID_CAMG)) + if (IFFL_PushChunk(iff, ID_ILBM, ID_CAMG) ) { - if(!IFFL_WriteChunkBytes(iff,&modeid,sizeof(modeid))) + if (!IFFL_WriteChunkBytes(iff, &modeid, sizeof(modeid)) ) { printf("Error writing CAMG data.\n"); goto error; } - if(!IFFL_PopChunk(iff)) + if (!IFFL_PopChunk(iff) ) { printf("Error closing CAMG chunk.\n"); goto error; @@ -203,28 +203,35 @@ BOOL MySaveScreen(struct Screen *screen,char *filename) /* ** Generate BODY */ - if(IFFL_PushChunk(iff,ID_ILBM,ID_BODY)) + if (IFFL_PushChunk(iff, ID_ILBM, ID_BODY) ) { UBYTE *bodybuf; - if(bodybuf = AllocMem(BODYBUFSIZE,MEMF_ANY)) + if (bodybuf = AllocMem(BODYBUFSIZE, MEMF_ANY) ) { UBYTE *planes[MAXSAVEDEPTH]; - int row,rowbytes,iplane,bodysize=0; + int row, rowbytes, iplane, bodysize=0; - rowbytes = bitmap->BytesPerRow; + /* + ** Under OS 3.x, we are not allowed to read the fields of a + ** BitMap structure directly (strange results may happen due + ** to ILBM modes), so we call GetBitMapAttr() under 3.x. + */ + rowbytes = (GfxBase->LibNode.lib_Version >= 39) ? + (GetBitMapAttr(bitmap, BMA_WIDTH) >> 3) : + bitmap->BytesPerRow; /* ** Copy the plane pointers into the local array "planes" */ - for(iplane=0; iplane < bmhd.nPlanes; ++iplane) + for (iplane=0; iplane < bmhd.nPlanes; ++iplane) { planes[iplane] = bitmap->Planes[iplane]; } - for(row=0; row < bmhd.h; ++row) + for (row=0; row < bmhd.h; ++row) { - for(iplane=0; iplane < bmhd.nPlanes; ++iplane) + for (iplane=0; iplane < bmhd.nPlanes; ++iplane) { int comprsize; @@ -232,9 +239,9 @@ BOOL MySaveScreen(struct Screen *screen,char *filename) ** To speed up things, we collect as much data ** as possible in bodybuf before we write it out. */ - if(bodysize > (BODYBUFSIZE-MAXPACKEDSIZE(rowbytes))) + if (bodysize > (BODYBUFSIZE-MAXPACKEDSIZE(rowbytes)) ) { - if(!IFFL_WriteChunkBytes(iff,bodybuf,bodysize)) + if (!IFFL_WriteChunkBytes(iff, bodybuf, bodysize) ) { printf("Error writing BODY data.\n"); goto error; @@ -245,30 +252,30 @@ BOOL MySaveScreen(struct Screen *screen,char *filename) /* ** Compress the next row */ - if(!(comprsize = IFFL_CompressBlock(planes[iplane], - bodybuf+bodysize,rowbytes,IFFL_COMPR_BYTERUN1))) + if ( !(comprsize = IFFL_CompressBlock(planes[iplane], + bodybuf+bodysize, rowbytes, IFFL_COMPR_BYTERUN1)) ) { printf("Error compressing BODY data.\n"); goto error; } bodysize += comprsize; - planes[iplane] += rowbytes; + planes[iplane] += bitmap->BytesPerRow; /* next line */ } } /* ** Now we're done, so flush the body data buffer */ - if(bodysize) + if (bodysize) { - if(!IFFL_WriteChunkBytes(iff,bodybuf,bodysize)) + if (!IFFL_WriteChunkBytes(iff, bodybuf, bodysize) ) { printf("Error writing BODY data.\n"); goto error; } } - FreeMem(bodybuf,BODYBUFSIZE); + FreeMem(bodybuf, BODYBUFSIZE); } else { @@ -276,7 +283,7 @@ BOOL MySaveScreen(struct Screen *screen,char *filename) goto error; } - if(!IFFL_PopChunk(iff)) + if (!IFFL_PopChunk(iff) ) { printf("Error closing BODY chunk.\n"); goto error; @@ -299,6 +306,7 @@ error: return result; } + /**************************************************************************** ** Main program */ @@ -307,21 +315,21 @@ int main(int argc, char **argv) { int result = RETURN_FAIL; - if(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0)) + if (GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0L) ) { - if(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0)) + if (IntuitionBase = (void *)OpenLibrary("intuition.library", 0) ) { /* ** For the new functions we need at least version 21 of iff.library. */ - if(IFFBase = OpenLibrary(IFFNAME,21)) + if (IFFBase = OpenLibrary(IFFNAME, 21L) ) { /* ** Note that we don't lock the screen, so it might go away while ** we're writing its contents to the file, and the picture may ** then contain garbage. */ - MySaveScreen(IntuitionBase->FirstScreen,"RAM:grabscreen.pic"); + MySaveScreen(IntuitionBase->FirstScreen, "RAM:grabscreen.pic"); result = RETURN_OK; CloseLibrary(IFFBase); @@ -338,3 +346,4 @@ int main(int argc, char **argv) return result; } + diff --git a/Examples/Grabber.S b/Examples/Grabber.S index 1a7faa1..3a3a91a 100644 --- a/Examples/Grabber.S +++ b/Examples/Grabber.S @@ -1,11 +1,11 @@ ** -** $Id: Grabber.S,v 21.1 92/05/28 17:09:27 chris Exp $ +** $Id: Grabber.S,v 21.1 92/06/02 18:09:22 chris Exp $ ** $Revision: 21.1 $ ** ** $Filename: Examples/Grabber.S $ ** $Authors: Christian Haller, CHW $ -** $Release: 21.1 $ -** $Date: 92/05/28 17:09:27 $ +** $Release: 23.2 $ +** $Date: 92/06/02 18:09:22 $ ** ** Example for low level Assembler hackers :-) ** diff --git a/Examples/Makefile b/Examples/Makefile index 3343a0d..5e4990f 100644 --- a/Examples/Makefile +++ b/Examples/Makefile @@ -1,11 +1,11 @@ ## -## $Id: $ -## $Revision: $ +## $Id: Makefile,v 21.1 92/06/02 18:14:03 chris Exp $ +## $Revision: 21.1 $ ## ## $Filename: Examples/Makefile $ ## $Author: Christian A. Weber $ ## $Release: 21.1 $ -## $Date: 92/05/17 03:09:18 $ +## $Date: 92/06/02 18:14:03 $ ## ## Makefile to build iff.library examples ## |