[comp.sys.mac.programmer] Must PixMap.rowBytes be even?

ml27192@uxa.cso.uiuc.edu (Mark Lanett) (06/08/91)

I've been puzzled lately. I've noticed that most of our tools don't compensate
for images with an odd width, i.e. when creating a PixMap, we put an odd number
into rowBytes. This doesn't cause crashes or any other obvious problems,
although IM 5 and IM 6 (prelim) say it must be even. Is QuickDraw doing
some checking for us, or are we asking for crashes if we do some obscure
operations?
--
//-----------------------------------------------------------------------------
Mark Lanett						mlanett@uiuc.edu
Software Tools Group, NCSA

keith@Apple.COM (Keith Rollin) (06/09/91)

In article <1991Jun8.002628.19871@ux1.cso.uiuc.edu> ml27192@uxa.cso.uiuc.edu (Mark Lanett) writes:
>I've been puzzled lately. I've noticed that most of our tools don't compensate
>for images with an odd width, i.e. when creating a PixMap, we put an odd number
>into rowBytes. This doesn't cause crashes or any other obvious problems,
>although IM 5 and IM 6 (prelim) say it must be even. Is QuickDraw doing
>some checking for us, or are we asking for crashes if we do some obscure
>operations?

Your results will probably vary depending on what CPU you are running
on. On the 68020 and 030, you can make word and longword accesses on
odd byte boundaries. However, attempting to do so on a 68000 will cause
you to crash. By putting an odd value into rowBytes, you run the risk
of causing QuickDraw to access a word or longword on an odd byte
boundary.

Now, you are using PixMaps under ColorQuickDraw. CQD strictly runs only
on 68020's and greater. However, under 7.0, more and more CQD
functionality is being moved down into Classic QD. This means that
PixMaps may one day live on 68000's (if they don't alreay -- I can't
remember everything QuickDraw under 7.0 gives you).

BTW: Inside Mac I (page 144) also warns against odd rowBytes values,
although this warning is for BitMaps.

-- 
------------------------------------------------------------------------------
Keith Rollin  ---  Apple Computer, Inc. 
INTERNET: keith@apple.com
    UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith
"But where the senses fail us, reason must step in."  - Galileo

dorner@pequod.cso.uiuc.edu (Steve Dorner) (06/10/91)

In article <53801@apple.Apple.COM> keith@Apple.COM (Keith Rollin) writes:
>on. On the 68020 and 030, you can make word and longword accesses on
>odd byte boundaries.

At a significant performance penalty, though, right?  So perhaps it's
a good idea to keep it even, even if you're assured of a 68020 or better.
--
Steve Dorner, U of Illinois Computing Services Office
Internet: s-dorner@uiuc.edu  UUCP: uunet!uiucuxc!uiuc.edu!s-dorner