[comp.sys.amiga] IFF Format

ewhac@well.UUCP (Leo L. Schwab) (04/07/88)

[ Cross-posted to comp.sys.amiga, and followups directed there. ]

In article <1328@silver.bacs.indiana.edu> sl137223@silver.UUCP, an ST user,
descibes IFF format bitmap files.

	Oy vey, have *you* got it wrong!

	Actually, this isn't totally fair.  You got the basic structure
right, but in the real world, IFF can take an infinite number of forms.
Your article made IFF seem like a very simple storage format, but it isn't.

	In order to correctly read an IFF file, you need to write a
recursive descent parser.  You can get away with a simple scanner/reader for
FORM ILBM's, but the moment you encounter a LIST or CAT file, you'll toss
your cookies (fortunately, there aren't many LISTs or CATs running around).

	The cheap way to do it is to scan the file for the opening longword
which is the ASCII string 'FORM'.  The next longword is the size in bytes.
The next longword will be the ASCII string 'ILBM'.  If you don't get this
right off the bat, your program should give up.

	At this point, *ANYTHING* can happen.  Usually, you will encounter a
chunk describing the characteristics of the bitmap.  This is flagged by the
longword-string 'BMHD' followed by a longword indicating the size of the
header structure, followed by the structure itself.

	After this you can run into nearly *anything*, and you need to know
how to intelligently deal with it.  You can bump into CMAP hunks, CAMG
hunks, DPPV hunks, CRNG hunks, and all sorts of other nonsense.  Or, you may
encounter *NONE* of these things.  In *ALL* cases, you must know how to
handle it.

	The last thing you'll encounter (*usually*) is the 'BODY' hunk,
which is the actual bitmap image, and which may or may not be compressed
using run-length encoding.

	All in all, IFF is a real bitch to do right.

	If you want to get the official IFF documents, complete with Lattice
C source code on an Amiga-format disk, send $20 to:

	Commodore Amiga Technical Support
	ATTN: Lauren Brown
	1200 Wilson Drive
	West Chester, PA   19380

	If you have any more questions pertaining to IFF, you really ought
to post them in comp.sys.amiga, since we have to deal with this mess almost
every day.  (Followups have been directed there.)

Disclaimer: I think IFF is a royal pain, since it's non-trivial to write a
reader program for an IFF file.  This should not be the case.
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
Leo L. Schwab -- The Guy in The Cape  ihnp4!pacbell -\
 \_ -_		Recumbent Bikes:	      dual ---> !{well,unicom}!ewhac
O----^o	      The Only Way To Fly.	      hplabs / (pronounced "AE-wack")
"Work FOR?  I don't work FOR anybody!  I'm just having fun."  -- The Doctor

mcdonald@fornax.UUCP (Ken Mcdonald) (02/22/89)

Could some kind soul please post or (preferably) send me a full description
of the IFF format, or at least references to where to obtain a complete and
clear description?  I'm a Mac II hacker, and I'd like to write an app to
convert back and for between Mac and Amiga pictures.  If possible, I'd
like:
	--description of IFF format for graphics, including any common
compression schemes.
	--descriptions of the working of the HAM mode, and its interactions
with IFF.
	--descriptions of other common picture formats, if any, for the
Amiga (aside from GIF, which I more or less know, but if you have good
GIF docs, I'd appreciate those too.)

Format for descriptions is (decreasing order of preference):
	--Pascal, C, or other language source code to read IFF files.
(I believe there are a few things like this floating around, but I can't
read ZOO files.)
	--description of the iff format
	--references to iff descriptions.

Please send your replies as standard text, not compress.  e-mail if
possible, (follow the return path), I'll try to read comp.sys.amiga for
the next week or so, but may miss followups.

Thanks for the help!

Ken McDonald
{...!ubc-cs!mcdonald@fornax.uucp}--but if you can, just follow the return
path.

ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) (02/27/89)

In article <895@fornax.UUCP> mcdonald@fornax.UUCP (Ken Mcdonald) writes:
>Could some kind soul please post or (preferably) send me a full description
>of the IFF format, [ ... ]

	The spec is enormous, and is far too large to post here.  It's also
probably too large to send via mail (the last time I sent it to someone, one
of the intervening postmasters complained about it).

	The IFF spec, however, is available from CATS.  For $20, you get a
quasi-spiral-bound book with the full IFF and ILBM specs, and source
listings to an IFF parser (which is next to useless, since the code is
unreadable).  You also get an Amiga-format disk with the full text of the
spec in machine-readable format, all the IFF sources, and some other example
programs.  The address to send your money to is something very close to:

	CATS Orders
	1200 Wilson Drive
	West Chester, PA   19380

_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
Leo L. Schwab -- The Guy in The Cape	INET: well!ewhac@ucbvax.Berkeley.EDU
 \_ -_		Recumbent Bikes:	UUCP: pacbell > !{well,unicom}!ewhac
O----^o	      The Only Way To Fly.	      hplabs / (pronounced "AE-wack")
"Work FOR?  I don't work FOR anybody!  I'm just having fun."  -- The Doctor

jjoshua@topaz.rutgers.edu (Jon Joshua) (06/05/89)

I could use some info on the .IFF format.  Specifically, I need to
know  how the header is laid out and how the data should be converted
to form the actual pixels.



JOn.
-- 
                        /\                    ?               ________________ 
jjoshua@topaz.rutgers.edu \  ____   __       fgu             |.signature under|
 Anything is possible...   \ |  |  / |     orywlut-          |  construction  |
                            ==========    gfgsdfsdfsd        |________________|
_____________________________OO_____O___hfdhksjdhfksjdfs_______||__________||__

jjoshua@topaz.rutgers.edu (Jon Joshua) (07/22/89)

I need specs for the .IFF format - in particular, graphics files.


Simple enuf,
JOn.
-- 
                        /\                    ?               ________________ 
jjoshua@topaz.rutgers.edu \  ____   __       fgu             |.signature under|
 Anything is possible...   \ |  |  / |     orywlut-          |  construction  |
                            ==========    gfgsdfsdfsd        |________________|
_____________________________OO_____O___hfdhksjdhfksjdfs_______||__________||__

pdermody@maths.tcd.ie (Paul Dermody) (10/03/89)

I am looking for help with the format if IFF picture files.
	1. I have some documantation from a magazine which says that
if the byte which refers to the masking tecnique is equal to 1, then
there is a mask interleaved with the data. I saved a picture using
DPII while a there was a stencil on and I got the relevent byte equal to
1, but I don't know which plane of data refers to the mask. Is it the
first/last plane, or is it application dependent?
	2. What is the format for the following chunks:
		GRAB	refers to a hotspot.
		DEST	?
		SPRT	sprite data.
		CAMG	something to do with HAM.
	    and any other chunks if there are any.

I realise that some of these questions require answers which are not exactly
neat and concise, but any help will be greatly appreciated.

Thanks, in advance, for any help. Mail directly to me, rather than post
it unless these type of questions are asked often. Or if I get many replies
or requests for info. I will post a summary.
BTW, I do not have the RKM's, I know I should but I don't.( They are first on
my list when I win the lottery. )

-- 
Paul Dermody: Mathsc.   | "An Irishman who doesn't drink. There's a turn up  
Trinity College, Dublin | for the books!": Light a penny candle, Maeve Binchy.
Ireland.                | "An Irishman who doesn't drink. Isn't that a
  Theorem: 26 + 6 = 1   |  Contradiction in terms?": Staten Island bouncer.