Path: utzoo!attcan!uunet!dino!ux1.cso.uiuc.edu!uwm.edu!bionet!apple!lsr From: lsr@Apple.COM (Larry Rosenstein) Newsgroups: comp.sys.mac.programmer Subject: Re: Dragging Bitmaps? Message-ID: <8992@goofy.Apple.COM> Date: 5 Jul 90 18:24:31 GMT References: <3398@husc6.harvard.edu> Organization: Apple Computer, Inc. Lines: 23 In article <3398@husc6.harvard.edu> siegel@endor.harvard.edu (Rich Siegel) writes: > >Does anyone have any suggestions on how to drag small bitmaps around, in the >same fashion as MacPaint? Currently I drag outlines around, but it would be >much nicer to move the object as a whole. The basic approach is to cache the image behind the moving bitmap, and use that cache to erase the bitmap before it moves. So the basic code would be to use 1 CopyBits to erase the old bitmap, and 1 CopyBits to draw the bitmap in its new position. (This assumes that you have cached the entire view beforehand. This is always better than copying the bits from the screen.) You will get better results if you do both steps with 1 CopyBits. To do this you need another offscreen bitmap the size of the union of the old and new rectangles. You initialize this bitmap from the larger cache, and draw the moving bitmap in its desired position. Then you use 1 CopyBits to copy everything onto the screen at once. -- Larry Rosenstein, Object Specialist Apple Computer, Inc. 20525 Mariani Ave, MS 46-B Cupertino, CA 95014 AppleLink:Rosenstein1 domain:lsr@Apple.COM UUCP:{sun,voder,nsc,decwrl}!apple!lsr