PICT's in HC

3 views
Skip to first unread message

Edward P. Costello

unread,
Apr 24, 1990, 12:20:25 AM4/24/90
to

Ok, my turn to post.

I have a stack where I have to show a cube rotating through 360 degrees.
I have 36 PICTs of the cube (1 for every 10 deg). What I want to know
is if there is a command which can show these (say if I out them in the
Resource fork of the stack). I looked at showPict but it doesn't seem
to deal with PICT's only hypercard paint pictures.


Thanks-
-ed costello
-communications design center
-carnegie mellon university

Tim Maroney

unread,
Apr 25, 1990, 3:52:22 AM4/25/90
to
In article <MaAxE9u00...@andrew.cmu.edu> ec...@andrew.cmu.edu

(Edward P. Costello) writes:
>I have a stack where I have to show a cube rotating through 360 degrees.
>I have 36 PICTs of the cube (1 for every 10 deg). What I want to know
>is if there is a command which can show these (say if I out them in the
>Resource fork of the stack). I looked at showPict but it doesn't seem
>to deal with PICT's only hypercard paint pictures.

Well, I have an XCMD that puts PICT resources into the clipboard so you
can use "doMenu Paste Picture" on them. It may or may not be fast
enough for your needs. Here it is, MPW C, use your own precompiled
header file in place of HEADER. See the initial error message string
for usage; note that you use the resource id, that the current resource
file is used if you don't specify a name (but you can use the name of
the current resource for the same effect), and that you can reposition
it with parameters 3 and 4.

#pragma load HEADER

void ErrAbort(XCmdPtr paramPtr, StringPtr s);
void CleanUp(short refNum, short curr, PicHandle pic, short err, XCmdPtr p);
void xcopy(StringPtr s, short i, XCmdPtr p);

pascal void EntryPoint(XCmdPtr p)
{ Str255 s; long n; short id, err, refNum = 0, curr;
PicHandle pic, pic2; Point pt; Rect r;

if (p->paramCount < 0 || p->paramCount > 4 || p->paramCount == 3) {
ErrAbort(p, "\pformat: CopyPict <id> [<file> [<h> <v>]]");
return;
}

/* get the resource id */
xcopy(s, 0, p); StringToNum(s, &n); id = n;

/* get the resource file name (if any) and open it */
if (p->paramCount > 1) {
xcopy(s, 1, p);
if (s[0]) {
curr = CurResFile();
if ((refNum = OpenRFPerm(s, 0, fsCurPerm)) < 0) {
NumToString(ResError(), s); ErrAbort(p, s);
return;
}
if (curr == refNum) refNum = 0;
}
}

/* get the point to paste it in at (if any) */
if (p->paramCount == 4) {
xcopy(s, 2, p); StringToNum(s, &n); pt.h = n;
xcopy(s, 3, p); StringToNum(s, &n); pt.v = n;
}

/* get the picture resource */
if ((pic = (PicHandle)Get1Resource('PICT', id)) == 0) {
if ((err = MemError()) == 0) err = resNotFound;
CleanUp(refNum, curr, pic, err, p);
return;
}

/* zero out the desk scrap */
if (err = ZeroScrap()) { CleanUp(refNum, curr, pic, err, p); return; }

/* copy the picture into the desk scrap */
if (p->paramCount == 4) {
/* offset the picture before copying it */
r = (*pic)->picFrame;
OffsetRect(&r, pt.h - r.left, pt.v - r.top);
if ((pic2 = OpenPicture(&r)) == 0)
{ CleanUp(refNum, curr, pic, err, p); return; }
DrawPicture(pic, &r);
ClosePicture();
HLock((Handle)pic2);
err = PutScrap(GetHandleSize((Handle)pic2), 'PICT',
*(Handle)pic2);
KillPicture(pic2);
}
else { /* just copy the picture into the desk scrap */
HLock((Handle)pic);
err = PutScrap(GetHandleSize((Handle)pic), 'PICT',
*(Handle)pic);
}

/* all done */
CleanUp(refNum, curr, pic, err, p);
}

void xcopy(StringPtr s, short i, XCmdPtr p)
{ HLock(p->params[i]);
ZeroToPas(p, *(p->params[i]), s);
HUnlock(p->params[i]);
}

void CleanUp(short refNum, short curr, PicHandle pic, short err, XCmdPtr p)
{ Str255 s;
if (refNum != 0)
{ CloseResFile(refNum); UseResFile(curr); }
else if (pic)
ReleaseResource((Handle)pic);
if (err) { NumToString(err, s); ErrAbort(p, s); }
}

void ErrAbort(XCmdPtr paramPtr, StringPtr s)
{ Handle h;
SysBeep(6);
if ((h = NewHandle((long)(s[0] + 1))) == 0) return;
BlockMove(s + 1, *h, s[0]); (*h)[s[0]] = 0; paramPtr->returnValue = h;
}
--
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, t...@toad.com

"This signature is not to be quoted." -- Erland Sommarskog

Leo Bores

unread,
Apr 25, 1990, 4:40:11 PM4/25/90
to
In an article of <24 Apr 90 04:20:25 GMT>, ec...@andrew.cmu.edu (Edward P. Costello) writes:

EP>From: ec...@andrew.cmu.edu (Edward P. Costello)
EP>Date: 24 Apr 90 04:20:25 GMT
EP>Organization: English, Carnegie Mellon, Pittsburgh, PA
EP>Message-ID: <MaAxE9u00...@andrew.cmu.edu>
EP>Newsgroups: comp.sys.mac.hypercard
EP>
EP>
EP>Ok, my turn to post.
EP>
EP>I have a stack where I have to show a cube rotating through 360
EP>degrees.
EP>I have 36 PICTs of the cube (1 for every 10 deg). What I want to know
EP>is if there is a command which can show these (say if I out them in the
EP>Resource fork of the stack). I looked at showPict but it doesn't seem
EP>to deal with PICT's only hypercard paint pictures.
EP>
EP>
EP>Thanks-
EP>-ed costello
EP>-communications design center
EP>-carnegie mellon university
EP>
The Dartmouth Tool Stack has an XCMD which should be able to do that for you.

Leo Bores


--
Uucp: ...{gatech,ames,rutgers}!ncar!asuvax!stjhmc!14!Leo.Bores
Internet: Leo....@f14.n114.z1.fidonet.org

Jann VanOver

unread,
Apr 25, 1990, 4:44:40 PM4/25/90
to
(Edward P. Costello) writes:
>is if there is a command which can show these [PICTS]...

I haven't used it (yet), but a product called "HyperWindows" is designed
to give you new ways to manage PICTS. It may or may not include the
feature you seek.

Producer: Tulip Software Phone (508) 475-8711
PO Box 3046
Andover, MA 018710

I've ordered the product, but may not see it for weeks (big company
procurement *{ ) Anybody out there who has USED it? Got any commments?

Jann E Van Over
van...@atc.boeing.com

Reply all
Reply to author
Forward
0 new messages