Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!columbia!rutgers!cbmvax!carolyn From: carolyn@cbmvax.cbm.UUCP (Carolyn Scheppner CATS) Newsgroups: comp.sys.amiga Subject: Re: DPaint II brushes to C Message-ID: <1836@cbmvax.cbmvax.cbm.UUCP> Date: Tue, 5-May-87 19:53:54 EDT Article-I.D.: cbmvax.1836 Posted: Tue May 5 19:53:54 1987 Date-Received: Thu, 7-May-87 06:04:03 EDT References: <2078@hoptoad.uucp> <2972@well.UUCP> <2973@well.UUCP> <2082@hoptoad.uucp> Reply-To: carolyn@cbmvax.UUCP (Carolyn Scheppner CATS) Distribution: world Organization: Commodore Technology, West Chester, PA Lines: 68 In article <2082@hoptoad.uucp> slc@hoptoad.UUCP (Steve Costa) writes: > >I used NEWZAP to look at the hex data for my DPaint II brushes, and >discovered that the "BODY" label was 64 bytes farther on than gi expected. >So, I changed gi.c to fseek() 64 bytes further and re-compiled it; it seems >to work. Sounds simple in retrospect, but it was unknown territory for me. > >It's not generalized, but it will work for my purposes. I'm glad you found a quick fix for yourself, even though it makes me CRINGE to see IFF files handled in such an incompatible way. Now PLEASE listen, everybody: It's not that hard to write a cheap chunk-oriented IFF reader. You don't even need the IFF modules. I've even written one in Basic. If you don't use the IFF modules, it may not be TOTALLY compatible but it will at least be able to handle FILES WITH EXTRA CHUNKS ! --------------------------------------------------------------------------- It's very simple: 1. Open the file 2. Make sure the first ULONG is "FORM" 3. Make sure the third ULONG is "ILBM" (or whatever FORM you want) LOOP UNTIL EOF: (You have 2 ULONG variables, ChunkID and ChunkLen) { 4. Read next ULONG into ChunkID, Read following ULONG into ChunkLen (Using switch statement on ChunkID or a bunch of if-elseif-elseif's) 5. Is this a chunk I want ? YES: Read the WHOLE chunk and do what you want. NO: Seek ChunkLen number of bytes EITHER YES OR NO: If ChunkLen is odd, Seek 1 byte (Now you are now positioned at the next ChunkID or EOF) } -------------------------------------------------------------------------- This type of reader will give a moderate amount of cross-application and cross-version compatibility to simple utilities which operate on IFF files. It is NOT intended for commercial applications ! This simple reader does NOT follow all of the IFF rules or handle all of the permutations of IFF files. But it WILL allow utilities like "gi" to find the chunks they need REGARDLESS of what additional chunks are in the FORM. So please, take a little extra time and write code that will last. --------------------------------------------------------------------------- The preceding was a public service message from the IFF POLICE !!!!!! (Hardcoding Seeks on IFF Files ???? Go ahead... Make my day.) BLAAAAMMMMMMMM ! -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Carolyn Scheppner -- CBM >>Amiga Technical Support<< UUCP ...{allegra,caip,ihnp4,seismo}!cbmvax!carolyn PHONE 215-431-9180 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=