lotus



previous page: 4.15) I hate dealing with the low-level file manager stuff; why didn't Apple provide a complete high-level interface using FSSpecs? (Files - Mac Programming)
  
page up: Mac Programming FAQ
  
next page: 5.2) Why is CopyBits still too slow? (Imaging with QuickDraw - Mac Programming)

5.1) Why is CopyBits so slow? (Imaging with QuickDraw - Mac Programming)




Description

This article is from the Mac Programming FAQ, by Jon Watte h+@austin.metrowerks.com with numerous contributions by others.

5.1) Why is CopyBits so slow? (Imaging with QuickDraw - Mac Programming)

It is not. It just requires some hand-holding to get good results.
The main rules are: Make sure the source and destination pixMaps are of
the same depth.

Make sure the front color is black and the back color is white.

Use srcCopy and don't use a masking region, unless it's rectangular.

Copy to an unclipped window (the frontmost window). Make sure the
ctSeed values of the source pixMap and dest pixMap match.

Copying few and large pixMaps is faster than copying many and small
ones. Icon-sized sprites count as small ones.

Make sure your source bitmap or pixelMap has the same alignment, when
adjusted for the source and destination rect expressed in global screen
coordinates. The necessary alignment is 32 bits (4 bytes), although 128
bit (16 byte) alignment is probably even better on 68040 macs and won't
hurt on other macs.

Example of global alignment:

Your window is positioned at (42,100) (H,V)

Your destination rectangle is (10,20)-(74,52)

The alignment coefficient of the rectangle in global coordinates is
(42+10)*bitDepth where bitDepth is one of 1,2,4,8,16 or 32.

Make sure your source pixmap rect has the same coeffecient modulo your
alignment factor (in bits) For black&white macs, this is still true,
although bitDepth is fix at 1. Offscreen pixMaps can calculate with a
"global posistion" of 0,0 and get correct results.

 

Continue to:















TOP
previous page: 4.15) I hate dealing with the low-level file manager stuff; why didn't Apple provide a complete high-level interface using FSSpecs? (Files - Mac Programming)
  
page up: Mac Programming FAQ
  
next page: 5.2) Why is CopyBits still too slow? (Imaging with QuickDraw - Mac Programming)