deadman@garnet.berkeley.edu (Ben Haller) (04/21/91)
In article <327@nic.cerf.net> moreland@nic.cerf.net (John Moreland) writes: >vague description in IM V. On page 52 and 53 the "rowBytes" field of a PICT >is described, but they don't quite tell how to calculate the "high-bits". >I know how to calculate the "raw" value of rowBytes, but what "function" >is used to set the 3 high-bits/flags ? > >I am using the "|" operator in C to set the bits, but I noticed that >a "C view" display from "PICT Detective" shows that they are using "+". >I know that these lead to very different results, but IM does not seem >to describe exactly which is correct. > >Here are a half dozen or so lines of C code that shows how *I* am >calculating rowBytes. Can somebody at Apple tell me which way is >the "right way" to set the high-bits ? > >rowBytes |= 0x8000; /* HIGH-BIT LIT MEANS "PIXMAP" */ >rowBytes &= 0x7FFF; /* UNDO THE HIGH-BIT SO WE CAN USE ROWBYTES "NORMALLY" */ You should do &= with 0x1FFF, since the three high bits are reserved by Apple. Besides this, you're fine. x+=0x8000 and x|=0x8000 will produce the same results, BTW, assuming that the high bit isn't already set, which is true of your example. -Ben Haller (deadman@garnet.berkeley.edu) "Shock the monkey to life..." - Peter Gabriel
jwhitnell@cup.portal.com (Jerry D Whitnell) (04/22/91)
Ben Haller (deadman@garnet.berkeley.edu) writes... |In article <327@nic.cerf.net> moreland@nic.cerf.net (John Moreland) writes: |>rowBytes |= 0x8000; /* HIGH-BIT LIT MEANS "PIXMAP" */ |>rowBytes &= 0x7FFF; /* UNDO THE HIGH-BIT SO WE CAN USE ROWBYTES "NORMALLY" */ | | You should do &= with 0x1FFF, since the three high bits are reserved by |Apple. Besides this, you're fine. Actually, it is now &= 0x3fff. Apple unreserved the 0x2000 bit with 32-bit QuickDraw. | |-Ben Haller (deadman@garnet.berkeley.edu) |"Shock the monkey to life..." - Peter Gabriel Jerry Whitnell SuperMac Technology