aries@rhi.hi.is (Mimir Reynisson) (05/24/91)
Hi, I have a very small problem, a two-byte problem to be precise. I have written a little utility which parses a PICT2 file and extracts all the bitmaps contained in it. Now the problem is a very slight one and it is to do with UnpackBits, according to the documentation in Inside Mac.V the pixData is in the following format: if rowBytes < 8 then data is unpacked data size = rowBytes * (bounds.bottom-bounds.top); if rowBytes >= 8 then data is packed Image contains (bounds.bottom-bounds.top) packed scanlines. Packed scanlines are produced by the PackBits routine. Each scanline consists of [byteCount] [data]. if rowBytes > 250 then byteCount is a word, else it is a byte. I can parse the entire PICT file and extract the color table from the bitmap and read all the _packed_ scanlines, but when I try to unpack them with the following method: In this loop I go backwards through the scanline buffer previously read in from disk. The count value has been initialized to the rowBytes value contained in the pixMap header. FOR indx := scanlines DOWNTO 1 DO BEGIN scanline := Ptr(LongInt(scanline) - SizeOf(Ptr)); pixData := Handle(scanline)^; UnpackBits(pixData, bmpLine, count); FailOnErr(FSWrite(bmpRef, count, bmpLine)); DisposPtr(pixData); END; Now I have tried both including the [byteCount] stored in the PICT file for each scanline in the first byte or word (depending on if rowbytes is greater than 250) of pixData. This code fragment above crashes the computer quite seriously, but if the UnpackBits command is removed it runs smoothly on any PICT file. There is one things I noticed when I looked at the UnpackBits command in IM 1 and that is that PackBits has a maximum bytecount of >127<. So I began to wonder if each scanline is divided into sections of maximum size 127 bytes and that I should try to unpack these sections rather than the entire scanline. Though I'm not too sure, the documentation certainly doesn't mention anything like that. So am I just stupid or is my head to far down in the bucket and I simply can't see some simple little detail? Hope I have given sufficent detail and thanks in advance :) P.S.: Don't give me any c*ap about _not_ parsing PICT files myself ... please _____________________________________________________________________________ Mimir Reynisson (aries@rhi.hi.is) Technology Development Centre Aries Software, Inc. Dunhagi 5, IS-107 Reykjavik -----------------------------------------------------------------------------