Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!bbn!husc6!sri-unix!stores From: stores@unix.SRI.COM (Matt Mora) Newsgroups: comp.sys.mac.programmer Subject: Re: Smoothly dragging small pictures Keywords: drag smooth copybits offscreen Message-ID: <30531@sri-unix.SRI.COM> Date: 11 May 89 16:16:10 GMT References: <12492910881010@osu-20.ircc.ohio-state.edu> Reply-To: stores@unix.sri.com (Matt Mora) Organization: SRI, Menlo Park, CA. Lines: 41 In article <12492910881010@osu-20.ircc.ohio-state.edu> TALLEY-J@osu-20.ircc.ohio-state.edu (James T. Talley) writes: >Can anyone point me to information on dragging small pictures >(not grey outlines) on the screen? The pictures that need to be >dragged are slightly larger than icons. I wrote a routine that >uses an offscreen bitmap and copybits to save and restore the >existing screen image while I copybits the picture from place to >place. The problem is that there is a terrible flicker. Is >there a trick to getting rid of the flicker? Is there a better >way that I haven't thought of yet? Any help is appreciated. The key is to do _all_ the drawing offsceen then copy the unionrect of the new location and the old location. First you saved the bits where the image was before it was drawn. You save the bits of where the image will be moved to. You replace the bits where the image was. Draw the image in the new location Now that the offscreen bitmap is fixed & the image is in the new location and the old location bits have been restored, you copy a rectangle from the offscreenbitmap that contains the union of old location rect and the new location rect directly to the screen. No Flicker because the user doesn't see the individual drawing and erasing steps. And copybits likes rectangles. This is what Scott Boyd wrote about in an article in Mactutor Volume 3 called "animated bitmaps" Hope this helps. -- ___________________________________________________________ Matthew Mora SRI International stores@unix.sri.com ___________________________________________________________