Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ukma!rutgers!apple!keith From: keith@Apple.COM (Keith Rollin) Newsgroups: comp.sys.mac.programmer Subject: Re: Saving area under dialog boxes (Re: WingZ) Message-ID: <29855@apple.Apple.COM> Date: 29 Apr 89 23:19:05 GMT References: <2993@tank.uchicago.edu> Distribution: na Organization: Apple Computer Inc, Cupertino, CA Lines: 61 In article <2993@tank.uchicago.edu> ra_robert@gsbacd.uchicago.edu writes: >In article <29827@apple.Apple.COM>, keith@Apple.COM (Keith Rollin) writes... > >> >>Saving data from your own window into an offscreen buffer is not much of a >>problem _right now_. It should even work in the forseeable future. However, I >>would recommend against it in favor of doing it the other way around; keep >>the master image in an offscreen buffer, and refresh from it exclusively. >[...] > > >What about in a paint type program? I've been working on one, and when someone >"draws" on the screen I first draw it on the screen (e.g. on the simplest level >with calls such as LineTo) and then blit it to my offscreen buffer (from which >I refresh my image) for permanent storage when the drawn object is done (i.e, >on MouseUp). Wouldn't there be times when you need to CopyBits from screen >memory to your offscreen buffer? I suppose one _could_ draw to your offscreen >bugger and CopyBits it on screen constantly, but that sounds fairly awful in >terms of speed, etc. I'm afraid that I don't see the problem here. Either you draw to the screen and copy it to an offscreen buffer, or you draw to an offscreen buffer and copy it to the screen. With paint programs, there is another advantage of keeping your master image created and stored in an offscreen buffer. By using two buffers, you can not only implement flickerless animation, but also undo. Imagine the following setup where you have a fullpage picture stored in an offscreen buffer, a temporary buffer, and the screen: offscreen image temporary buffer image on screen +-----------------------+ +-----------------------+ +-----------------------+ |$$$$$$$$$$$$$$$$$$$$$$$| | | |$$$$$$$$$$$$$$$$$$$$$$$| |$$$$$$$$$$$$$$$$$$$$$$$| | .$$$$$$ | |$$$.$$$$$$$$$$$$$$$$$$$| |$$$$$$$$$$$$$$$$$$$$$$$| | $.$$$$$ | |$$$$.$$$$$$$$$$$$$$$$$$| |$$$$$$$$$$$$$$$$$$$$$$$| | $$.$$$$ | |$$$$$.$$$$$$$$$$$$$$$$$| |$$$$$$$$$$$$$$$$$$$$$$$| | $$$.$$$ | |$$$$$$.$$$$$$$$$$$$$$$$| |$$$$$$$$$$$$$$$$$$$$$$$| | $$$$.$$ | |$$$$$$$.$$$$$$$$$$$$$$$| |$$$$$$$$$$$$$$$$$$$$$$$| | $$$$$.$ | |$$$$$$$$.$$$$$$$$$$$$$$| |$$$$$$$$$$$$$$$$$$$$$$$| | $$$$$$. | |$$$$$$$$$.$$$$$$$$$$$$$| |$$$$$$$$$$$$$$$$$$$$$$$| | | |$$$$$$$$$$$$$$$$$$$$$$$| |$$$$$$$$$$$$$$$$$$$$$$$| | | |$$$$$$$$$$$$$$$$$$$$$$$| +-----------------------+ +-----------------------+ +-----------------------+ The offscreen image holds your picture up to that time. The temporary buffer holds a copy of the affected background, along with the line/rectangle/duodeca- hedron/whatever you are drawing at that time. This combination is the blitted onto the screen. (Admittedly, this is slower than what you are doing right now, but not always appreciable so. Degradation really only comes into play when you are dealing with large amounts of data in large-bit color modes.) When the drawing is done, the buffers are left in this state until the next drawing begins. Up until that time, the user will be able to Undo the drawing s/he has done by recovering it from the left hand buffer. ------------------------------------------------------------------------------ Keith Rollin --- Apple Computer, Inc. --- Developer Technical Support INTERNET: keith@apple.com UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith "Argue for your Apple, and sure enough, it's yours" - Keith Rollin, Contusions