Path: utzoo!attcan!uunet!husc6!bbn!uwmcsd1!nic.MR.NET!umn-cs!crayview!imp From: imp@crayview.msi.umn.edu (Chuck Lukaszewski) Newsgroups: comp.sys.mac.programmer Subject: Re: Scrap Manager (PICT Format) Summary: That won't work, this will Message-ID: <6566@umn-cs.cs.umn.edu> Date: 7 Aug 88 17:12:59 GMT References: <28049@bbn.COM> <6229@chinet.chi.il.us> Sender: news@umn-cs.cs.umn.edu Lines: 46 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. The fastest way to get something into PICT format is to build the picture with a bitmap editor like MacPaint, 'cut' it so it gets into the clipboard, and then run ResEdit on the file you want to store the PICT in. If the type 'PICT' does not exist, then make it. All you have to do now is do a 'paste' (Command-V). ResEdit automatically converts the bitmap in the clipboard to a PICT. 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. This is pretty straight- forward. There is a technote which specifically covers this topic. Basically, the PICT format is as follows (I may not be exactly right, but this is close): 1 word - length of resource data 2 words - 'PICT' 4 words - rectangle 1 word - rowbytes n words - bitmap data. You will need to figure out the size of this structure before you make the calls to turn it into a PICT, because you **MUST** use _NewHandle to allocate the memory for it. Once you have done that, you can either construct it in the newly allocated block, or (if you have the bitmap already) you can just use _BlockMove to copy it in. Either way, the reason you need to use _NewHandle is that you have to use Resource Manager calls to store the resource. Since your handle is not any previously existing resource, you can go straight to an _AddResource call (assuming you have your resource file open). Then do an _UpdateResFile and you are set. ---===---===---===---===--/* Chuck Lukaszewski */--===---===---===---===--- ARPAnet/NSFnet/MRnet: AppleLink: SnailMail: Ma Bell: imp@crayview.msi.umn.edu UG0138 Minneapolis MN 55418 612/789-0931