joe@cbdkc1.ATT.COM (Here comes the ...) (12/08/87)
(Dang computer doesn't do what I want, does what I say ... mumble.. mumble) This is really simple. Would some LSC/Resource/Quickdraw person tell me what's wrong ?? I have a picture in MacPaint, I want to show as the Title Screen in a window for an application/game (to be posted when done). OK here's what I do: ------------------------------------------------------------------------------ - put the selection box around the area (about 1/2 the screen size). actual coordinates are: top 25, left 03, bottom 225, right 508 - Copy it out, pull down apple menu to scrapbook, paste the picture in it. - go to ResEdit, paste the Picture in my built application. - Info on it, set it to rsrc # 256 - I also make a WIND, rsrc# 256 also,:top 25, left 03, bottom 225, right 508 ------------------------------------------------------------------------------ (Don't flame, this code is from (hazy, anger filled) memory: ) I try two things in C: 1) MyWindPtr = GetNewWindow(256); MyPicHdl = (PicHandle)GetPicture(256); SetWindowPic(MyWindowPtr, MyPicHdl); /* tried & operator on these */ ShowWindow(MyWindPtr); /* something like this */ and 2) MyPicHdl = (PicHandle)GetPicture(256); SomeRect = (**MyPicHdl).picFrame; MyWindPtr = NewWindow(&w_rec, &SomeRect, blah, blah); DrawPicture(&SomeRect, MyPicHdl); /* something like this */ ------------------------------------------------------------------------------ Questions are: WHY don't these work? WHAT specific code, exactly, would take a PICT rsrc and show it in a screen??????? THANK YOU - PLEASE... -- Joseph Judge ihnp4!cbdkc1!joe AT&T Bell Labs --
fry@huma1.HARVARD.EDU (David Fry) (12/09/87)
In article <2592@cbdkc1.ATT.COM> joe@cbdkc1.UUCP (Joseph !. Judge) writes: >I have a picture in MacPaint, I want to show as the Title Screen in a window >for an application/game (to be posted when done). > >OK here's what I do: >------------------------------------------------------------------------------ >- put the selection box around the area (about 1/2 the screen size). > actual coordinates are: top 25, left 03, bottom 225, right 508 >- Copy it out, pull down apple menu to scrapbook, paste the picture > in it. >- go to ResEdit, paste the Picture in my built application. >- Info on it, set it to rsrc # 256 >- I also make a WIND, rsrc# 256 also,:top 25, left 03, bottom 225, right 508 >------------------------------------------------------------------------------ > >(Don't flame, this code is from (hazy, anger filled) memory: ) >I try two things in C: >1) > MyWindPtr = GetNewWindow(256); > MyPicHdl = (PicHandle)GetPicture(256); > SetWindowPic(MyWindowPtr, MyPicHdl); /* tried & operator on these */ > ShowWindow(MyWindPtr); /* something like this */ I haven't given it too much thought, but here goes: When doing window updating in this fashion, QuickDraw will only draw your picture upon *updates*. You said this is a startup screen so undoubtably MyWindPtr is the only window on the screen. If your window is displayed at the time of GetNewWindow(), it has no reason to do an update when you call ShowWindow(). Go back to the WIND resource in ResEdit and set its visible bit to FALSE. Maybe it will work then. >and >2) > MyPicHdl = (PicHandle)GetPicture(256); > SomeRect = (**MyPicHdl).picFrame; > MyWindPtr = NewWindow(&w_rec, &SomeRect, blah, blah); > DrawPicture(&SomeRect, MyPicHdl); /* something like this */ First, you should set the port before drawing, just to make sure, with the call SetPort(MyWindPtr). Also, the rect SomeRect is not guaranteed to have a topleft corner of (0,0) so it may be off the edge of your window. Before DrawPicture(MyPicHdl,&SomeRect) (note the syntax), say OffsetRect(&SomeRect,-SomeRect.left,-SomeRect.top). For both of these techniques it is handy to call DetachResource(MyPicHdl) right after reading it from disk so that the Handle points to a picture, and not a resource. I hope this solves the problem. David Fry fry@huma1.harvard.EDU Department of Mathematics fry@harvma1.bitnet Harvard University ...!harvard!huma1!fry Cambridge, MA 02138
fry@huma1.HARVARD.EDU (David Fry) (12/09/87)
In article <3504@husc6.harvard.edu> fry@huma1.UUCP I write: >In article <2592@cbdkc1.ATT.COM> joe@cbdkc1.UUCP (Joseph !. Judge) writes: >>I have a picture in MacPaint, I want to show as the Title Screen in a window >>for an application/game (to be posted when done). >> >>OK here's what I do: >>------------------------------------------------------------------------------ >>- put the selection box around the area (about 1/2 the screen size). >> actual coordinates are: top 25, left 03, bottom 225, right 508 >>- Copy it out, pull down apple menu to scrapbook, paste the picture >> in it. >>- go to ResEdit, paste the Picture in my built application. Oops, I didn't read the original posting carefully enough. This may be the problem. If you're trying this out from within LSC itself you'll need to create a resource file for all your resoruces. If your project is called My Proj, call the resource file My Proj.rsrc. Put the window and picture resources in there. David Fry fry@huma1.harvard.EDU Department of Mathematics fry@harvma1.bitnet Harvard University ...!harvard!huma1!fry Cambridge, MA 02138
schmidt@lsrhs.UUCP (Chris Schmidt) (12/12/87)
In article <2592@cbdkc1.ATT.COM> joe@cbdkc1.UUCP (Joseph !. Judge) writes: >WHY don't these work? WHAT specific code, exactly, would take a PICT rsrc and >show it in a screen??????? Ok, let's see how good my memory is. Once I drew PICT resources all over the screen of my original Mac 128k using Mainstay's Assembler (nigh on two year ago -- pull up a seat sunny, toast them dogs nearer the fire . . .) You've done the right thing creating the PICT resource. Now your code's gotta do something *like* the following. PicHandle mypic; Handle myres; Rect destrec; ClipRect(destrec); /*an odd, but necessary thing*/ mypic = OpenPic(destrec); myres = GetResource("\pPICT",ID); /* Careful now -- I don't know if your compiler will regard *mypic as a proper lvalue -- I'm translating from assembly . . .*/ *mypic = *myres; DrawPicture(mypic); Basically, you're fooling the machine into thinking that that resource is a picture record you've defined on the fly. Obviously, to make this more secure, you should do copy the resource data, not just juggle pointers. Again, it works in assembly, where you can swap the contents of one address register for another -- I'm a little uncomfortable with the way it looks in C (and I'm WAY too lazy to try it myself). Hope this is helpful. -- ------------------------------------------------------------------------ Chris Schmidt/Lincoln-Sudbury High School/390 Lincoln Rd/Sudbury/Ma/01776 (617) 926-3242 -----> mit-caf!lsrhs!schmidt@eddie.mit.edu
shane@pepe.cc.umich.edu (Shane Looker) (12/14/87)
In article <667@lsrhs.UUCP> schmidt@lsrhs.UUCP (Chris Schmidt) writes: >In article <2592@cbdkc1.ATT.COM> joe@cbdkc1.UUCP (Joseph !. Judge) writes: >>WHY don't these work? WHAT specific code, exactly, would take a PICT rsrc and >>show it in a screen??????? > >You've done the right thing creating the PICT resource. Now your code's >gotta do something *like* the following. > > ClipRect(destrec); /*an odd, but necessary thing*/ > mypic = OpenPic(destrec); > myres = GetResource("\pPICT",ID); > > /* Careful now -- I don't know if your compiler will regard > *mypic as a proper lvalue -- I'm translating from assembly . . .*/ > > *mypic = *myres; > DrawPicture(mypic); >------------------------------------------------------------------------ >Chris Schmidt/Lincoln-Sudbury High School/390 Lincoln Rd/Sudbury/Ma/01776 > (617) 926-3242 -----> mit-caf!lsrhs!schmidt@eddie.mit.edu I'm not sure why you are doing an OpenPic. Try the following (trust me, my code *always* works): Rect destRec; Handle myRes; unsigned long resname; ClipRect(destRec); /* you need this I think */ resname = 'PICT'; /* Stuff the res type into 4 bytes */ /* you may need to make this hex, then stuff it in */ myRes = GetResource((ResType)resname, ID); DrawPicture((PicHandle) myRes); And away you should go. This may be totally wrong of course, but I don't want to try this under LSC with MulitFinder. Shane Looker | "He's dead Jim, shane@pepe.cc.umich.edu | you grab his tricorder, uunet!umix!pepe.cc.umich.edu!shane | I'll get his wallet." Looker@um.cc.umich.edu
raylau@dasys1.UUCP (Raymond Lau) (12/17/87)
The following code was extracted from StuffIt, so I know it works: statusPict = (PicHandle)GetPicture(128); DrawPicture(statusPict,&rect); simple enough... Of course, before it we have: PicHandle statusPict; Rect rect; In this case, 128 is the PICT rsrc ID number. and we've set the rect' angle appropriately. If you want the rect to depend on the size of the picture, you can get hte vertices of the picture rectangle with something like: rect.top = (*statusPict)->picFrame.top; rect.bottom = ... picFrame.bottom etc. And the usual, make sure your drawing port is set correctly, etc -- Raymond Lau GEnie: RayLau 100-04 70 Ave. CIS: 76174,2617 Forest Hills, NY 11375-5133 Delphi: RaymondLau United States of America MacNET: RayLau uucp: raylau@dasys1.UUCP (..{phri,cucard,bc-cis,mstan}!dasys1!raylau})