Path: utzoo!utgpu!attcan!uunet!lll-winken!lll-tis!ames!ll-xn!mit-eddie!uw-beaver!microsoft!t-benw From: t-benw@microsoft.UUCP (Benjamin Waldmin) Newsgroups: comp.sys.mac.programmer Subject: Re: Scrap Manager (PICT Format) Summary: Yes, you can use CopyBits to put a bitmap into a picture Message-ID: <1708@microsoft.UUCP> Date: 8 Aug 88 23:06:40 GMT References: <28049@bbn.COM> <6229@chinet.chi.il.us> <6566@umn-cs.cs.umn.edu> Reply-To: t-benw@microsoft.uucp (Benjamin Waldman) Organization: Microsoft Corporation, Redmond, WA Lines: 51 In article <6566@umn-cs.cs.umn.edu> imp@crayview.msi.umn.edu (Chuck Lukaszewski) writes: >In article <6229@chinet.chi.il.us>, jkingdon@chinet.chi.il.us (James Kingdon) writes: >> In article <28049@bbn.COM> dredick@vax.bbn.com (The Druid) writes: >> >So..., How do you specified a Bit Map in a 'PICT'? or am I going about this >> >wrong? >> >> I would think you could just do an OpenPicture, then a CopyBits (giving >> it as destination bitmap thePort^.portBits perhaps, I'm not sure the >> destination bitmap even matters), then ClosePicture and so on. Have >> you tried this? >> >That approach will disappoint you. The _OpenPicture and _ClosePicture traps >are a sort of 'journaling' mechanism by which a series of quickdraw operations >can be recorded. _OpenPicture operates on a rectangle you specify, not on >a brand new window. > >That approach only works if you can make the bitmap before you complete your >program. If you must do bitmap->PICT conversions on the fly in a program, you >will need to build your own PICT resource in memory. [complicated stuff deleted] No, you don't have to build your PICT resource. There's a much easier way. Suppose I have a window, and I want to create a PICT containing the windows contents. I can do the following: GetPort(&savePort); SetPort(&myWindow); myHandle = OpenPicture(myWindow.portRect); CopyBits(myWindow.portBits,mywindow.portBits, myWindow.portRect,myWindow.portRect,srcCopy,0L); ClosePicture(); This code opens a picture the same size as your window, and then does a copybits, copying the window's contents onto itself. However, since a picture is open, drawing into the window with the CopyBits is recorded in the picture. Now that you have the picture, you can just copy it to a disk file or to the clipboard. Of course, if you only want to copy a portion of the window, rather than the entire thing, make all the rectangles smaller! Ben Waldman Software Design Engineer Microsoft Corporation uw-beaver!microsoft!t-benw Disclaimer: My thoughts, opinions, suggestions and ideas are purely my own and are not endorsed by my employer.