Article View: comp.sys.mac
Article #19644Re: Help wanted: LSC, MacPaint
From: David Palmer
Date: Tue, 29 Sep 1987 20:00
Date: Tue, 29 Sep 1987 20:00
36 lines
2263 bytes
2263 bytes
In article <3320023@hpcid.HP.COM> tedj@hpcid.HP.COM (Ted Johnson) writes:
>
>The following 90 line program is my attempt at using a SFGetFile dialog
>to select a MacPaint file, and then using CopyBits to display the file
>on the Mac's screen. This program is meant to be a Lightspeed C version
>of Technical Note #86, which gave a Pascal example for reading a MacPaint
>file.
>
>Unfortunately, this program displays junk (it looks like "snow" on a
>TV screen) on the Mac's screen instead of the MacPaint picture. Any clues
>as to where I'm going wrong would be greatly appreciated! (I suspect that
>my syntax in calling CopyBits() is wrong...)
...
>
> for (scanLine = 1; scanLine <= 720; scanLine++) {
> UnpackBits(srcPtr, dstPtr, 72);
> }
If UnpackBits() is defined with srcPtr and dstPtr as VAR, then the line
should be:
UnpackBits(&srcPtr, &dstPtr, 72);
The loop as it stands does not change srcPtr and dstPtr so you do the
same thing 720 times, and the wrong thing to boot. In C, you 'call by
name' by passing a pointer to an object.
Stylistic note: most C programmers would write the first line:
for (scanLine = 0 ; scanLine < 720 ; scanLine++)
because this would allow the use of scanLine as an array index. (In C,
a 720 element array has indices from 0 to 719, inclusive). This is unimportant
in this case, but you might as well be consistent.
David Palmer
palmer@tybalt.caltech.edu
...rutgers!cit-vax!tybalt.caltech.edu!palmer
The opinions expressed are those of an 8000 year old Atlantuan
priestess named Mrla, and not necessarily those of her channel.
Technical Details
Message-ID:
<4096@cit-vax.Caltech.Edu>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!amdcad!ames!elroy!cit-vax!tybalt.caltech.edu!palmerReferences:
<3320023@hpcid.HP.COM>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!amdcad!ames!elroy!cit-vax!tybalt.caltech.edu!palmer From: palmer@tybalt.caltech.edu (David Palmer) Newsgroups: comp.sys.mac Subject: Re: Help wanted: LSC, MacPaint Message-ID: <4096@cit-vax.Caltech.Edu> Date: Tue, 29-Sep-87 16:00:20 EDT Article-I.D.: cit-vax.4096 Posted: Tue Sep 29 16:00:20 1987 Date-Received: Thu, 1-Oct-87 05:31:26 EDT References: <3320023@hpcid.HP.COM> Sender: news@cit-vax.Caltech.Edu Reply-To: palmer@tybalt.caltech.edu.UUCP (David Palmer) Organization: California Institute of Technology Lines: 36