[comp.sys.mac.programmer] UnpackBits question

bill@hao.ucar.edu (Bill Roberts) (04/03/89)

I want to read a Macpaint file, unpack the bit image and write out the unpacked
bits to a file.  Simply enough, right?  But IM sez 

	UnpackBits (VAR srcPtr, dstPtr: Ptr; dstBytes: INTEGER);

where dstBytes is the length that the expanded data will be; it should be the
value that was passed to PackBits.  Now, I don't know what that value is.  Can
anyone give me a hint on how to find out this value.  IM sez srcPtr will be 
incremented the number of expanded bytes, but that doesn't help me.  I
read the file ok and then do an lseek() to set the file cursor past the header 
stuff.   Thanks in advance.  I hope this isn't a stupid question!

--Bill

UUCP: {nbires, noao}!ncar!hao!bill
CSNET: bill@ncar.csnet
ARPA: bill%ncar@CSNET-RELAY.ARPA
INTERNET: bill@hao.ucar.edu

  "... the Eagle Wing palace of the Queen Chinee'"

mystone@caen.engin.umich.edu (Dean Yu) (04/03/89)

In article <1709@ncar.ucar.edu> bill@hao.ucar.edu (Bill Roberts) writes:
>I want to read a Macpaint file, unpack the bit image and write out the unpacked
>bits to a file.  Simply enough, right?  But IM sez 
>
>	UnpackBits (VAR srcPtr, dstPtr: Ptr; dstBytes: INTEGER);
>
>where dstBytes is the length that the expanded data will be; it should be the
>value that was passed to PackBits.  Now, I don't know what that value is.  Can
>anyone give me a hint on how to find out this value.

  MacPaint uses the maximum number of bytes that PackBits can pack at once,
namely 127 bytes.  So you should call UnpackBits with dstBytes equal to 127.
By the way, one of the earlier Tech Notes -- I forget which one; I think it's
in the teens -- has a sample program that will read a MacPaint file.

 
_______________________________________________________________________________
Dean Yu                            | E-mail: mystone@{sol,caen}.engin.umich.edu
University of Michigan             | Real-mail: Dean Yu
Computer Aided Engineering Network |            2413 Kelsey House
===================================|            600 E Madison
"These are MY opinions." (My       |            Ann Arbor, MI 48109
 employer doesn't want them.       |===========================================
 Actually, they don't really care  | 
 what I think.  But President      |   This space intentionally left blank.  
 Duderstadt does...)               | 
-------------------------------------------------------------------------------  

lsr@Apple.COM (Larry Rosenstein) (04/04/89)

Tech Note #86 has example code for reading & writing MacPaint files.  It 
uses 72 as the number to pass to UnpackBits.

Larry Rosenstein, Apple Computer, Inc.
Object Specialist

Internet: lsr@Apple.com   UUCP: {nsc, sun}!apple!lsr
AppleLink: Rosenstein1