Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!amdahl!pacbell!hoptoad!tim From: tim@hoptoad.uucp (Tim Maroney) Newsgroups: comp.sys.mac.programmer Subject: Re: CopyBits() question Message-ID: <7407@hoptoad.uucp> Date: 23 May 89 19:11:30 GMT References: <8134@boring.cwi.nl> Reply-To: tim@hoptoad.UUCP (Tim Maroney) Organization: Eclectic Software, San Francisco Lines: 49 In article <8134@boring.cwi.nl> jurjen@cwi.nl (Jurjen N.E. Bos) writes: >I have an offscreen bitmap of size about 300*500. At an update event, this >whole stuff needs to be dumped on screen. >This seems easy--one CopyBits call does the trick. >But then I read in IM that is is considered to be bad practice to copy large >bitmaps (>3K), because they use up stack space as large as the bitmap. > >The question is: is this still true in the following case: >no overlap between source and destination, no reduction, no mask region. I don't know; perhaps one of the kind people from Apple could let us know. It is possible this problem was fixed in the MacPlus ROMs. I've done CopyBits larger than the stack space on 128K ROMs and up and not had a problem; never tried it on the 64K ROMs. I was copying an entire MacPaint file bitmap, so it should have cut a deep swath in my application heap if things were still as described in IMvI. >It would save me a lot of dirty code if I could still do it with a single call. >Help, anyone? I finally decided I was playing with fire by doing these large CopyBits's, so I wrote a row-by-row copy routine that seems to run fast enough. It would be more efficient to compute how many rows would fit in 3K, but there really didn't seem to be a speed problem with doing things a row at a time, so I didn't bother. void CopyRows(in, out, inBounds, outBounds, mode, mask) BitMap *in, *out; Rect *inBounds, *outBounds; short mode; RgnHandle mask; { short i = 0, rows = inBounds->bottom - inBounds->top; Rect ir, or; while (i < rows) { ir = *inBounds, or = *outBounds; ir.top += i; ir.bottom = ir.top + 1; or.top += i; or.bottom = or.top + 1; CopyBits(in, out, &ir, &or, mode, mask); i++; } } -- Tim Maroney, Consultant, Eclectic Software, sun!hoptoad!tim "What's the ugliest part of your body? Some say your nose, some say your toes, But I think it's your mind." -- Frank Zappa