Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!gatech!udel!princeton!andante!bwb From: bwb@andante.UUCP (Bruce Ballard) Newsgroups: comp.sys.mac.programmer Subject: rowBytes for a pixmap Message-ID: <21104@andante.UUCP> Date: 20 Jul 89 15:29:54 GMT Organization: AT&T Bell Laboratories, Murray Hill Lines: 21 I'm reading Knaster's Macintosh Programming Secrets for the first time, and I wonder whether the computation of rowBytes on pages 202 and 216 is known to be incorrect, or whether I am missing something. For a bitmap (p. 202) he gives (((Right - Left - 1) div 16) + 1) * 2 which is equivalent to the simpler formula ((Right - Left + 15) div 16) * 2 but either is correct. For a pixmap (p. 216), however, he gives ((depth*(Right - Left - 1) div 16) + 1) * 2 which he then uses to compute 208 as the rowBytes for an 8-bit-deep pixmap having 200 pixels across. But at this depth, we want one byte per pixel, right, so we should have a rowBytes of 200? It seems that a *correct* formula, which is easily derived from the alternate one I gave above, is (depth * (Right - Left + 15) div 16) * 2 The difference is significant: for his 200-by-200 pixmap, 1600 of his 41600 bytes are wasted. I love the book, but can someone clarify this point? -Bruce Ballard bwb@allegra.att.com